diff mbox series

[v7,08/11] examples/fips_validation: add parsing for cmac

Message ID 593f0e542ae7d618f08ad409ffaa26602ec44544.1653551880.git.gmuthukrishn@marvell.com (mailing list archive)
State Superseded
Delegated to: akhil goyal
Headers show
Series Add JSON vector set support to fips validation | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gowrishankar Muthukrishnan May 26, 2022, 8:02 a.m. UTC
From: Brandon Lo <blo@iol.unh.edu>

Added function to parse algorithm for CMAC test.

Signed-off-by: Brandon Lo <blo@iol.unh.edu>
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
--
v5:
* parser_read_cmac_direction_str implementation moved to static.
---
 examples/fips_validation/fips_validation.c | 19 ++++++++++++++++---
 examples/fips_validation/main.c            |  3 +++
 2 files changed, 19 insertions(+), 3 deletions(-)

Comments

Zhang, Roy Fan May 26, 2022, 9:50 a.m. UTC | #1
> -----Original Message-----
> From: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Sent: Thursday, May 26, 2022 9:02 AM
> To: dev@dpdk.org
> Cc: Zhang, Roy Fan <roy.fan.zhang@intel.com>; Dooley, Brian
> <brian.dooley@intel.com>; lylavoie@iol.unh.edu; Anoob Joseph
> <anoobj@marvell.com>; Archana Muniganti <marchana@marvell.com>;
> Jerin Jacob <jerinj@marvell.com>; Brandon Lo <blo@iol.unh.edu>;
> Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> Subject: [v7, 08/11] examples/fips_validation: add parsing for cmac
> 
> From: Brandon Lo <blo@iol.unh.edu>
> 
> Added function to parse algorithm for CMAC test.
> 
> Signed-off-by: Brandon Lo <blo@iol.unh.edu>
> Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
> --
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
diff mbox series

Patch

diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index e8520f59cf..ab4c0d0eca 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.
 			 */
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 45b453b913..d104d82221 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1947,6 +1947,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;
 	}