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,
39 FIPS_TEST_ENC_AUTH_GEN = 1,
40 FIPS_TEST_DEC_AUTH_VERIF,
43 #define MAX_LINE_PER_VECTOR 16
50 struct fips_test_vector {
54 struct fips_val digest;
55 struct fips_val auth_aad;
60 struct fips_val digest;
69 enum rte_crypto_op_status status;
72 typedef int (*post_prcess_t)(struct fips_val *val);
74 typedef int (*parse_callback_t)(const char *key, char *text,
75 struct fips_val *val);
77 struct fips_test_callback {
83 enum fips_aesavs_test_types {
84 AESAVS_TYPE_GFXBOX = 1,
92 enum fips_tdes_test_types {
93 TDES_INVERSE_PERMUTATION = 0,
95 TDES_SUBSTITUTION_TABLE,
99 TDES_MCT, /* Monte Carlo (Modes) Test */
100 TDES_MMT /* Multi block Message Test */
103 struct aesavs_interim_data {
104 enum fips_aesavs_test_types test_type;
105 uint32_t cipher_algo;
109 struct hmac_interim_data {
110 enum rte_crypto_auth_algorithm algo;
113 struct tdes_interim_data {
114 enum fips_tdes_test_types test_type;
118 struct fips_test_interim_info {
121 enum file_types file_type;
122 enum fips_test_algorithms algo;
124 char *vec[MAX_LINE_PER_VECTOR];
125 uint32_t nb_vec_lines;
126 char device_name[MAX_STRING_SIZE];
129 struct aesavs_interim_data aes_data;
130 struct hmac_interim_data hmac_data;
131 struct tdes_interim_data tdes_data;
135 enum fips_test_op op;
137 const struct fips_test_callback *callbacks;
138 const struct fips_test_callback *interim_callbacks;
139 const struct fips_test_callback *writeback_callbacks;
141 post_prcess_t parse_writeback;
142 post_prcess_t kat_check;
145 extern struct fips_test_vector vec;
146 extern struct fips_test_interim_info info;
149 fips_test_init(const char *req_file_path, const char *rsp_file_path,
150 const char *device_name);
153 fips_test_clear(void);
156 fips_test_fetch_one_block(void);
159 fips_test_parse_one_case(void);
162 fips_test_write_one_case(void);
165 parse_test_aes_init(void);
168 parse_test_tdes_init(void);
171 parse_test_hmac_init(void);
174 parser_read_uint8_hex(uint8_t *value, const char *p);
177 parse_uint8_hex_str(const char *key, char *src, struct fips_val *val);
180 parse_uint8_known_len_hex_str(const char *key, char *src, struct fips_val *val);
183 parser_read_uint32_val(const char *key, char *src, struct fips_val *val);
186 parser_read_uint32_bit_val(const char *key, char *src, struct fips_val *val);
189 parser_read_uint32(uint32_t *value, char *p);
192 parser_read_uint32_val(const char *key, char *src, struct fips_val *val);
195 writeback_hex_str(const char *key, char *dst, struct fips_val *val);
198 parse_write_hex_str(struct fips_val *src);
201 update_info_vec(uint32_t count);