DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Roy Fan" <roy.fan.zhang@intel.com>
To: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "Dooley, Brian" <brian.dooley@intel.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Archana Muniganti <marchana@marvell.com>,
	Jerin Jacob <jerinj@marvell.com>
Subject: RE: [PATCH v1] examples/fips_validation: add parsing for sha
Date: Wed, 29 Jun 2022 08:25:28 +0000	[thread overview]
Message-ID: <MW5PR11MB580935654D1F4F0DDA721D89B8BB9@MW5PR11MB5809.namprd11.prod.outlook.com> (raw)
In-Reply-To: <c769c6adfa37f48bd22c7a674dcb913a964234f2.1656421456.git.gmuthukrishn@marvell.com>

Hi,

> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Tuesday, June 28, 2022 2:14 PM
> To: dev@dpdk.org
> Cc: Zhang, Roy Fan <roy.fan.zhang@intel.com>; Dooley, Brian
> <brian.dooley@intel.com>; Anoob Joseph <anoobj@marvell.com>; Archana
> Muniganti <marchana@marvell.com>; Jerin Jacob <jerinj@marvell.com>;
> Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Subject: [PATCH v1] examples/fips_validation: add parsing for sha
> 
> Added function to parse algorithm for SHA test. Verified with SHA 1 and 256
> vectors. SHA 384 and 512 has some issues with the way jansson objects are
> created, which could be addressed separately.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> ---
<snip>

> +#endif /* USE_JANSSON */
> diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
> index 7ccb5f52f4..41347de199 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1693,19 +1693,24 @@ fips_mct_sha_test(void)
>  #define SHA_EXTERN_ITER	100
>  #define SHA_INTERN_ITER	1000
>  #define SHA_MD_BLOCK	3
> -	struct fips_val val = {NULL, 0}, md[SHA_MD_BLOCK];
> +	struct fips_val val[2] = {{NULL, 0},}, md[SHA_MD_BLOCK], msg;

I see to get around with the callback function limitation you extend the fips val to
an array. Nice move! But if it is not too much trouble for you - please comment
the purpose of the change - it will make the future maintenance much easier!

>  	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);
>  	for (i = 0; i < SHA_MD_BLOCK; i++)
>  		md[i].val = rte_malloc(NULL, (MAX_DIGEST_SIZE*2), 0);
> 
>  	rte_free(vec.pt.val);
>  	vec.pt.val = rte_malloc(NULL, (MAX_DIGEST_SIZE*SHA_MD_BLOCK), 0);
> 
> -	fips_test_write_one_case();
> -	fprintf(info.fp_wr, "\n");
> +	if (info.file_type != FIPS_TYPE_JSON) {
> +		fips_test_write_one_case();
> +		fprintf(info.fp_wr, "\n");
> +	}
> 
>  	for (j = 0; j < SHA_EXTERN_ITER; j++) {
> 
> @@ -1719,6 +1724,9 @@ fips_mct_sha_test(void)
>  			vec.cipher_auth.digest.len);
>  		md[2].len = vec.cipher_auth.digest.len;
> 
> +		for (i = 0; i < SHA_MD_BLOCK; i++)
> +			memcpy(&msg.val[i * md[i].len], md[i].val, md[i].len);
> +
>  		for (i = 0; i < (SHA_INTERN_ITER); i++) {
> 
>  			memcpy(vec.pt.val, md[0].val,
> @@ -1742,7 +1750,7 @@ fips_mct_sha_test(void)
>  				return ret;
>  			}
> 
> -			ret = get_writeback_data(&val);
> +			ret = get_writeback_data(&val[0]);
>  			if (ret < 0)
>  				return ret;
> 
> @@ -1751,7 +1759,7 @@ fips_mct_sha_test(void)
>  			memcpy(md[1].val, md[2].val, md[2].len);
>  			md[1].len = md[2].len;
> 
> -			memcpy(md[2].val, (val.val + vec.pt.len),
> +			memcpy(md[2].val, (val[0].val + vec.pt.len),
>  				vec.cipher_auth.digest.len);
>  			md[2].len = vec.cipher_auth.digest.len;
>  		}
> @@ -1759,11 +1767,14 @@ 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;
> 
> -		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);
> +		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);
>  	}
> 
>  	for (i = 0; i < (SHA_MD_BLOCK); i++)
> @@ -1771,7 +1782,8 @@ fips_mct_sha_test(void)
> 
>  	rte_free(vec.pt.val);
> 
> -	free(val.val);
> +	free(val[0].val);

It took me a while to understand why you don't free val[1] ??.
Nicely done anyway.

> +	free(msg.val);
> 
>  	return 0;
>  }
> @@ -1996,6 +2008,9 @@ fips_test_one_test_group(void)
>  	case FIPS_TEST_ALGO_AES:
>  		ret = parse_test_aes_json_init();
>  		break;
> +	case FIPS_TEST_ALGO_SHA:
> +		ret = parse_test_sha_json_init();
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> --
> 2.25.1

Other than that
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>

  reply	other threads:[~2022-06-29  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28 13:14 Gowrishankar Muthukrishnan
2022-06-29  8:25 ` Zhang, Roy Fan [this message]
2022-06-29  9:38   ` Gowrishankar Muthukrishnan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MW5PR11MB580935654D1F4F0DDA721D89B8BB9@MW5PR11MB5809.namprd11.prod.outlook.com \
    --to=roy.fan.zhang@intel.com \
    --cc=anoobj@marvell.com \
    --cc=brian.dooley@intel.com \
    --cc=dev@dpdk.org \
    --cc=gmuthukrishn@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=marchana@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).