From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5CB63A0C4E; Tue, 2 Nov 2021 14:50:22 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20CAE411CB; Tue, 2 Nov 2021 14:49:32 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id E90C041158 for ; Tue, 2 Nov 2021 14:49:25 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10155"; a="231518301" X-IronPort-AV: E=Sophos;i="5.87,203,1631602800"; d="scan'208";a="231518301" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Nov 2021 06:49:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,203,1631602800"; d="scan'208";a="449393567" Received: from silpixa00400272.ir.intel.com (HELO silpixa00400272.ger.corp.intel.com) ([10.237.223.111]) by orsmga006.jf.intel.com with ESMTP; 02 Nov 2021 06:49:24 -0700 From: Kai Ji To: dev@dpdk.org Cc: Kai Ji , pablo.de.lara.guarch@intel.com, adamx.dybkowski@intel.com Date: Tue, 2 Nov 2021 13:49:12 +0000 Message-Id: <20211102134913.21148-8-kai.ji@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211102134913.21148-1-kai.ji@intel.com> References: <20211101231257.7629-1-kai.ji@intel.com> <20211102134913.21148-1-kai.ji@intel.com> Subject: [dpdk-dev] [dpdk-dev v3 7/8] app/test: cryptodev test fix X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" test_mixed_auth_cipher: ensure enough space allocate in ibuf & obuf for mbuf to vec conversion test_kasumi_decryption: cipher length update. Fixes: 681f540da52b ("cryptodev: do not use AAD in wireless algorithms") Cc: pablo.de.lara.guarch@intel.com Fixes: e847fc512817 ("test/crypto: add encrypted digest case for AES-CTR-CMAC") Cc: adamx.dybkowski@intel.com Signed-off-by: Kai Ji --- app/test/test_cryptodev.c | 58 +++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index 814a0b401d..bfc6408eda 100644 --- a/app/test/test_cryptodev.c +++ b/app/test/test_cryptodev.c @@ -179,6 +179,10 @@ post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused, RTE_CRYPTO_OP_STATUS_ERROR; } +static struct crypto_testsuite_params testsuite_params = { NULL }; +struct crypto_testsuite_params *p_testsuite_params = &testsuite_params; +static struct crypto_unittest_params unittest_params; + void process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth, @@ -193,6 +197,7 @@ process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, struct rte_crypto_sgl sgl, dest_sgl; uint32_t max_len; union rte_cryptodev_session_ctx sess; + uint64_t auth_end_iova; uint32_t count = 0; struct rte_crypto_raw_dp_ctx *ctx; uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0, @@ -202,6 +207,9 @@ process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, int ctx_service_size; int32_t status = 0; int enqueue_status, dequeue_status; + struct crypto_unittest_params *ut_params = &unittest_params; + int is_sgl = sop->m_src->nb_segs > 1; + int is_oop = 0; ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id); if (ctx_service_size < 0) { @@ -240,6 +248,9 @@ process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, ofs.raw = 0; + if ((sop->m_dst != NULL) && (sop->m_dst != sop->m_src)) + is_oop = 1; + if (is_cipher && is_auth) { cipher_offset = sop->cipher.data.offset; cipher_len = sop->cipher.data.length; @@ -267,6 +278,31 @@ process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, digest.va = (void *)sop->auth.digest.data; digest.iova = sop->auth.digest.phys_addr; + if (is_sgl) { + uint32_t remaining_off = auth_offset + auth_len; + struct rte_mbuf *sgl_buf = sop->m_src; + if (is_oop) + sgl_buf = sop->m_dst; + + while (remaining_off >= rte_pktmbuf_data_len(sgl_buf) + && sgl_buf->next != NULL) { + remaining_off -= rte_pktmbuf_data_len(sgl_buf); + sgl_buf = sgl_buf->next; + } + + auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset( + sgl_buf, remaining_off); + } else { + auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) + + auth_offset + auth_len; + } + /* Then check if digest-encrypted conditions are met */ + if ((auth_offset + auth_len < cipher_offset + cipher_len) && + (digest.iova == auth_end_iova) && is_sgl) + max_len = RTE_MAX(max_len, + auth_offset + auth_len + + ut_params->auth_xform.auth.digest_length); + } else if (is_cipher) { cipher_offset = sop->cipher.data.offset; cipher_len = sop->cipher.data.length; @@ -327,7 +363,7 @@ process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id, sgl.num = n; /* Out of place */ - if (sop->m_dst != NULL) { + if (is_oop) { dest_sgl.vec = dest_data_vec; vec.dest_sgl = &dest_sgl; n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len, @@ -503,10 +539,6 @@ process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op) return op; } -static struct crypto_testsuite_params testsuite_params = { NULL }; -struct crypto_testsuite_params *p_testsuite_params = &testsuite_params; -static struct crypto_unittest_params unittest_params; - static int testsuite_setup(void) { @@ -4077,9 +4109,9 @@ test_kasumi_decryption(const struct kasumi_test_data *tdata) /* Create KASUMI operation */ retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data, - tdata->cipher_iv.len, - tdata->ciphertext.len, - tdata->validCipherOffsetInBits.len); + tdata->cipher_iv.len, + RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8), + tdata->validCipherOffsetInBits.len); if (retval < 0) return retval; @@ -7310,6 +7342,7 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, unsigned int plaintext_len; unsigned int ciphertext_pad_len; unsigned int ciphertext_len; + unsigned int data_len; struct rte_cryptodev_info dev_info; struct rte_crypto_op *op; @@ -7370,21 +7403,22 @@ test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, plaintext_len = ceil_byte_length(tdata->plaintext.len_bits); ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16); plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16); + data_len = RTE_MAX(ciphertext_pad_len, plaintext_pad_len); if (verify) { ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, - ciphertext_pad_len); + data_len); memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); if (op_mode == OUT_OF_PLACE) - rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len); + rte_pktmbuf_append(ut_params->obuf, data_len); debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len); } else { plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, - plaintext_pad_len); + data_len); memcpy(plaintext, tdata->plaintext.data, plaintext_len); if (op_mode == OUT_OF_PLACE) - rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len); + rte_pktmbuf_append(ut_params->obuf, data_len); debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len); } -- 2.17.1