From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pablo.de.lara.guarch@intel.com>
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id 55A8D9105
 for <stable@dpdk.org>; Wed, 16 Aug 2017 10:16:06 +0200 (CEST)
Received: from fmsmga004.fm.intel.com ([10.253.24.48])
 by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 16 Aug 2017 01:16:03 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.41,381,1498546800"; d="scan'208";a="300739357"
Received: from silpixa00399464.ir.intel.com (HELO
 silpixa00399464.ger.corp.intel.com) ([10.237.222.157])
 by fmsmga004.fm.intel.com with ESMTP; 16 Aug 2017 01:16:02 -0700
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: yliu@fridaylinux.org
Cc: stable@dpdk.org,
	Pablo de Lara <pablo.de.lara.guarch@intel.com>
Date: Wed, 16 Aug 2017 01:16:16 +0100
Message-Id: <20170816001616.8036-6-pablo.de.lara.guarch@intel.com>
X-Mailer: git-send-email 2.9.4
In-Reply-To: <20170816001616.8036-1-pablo.de.lara.guarch@intel.com>
References: <20170816001616.8036-1-pablo.de.lara.guarch@intel.com>
Subject: [dpdk-stable] [PATCH 5/5] test/crypto: fix wrong AAD setting
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 16 Aug 2017 08:16:13 -0000

[ backported from upstream commit f2522ce5978e503a2b2c63220898cdffce257909 ]

AAD should not point at IV for AES algorithms.
For AES-GCM, AAD will point at additional data in the mbuf.
For the other algorithms (such as 3DES CBC), AAD is not used.

Fixes: ffbe3be0d4b5 ("app/test: add libcrypto")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Fiona Trahe <fiona.trahe@intel.com>
---
 app/test/test_cryptodev_perf.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index 89a6795..2a31349 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -2475,6 +2475,11 @@ static uint8_t aes_key[] = {
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
+static uint8_t aes_gcm_aad[] = {
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
 static uint8_t aes_iv[] = {
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -2687,7 +2692,7 @@ test_perf_create_openssl_session(uint8_t dev_id, enum chain_mode chain,
 
 #define AES_BLOCK_SIZE 16
 #define AES_CIPHER_IV_LENGTH 16
-
+#define AES_GCM_AAD_LENGTH 16
 #define TRIPLE_DES_BLOCK_SIZE 8
 #define TRIPLE_DES_CIPHER_IV_LENGTH 8
 
@@ -2722,8 +2727,6 @@ test_perf_set_crypto_op_aes(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(m,
 			AES_CIPHER_IV_LENGTH + data_len);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = aes_iv;
-	op->sym->auth.aad.length = AES_CIPHER_IV_LENGTH;
 
 	/* Cipher Parameters */
 	op->sym->cipher.iv.data = rte_pktmbuf_mtod(m, uint8_t *);
@@ -2760,8 +2763,8 @@ test_perf_set_crypto_op_aes_gcm(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->auth.digest.phys_addr =
 				rte_pktmbuf_mtophys_offset(m, data_len);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = aes_iv;
-	op->sym->auth.aad.length = AES_CIPHER_IV_LENGTH;
+	op->sym->auth.aad.data = aes_gcm_aad;
+	op->sym->auth.aad.length = AES_GCM_AAD_LENGTH;
 
 	/* Cipher Parameters */
 	op->sym->cipher.iv.data = aes_iv;
@@ -2893,8 +2896,6 @@ test_perf_set_crypto_op_3des(struct rte_crypto_op *op, struct rte_mbuf *m,
 	op->sym->auth.digest.phys_addr =
 				rte_pktmbuf_mtophys_offset(m, data_len);
 	op->sym->auth.digest.length = digest_len;
-	op->sym->auth.aad.data = triple_des_iv;
-	op->sym->auth.aad.length = TRIPLE_DES_CIPHER_IV_LENGTH;
 
 	/* Cipher Parameters */
 	op->sym->cipher.iv.data = triple_des_iv;
-- 
2.9.4