dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] examples/fips_validation: fix memory allocation in aes mct test
@ 2022-07-13  6:44 Gowrishankar Muthukrishnan
  2022-08-12 11:47 ` [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test Gowrishankar Muthukrishnan
  0 siblings, 1 reply; 4+ messages in thread
From: Gowrishankar Muthukrishnan @ 2022-07-13  6:44 UTC (permalink / raw)
  To: dev
  Cc: Akhil Goyal, Fan Zhang, Brian Dooley, Anoob Joseph,
	Archana Muniganti, Jerin Jacob, Gowrishankar Muthukrishnan

Instead of allocating memory in every external iteration, do once
in the beginning of AES MCT tests and free at the end.

Fixes: 8b8546aaedf ("examples/fips_validation: add parsing for AES-CBC")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
 examples/fips_validation/main.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 5e65c5e193..8babbb3298 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1588,9 +1588,12 @@ fips_mct_aes_test(void)
 	if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB)
 		return fips_mct_aes_ecb_test();
 
-	memset(&pt, 0, sizeof(struct fips_val));
-	memset(&ct, 0, sizeof(struct fips_val));
-	memset(&iv, 0, sizeof(struct fips_val));
+	pt.len = vec.pt.len;
+	pt.val = calloc(1, pt.len);
+	ct.len = vec.ct.len;
+	ct.val = calloc(1, ct.len);
+	iv.len = vec.iv.len;
+	iv.val = calloc(1, iv.len);
 	for (i = 0; i < AES_EXTERN_ITER; i++) {
 		if (info.file_type != FIPS_TYPE_JSON) {
 			if (i != 0)
@@ -1622,16 +1625,8 @@ fips_mct_aes_test(void)
 
 			if (j == 0) {
 				memcpy(prev_out, val[0].val, AES_BLOCK_SIZE);
-				pt.len = vec.pt.len;
-				pt.val = calloc(1, pt.len);
 				memcpy(pt.val, vec.pt.val, pt.len);
-
-				ct.len = vec.ct.len;
-				ct.val = calloc(1, ct.len);
 				memcpy(ct.val, vec.ct.val, ct.len);
-
-				iv.len = vec.iv.len;
-				iv.val = calloc(1, iv.len);
 				memcpy(iv.val, vec.iv.val, iv.len);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
@@ -1670,12 +1665,8 @@ fips_mct_aes_test(void)
 		if (info.file_type != FIPS_TYPE_JSON)
 			fprintf(info.fp_wr, "\n");
 
-		if (i == AES_EXTERN_ITER - 1) {
-			free(pt.val);
-			free(ct.val);
-			free(iv.val);
+		if (i == AES_EXTERN_ITER - 1)
 			continue;
-		}
 
 		/** update key */
 		memcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key));
@@ -1706,6 +1697,9 @@ fips_mct_aes_test(void)
 	}
 
 	free(val[0].val);
+	free(pt.val);
+	free(ct.val);
+	free(iv.val);
 
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test
  2022-07-13  6:44 [PATCH v1] examples/fips_validation: fix memory allocation in aes mct test Gowrishankar Muthukrishnan
@ 2022-08-12 11:47 ` Gowrishankar Muthukrishnan
  2022-09-23 16:30   ` Dooley, Brian
  0 siblings, 1 reply; 4+ messages in thread
From: Gowrishankar Muthukrishnan @ 2022-08-12 11:47 UTC (permalink / raw)
  To: dev
  Cc: Anoob Joseph, Fan Zhang, Brian Dooley, Akhil Goyal,
	Gowrishankar Muthukrishnan

Instead of allocating memory in every external iteration, do once
in the beginning of AES MCT tests and free at the end.

Fixes: 8b8546aaedf ("examples/fips_validation: add parsing for AES-CBC")

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v2:
 - commit message.
---
 examples/fips_validation/main.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 8bd5a66889..5c3f79a91c 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1565,9 +1565,12 @@ fips_mct_aes_test(void)
 	if (info.interim_info.aes_data.cipher_algo == RTE_CRYPTO_CIPHER_AES_ECB)
 		return fips_mct_aes_ecb_test();
 
-	memset(&pt, 0, sizeof(struct fips_val));
-	memset(&ct, 0, sizeof(struct fips_val));
-	memset(&iv, 0, sizeof(struct fips_val));
+	pt.len = vec.pt.len;
+	pt.val = calloc(1, pt.len);
+	ct.len = vec.ct.len;
+	ct.val = calloc(1, ct.len);
+	iv.len = vec.iv.len;
+	iv.val = calloc(1, iv.len);
 	for (i = 0; i < AES_EXTERN_ITER; i++) {
 		if (info.file_type != FIPS_TYPE_JSON) {
 			if (i != 0)
@@ -1599,16 +1602,8 @@ fips_mct_aes_test(void)
 
 			if (j == 0) {
 				memcpy(prev_out, val[0].val, AES_BLOCK_SIZE);
-				pt.len = vec.pt.len;
-				pt.val = calloc(1, pt.len);
 				memcpy(pt.val, vec.pt.val, pt.len);
-
-				ct.len = vec.ct.len;
-				ct.val = calloc(1, ct.len);
 				memcpy(ct.val, vec.ct.val, ct.len);
-
-				iv.len = vec.iv.len;
-				iv.val = calloc(1, iv.len);
 				memcpy(iv.val, vec.iv.val, iv.len);
 
 				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
@@ -1647,12 +1642,8 @@ fips_mct_aes_test(void)
 		if (info.file_type != FIPS_TYPE_JSON)
 			fprintf(info.fp_wr, "\n");
 
-		if (i == AES_EXTERN_ITER - 1) {
-			free(pt.val);
-			free(ct.val);
-			free(iv.val);
+		if (i == AES_EXTERN_ITER - 1)
 			continue;
-		}
 
 		/** update key */
 		memcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key));
@@ -1683,6 +1674,9 @@ fips_mct_aes_test(void)
 	}
 
 	free(val[0].val);
+	free(pt.val);
+	free(ct.val);
+	free(iv.val);
 
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test
  2022-08-12 11:47 ` [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test Gowrishankar Muthukrishnan
@ 2022-09-23 16:30   ` Dooley, Brian
  2022-10-07  9:56     ` Akhil Goyal
  0 siblings, 1 reply; 4+ messages in thread
From: Dooley, Brian @ 2022-09-23 16:30 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev; +Cc: Anoob Joseph, Zhang, Roy Fan, Akhil Goyal

> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Friday, August 12, 2022 12:47 PM
> To: dev@dpdk.org
> Cc: Anoob Joseph <anoobj@marvell.com>; Zhang, Roy Fan
> <roy.fan.zhang@intel.com>; Dooley, Brian <brian.dooley@intel.com>; Akhil
> Goyal <gakhil@marvell.com>; Gowrishankar Muthukrishnan
> <gmuthukrishn@marvell.com>
> Subject: [PATCH v2] examples/fips_validation: fix memory allocation in AES
> MCT test
> 
> Instead of allocating memory in every external iteration, do once in the
> beginning of AES MCT tests and free at the end.
> 
> Fixes: 8b8546aaedf ("examples/fips_validation: add parsing for AES-CBC")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
> v2:
>  - commit message.
> ---
>  examples/fips_validation/main.c | 26 ++++++++++----------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/examples/fips_validation/main.c
> b/examples/fips_validation/main.c index 8bd5a66889..5c3f79a91c 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1565,9 +1565,12 @@ fips_mct_aes_test(void)
>  	if (info.interim_info.aes_data.cipher_algo ==
> RTE_CRYPTO_CIPHER_AES_ECB)
>  		return fips_mct_aes_ecb_test();
> 
> -	memset(&pt, 0, sizeof(struct fips_val));
> -	memset(&ct, 0, sizeof(struct fips_val));
> -	memset(&iv, 0, sizeof(struct fips_val));
> +	pt.len = vec.pt.len;
> +	pt.val = calloc(1, pt.len);
> +	ct.len = vec.ct.len;
> +	ct.val = calloc(1, ct.len);
> +	iv.len = vec.iv.len;
> +	iv.val = calloc(1, iv.len);
>  	for (i = 0; i < AES_EXTERN_ITER; i++) {
>  		if (info.file_type != FIPS_TYPE_JSON) {
>  			if (i != 0)
> @@ -1599,16 +1602,8 @@ fips_mct_aes_test(void)
> 
>  			if (j == 0) {
>  				memcpy(prev_out, val[0].val,
> AES_BLOCK_SIZE);
> -				pt.len = vec.pt.len;
> -				pt.val = calloc(1, pt.len);
>  				memcpy(pt.val, vec.pt.val, pt.len);
> -
> -				ct.len = vec.ct.len;
> -				ct.val = calloc(1, ct.len);
>  				memcpy(ct.val, vec.ct.val, ct.len);
> -
> -				iv.len = vec.iv.len;
> -				iv.val = calloc(1, iv.len);
>  				memcpy(iv.val, vec.iv.val, iv.len);
> 
>  				if (info.op == FIPS_TEST_ENC_AUTH_GEN) {
> @@ -1647,12 +1642,8 @@ fips_mct_aes_test(void)
>  		if (info.file_type != FIPS_TYPE_JSON)
>  			fprintf(info.fp_wr, "\n");
> 
> -		if (i == AES_EXTERN_ITER - 1) {
> -			free(pt.val);
> -			free(ct.val);
> -			free(iv.val);
> +		if (i == AES_EXTERN_ITER - 1)
>  			continue;
> -		}
> 
>  		/** update key */
>  		memcpy(&val_key, &vec.cipher_auth.key, sizeof(val_key));
> @@ -1683,6 +1674,9 @@ fips_mct_aes_test(void)
>  	}
> 
>  	free(val[0].val);
> +	free(pt.val);
> +	free(ct.val);
> +	free(iv.val);
> 
>  	return 0;
>  }
> --
> 2.25.1

Acked-by: Brian Dooley <brian.dooley@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test
  2022-09-23 16:30   ` Dooley, Brian
@ 2022-10-07  9:56     ` Akhil Goyal
  0 siblings, 0 replies; 4+ messages in thread
From: Akhil Goyal @ 2022-10-07  9:56 UTC (permalink / raw)
  To: Dooley, Brian, Gowrishankar Muthukrishnan, dev
  Cc: Anoob Joseph, Zhang, Roy Fan

> > Subject: [PATCH v2] examples/fips_validation: fix memory allocation in AES
> > MCT test
> >
> > Instead of allocating memory in every external iteration, do once in the
> > beginning of AES MCT tests and free at the end.
> >
> > Fixes: 8b8546aaedf ("examples/fips_validation: add parsing for AES-CBC")
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> 
> Acked-by: Brian Dooley <brian.dooley@intel.com>
Applied to dpdk-next-crypto
Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-07  9:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13  6:44 [PATCH v1] examples/fips_validation: fix memory allocation in aes mct test Gowrishankar Muthukrishnan
2022-08-12 11:47 ` [PATCH v2] examples/fips_validation: fix memory allocation in AES MCT test Gowrishankar Muthukrishnan
2022-09-23 16:30   ` Dooley, Brian
2022-10-07  9:56     ` Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).