From: Arek Kusztal Date: Thu, 22 Sep 2016 10:45:53 +0000 (+0100) Subject: crypto/aesni_gcm: move pre-counter block to driver X-Git-Tag: spdx-start~5721 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b2bb3597470c;p=dpdk.git crypto/aesni_gcm: move pre-counter block to driver This patch moves computing of pre-counter block into the AESNI-GCM driver so it can be moved from test files. Signed-off-by: Arek Kusztal Acked-by: Deepak Kumar Jain --- diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 024a9e0c04..3733315ba1 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -3259,14 +3259,10 @@ create_gcm_operation(enum rte_crypto_cipher_operation op, memset(sym_op->cipher.iv.data, 0, iv_pad_len); sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf); - sym_op->cipher.iv.length = iv_pad_len; + sym_op->cipher.iv.length = iv_len; rte_memcpy(sym_op->cipher.iv.data, iv, iv_len); - /* CalcY0 */ - if (iv_len != 16) - sym_op->cipher.iv.data[15] = 1; - /* * Always allocate the aad up to the block size. * The cryptodev API calls out - diff --git a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c index 317c556fed..76dce9cc51 100644 --- a/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c +++ b/drivers/crypto/aesni_gcm/aesni_gcm_pmd.c @@ -230,11 +230,20 @@ process_gcm_crypto_op(struct aesni_gcm_qp *qp, struct rte_crypto_sym_op *op, op->cipher.data.offset); /* sanity checks */ - if (op->cipher.iv.length != 16 && op->cipher.iv.length != 0) { + if (op->cipher.iv.length != 16 && op->cipher.iv.length != 12 && + op->cipher.iv.length != 0) { GCM_LOG_ERR("iv"); return -1; } + /* + * GCM working in 12B IV mode => 16B pre-counter block we need + * to set BE LSB to 1, driver expects that 16B is allocated + */ + if (op->cipher.iv.length == 12) { + op->cipher.iv.data[15] = 1; + } + if (op->auth.aad.length != 12 && op->auth.aad.length != 8 && op->auth.aad.length != 0) { GCM_LOG_ERR("iv");