examples/fips_validation: add JSON info to header

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>
Tested-by: Jakub Poczatek <jakub.poczatek@intel.com>
This commit is contained in:
Brandon Lo 2022-05-30 21:22:36 +05:30 committed by Akhil Goyal
parent 1230526d13
commit f556293fd5
3 changed files with 49 additions and 7 deletions

View File

@ -270,11 +270,11 @@ parse_file_type(const char *path)
{ {
const char *tmp = path + strlen(path) - 3; 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; 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; 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; info.file_type = FIPS_TYPE_FAX;
else else
return -EINVAL; return -EINVAL;

View File

@ -5,6 +5,10 @@
#ifndef _FIPS_VALIDATION_H_ #ifndef _FIPS_VALIDATION_H_
#define _FIPS_VALIDATION_H_ #define _FIPS_VALIDATION_H_
#ifdef RTE_HAS_JANSSON
#include <jansson.h>
#endif /* RTE_HAS_JANSSON */
#define FIPS_PARSE_ERR(fmt, args) \ #define FIPS_PARSE_ERR(fmt, args) \
RTE_LOG(ERR, USER1, "FIPS parse error" ## fmt ## "\n", ## args) RTE_LOG(ERR, USER1, "FIPS parse error" ## fmt ## "\n", ## args)
@ -21,9 +25,12 @@
#define POSITIVE_TEST 0 #define POSITIVE_TEST 0
#define NEGATIVE_TEST -1 #define NEGATIVE_TEST -1
#define REQ_FILE_PERFIX "req" #define REQ_FILE_PREFIX "req"
#define RSP_FILE_PERFIX "rsp" #define RSP_FILE_PREFIX "rsp"
#define FAX_FILE_PERFIX "fax" #define FAX_FILE_PREFIX "fax"
#define JSON_FILE_PREFIX "json"
#define ACVVERSION "1.0"
enum fips_test_algorithms { enum fips_test_algorithms {
FIPS_TEST_ALGO_AES = 0, FIPS_TEST_ALGO_AES = 0,
@ -40,7 +47,8 @@ enum fips_test_algorithms {
enum file_types { enum file_types {
FIPS_TYPE_REQ = 1, FIPS_TYPE_REQ = 1,
FIPS_TYPE_FAX, FIPS_TYPE_FAX,
FIPS_TYPE_RSP FIPS_TYPE_RSP,
FIPS_TYPE_JSON,
}; };
enum fips_test_op { enum fips_test_op {
@ -161,6 +169,23 @@ struct gcm_interim_data {
uint8_t gen_iv; 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 { struct fips_test_interim_info {
FILE *fp_rd; FILE *fp_rd;
FILE *fp_wr; FILE *fp_wr;
@ -196,6 +221,10 @@ struct fips_test_interim_info {
extern struct fips_test_vector vec; extern struct fips_test_vector vec;
extern struct fips_test_interim_info info; extern struct fips_test_interim_info info;
#ifdef RTE_HAS_JANSSON
extern struct fips_test_json_info json_info;
#endif /* RTE_HAS_JANSSON */
int int
fips_test_init(const char *req_file_path, const char *rsp_file_path, fips_test_init(const char *req_file_path, const char *rsp_file_path,
const char *device_name); const char *device_name);
@ -212,6 +241,17 @@ fips_test_parse_one_case(void);
void void
fips_test_write_one_case(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 int
parse_test_aes_init(void); parse_test_aes_init(void);

View File

@ -1251,6 +1251,8 @@ fips_generic_test(void)
if (ret < 0) if (ret < 0)
return ret; return ret;
break; break;
default:
break;
} }
fprintf(info.fp_wr, "\n"); fprintf(info.fp_wr, "\n");