[dpdk-dev] [PATCH v2 2/9] test/crypto: fix wrong AAD setting

Pablo de Lara pablo.de.lara.guarch at intel.com
Thu Jun 22 14:02:28 CEST 2017


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")
CC: stable at dpdk.org

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

diff --git a/test/test/test_cryptodev_perf.c b/test/test/test_cryptodev_perf.c
index d60028d..894b2dd 100644
--- a/test/test/test_cryptodev_perf.c
+++ b/test/test/test_cryptodev_perf.c
@@ -2634,6 +2634,11 @@ static uint8_t aes_iv[] = {
 		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 triple_des_key[] = {
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -2895,7 +2900,7 @@ test_perf_create_armv8_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
 
@@ -2939,8 +2944,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;
 		op->sym->auth.data.offset = AES_CIPHER_IV_LENGTH;
 		op->sym->auth.data.length = data_len;
 	}
@@ -2977,8 +2980,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;
@@ -3110,8 +3113,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



More information about the dev mailing list