1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #ifndef _FIPS_VALIDATION_H_
6 #define _FIPS_VALIDATION_H_
8 #define FIPS_PARSE_ERR(fmt, args) \
9 RTE_LOG(ERR, USER1, "FIPS parse error" ## fmt ## "\n", ## args)
11 #define ERR_MSG_SIZE 128
12 #define MAX_CASE_LINE 15
13 #define MAX_LINE_CHAR 204800 /*< max number of characters per line */
14 #define MAX_NB_TESTS 10240
15 #define MAX_BUF_SIZE 2048
16 #define MAX_STRING_SIZE 64
18 #define POSITIVE_TEST 0
19 #define NEGATIVE_TEST -1
21 #define REQ_FILE_PERFIX "req"
22 #define RSP_FILE_PERFIX "rsp"
23 #define FAX_FILE_PERFIX "fax"
25 enum fips_test_algorithms {
26 FIPS_TEST_ALGO_AES = 0,
38 FIPS_TEST_ENC_AUTH_GEN = 1,
39 FIPS_TEST_DEC_AUTH_VERIF,
42 #define MAX_LINE_PER_VECTOR 16
49 struct fips_test_vector {
53 struct fips_val digest;
54 struct fips_val auth_aad;
59 struct fips_val digest;
68 enum rte_crypto_op_status status;
71 typedef int (*post_prcess_t)(struct fips_val *val);
73 typedef int (*parse_callback_t)(const char *key, char *text,
74 struct fips_val *val);
76 struct fips_test_callback {
82 enum fips_aesavs_test_types {
83 AESAVS_TYPE_GFXBOX = 1,
91 struct aesavs_interim_data {
92 enum fips_aesavs_test_types test_type;
97 struct hmac_interim_data {
98 enum rte_crypto_auth_algorithm algo;
101 struct fips_test_interim_info {
104 enum file_types file_type;
105 enum fips_test_algorithms algo;
107 char *vec[MAX_LINE_PER_VECTOR];
108 uint32_t nb_vec_lines;
109 char device_name[MAX_STRING_SIZE];
112 struct aesavs_interim_data aes_data;
113 struct hmac_interim_data hmac_data;
117 enum fips_test_op op;
119 const struct fips_test_callback *callbacks;
120 const struct fips_test_callback *interim_callbacks;
121 const struct fips_test_callback *writeback_callbacks;
123 post_prcess_t parse_writeback;
124 post_prcess_t kat_check;
127 extern struct fips_test_vector vec;
128 extern struct fips_test_interim_info info;
131 fips_test_init(const char *req_file_path, const char *rsp_file_path,
132 const char *device_name);
135 fips_test_clear(void);
138 fips_test_fetch_one_block(void);
141 fips_test_parse_one_case(void);
144 fips_test_write_one_case(void);
147 parse_test_aes_init(void);
150 parse_test_hmac_init(void);
153 parser_read_uint8_hex(uint8_t *value, const char *p);
156 parse_uint8_hex_str(const char *key, char *src, struct fips_val *val);
159 parse_uint8_known_len_hex_str(const char *key, char *src, struct fips_val *val);
162 parser_read_uint32_val(const char *key, char *src, struct fips_val *val);
165 parser_read_uint32_bit_val(const char *key, char *src, struct fips_val *val);
168 parser_read_uint32(uint32_t *value, char *p);
171 parser_read_uint32_val(const char *key, char *src, struct fips_val *val);
174 writeback_hex_str(const char *key, char *dst, struct fips_val *val);
177 parse_write_hex_str(struct fips_val *src);
180 update_info_vec(uint32_t count);