#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)
#define MAX_CASE_LINE 15
#define MAX_LINE_CHAR 204800 /*< max number of characters per line */
#define MAX_NB_TESTS 10240
-#define MAX_BUF_SIZE 2048
+#define DEF_MBUF_SEG_SIZE (UINT16_MAX - sizeof(struct rte_mbuf) - \
+ RTE_PKTMBUF_HEADROOM)
#define MAX_STRING_SIZE 64
+#define MAX_FILE_NAME_SIZE 256
+#define MAX_DIGEST_SIZE 64
#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,
FIPS_TEST_ALGO_AES_GCM,
+ FIPS_TEST_ALGO_AES_CMAC,
+ FIPS_TEST_ALGO_AES_CCM,
FIPS_TEST_ALGO_HMAC,
FIPS_TEST_ALGO_TDES,
+ FIPS_TEST_ALGO_SHA,
+ FIPS_TEST_ALGO_AES_XTS,
FIPS_TEST_ALGO_MAX
};
enum file_types {
FIPS_TYPE_REQ = 1,
FIPS_TYPE_FAX,
- FIPS_TYPE_RSP
+ FIPS_TYPE_RSP,
+ FIPS_TYPE_JSON,
};
enum fips_test_op {
AESAVS_TYPE_VARTXT,
AESAVS_TYPE_MMT,
AESAVS_TYPE_MCT,
+ AESAVS_TYPE_AFT,
};
enum fips_tdes_test_types {
TDES_MMT /* Multi block Message Test */
};
+enum fips_tdes_test_mode {
+ TDES_MODE_CBC = 0,
+ TDES_MODE_ECB
+};
+
+enum fips_ccm_test_types {
+ CCM_VADT = 1, /* Variable Associated Data Test */
+ CCM_VPT, /* Variable Payload Test */
+ CCM_VNT, /* Variable Nonce Test */
+ CCM_VTT, /* Variable Tag Test */
+ CCM_DVPT, /* Decryption-Verification Process Test */
+};
+
+enum fips_sha_test_types {
+ SHA_KAT = 0,
+ SHA_MCT
+};
+
struct aesavs_interim_data {
enum fips_aesavs_test_types test_type;
uint32_t cipher_algo;
struct tdes_interim_data {
enum fips_tdes_test_types test_type;
+ enum fips_tdes_test_mode test_mode;
uint32_t nb_keys;
};
+struct ccm_interim_data {
+ enum fips_ccm_test_types test_type;
+ uint32_t aad_len;
+ uint32_t pt_len;
+ uint32_t digest_len;
+ uint32_t key_len;
+ uint32_t iv_len;
+};
+
+struct sha_interim_data {
+ enum fips_sha_test_types test_type;
+ enum rte_crypto_auth_algorithm algo;
+};
+
+struct gcm_interim_data {
+ uint8_t is_gmac;
+ 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;
enum fips_test_algorithms algo;
char *one_line_text;
char *vec[MAX_LINE_PER_VECTOR];
+ uint32_t vec_start_off;
uint32_t nb_vec_lines;
char device_name[MAX_STRING_SIZE];
+ char file_name[MAX_FILE_NAME_SIZE];
+ float version;
union {
struct aesavs_interim_data aes_data;
struct hmac_interim_data hmac_data;
struct tdes_interim_data tdes_data;
-
+ struct ccm_interim_data ccm_data;
+ struct sha_interim_data sha_data;
+ struct gcm_interim_data gcm_data;
} interim_info;
enum fips_test_op op;
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);
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);
+
+int
+parse_test_gcm_json_init(void);
+
+int
+parse_test_hmac_json_init(void);
+
+int
+parse_test_hmac_json_algorithm(void);
+
+int
+parse_test_cmac_json_init(void);
+
+int
+parse_test_aes_json_init(void);
+#endif /* RTE_HAS_JANSSON */
+
int
parse_test_aes_init(void);
int
parse_test_gcm_init(void);
+int
+parse_test_cmac_init(void);
+
+int
+parse_test_ccm_init(void);
+
+int
+parse_test_sha_init(void);
+
+int
+parse_test_xts_init(void);
+
int
parser_read_uint8_hex(uint8_t *value, const char *p);
int
parse_uint8_known_len_hex_str(const char *key, char *src, struct fips_val *val);
+int
+parser_read_uint16(uint16_t *value, const char *p);
+
int
parser_read_uint32_val(const char *key, char *src, struct fips_val *val);
int
update_info_vec(uint32_t count);
+typedef int (*fips_test_one_case_t)(void);
+typedef int (*fips_prepare_op_t)(void);
+typedef int (*fips_prepare_xform_t)(struct rte_crypto_sym_xform *);
+
+struct fips_test_ops {
+ fips_prepare_xform_t prepare_xform;
+ fips_prepare_op_t prepare_op;
+ fips_test_one_case_t test;
+};
+
+extern struct fips_test_ops test_ops;
+
+int prepare_aead_op(void);
+
+int prepare_auth_op(void);
+
+int prepare_gcm_xform(struct rte_crypto_sym_xform *xform);
+
+int prepare_gmac_xform(struct rte_crypto_sym_xform *xform);
+
#endif