diff mbox series

[v4,8/8] examples/fips_validation: add parsing for cmac

Message ID 20220429161559.415645-9-blo@iol.unh.edu (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers show
Series Add JSON vector set support to fips validation | expand

Checks

Context Check Description
ci/iol-abi-testing success Testing PASS
ci/iol-aarch64-compile-testing fail Testing issues
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/Intel-compilation fail Compilation issues
ci/checkpatch success coding style OK

Commit Message

Brandon Lo April 29, 2022, 4:15 p.m. UTC
Added function to parse algorithm for CMAC test.

Signed-off-by: Brandon Lo <blo@iol.unh.edu>
---
 examples/fips_validation/fips_validation.c | 31 +++++++++++++++++++---
 examples/fips_validation/main.c            |  3 +++
 2 files changed, 31 insertions(+), 3 deletions(-)

Comments

Gowrishankar Muthukrishnan May 18, 2022, 3:46 p.m. UTC | #1
Verified the functionality changes and looks good to me.

Acked-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>

Thanks.

> -----Original Message-----
> From: Brandon Lo <blo@iol.unh.edu>
> Sent: Friday, April 29, 2022 9:46 PM
> To: roy.fan.zhang@intel.com; ciara.power@intel.com
> Cc: dev@dpdk.org; Brandon Lo <blo@iol.unh.edu>
> Subject: [EXT] [PATCH v4 8/8] examples/fips_validation: add parsing for cmac
> 
> External Email
> 
> ----------------------------------------------------------------------
> Added function to parse algorithm for CMAC test.
> 
> Signed-off-by: Brandon Lo <blo@iol.unh.edu>
> ---
>  examples/fips_validation/fips_validation.c | 31 +++++++++++++++++++---
>  examples/fips_validation/main.c            |  3 +++
>  2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/examples/fips_validation/fips_validation.c
> b/examples/fips_validation/fips_validation.c
> index 04dfb85262..8e0a55c624 100644
> --- a/examples/fips_validation/fips_validation.c
> +++ b/examples/fips_validation/fips_validation.c
> @@ -460,6 +460,8 @@ fips_test_parse_one_json_vector_set(void)
>  		info.algo = FIPS_TEST_ALGO_AES_GCM;
>  	if (strstr(algo_str, "HMAC"))
>  		info.algo = FIPS_TEST_ALGO_HMAC;
> +	if (strstr(algo_str, "CMAC"))
> +		info.algo = FIPS_TEST_ALGO_AES_CMAC;
>  	else
>  		return -EINVAL;
> 
> @@ -470,7 +472,6 @@ int
>  fips_test_parse_one_json_group(void)
>  {
>  	int ret, i;
> -	json_int_t val;
>  	json_t *param;
> 
>  	if (info.interim_callbacks) {
> @@ -478,8 +479,20 @@ fips_test_parse_one_json_group(void)
>  		for (i = 0; info.interim_callbacks[i].key != NULL; i++) {
>  			param =
> json_object_get(json_info.json_test_group,
>  					info.interim_callbacks[i].key);
> -			val = json_integer_value(param);
> -			snprintf(json_value, 255,
> "%"JSON_INTEGER_FORMAT, val);
> +			switch (json_typeof(param)) {
> +			case JSON_STRING:
> +				snprintf(json_value, 256, "%s",
> json_string_value(param));
> +				break;
> +
> +			case JSON_INTEGER:
> +				snprintf(json_value, 255,
> "%"JSON_INTEGER_FORMAT,
> +						json_integer_value(param));
> +				break;
> +
> +			default:
> +				return -EINVAL;
> +			}
> +
>  			/* First argument is blank because the key
>  			 * is not included in the string being parsed.
>  			 */
> @@ -673,6 +686,18 @@ parser_read_uint32_bit_val(const char *key, char
> *src, struct fips_val *val)
>  	return 0;
>  }
> 
> +int
> +parser_read_cmac_direction_str(__rte_unused const char *key, char *src,
> +		__rte_unused struct fips_val *val)
> +{
> +	if (strcmp(src, "gen") == 0)
> +		info.op = FIPS_TEST_ENC_AUTH_GEN;
> +	else if (strcmp(src, "ver") == 0)
> +		info.op = FIPS_TEST_DEC_AUTH_VERIF;
> +
> +	return 0;
> +}
> +
>  int
>  writeback_hex_str(const char *key, char *dst, struct fips_val *val)  { diff --git
> a/examples/fips_validation/main.c b/examples/fips_validation/main.c index
> de6dedaf75..aa8034c29f 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1946,6 +1946,9 @@ fips_test_one_test_group(void)
>  	case FIPS_TEST_ALGO_HMAC:
>  		ret = parse_test_hmac_json_init();
>  		break;
> +	case FIPS_TEST_ALGO_AES_CMAC:
> +		ret = parse_test_cmac_json_init();
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> --
> 2.25.1
Gowrishankar Muthukrishnan May 19, 2022, 5:31 a.m. UTC | #2
Please find comments inline from CI point of view.

> -----Original Message-----
> From: Brandon Lo <blo@iol.unh.edu>
> Sent: Friday, April 29, 2022 9:46 PM
> To: roy.fan.zhang@intel.com; ciara.power@intel.com
> Cc: dev@dpdk.org; Brandon Lo <blo@iol.unh.edu>
> Subject: [EXT] [PATCH v4 8/8] examples/fips_validation: add parsing for cmac
> 
> External Email
> 
> ----------------------------------------------------------------------
> Added function to parse algorithm for CMAC test.
> 
> Signed-off-by: Brandon Lo <blo@iol.unh.edu>
> ---
>  examples/fips_validation/fips_validation.c | 31 +++++++++++++++++++---
>  examples/fips_validation/main.c            |  3 +++
>  2 files changed, 31 insertions(+), 3 deletions(-)
> 
> diff --git a/examples/fips_validation/fips_validation.c
> b/examples/fips_validation/fips_validation.c
> index 04dfb85262..8e0a55c624 100644
> --- a/examples/fips_validation/fips_validation.c
> +++ b/examples/fips_validation/fips_validation.c
> @@ -460,6 +460,8 @@ fips_test_parse_one_json_vector_set(void)
>  		info.algo = FIPS_TEST_ALGO_AES_GCM;
......
......
> 
> +int
> +parser_read_cmac_direction_str(__rte_unused const char *key, char *src,
> +		__rte_unused struct fips_val *val)

Can this function be static in fips_validation_cmac.c which is more appropriate also ?.

Thanks,
Gowrishankar
Gowrishankar Muthukrishnan May 19, 2022, 9:11 a.m. UTC | #3
+ lylavoie@iol.unh.edu 

> -----Original Message-----
> From: Gowrishankar Muthukrishnan
> Sent: Thursday, May 19, 2022 11:01 AM
> To: Brandon Lo <blo@iol.unh.edu>; roy.fan.zhang@intel.com;
> ciara.power@intel.com
> Cc: dev@dpdk.org
> Subject: RE: [EXT] [PATCH v4 8/8] examples/fips_validation: add parsing for
> cmac
> 
> Please find comments inline from CI point of view.
> 
> > -----Original Message-----
> > From: Brandon Lo <blo@iol.unh.edu>
> > Sent: Friday, April 29, 2022 9:46 PM
> > To: roy.fan.zhang@intel.com; ciara.power@intel.com
> > Cc: dev@dpdk.org; Brandon Lo <blo@iol.unh.edu>
> > Subject: [EXT] [PATCH v4 8/8] examples/fips_validation: add parsing for
> cmac
> >
> > External Email
> >
> > ----------------------------------------------------------------------
> > Added function to parse algorithm for CMAC test.
> >
> > Signed-off-by: Brandon Lo <blo@iol.unh.edu>
> > ---
> >  examples/fips_validation/fips_validation.c | 31 +++++++++++++++++++---
> >  examples/fips_validation/main.c            |  3 +++
> >  2 files changed, 31 insertions(+), 3 deletions(-)
> >
> > diff --git a/examples/fips_validation/fips_validation.c
> > b/examples/fips_validation/fips_validation.c
> > index 04dfb85262..8e0a55c624 100644
> > --- a/examples/fips_validation/fips_validation.c
> > +++ b/examples/fips_validation/fips_validation.c
> > @@ -460,6 +460,8 @@ fips_test_parse_one_json_vector_set(void)
> >  		info.algo = FIPS_TEST_ALGO_AES_GCM;
> ......
> ......
> >
> > +int
> > +parser_read_cmac_direction_str(__rte_unused const char *key, char
> *src,
> > +		__rte_unused struct fips_val *val)
> 
> Can this function be static in fips_validation_cmac.c which is more
> appropriate also ?.
> 
> Thanks,
> Gowrishankar
diff mbox series

Patch

diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 04dfb85262..8e0a55c624 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -460,6 +460,8 @@  fips_test_parse_one_json_vector_set(void)
 		info.algo = FIPS_TEST_ALGO_AES_GCM;
 	if (strstr(algo_str, "HMAC"))
 		info.algo = FIPS_TEST_ALGO_HMAC;
+	if (strstr(algo_str, "CMAC"))
+		info.algo = FIPS_TEST_ALGO_AES_CMAC;
 	else
 		return -EINVAL;
 
@@ -470,7 +472,6 @@  int
 fips_test_parse_one_json_group(void)
 {
 	int ret, i;
-	json_int_t val;
 	json_t *param;
 
 	if (info.interim_callbacks) {
@@ -478,8 +479,20 @@  fips_test_parse_one_json_group(void)
 		for (i = 0; info.interim_callbacks[i].key != NULL; i++) {
 			param = json_object_get(json_info.json_test_group,
 					info.interim_callbacks[i].key);
-			val = json_integer_value(param);
-			snprintf(json_value, 255, "%"JSON_INTEGER_FORMAT, val);
+			switch (json_typeof(param)) {
+			case JSON_STRING:
+				snprintf(json_value, 256, "%s", json_string_value(param));
+				break;
+
+			case JSON_INTEGER:
+				snprintf(json_value, 255, "%"JSON_INTEGER_FORMAT,
+						json_integer_value(param));
+				break;
+
+			default:
+				return -EINVAL;
+			}
+
 			/* First argument is blank because the key
 			 * is not included in the string being parsed.
 			 */
@@ -673,6 +686,18 @@  parser_read_uint32_bit_val(const char *key, char *src, struct fips_val *val)
 	return 0;
 }
 
+int
+parser_read_cmac_direction_str(__rte_unused const char *key, char *src,
+		__rte_unused struct fips_val *val)
+{
+	if (strcmp(src, "gen") == 0)
+		info.op = FIPS_TEST_ENC_AUTH_GEN;
+	else if (strcmp(src, "ver") == 0)
+		info.op = FIPS_TEST_DEC_AUTH_VERIF;
+
+	return 0;
+}
+
 int
 writeback_hex_str(const char *key, char *dst, struct fips_val *val)
 {
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index de6dedaf75..aa8034c29f 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1946,6 +1946,9 @@  fips_test_one_test_group(void)
 	case FIPS_TEST_ALGO_HMAC:
 		ret = parse_test_hmac_json_init();
 		break;
+	case FIPS_TEST_ALGO_AES_CMAC:
+		ret = parse_test_cmac_json_init();
+		break;
 	default:
 		return -EINVAL;
 	}