[v7,02/11] examples/fips_validation: add json info to header

Message ID 06fc0444ab11420680f8078ba50a007fd145c278.1653551880.git.gmuthukrishn@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series Add JSON vector set support to fips validation |

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 json-specific functions and other information needed to
test the new FIPS test vectors.

Signed-off-by: Brandon Lo <blo@iol.unh.edu>
Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
v7:
* fix switch clause for info.file_type.

v5:
* fix typo in macro name for prefixes.

v2:
* fix type of prefix to suffix
---
 examples/fips_validation/fips_validation.c |  6 +--
 examples/fips_validation/fips_validation.h | 48 ++++++++++++++++++++--
 examples/fips_validation/main.c            |  2 +
 3 files changed, 49 insertions(+), 7 deletions(-)
  

Comments

Fan Zhang May 26, 2022, 9:46 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, 02/11] examples/fips_validation: add json info to header
> 
> From: Brandon Lo <blo@iol.unh.edu>
> 
> Added json-specific functions and other information needed to
> test the new FIPS test vectors.
> 
> 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>
  

Patch

diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c
index 94253eaee8..38c99b291c 100644
--- a/examples/fips_validation/fips_validation.c
+++ b/examples/fips_validation/fips_validation.c
@@ -270,11 +270,11 @@  parse_file_type(const char *path)
 {
 	const char *tmp = path + strlen(path) - 3;
 
-	if (strstr(tmp, REQ_FILE_PERFIX))
+	if (strstr(tmp, REQ_FILE_PREFIX))
 		info.file_type = FIPS_TYPE_REQ;
-	else if (strstr(tmp, RSP_FILE_PERFIX))
+	else if (strstr(tmp, RSP_FILE_PREFIX))
 		info.file_type = FIPS_TYPE_RSP;
-	else if (strstr(path, FAX_FILE_PERFIX))
+	else if (strstr(path, FAX_FILE_PREFIX))
 		info.file_type = FIPS_TYPE_FAX;
 	else
 		return -EINVAL;
diff --git a/examples/fips_validation/fips_validation.h b/examples/fips_validation/fips_validation.h
index aaadf01ba8..a1c83a9a6a 100644
--- a/examples/fips_validation/fips_validation.h
+++ b/examples/fips_validation/fips_validation.h
@@ -5,6 +5,10 @@ 
 #ifndef _FIPS_VALIDATION_H_
 #define _FIPS_VALIDATION_H_
 
+#ifdef RTE_HAS_JANSSON
+#include <jansson.h>
+#endif /* RTE_HAS_JANSSON */
+
 #define FIPS_PARSE_ERR(fmt, args)					\
 	RTE_LOG(ERR, USER1, "FIPS parse error" ## fmt ## "\n", ## args)
 
@@ -21,9 +25,12 @@ 
 #define POSITIVE_TEST		0
 #define NEGATIVE_TEST		-1
 
-#define REQ_FILE_PERFIX		"req"
-#define RSP_FILE_PERFIX		"rsp"
-#define FAX_FILE_PERFIX		"fax"
+#define REQ_FILE_PREFIX		"req"
+#define RSP_FILE_PREFIX		"rsp"
+#define FAX_FILE_PREFIX		"fax"
+#define JSON_FILE_PREFIX	"json"
+
+#define ACVVERSION			"1.0"
 
 enum fips_test_algorithms {
 		FIPS_TEST_ALGO_AES = 0,
@@ -40,7 +47,8 @@  enum fips_test_algorithms {
 enum file_types {
 	FIPS_TYPE_REQ = 1,
 	FIPS_TYPE_FAX,
-	FIPS_TYPE_RSP
+	FIPS_TYPE_RSP,
+	FIPS_TYPE_JSON,
 };
 
 enum fips_test_op {
@@ -161,6 +169,23 @@  struct gcm_interim_data {
 	uint8_t gen_iv;
 };
 
+#ifdef RTE_HAS_JANSSON
+struct fips_test_json_info {
+	/* Information used for reading from json */
+	json_t *json_root;
+	json_t *json_vector_set;
+	json_t *json_test_group;
+	json_t *json_test_case;
+	/* Location of json write output */
+	json_t *json_write_root;
+	json_t *json_write_group;
+	json_t *json_write_set;
+	json_t *json_write_case;
+	/* Other info */
+	uint8_t is_sample;
+};
+#endif /* RTE_HAS_JANSSON */
+
 struct fips_test_interim_info {
 	FILE *fp_rd;
 	FILE *fp_wr;
@@ -196,6 +221,10 @@  struct fips_test_interim_info {
 extern struct fips_test_vector vec;
 extern struct fips_test_interim_info info;
 
+#ifdef RTE_HAS_JANSSON
+extern struct fips_test_json_info json_info;
+#endif /* RTE_HAS_JANSSON */
+
 int
 fips_test_init(const char *req_file_path, const char *rsp_file_path,
 		const char *device_name);
@@ -212,6 +241,17 @@  fips_test_parse_one_case(void);
 void
 fips_test_write_one_case(void);
 
+#ifdef RTE_HAS_JANSSON
+int
+fips_test_parse_one_json_vector_set(void);
+
+int
+fips_test_parse_one_json_group(void);
+
+int
+fips_test_parse_one_json_case(void);
+#endif /* RTE_HAS_JANSSON */
+
 int
 parse_test_aes_init(void);
 
diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index e06ae37567..554d74cda0 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1251,6 +1251,8 @@  fips_generic_test(void)
 		if (ret < 0)
 			return ret;
 		break;
+	default:
+		break;
 	}
 
 	fprintf(info.fp_wr, "\n");