From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D3484A31F3 for ; Fri, 18 Oct 2019 17:00:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5BD671C1B9; Fri, 18 Oct 2019 17:00:22 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 87A901C1AE for ; Fri, 18 Oct 2019 17:00:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Oct 2019 08:00:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,312,1566889200"; d="scan'208";a="202722892" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 18 Oct 2019 08:00:19 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 18 Oct 2019 08:00:19 -0700 Received: from hasmsx111.ger.corp.intel.com (10.184.198.39) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 18 Oct 2019 08:00:18 -0700 Received: from HASMSX109.ger.corp.intel.com ([169.254.3.95]) by HASMSX111.ger.corp.intel.com ([169.254.5.5]) with mapi id 14.03.0439.000; Fri, 18 Oct 2019 18:00:15 +0300 From: "Kusztal, ArkadiuszX" To: "Dybkowski, AdamX" , "dev@dpdk.org" , "Trahe, Fiona" , "Naveen.Kumar@commagility.com" Thread-Topic: [PATCH] test/crypto: add unit tests for AES-CTR + AES CMAC Thread-Index: AQHVhbYC/S8JPel5rEC+BuEHMpObzadgeP9w Date: Fri, 18 Oct 2019 15:00:15 +0000 Message-ID: <06EE24DD0B19E248B53F6DC8657831551B2B1E42@hasmsx109.ger.corp.intel.com> References: <20191018130235.7836-1-adamx.dybkowski@intel.com> In-Reply-To: <20191018130235.7836-1-adamx.dybkowski@intel.com> Accept-Language: pl-PL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.184.70.11] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] test/crypto: add unit tests for AES-CTR + AES CMAC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Hi Adam, Can you add some information that it is digest encrypted case? This change also needs change in QAT capabilities (currently we support 12-= 16 bytes digest size), I will send it as a fix as 3gpp specifies MAC-I for = CMAC as MSb32, same way as IPSec CMAC-96 (MSb96) which is already working. > -----Original Message----- > From: Dybkowski, AdamX > Sent: Friday, October 18, 2019 3:03 PM > To: dev@dpdk.org; Trahe, Fiona ; Kusztal, > ArkadiuszX ; > Naveen.Kumar@commagility.com > Cc: Dybkowski, AdamX > Subject: [PATCH] test/crypto: add unit tests for AES-CTR + AES CMAC >=20 > This patch adds tests for AES-CTR + AES CMAC using mixed auth-cipher > algorithm functions. Tests allow easy extending with new cases, check in- > place and out-of-place operations and use linear and sgl buffers as > input/output. >=20 > Signed-off-by: Adam Dybkowski > --- > app/test/test_cryptodev.c | 488 ++++++++++++++++++- > app/test/test_cryptodev_mixed_test_vectors.h | 172 +++++++ > 2 files changed, 656 insertions(+), 4 deletions(-) create mode 100644 > app/test/test_cryptodev_mixed_test_vectors.h >=20 > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index > 65d80837a..d5a8ec440 100644 > --- a/app/test/test_cryptodev.c > +++ b/app/test/test_cryptodev.c > @@ -38,6 +38,7 @@ > #include "test_cryptodev_zuc_test_vectors.h" > #include "test_cryptodev_aead_test_vectors.h" > #include "test_cryptodev_hmac_test_vectors.h" > +#include "test_cryptodev_mixed_test_vectors.h" > #ifdef RTE_LIBRTE_SECURITY > #include "test_cryptodev_security_pdcp_test_vectors.h" > #include "test_cryptodev_security_pdcp_test_func.h" > @@ -3021,6 +3022,11 @@ > create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len, > struct crypto_testsuite_params *ts_params =3D &testsuite_params; > struct crypto_unittest_params *ut_params =3D &unittest_params; >=20 > + enum rte_crypto_cipher_algorithm cipher_algo =3D > + ut_params->cipher_xform.cipher.algo; > + enum rte_crypto_auth_algorithm auth_algo =3D > + ut_params->auth_xform.auth.algo; > + > /* Generate Crypto op data structure */ > ut_params->op =3D rte_crypto_op_alloc(ts_params->op_mpool, > RTE_CRYPTO_OP_TYPE_SYMMETRIC); > @@ -3076,11 +3082,25 @@ > create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len, > iv_ptr +=3D cipher_iv_len; > rte_memcpy(iv_ptr, auth_iv, auth_iv_len); >=20 > - sym_op->cipher.data.length =3D cipher_len; > - sym_op->cipher.data.offset =3D cipher_offset; > + if (cipher_algo =3D=3D RTE_CRYPTO_CIPHER_SNOW3G_UEA2 || > + cipher_algo =3D=3D RTE_CRYPTO_CIPHER_KASUMI_F8 || > + cipher_algo =3D=3D RTE_CRYPTO_CIPHER_ZUC_EEA3) { > + sym_op->cipher.data.length =3D cipher_len; > + sym_op->cipher.data.offset =3D cipher_offset; > + } else { > + sym_op->cipher.data.length =3D cipher_len >> 3; > + sym_op->cipher.data.offset =3D cipher_offset >> 3; > + } >=20 > - sym_op->auth.data.length =3D auth_len; > - sym_op->auth.data.offset =3D auth_offset; > + if (auth_algo =3D=3D RTE_CRYPTO_AUTH_SNOW3G_UIA2 || > + auth_algo =3D=3D RTE_CRYPTO_AUTH_KASUMI_F9 || > + auth_algo =3D=3D RTE_CRYPTO_AUTH_ZUC_EIA3) { > + sym_op->auth.data.length =3D auth_len; > + sym_op->auth.data.offset =3D auth_offset; > + } else { > + sym_op->auth.data.length =3D auth_len >> 3; > + sym_op->auth.data.offset =3D auth_offset >> 3; > + } >=20 > return 0; > } > @@ -6511,6 +6531,446 @@ > test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void) > &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1); } >=20 > +static int > +test_mixed_check_if_unsupported(const struct > +mixed_cipher_auth_test_data *tdata) { > + uint8_t dev_id =3D testsuite_params.valid_devs[0]; > + > + struct rte_cryptodev_sym_capability_idx cap_idx; > + > + /* Check if device supports particular cipher algorithm */ > + cap_idx.type =3D RTE_CRYPTO_SYM_XFORM_CIPHER; > + cap_idx.algo.cipher =3D tdata->cipher_algo; > + if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) =3D=3D NULL) > + return -ENOTSUP; > + > + /* Check if device supports particular hash algorithm */ > + cap_idx.type =3D RTE_CRYPTO_SYM_XFORM_AUTH; > + cap_idx.algo.auth =3D tdata->auth_algo; > + if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) =3D=3D NULL) > + return -ENOTSUP; > + > + return 0; > +} > + > +static int > +test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata, > + uint8_t op_mode, uint8_t verify) > +{ > + struct crypto_testsuite_params *ts_params =3D &testsuite_params; > + struct crypto_unittest_params *ut_params =3D &unittest_params; > + > + int retval; > + > + uint8_t *plaintext =3D NULL, *ciphertext =3D NULL; > + unsigned int plaintext_pad_len; > + unsigned int plaintext_len; > + unsigned int ciphertext_pad_len; > + unsigned int ciphertext_len; > + > + struct rte_cryptodev_info dev_info; > + > + /* Check if device supports particular algorithms */ > + if (test_mixed_check_if_unsupported(tdata)) > + return -ENOTSUP; > + > + rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); > + > + uint64_t feat_flags =3D dev_info.feature_flags; > + > + if (op_mode =3D=3D OUT_OF_PLACE) { > + if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { > + printf("Device doesn't support digest encrypted.\n"); > + return -ENOTSUP; > + } > + } > + > + /* Create the session */ > + retval =3D create_wireless_algo_auth_cipher_session( > + ts_params->valid_devs[0], > + (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT > + : > RTE_CRYPTO_CIPHER_OP_ENCRYPT), > + (verify ? RTE_CRYPTO_AUTH_OP_VERIFY > + : > RTE_CRYPTO_AUTH_OP_GENERATE), > + tdata->auth_algo, > + tdata->cipher_algo, > + tdata->auth_key.data, tdata->auth_key.len, > + tdata->auth_iv.len, tdata->digest_enc.len, > + tdata->cipher_iv.len); > + > + if (retval < 0) > + return retval; > + > + ut_params->ibuf =3D rte_pktmbuf_alloc(ts_params->mbuf_pool); > + if (op_mode =3D=3D OUT_OF_PLACE) > + ut_params->obuf =3D rte_pktmbuf_alloc(ts_params- > >mbuf_pool); > + > + /* clear mbuf payload */ > + memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0, > + rte_pktmbuf_tailroom(ut_params->ibuf)); > + if (op_mode =3D=3D OUT_OF_PLACE) > + memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0, > + rte_pktmbuf_tailroom(ut_params->obuf)); > + > + ciphertext_len =3D ceil_byte_length(tdata->ciphertext.len_bits); > + plaintext_len =3D ceil_byte_length(tdata->plaintext.len_bits); > + ciphertext_pad_len =3D RTE_ALIGN_CEIL(ciphertext_len, 16); > + plaintext_pad_len =3D RTE_ALIGN_CEIL(plaintext_len, 16); > + > + if (verify) { > + ciphertext =3D (uint8_t *)rte_pktmbuf_append(ut_params- > >ibuf, > + ciphertext_pad_len); > + memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len); > + if (op_mode =3D=3D OUT_OF_PLACE) > + rte_pktmbuf_append(ut_params->obuf, > ciphertext_pad_len); > + debug_hexdump(stdout, "ciphertext:", ciphertext, > + ciphertext_len); > + } else { > + plaintext =3D (uint8_t *)rte_pktmbuf_append(ut_params->ibuf, > + plaintext_pad_len); > + memcpy(plaintext, tdata->plaintext.data, plaintext_len); > + if (op_mode =3D=3D OUT_OF_PLACE) > + rte_pktmbuf_append(ut_params->obuf, > plaintext_pad_len); > + debug_hexdump(stdout, "plaintext:", plaintext, > plaintext_len); > + } > + > + /* Create the operation */ > + retval =3D create_wireless_algo_auth_cipher_operation( > + tdata->digest_enc.len, > + tdata->cipher_iv.data, tdata->cipher_iv.len, > + tdata->auth_iv.data, tdata->auth_iv.len, > + (tdata->digest_enc.offset =3D=3D 0 ? > + (verify ? ciphertext_pad_len : plaintext_pad_len) > + : tdata->digest_enc.offset), > + tdata->validCipherLen.len_bits, > + tdata->cipher.offset_bits, > + tdata->validAuthLen.len_bits, > + tdata->auth.offset_bits, > + op_mode, 0); > + > + if (retval < 0) > + return retval; > + > + ut_params->op =3D process_crypto_request(ts_params->valid_devs[0], > + ut_params->op); > + > + TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); > + > + ut_params->obuf =3D (op_mode =3D=3D IN_PLACE ? > + ut_params->op->sym->m_src : ut_params->op->sym- > >m_dst); > + > + if (verify) { > + if (ut_params->obuf) > + plaintext =3D rte_pktmbuf_mtod(ut_params->obuf, > + uint8_t *); > + else > + plaintext =3D ciphertext + > + (tdata->cipher.offset_bits >> 3); > + > + debug_hexdump(stdout, "plaintext:", plaintext, > + (tdata->plaintext.len_bits >> 3) - > + tdata->digest_enc.len); > + debug_hexdump(stdout, "plaintext expected:", > + tdata->plaintext.data, > + (tdata->plaintext.len_bits >> 3) - > + tdata->digest_enc.len); > + } else { > + if (ut_params->obuf) > + ciphertext =3D rte_pktmbuf_mtod(ut_params->obuf, > + uint8_t *); > + else > + ciphertext =3D plaintext; > + > + debug_hexdump(stdout, "ciphertext:", ciphertext, > + ciphertext_len); > + debug_hexdump(stdout, "ciphertext expected:", > + tdata->ciphertext.data, > + tdata->ciphertext.len_bits >> 3); > + > + ut_params->digest =3D rte_pktmbuf_mtod(ut_params->obuf, > uint8_t *) > + + (tdata->digest_enc.offset =3D=3D 0 ? > + plaintext_pad_len : tdata->digest_enc.offset); > + > + debug_hexdump(stdout, "digest:", ut_params->digest, > + tdata->digest_enc.len); > + debug_hexdump(stdout, "digest expected:", > + tdata->digest_enc.data, > + tdata->digest_enc.len); > + } > + > + /* Validate obuf */ > + if (verify) { > + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( > + plaintext, > + tdata->plaintext.data, > + tdata->plaintext.len_bits >> 3, > + "Plaintext data not as expected"); > + } else { > + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( > + ciphertext, > + tdata->ciphertext.data, > + tdata->validDataLen.len_bits, > + "Ciphertext data not as expected"); > + > + TEST_ASSERT_BUFFERS_ARE_EQUAL( > + ut_params->digest, > + tdata->digest_enc.data, > + DIGEST_BYTE_LENGTH_SNOW3G_UIA2, > + "Generated auth tag not as expected"); > + } > + return 0; > +} > + > +static int > +test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data > *tdata, > + uint8_t op_mode, uint8_t verify) > +{ > + struct crypto_testsuite_params *ts_params =3D &testsuite_params; > + struct crypto_unittest_params *ut_params =3D &unittest_params; > + > + int retval; > + > + const uint8_t *plaintext =3D NULL; > + const uint8_t *ciphertext =3D NULL; > + const uint8_t *digest =3D NULL; > + unsigned int plaintext_pad_len; > + unsigned int plaintext_len; > + unsigned int ciphertext_pad_len; > + unsigned int ciphertext_len; > + uint8_t buffer[10000]; > + uint8_t digest_buffer[10000]; > + > + struct rte_cryptodev_info dev_info; > + > + /* Check if device supports particular algorithms */ > + if (test_mixed_check_if_unsupported(tdata)) > + return -ENOTSUP; > + > + rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info); > + > + uint64_t feat_flags =3D dev_info.feature_flags; > + > + if (op_mode =3D=3D IN_PLACE) { > + if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) { > + printf("Device doesn't support in-place scatter-gather > " > + "in both input and output > mbufs.\n"); > + return -ENOTSUP; > + } > + } else { > + if (!(feat_flags & > RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) { > + printf("Device doesn't support out-of-place scatter- > gather " > + "in both input and output > mbufs.\n"); > + return -ENOTSUP; > + } > + if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) { > + printf("Device doesn't support digest encrypted.\n"); > + return -ENOTSUP; > + } > + } > + > + /* Create the session */ > + retval =3D create_wireless_algo_auth_cipher_session( > + ts_params->valid_devs[0], > + (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT > + : > RTE_CRYPTO_CIPHER_OP_ENCRYPT), > + (verify ? RTE_CRYPTO_AUTH_OP_VERIFY > + : > RTE_CRYPTO_AUTH_OP_GENERATE), > + tdata->auth_algo, > + tdata->cipher_algo, > + tdata->auth_key.data, tdata->auth_key.len, > + tdata->auth_iv.len, tdata->digest_enc.len, > + tdata->cipher_iv.len); > + > + if (retval < 0) > + return retval; > + > + ciphertext_len =3D ceil_byte_length(tdata->ciphertext.len_bits); > + plaintext_len =3D ceil_byte_length(tdata->plaintext.len_bits); > + ciphertext_pad_len =3D RTE_ALIGN_CEIL(ciphertext_len, 16); > + plaintext_pad_len =3D RTE_ALIGN_CEIL(plaintext_len, 16); > + > + ut_params->ibuf =3D create_segmented_mbuf(ts_params->mbuf_pool, > + plaintext_pad_len, 15, 0); > + TEST_ASSERT_NOT_NULL(ut_params->ibuf, > + "Failed to allocate input buffer in mempool"); > + > + if (op_mode =3D=3D OUT_OF_PLACE) { > + ut_params->obuf =3D create_segmented_mbuf(ts_params- > >mbuf_pool, > + plaintext_pad_len, 15, 0); > + TEST_ASSERT_NOT_NULL(ut_params->obuf, > + "Failed to allocate output buffer in > mempool"); > + } > + > + if (verify) { > + pktmbuf_write(ut_params->ibuf, 0, ciphertext_len, > + tdata->ciphertext.data); > + ciphertext =3D rte_pktmbuf_read(ut_params->ibuf, 0, > + ciphertext_len, buffer); > + debug_hexdump(stdout, "ciphertext:", ciphertext, > + ciphertext_len); > + } else { > + pktmbuf_write(ut_params->ibuf, 0, plaintext_len, > + tdata->plaintext.data); > + plaintext =3D rte_pktmbuf_read(ut_params->ibuf, 0, > + plaintext_len, buffer); > + debug_hexdump(stdout, "plaintext:", plaintext, > + plaintext_len); > + } > + memset(buffer, 0, sizeof(buffer)); > + > + /* Create the operation */ > + retval =3D create_wireless_algo_auth_cipher_operation( > + tdata->digest_enc.len, > + tdata->cipher_iv.data, tdata->cipher_iv.len, > + tdata->auth_iv.data, tdata->auth_iv.len, > + (tdata->digest_enc.offset =3D=3D 0 ? > + (verify ? ciphertext_pad_len : plaintext_pad_len) > + : tdata->digest_enc.offset), > + tdata->validCipherLen.len_bits, > + tdata->cipher.offset_bits, > + tdata->validAuthLen.len_bits, > + tdata->auth.offset_bits, > + op_mode, 1); > + > + if (retval < 0) > + return retval; > + > + ut_params->op =3D process_crypto_request(ts_params->valid_devs[0], > + ut_params->op); > + > + TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf"); > + > + ut_params->obuf =3D (op_mode =3D=3D IN_PLACE ? > + ut_params->op->sym->m_src : ut_params->op->sym- > >m_dst); > + > + if (verify) { > + if (ut_params->obuf) > + plaintext =3D rte_pktmbuf_read(ut_params->obuf, 0, > + plaintext_len, buffer); > + else > + plaintext =3D rte_pktmbuf_read(ut_params->ibuf, 0, > + plaintext_len, buffer); > + > + debug_hexdump(stdout, "plaintext:", plaintext, > + (tdata->plaintext.len_bits >> 3) - > + tdata->digest_enc.len); > + debug_hexdump(stdout, "plaintext expected:", > + tdata->plaintext.data, > + (tdata->plaintext.len_bits >> 3) - > + tdata->digest_enc.len); > + } else { > + if (ut_params->obuf) > + ciphertext =3D rte_pktmbuf_read(ut_params->obuf, 0, > + ciphertext_len, buffer); > + else > + ciphertext =3D rte_pktmbuf_read(ut_params->ibuf, 0, > + ciphertext_len, buffer); > + > + debug_hexdump(stdout, "ciphertext:", ciphertext, > + ciphertext_len); > + debug_hexdump(stdout, "ciphertext expected:", > + tdata->ciphertext.data, > + tdata->ciphertext.len_bits >> 3); > + > + if (ut_params->obuf) > + digest =3D rte_pktmbuf_read(ut_params->obuf, > + (tdata->digest_enc.offset =3D=3D 0 ? > + plaintext_pad_len : > + tdata->digest_enc.offset), > + tdata->digest_enc.len, digest_buffer); > + else > + digest =3D rte_pktmbuf_read(ut_params->ibuf, > + (tdata->digest_enc.offset =3D=3D 0 ? > + plaintext_pad_len : > + tdata->digest_enc.offset), > + tdata->digest_enc.len, digest_buffer); > + > + debug_hexdump(stdout, "digest:", digest, > + tdata->digest_enc.len); > + debug_hexdump(stdout, "digest expected:", > + tdata->digest_enc.data, tdata- > >digest_enc.len); > + } > + > + /* Validate obuf */ > + if (verify) { > + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( > + plaintext, > + tdata->plaintext.data, > + tdata->plaintext.len_bits >> 3, > + "Plaintext data not as expected"); > + } else { > + TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT( > + ciphertext, > + tdata->ciphertext.data, > + tdata->validDataLen.len_bits, > + "Ciphertext data not as expected"); > + TEST_ASSERT_BUFFERS_ARE_EQUAL( > + digest, > + tdata->digest_enc.data, > + tdata->digest_enc.len, > + "Generated auth tag not as expected"); > + } > + return 0; > +} > + > +/** AUTH AES CMAC + CIPHER AES CTR */ > + > +static int > +test_aes_cmac_aes_ctr_test_case_1(void) > +{ > + return test_mixed_auth_cipher( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0); > } > + > +static int > +test_aes_cmac_aes_ctr_test_case_1_oop(void) > +{ > + return test_mixed_auth_cipher( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, > OUT_OF_PLACE, 0); } > + > +static int > +test_aes_cmac_aes_ctr_test_case_1_sgl(void) > +{ > + return test_mixed_auth_cipher_sgl( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0); > } > + > +static int > +test_aes_cmac_aes_ctr_test_case_1_oop_sgl(void) > +{ > + return test_mixed_auth_cipher_sgl( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, > OUT_OF_PLACE, 0); } > + > +static int > +test_verify_aes_cmac_aes_ctr_test_case_1(void) > +{ > + return test_mixed_auth_cipher( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1); > } > + > +static int > +test_verify_aes_cmac_aes_ctr_test_case_1_oop(void) > +{ > + return test_mixed_auth_cipher( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, > OUT_OF_PLACE, 1); } > + > +static int > +test_verify_aes_cmac_aes_ctr_test_case_1_sgl(void) > +{ > + return test_mixed_auth_cipher_sgl( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1); > } > + > +static int > +test_verify_aes_cmac_aes_ctr_test_case_1_oop_sgl(void) > +{ > + return test_mixed_auth_cipher_sgl( > + &auth_aes_cmac_cipher_aes_ctr_test_case_1, > OUT_OF_PLACE, 1); } > + > static int > test_3DES_chain_qat_all(void) > { > @@ -11802,6 +12262,26 @@ static struct unit_test_suite > cryptodev_qat_testsuite =3D { > TEST_CASE_ST(ut_setup, ut_teardown, >=20 > auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt), >=20 > + /** Mixed CIPHER + HASH algorithms */ > + > + /** AUTH AES CMAC + CIPHER AES CTR */ > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_aes_cmac_aes_ctr_test_case_1), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_aes_cmac_aes_ctr_test_case_1_oop), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_aes_cmac_aes_ctr_test_case_1_sgl), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_aes_cmac_aes_ctr_test_case_1_oop_sgl), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_verify_aes_cmac_aes_ctr_test_case_1), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_verify_aes_cmac_aes_ctr_test_case_1_oop), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_verify_aes_cmac_aes_ctr_test_case_1_sgl), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_verify_aes_cmac_aes_ctr_test_case_1_oop_sgl), > + > TEST_CASES_END() /**< NULL terminate unit test array */ > } > }; > diff --git a/app/test/test_cryptodev_mixed_test_vectors.h > b/app/test/test_cryptodev_mixed_test_vectors.h > new file mode 100644 > index 000000000..bca47c05c > --- /dev/null > +++ b/app/test/test_cryptodev_mixed_test_vectors.h > @@ -0,0 +1,172 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2019 Intel Corporation > + */ > + > +#ifndef TEST_CRYPTODEV_MIXED_TEST_VECTORS_H_ > +#define TEST_CRYPTODEV_MIXED_TEST_VECTORS_H_ > + > +struct mixed_cipher_auth_test_data { > + > + enum rte_crypto_auth_algorithm auth_algo; > + > + struct { > + uint8_t data[64]; > + unsigned int len; /* length must be in Bytes */ > + } auth_key; > + > + struct { > + uint8_t data[64]; > + unsigned int len; /* length must be in Bytes */ > + } auth_iv; > + > + struct { > + unsigned int len_bits; > + unsigned int offset_bits; > + } auth; > + > + enum rte_crypto_cipher_algorithm cipher_algo; > + > + struct { > + uint8_t data[64]; > + unsigned int len; /* length must be in Bytes */ > + } cipher_key; > + > + struct { > + uint8_t data[64] __rte_aligned(16); > + unsigned int len; /* length must be in Bytes */ > + } cipher_iv; > + > + struct { > + unsigned int len_bits; > + unsigned int offset_bits; > + } cipher; > + > + struct { > + uint8_t data[1024]; > + unsigned int len_bits; > + } plaintext; > + > + struct { > + uint8_t data[1024]; > + unsigned int len_bits; > + } ciphertext; > + > + struct { > + uint8_t data[64]; > + unsigned int len; /* length must be in Bytes */ > + unsigned int offset; /* offset must be in Bytes */ > + } digest_enc; > + > + struct { > + unsigned int len_bits; > + } validDataLen; > + > + struct { > + unsigned int len_bits; > + } validCipherLen; > + > + struct { > + unsigned int len_bits; > + } validAuthLen; > +}; > + > +struct mixed_cipher_auth_test_data > auth_aes_cmac_cipher_aes_ctr_test_case_1 =3D { > + .auth_algo =3D RTE_CRYPTO_AUTH_AES_CMAC, > + .auth_key =3D { > + .data =3D { > + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, > + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, > + }, > + .len =3D 16, > + }, > + .auth_iv =3D { > + .data =3D { > + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + }, > + .len =3D 16, > + }, > + .auth =3D { > + .len_bits =3D 124 << 3, > + .offset_bits =3D 0, > + }, > + .cipher_algo =3D RTE_CRYPTO_CIPHER_AES_CTR, > + .cipher_key =3D { > + .data =3D { > + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, > + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, > + }, > + .len =3D 16, > + }, > + .cipher_iv =3D { > + .data =3D { > + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, > + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, > + }, > + .len =3D 16, > + }, > + .cipher =3D { > + .len_bits =3D 126 << 3, > + .offset_bits =3D 2 << 3, > + }, > + .plaintext =3D { > + .data =3D { > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, > + }, > + .len_bits =3D 128 << 3, > + }, > + .ciphertext =3D { > + .data =3D { > + 0x5A, 0x5A, 0xC9, 0x79, 0xCA, 0xCB, 0xDF, 0x96, > + 0x97, 0xA5, 0xB0, 0xFC, 0x56, 0xE9, 0xC4, 0xB4, > + 0x32, 0x5F, 0x55, 0x59, 0xCF, 0x1A, 0xA5, 0xB5, > + 0x63, 0xAC, 0x94, 0x87, 0x6F, 0xFB, 0x5A, 0x54, > + 0x4E, 0xE2, 0x2B, 0x32, 0x04, 0x0C, 0xDF, 0x7D, > + 0x58, 0x73, 0xCE, 0x64, 0x71, 0xEA, 0x31, 0x19, > + 0xE1, 0x37, 0x9E, 0x89, 0x15, 0x1F, 0xDE, 0x99, > + 0x17, 0x80, 0x2A, 0x95, 0xAB, 0x37, 0xDF, 0x01, > + 0x7F, 0x3B, 0x17, 0x07, 0xFA, 0x93, 0xC9, 0xC8, > + 0x6A, 0x1C, 0xE2, 0x34, 0x2F, 0x33, 0x59, 0xE4, > + 0xE2, 0x56, 0x1A, 0x23, 0xCC, 0xCE, 0x29, 0x33, > + 0xC7, 0xAF, 0x92, 0x28, 0x86, 0x5B, 0x91, 0x5B, > + 0x0E, 0x4E, 0xFB, 0x3B, 0x9D, 0x9F, 0xDF, 0x16, > + 0x79, 0x90, 0x86, 0xBA, 0x70, 0xD9, 0xF7, 0x9B, > + 0xEC, 0x46, 0xA9, 0x98, 0x5A, 0xF1, 0x5A, 0x05, > + 0x3E, 0xD9, 0xE5, 0x03, 0x5D, 0x41, 0xB4, 0xDF > + }, > + .len_bits =3D 128 << 3, > + }, > + .digest_enc =3D { > + .data =3D { > + 0x5D, 0x41, 0xB4, 0xDF, > + }, > + .len =3D 4, > + .offset =3D 124, > + }, > + .validDataLen =3D { > + .len_bits =3D 128 << 3, > + }, > + .validCipherLen =3D { > + .len_bits =3D 126 << 3, > + }, > + .validAuthLen =3D { > + .len_bits =3D 124 << 3, > + } > +}; > + > +#endif /* TEST_CRYPTODEV_MIXED_TEST_VECTORS_H_ */ > -- > 2.17.1