[v2] test/cryptodev: fix incomplete data length

Message ID 20211109102703.23006-1-kai.ji@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [v2] test/cryptodev: fix incomplete data length |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Ji, Kai Nov. 9, 2021, 10:27 a.m. UTC
  This patch fixes incorrect data lengths computation in cryptodev
unit test. Previously some data lengths were incorrectly set, which
was insensitive for crypto op unit tets but is critical for raw data
path API unit tests. The patch addressed the issue by setting the
correct data lengths for some tests.

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

Fixes: b1c1df46878d ("test/crypto: add ZUC test cases for auth-cipher")
Cc: damianx.nowak@intel.com

Signed-off-by: Kai Ji <kai.ji@intel.com>
---
 app/test/test_cryptodev.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)
  

Comments

Anoob Joseph Nov. 9, 2021, 10:32 a.m. UTC | #1
Hi Kai,

Minor nit inline.

Thanks,
Anoob

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Kai Ji
> Sent: Tuesday, November 9, 2021 3:57 PM
> To: dev@dpdk.org
> Cc: Kai Ji <kai.ji@intel.com>; pablo.de.lara.guarch@intel.com;
> adamx.dybkowski@intel.com; damianx.nowak@intel.com
> Subject: [EXT] [dpdk-dev] [dpdk-dev v2] test/cryptodev: fix incomplete data
> length
> 
> External Email
> 
> ----------------------------------------------------------------------
> This patch fixes incorrect data lengths computation in cryptodev unit test.
> Previously some data lengths were incorrectly set, which was insensitive for
> crypto op unit tets but is critical for raw data path API unit tests. The patch
> addressed the issue by setting the correct data lengths for some tests.
> 
> 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
> 
> Fixes: b1c1df46878d ("test/crypto: add ZUC test cases for auth-cipher")
> Cc: damianx.nowak@intel.com
> 
> Signed-off-by: Kai Ji <kai.ji@intel.com>
> ---
>  app/test/test_cryptodev.c | 28 +++++++++++++++-------------
>  1 file changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index
> 52457596e2..2dd1bbb64c 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -4102,9 +4102,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;
> 
> @@ -6332,20 +6332,20 @@ test_zuc_auth_cipher(const struct
> wireless_test_data *tdata,
>  		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params-
> >ibuf,
>  					ciphertext_pad_len);
>  		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
> -		if (op_mode == OUT_OF_PLACE)
> -			rte_pktmbuf_append(ut_params->obuf,
> ciphertext_pad_len);
>  		debug_hexdump(stdout, "ciphertext:", ciphertext,
>  			ciphertext_len);
>  	} else {
> +		/* make sure enough space to cover partial digest verify case
> */
>  		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params-
> >ibuf,
> -					plaintext_pad_len);
> +					ciphertext_pad_len);
>  		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
> -		if (op_mode == OUT_OF_PLACE)
> -			rte_pktmbuf_append(ut_params->obuf,
> plaintext_pad_len);
>  		debug_hexdump(stdout, "plaintext:", plaintext,
>  			plaintext_len);
>  	}
> 
> +	if (op_mode == OUT_OF_PLACE)
> +		rte_pktmbuf_append(ut_params->obuf,
> ciphertext_pad_len);
> +
>  	/* Create ZUC operation */
>  	retval = create_wireless_algo_auth_cipher_operation(
>  		tdata->digest.data, tdata->digest.len, @@ -7395,24 +7395,26
> @@ 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);
> +	if (ciphertext_pad_len > plaintext_pad_len)
> +		printf("NOOB: \n");

[Anoob] Is the above intentional?
 
> 
>  	if (verify) {
>  		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params-
> >ibuf,
>  				ciphertext_pad_len);
>  		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
> -		if (op_mode == OUT_OF_PLACE)
> -			rte_pktmbuf_append(ut_params->obuf,
> ciphertext_pad_len);
>  		debug_hexdump(stdout, "ciphertext:", ciphertext,
>  				ciphertext_len);
>  	} else {
> +		/* make sure enough space to cover partial digest verify case
> */
>  		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params-
> >ibuf,
> -				plaintext_pad_len);
> +				ciphertext_pad_len);
>  		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
> -		if (op_mode == OUT_OF_PLACE)
> -			rte_pktmbuf_append(ut_params->obuf,
> plaintext_pad_len);
>  		debug_hexdump(stdout, "plaintext:", plaintext,
> plaintext_len);
>  	}
> 
> +	if (op_mode == OUT_OF_PLACE)
> +		rte_pktmbuf_append(ut_params->obuf,
> ciphertext_pad_len);
> +
>  	/* Create the operation */
>  	retval = create_wireless_algo_auth_cipher_operation(
>  			tdata->digest_enc.data, tdata->digest_enc.len,
> --
> 2.17.1
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 52457596e2..2dd1bbb64c 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -4102,9 +4102,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;
 
@@ -6332,20 +6332,20 @@  test_zuc_auth_cipher(const struct wireless_test_data *tdata,
 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 					ciphertext_pad_len);
 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
-		if (op_mode == OUT_OF_PLACE)
-			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
 		debug_hexdump(stdout, "ciphertext:", ciphertext,
 			ciphertext_len);
 	} else {
+		/* make sure enough space to cover partial digest verify case */
 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-					plaintext_pad_len);
+					ciphertext_pad_len);
 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
-		if (op_mode == OUT_OF_PLACE)
-			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
 		debug_hexdump(stdout, "plaintext:", plaintext,
 			plaintext_len);
 	}
 
+	if (op_mode == OUT_OF_PLACE)
+		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+
 	/* Create ZUC operation */
 	retval = create_wireless_algo_auth_cipher_operation(
 		tdata->digest.data, tdata->digest.len,
@@ -7395,24 +7395,26 @@  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);
+	if (ciphertext_pad_len > plaintext_pad_len)
+		printf("NOOB: \n");
 
 	if (verify) {
 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
 				ciphertext_pad_len);
 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
-		if (op_mode == OUT_OF_PLACE)
-			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
 		debug_hexdump(stdout, "ciphertext:", ciphertext,
 				ciphertext_len);
 	} else {
+		/* make sure enough space to cover partial digest verify case */
 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
-				plaintext_pad_len);
+				ciphertext_pad_len);
 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
-		if (op_mode == OUT_OF_PLACE)
-			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
 	}
 
+	if (op_mode == OUT_OF_PLACE)
+		rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
+
 	/* Create the operation */
 	retval = create_wireless_algo_auth_cipher_operation(
 			tdata->digest_enc.data, tdata->digest_enc.len,