[v7,08/11] examples/fips_validation: add parsing for cmac
Checks
Commit Message
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
> -----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>
@@ -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.
*/
@@ -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;
}