From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id DA445A0679 for ; Thu, 28 Mar 2019 14:09:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA5ED1B150; Thu, 28 Mar 2019 14:09:32 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 069C61B146 for ; Thu, 28 Mar 2019 14:09:30 +0100 (CET) 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; 28 Mar 2019 06:09:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="144619126" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by FMSMGA003.fm.intel.com with ESMTP; 28 Mar 2019 06:09:29 -0700 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.230]) by IRSMSX106.ger.corp.intel.com ([169.254.8.205]) with mapi id 14.03.0415.000; Thu, 28 Mar 2019 13:09:28 +0000 From: "Trahe, Fiona" To: "Krakowiak, LukaszX" , "De Lara Guarch, Pablo" CC: "dev@dpdk.org" , "Trahe, Fiona" Thread-Topic: [PATCH v3] test: add snow3g test cases when digest is encrypted Thread-Index: AQHU4vluN4aBhxReKk+oQ+OpBkpQ8qYhCLSg Date: Thu, 28 Mar 2019 13:09:27 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B4358972104E@IRSMSX101.ger.corp.intel.com> References: <20190227101802.7228-1-lukaszx.krakowiak@intel.com> <20190325104758.14855-1-lukaszx.krakowiak@intel.com> In-Reply-To: <20190325104758.14855-1-lukaszx.krakowiak@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWI3NmRmMzItMjkxMi00ZDg5LWI5YjMtMjQ1NjhjZTZlMWIzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoielNvbkh5YVwvY25GODhQYWhwY21yaUtPSGQwOXVMajY2WlZHTHROeXBEUHA3QkdCYWdyZlwvQ2F0QmlnQVF4UlNsIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] test: add snow3g test cases when digest is encrypted 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" Message-ID: <20190328130927.GD5pR7llYfvzNhUoF7nxcmjWyVP72QsAHF-y6rF9mb4@z> > -----Original Message----- > From: Krakowiak, LukaszX > Sent: Monday, March 25, 2019 10:48 AM > To: De Lara Guarch, Pablo > Cc: dev@dpdk.org; Trahe, Fiona ; Krakowiak, Lukasz= X > > Subject: [PATCH v3] test: add snow3g test cases when digest is encrypted >=20 > Add test case for encryption, dectryption for snow3g when digest > is encrypted >=20 > --- > v3: > * fixed path for test directory. >=20 > v2: > * coding style improved >=20 > Signed-off-by: Lukasz Krakowiak > --- > app/test/test_cryptodev.c | 91 ++++++++++-- > app/test/test_cryptodev_snow3g_test_vectors.h | 132 +++++++++++++++++- > 2 files changed, 210 insertions(+), 13 deletions(-) >=20 > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c > index 2ff204137..9f31aaa7e 100644 > --- a/app/test/test_cryptodev.c > +++ b/app/test/test_cryptodev.c > @@ -2834,8 +2834,8 @@ create_wireless_algo_auth_cipher_operation(unsigned= int auth_tag_len, > sym_op->m_src =3D ut_params->ibuf; >=20 > /* digest */ > - sym_op->auth.digest.data =3D (uint8_t *)rte_pktmbuf_append( > - ut_params->ibuf, auth_tag_len); > + sym_op->auth.digest.data =3D (uint8_t *) rte_pktmbuf_mtod_offset( > + ut_params->ibuf, uint8_t *, data_pad_len); >=20 > TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data, > "no room to append auth tag"); > @@ -2845,10 +2845,6 @@ create_wireless_algo_auth_cipher_operation(unsigne= d int auth_tag_len, >=20 > memset(sym_op->auth.digest.data, 0, auth_tag_len); >=20 > - debug_hexdump(stdout, "digest:", > - sym_op->auth.digest.data, > - auth_tag_len); > - > /* Copy cipher and auth IVs at the end of the crypto operation */ > uint8_t *iv_ptr =3D rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, > IV_OFFSET); > @@ -4053,7 +4049,7 @@ static int test_snow3g_decryption(const struct snow= 3g_test_data *tdata) > retval =3D create_wireless_algo_cipher_operation(tdata->cipher_iv.data, > tdata->cipher_iv.len, > tdata->validCipherLenInBits.len, > - 0); > + tdata->cipher.offset_bits); > if (retval < 0) > return retval; >=20 > @@ -4361,11 +4357,12 @@ test_snow3g_auth_cipher(const struct snow3g_test_= data *tdata) > tdata->digest.len, > tdata->cipher_iv.data, tdata->cipher_iv.len, > tdata->auth_iv.data, tdata->auth_iv.len, > - plaintext_pad_len, > + tdata->digest.offset_bytes =3D=3D 0 ? > + plaintext_pad_len : tdata->digest.offset_bytes, > tdata->validCipherLenInBits.len, > - 0, > + tdata->cipher.offset_bits, > tdata->validAuthLenInBits.len, > - 0); > + tdata->auth.offset_bits); >=20 > if (retval < 0) > return retval; > @@ -4380,7 +4377,10 @@ test_snow3g_auth_cipher(const struct snow3g_test_d= ata *tdata) > ciphertext =3D plaintext; >=20 > ut_params->digest =3D rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) > - + plaintext_pad_len; > + + (tdata->digest.offset_bytes =3D=3D 0 ? > + plaintext_pad_len : tdata->digest.offset_bytes); > + > + debug_hexdump(stdout, "digest:", ut_params->digest, tdata->digest.len); > debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len); >=20 > /* Validate obuf */ > @@ -4974,6 +4974,61 @@ test_snow3g_decryption_test_case_5(void) > { > return test_snow3g_decryption(&snow3g_test_case_5); > } > + > +/* > + * Function prepares snow3g_hash_test_data from snow3g_test_data. > + * Pattern digest from snow3g_test_data must be allocated as > + * 4 last bytes in plaintext. > + */ > +static void > +snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern, > + struct snow3g_hash_test_data *output) > +{ > + if ((pattern !=3D NULL) && (output !=3D NULL)) { > + output->key.len =3D pattern->key.len; > + > + memcpy(output->key.data, > + pattern->key.data, pattern->key.len); > + > + output->auth_iv.len =3D pattern->auth_iv.len; > + > + memcpy(output->auth_iv.data, > + pattern->auth_iv.data, pattern->auth_iv.len); > + > + output->plaintext.len =3D pattern->plaintext.len; > + > + memcpy(output->plaintext.data, > + pattern->plaintext.data, pattern->plaintext.len >> 3); > + > + output->digest.len =3D pattern->digest.len; > + > + memcpy(output->digest.data, > + &pattern->plaintext.data[pattern->digest.offset_bytes], > + pattern->digest.len); > + > + output->validAuthLenInBits.len =3D > + pattern->validAuthLenInBits.len; > + } > +} > + > +/* > + * Test case verify computed cipher and digest from snow3g_test_case_7 d= ata. > + */ > +static int > +test_snow3g_decryption_with_digest_test_case_1(void) > +{ > + struct snow3g_hash_test_data snow3g_hash_data; > + > + /* > + * Function prepare data for hash veryfication test case. > + * Digest is allocated in 4 last bytes in plaintext, pattern. > + */ > + snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data); > + > + return test_snow3g_decryption(&snow3g_test_case_7) & > + test_snow3g_authentication_verify(&snow3g_hash_data); > +} > + > static int > test_snow3g_cipher_auth_test_case_1(void) > { > @@ -4986,6 +5041,12 @@ test_snow3g_auth_cipher_test_case_1(void) > return test_snow3g_auth_cipher(&snow3g_test_case_6); > } >=20 > +static int > +test_snow3g_auth_cipher_with_digest_test_case_1(void) > +{ > + return test_snow3g_auth_cipher(&snow3g_test_case_7); > +} > + > static int > test_kasumi_auth_cipher_test_case_1(void) > { > @@ -9139,6 +9200,8 @@ static struct unit_test_suite cryptodev_qat_testsui= te =3D { > test_snow3g_decryption_test_case_4), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_decryption_test_case_5), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_snow3g_decryption_with_digest_test_case_1), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_hash_generate_test_case_1), > TEST_CASE_ST(ut_setup, ut_teardown, > @@ -9155,6 +9218,8 @@ static struct unit_test_suite cryptodev_qat_testsui= te =3D { > test_snow3g_cipher_auth_test_case_1), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_auth_cipher_test_case_1), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_snow3g_auth_cipher_with_digest_test_case_1), >=20 > /** ZUC encrypt only (EEA3) */ > TEST_CASE_ST(ut_setup, ut_teardown, > @@ -9873,6 +9938,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_t= estsuite =3D { > test_snow3g_encryption_test_case_4), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_encryption_test_case_5), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_snow3g_auth_cipher_with_digest_test_case_1), >=20 > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_encryption_test_case_1_oop), > @@ -9895,6 +9962,8 @@ static struct unit_test_suite cryptodev_sw_snow3g_t= estsuite =3D { > test_snow3g_decryption_test_case_4), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_decryption_test_case_5), > + TEST_CASE_ST(ut_setup, ut_teardown, > + test_snow3g_decryption_with_digest_test_case_1), > TEST_CASE_ST(ut_setup, ut_teardown, > test_snow3g_hash_generate_test_case_1), > TEST_CASE_ST(ut_setup, ut_teardown, > diff --git a/app/test/test_cryptodev_snow3g_test_vectors.h > b/app/test/test_cryptodev_snow3g_test_vectors.h > index cb9dc4b35..3e55ac1f9 100644 > --- a/app/test/test_cryptodev_snow3g_test_vectors.h > +++ b/app/test/test_cryptodev_snow3g_test_vectors.h > @@ -45,8 +45,19 @@ struct snow3g_test_data { >=20 > struct { > uint8_t data[64]; > - unsigned len; > + unsigned int len; /* length must be in Bytes */ > + unsigned int offset_bytes; /* offset must be in Bytes */ > } digest; > + > + struct { > + unsigned int len_bits; /* length must be in Bits */ > + unsigned int offset_bits; > + } cipher; > + > + struct { > + unsigned int len_bits; /* length must be in Bits */ > + unsigned int offset_bits; > + } auth; > }; > struct snow3g_test_data snow3g_test_case_1 =3D { > .key =3D { > @@ -99,6 +110,9 @@ struct snow3g_test_data snow3g_test_case_1 =3D { > }, > .len =3D 800 > }, > + .cipher =3D { > + .offset_bits =3D 0 > + }, > .validDataLenInBits =3D { > .len =3D 798 > }, > @@ -155,6 +169,9 @@ struct snow3g_test_data snow3g_test_case_2 =3D { > }, > .len =3D 512 > }, > + .cipher =3D { > + .offset_bits =3D 0 > + }, > .validDataLenInBits =3D { > .len =3D 510 > }, > @@ -199,6 +216,9 @@ struct snow3g_test_data snow3g_test_case_3 =3D { > }, > .len =3D 120 > }, > + .cipher =3D { > + .offset_bits =3D 0 > + }, > .validDataLenInBits =3D { > .len =3D 120 > }, > @@ -254,6 +274,9 @@ struct snow3g_test_data snow3g_test_case_4 =3D { > }, > .len =3D 256 > }, > + .cipher =3D { > + .offset_bits =3D 0 > + }, > .validDataLenInBits =3D { > .len =3D 253 > }, > @@ -314,6 +337,9 @@ struct snow3g_test_data snow3g_test_case_5 =3D { > }, > .len =3D 840 > }, > + .cipher =3D { > + .offset_bits =3D 0 > + }, > .validDataLenInBits =3D { > .len =3D 837 > }, > @@ -365,9 +391,18 @@ struct snow3g_test_data snow3g_test_case_6 =3D { > }, > .len =3D 384 > }, > + .cipher =3D { > + .len_bits =3D 384, > + .offset_bits =3D 0 > + }, > + .auth =3D { > + .len_bits =3D 384, > + .offset_bits =3D 0 > + }, > .digest =3D { > .data =3D {0x38, 0xB5, 0x54, 0xC0 }, > - .len =3D 4 > + .len =3D 4, > + .offset_bytes =3D 0 > }, > .validDataLenInBits =3D { > .len =3D 384 > @@ -380,4 +415,97 @@ struct snow3g_test_data snow3g_test_case_6 =3D { > }, > }; >=20 > + > +struct snow3g_test_data snow3g_test_case_7 =3D { > + .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, > + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 > + }, > + .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 > + }, > + .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, 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0x85, > + 0xB2, 0x92, 0x7C, 0x37, 0xD3, 0x2E, 0xD9, 0xF4, > + 0x4A, 0x69, 0x25, 0x30, 0xE3, 0x5B, 0x8B, 0xF6, > + 0x0F, 0xDE, 0x0B, 0x92, 0xD5, 0x25, 0x52, 0x6D, > + 0x26, 0xEB, 0x2F, 0x8A, 0x3B, 0x8B, 0x38, 0xE2, > + 0x48, 0xD3, 0x4A, 0x98, 0xF7, 0x3A, 0xC2, 0x46, > + 0x69, 0x8D, 0x73, 0x3E, 0x57, 0x88, 0x2C, 0x80, > + 0xF0, 0xF2, 0x75, 0xB8, 0x7D, 0x27, 0xC6, 0xDA, > + > + }, > + .len =3D 128 << 3 > + }, > + .cipher =3D { > + .len_bits =3D 126 << 3, > + .offset_bits =3D 2 << 3 > + }, > + .auth =3D { > + .len_bits =3D 124 << 3, > + .offset_bits =3D 0 > + }, > + .digest =3D { > + .data =3D { > + 0x7D, 0x27, 0xC6, 0xDA > + }, > + .len =3D 4, > + .offset_bytes =3D 124 > + }, > + .validDataLenInBits =3D { > + .len =3D 128 << 3 > + }, > + .validCipherLenInBits =3D { > + .len =3D 126 << 3 > + }, > + .validAuthLenInBits =3D { > + .len =3D 124 << 3 > + }, > +}; > + > #endif /* TEST_CRYPTODEV_SNOW3G_TEST_VECTORS_H_ */ > -- > 2.19.2