dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [v1] examples/fips_validation: fix SHA MCT test from segfault
@ 2022-09-16 14:01 Gowrishankar Muthukrishnan
  2022-09-23 16:25 ` Dooley, Brian
  0 siblings, 1 reply; 3+ messages in thread
From: Gowrishankar Muthukrishnan @ 2022-09-16 14:01 UTC (permalink / raw)
  To: dev
  Cc: Anoob Joseph, Fan Zhang, Brian Dooley, Akhil Goyal, jerinj,
	Gowrishankar Muthukrishnan

In case of FIPS 140-2 format of test vectors in MCT test, msg is
not given in the test vector, hence pt will be NULL which test
function has to handle correctly.

Fixes: d5c247145c2c ("examples/fips_validation: add parsing for SHA")

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

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 8bd5a66889..cab3dd22b9 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1696,13 +1696,14 @@ fips_mct_sha_test(void)
 	/* val[0] is op result and other value is for parse_writeback callback */
 	struct fips_val val[2] = {{NULL, 0},};
 	struct fips_val  md[SHA_MD_BLOCK], msg;
-	char temp[MAX_DIGEST_SIZE*2];
 	int ret;
 	uint32_t i, j;
 
 	msg.len = SHA_MD_BLOCK * vec.cipher_auth.digest.len;
 	msg.val = calloc(1, msg.len);
-	memcpy(vec.cipher_auth.digest.val, vec.pt.val, vec.cipher_auth.digest.len);
+	if (vec.pt.val)
+		memcpy(vec.cipher_auth.digest.val, vec.pt.val, vec.cipher_auth.digest.len);
+
 	for (i = 0; i < SHA_MD_BLOCK; i++)
 		md[i].val = rte_malloc(NULL, (MAX_DIGEST_SIZE*2), 0);
 
@@ -1769,14 +1770,15 @@ fips_mct_sha_test(void)
 		memcpy(vec.cipher_auth.digest.val, md[2].val, md[2].len);
 		vec.cipher_auth.digest.len = md[2].len;
 
-		if (info.file_type != FIPS_TYPE_JSON) {
+		if (info.file_type != FIPS_TYPE_JSON)
 			fprintf(info.fp_wr, "COUNT = %u\n", j);
-			writeback_hex_str("", temp, &vec.cipher_auth.digest);
-			fprintf(info.fp_wr, "MD = %s\n\n", temp);
-		}
+
 		val[1].val = msg.val;
 		val[1].len = msg.len;
 		info.parse_writeback(val);
+
+		if (info.file_type != FIPS_TYPE_JSON)
+			fprintf(info.fp_wr, "\n");
 	}
 
 	for (i = 0; i < (SHA_MD_BLOCK); i++)
-- 
2.25.1


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

* RE: [v1] examples/fips_validation: fix SHA MCT test from segfault
  2022-09-16 14:01 [v1] examples/fips_validation: fix SHA MCT test from segfault Gowrishankar Muthukrishnan
@ 2022-09-23 16:25 ` Dooley, Brian
  2022-10-07  9:53   ` Akhil Goyal
  0 siblings, 1 reply; 3+ messages in thread
From: Dooley, Brian @ 2022-09-23 16:25 UTC (permalink / raw)
  To: Gowrishankar Muthukrishnan, dev
  Cc: Anoob Joseph, Zhang, Roy Fan, Akhil Goyal, jerinj

> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Friday, September 16, 2022 3:02 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>; jerinj@marvell.com; Gowrishankar
> Muthukrishnan <gmuthukrishn@marvell.com>
> Subject: [v1] examples/fips_validation: fix SHA MCT test from segfault
> 
> In case of FIPS 140-2 format of test vectors in MCT test, msg is not given in
> the test vector, hence pt will be NULL which test function has to handle
> correctly.
> 
> Fixes: d5c247145c2c ("examples/fips_validation: add parsing for SHA")
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
>  examples/fips_validation/main.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/examples/fips_validation/main.c
> b/examples/fips_validation/main.c index 8bd5a66889..cab3dd22b9 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1696,13 +1696,14 @@ fips_mct_sha_test(void)
>  	/* val[0] is op result and other value is for parse_writeback callback
> */
>  	struct fips_val val[2] = {{NULL, 0},};
>  	struct fips_val  md[SHA_MD_BLOCK], msg;
> -	char temp[MAX_DIGEST_SIZE*2];
>  	int ret;
>  	uint32_t i, j;
> 
>  	msg.len = SHA_MD_BLOCK * vec.cipher_auth.digest.len;
>  	msg.val = calloc(1, msg.len);
> -	memcpy(vec.cipher_auth.digest.val, vec.pt.val,
> vec.cipher_auth.digest.len);
> +	if (vec.pt.val)
> +		memcpy(vec.cipher_auth.digest.val, vec.pt.val,
> +vec.cipher_auth.digest.len);
> +
>  	for (i = 0; i < SHA_MD_BLOCK; i++)
>  		md[i].val = rte_malloc(NULL, (MAX_DIGEST_SIZE*2), 0);
> 
> @@ -1769,14 +1770,15 @@ fips_mct_sha_test(void)
>  		memcpy(vec.cipher_auth.digest.val, md[2].val, md[2].len);
>  		vec.cipher_auth.digest.len = md[2].len;
> 
> -		if (info.file_type != FIPS_TYPE_JSON) {
> +		if (info.file_type != FIPS_TYPE_JSON)
>  			fprintf(info.fp_wr, "COUNT = %u\n", j);
> -			writeback_hex_str("", temp,
> &vec.cipher_auth.digest);
> -			fprintf(info.fp_wr, "MD = %s\n\n", temp);
> -		}
> +
>  		val[1].val = msg.val;
>  		val[1].len = msg.len;
>  		info.parse_writeback(val);
> +
> +		if (info.file_type != FIPS_TYPE_JSON)
> +			fprintf(info.fp_wr, "\n");
>  	}
> 
>  	for (i = 0; i < (SHA_MD_BLOCK); i++)
> --
> 2.25.1

LGTM

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

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

* RE: [v1] examples/fips_validation: fix SHA MCT test from segfault
  2022-09-23 16:25 ` Dooley, Brian
@ 2022-10-07  9:53   ` Akhil Goyal
  0 siblings, 0 replies; 3+ messages in thread
From: Akhil Goyal @ 2022-10-07  9:53 UTC (permalink / raw)
  To: Dooley, Brian, Gowrishankar Muthukrishnan, dev
  Cc: Anoob Joseph, Zhang, Roy Fan, Jerin Jacob Kollanukkaran

> > Subject: [v1] examples/fips_validation: fix SHA MCT test from segfault
> >
> > In case of FIPS 140-2 format of test vectors in MCT test, msg is not given in
> > the test vector, hence pt will be NULL which test function has to handle
> > correctly.
> >
> > Fixes: d5c247145c2c ("examples/fips_validation: add parsing for SHA")
> >
> > Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> > ---
> Tested-by: Brian Dooley <brian.dooley@intel.com>
Applied to dpdk-next-crypto

Thanks.

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 14:01 [v1] examples/fips_validation: fix SHA MCT test from segfault Gowrishankar Muthukrishnan
2022-09-23 16:25 ` Dooley, Brian
2022-10-07  9:53   ` 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).