-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathfips_cert.h
267 lines (238 loc) · 10.1 KB
/
fips_cert.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*************************************************************************
* Copyright (C) 2023 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*************************************************************************/
#ifndef IPPCP_FIPS_CERT_H
#define IPPCP_FIPS_CERT_H
#include <ippcp.h>
#include <ippcpdefs.h>
#if defined( __cplusplus )
extern "C" {
#endif
typedef int fips_test_status;
typedef int func_fips_approved;
#define IPPCP_ALGO_SELFTEST_OK (0)
#define IPPCP_ALGO_SELFTEST_BAD_ARGS_ERR (1)
#define IPPCP_ALGO_SELFTEST_KAT_ERR (2)
/* Enc/Dec */
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptDecrypt_get_size, (int *pBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCBC, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCBC, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCBC_CS1, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCBC_CS2, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCBC_CS3, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCBC_CS1, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCBC_CS2, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCBC_CS3, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCFB, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCFB, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptOFB, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptOFB, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptCTR, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESDecryptCTR, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptDecryptCCM_get_size, (int *pBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsAES_CCMEncrypt, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAES_CCMDecrypt, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAES_GCM_get_size, (int *pBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsAES_GCMEncrypt, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAES_GCMDecrypt, (Ipp8u *pBuffer))
/* Selftests are disabled for now, since AES-XTS algorithm didn't pass CAVP testing */
// IPPAPI(fips_test_status, fips_selftest_ippsAESEncryptDecryptXTS_get_size, (int *pBuffSize))
// IPPAPI(fips_test_status, fips_selftest_ippsAES_XTSEncrypt, (Ipp8u *pBuffer))
// IPPAPI(fips_test_status, fips_selftest_ippsAES_XTSDecrypt, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsAES_CMAC_get_size, (int *pBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsAES_CMACUpdate, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSAEncryptDecrypt_OAEP_rmf_get_size_keys, (int *pKeysBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsRSAEncryptDecrypt_OAEP_rmf_get_size, (int *pBufferSize, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSAEncrypt_OAEP_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSADecrypt_OAEP_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
/* Hashes */
IPPAPI(fips_test_status, fips_selftest_ippsHash_rmf_get_size, (int *pBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsHashUpdate_rmf, (IppHashAlgId hashAlgId, Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsHashMessage_rmf, (IppHashAlgId hashAlgId))
/* HMAC */
IPPAPI(fips_test_status, fips_selftest_ippsHMAC_rmf_get_size, (int *pBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsHMACUpdate_rmf, (Ipp8u *pBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsHMACMessage_rmf, (void))
/* RSA sign/verify */
#define LEAN_GET_SIZE "Function reports more memory than required. A leaner alternative is available: \
fips_selftest_ippsRSASign_PKCS1v15_rmf_get_size_keys, fips_selftest_ippsRSASign_PKCS1v15_rmf_get_size, \
fips_selftest_ippsRSAVerify_PKCS1v15_rmf_get_size_keys, fips_selftest_ippsRSAVerify_PKCS1v15_rmf_get_size."
IPP_DEPRECATED(LEAN_GET_SIZE) \
IPPAPI(fips_test_status, fips_selftest_ippsRSASignVerify_PKCS1v15_rmf_get_size_keys, (int *pKeysBufferSize))
IPP_DEPRECATED(LEAN_GET_SIZE) \
IPPAPI(fips_test_status, fips_selftest_ippsRSASignVerify_PKCS1v15_rmf_get_size, (int *pBufferSize, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSASign_PKCS1v15_rmf_get_size_keys, (int *pKeysBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsRSASign_PKCS1v15_rmf_get_size, (int *pBufferSize, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSAVerify_PKCS1v15_rmf_get_size_keys, (int *pKeysBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsRSAVerify_PKCS1v15_rmf_get_size, (int *pBufferSize, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSASign_PKCS1v15_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSAVerify_PKCS1v15_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSASignVerify_PSS_rmf_get_size_keys, (int *pKeysBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsRSASignVerify_PSS_rmf_get_size, (int *pBufferSize, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSASign_PSS_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSAVerify_PSS_rmf, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
IPPAPI(fips_test_status, fips_selftest_ippsRSA_GenerateKeys, (Ipp8u *pBuffer, Ipp8u *pKeysBuffer))
/* ECDSA sign/verify */
IPPAPI(fips_test_status, fips_selftest_ippsGFpECSignVerifyDSA_get_size_GFp_buff, (int *pGFpBuffSize))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECSignVerifyDSA_get_size_GFpEC_buff, (int *pGFpECBuffSize, Ipp8u *pGFpBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECSignVerifyDSA_get_size_data_buff, (int *pDataBuffSize, Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECSignDSA, (Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff, Ipp8u *pDataBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECVerifyDSA, (Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff, Ipp8u *pDataBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECPublicKey, (Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff, Ipp8u *pDataBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECPrivateKey, (Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff, Ipp8u *pDataBuff))
IPPAPI(fips_test_status, fips_selftest_ippsGFpECSharedSecretDH, (Ipp8u *pGFpBuff, Ipp8u *pGFpECBuff, Ipp8u *pDataBuff))
/* LMS */
IPPAPI(fips_test_status, fips_selftest_ippsLMSVerify_get_size, (int *pBufferSize))
IPPAPI(fips_test_status, fips_selftest_ippsLMSVerify, (Ipp8u *pDataBuff))
/*
// Enumerator that contains information about FIPS-approved
// functions inside the ippcp cryptographic boundary
*/
enum FIPS_IPPCP_FUNC {
/* Approved functions, > 0 */
AESEncryptCBC = 0x1,
AESEncryptCBC_CS1,
AESEncryptCBC_CS2,
AESEncryptCBC_CS3,
AESDecryptCBC,
AESDecryptCBC_CS1,
AESDecryptCBC_CS2,
AESDecryptCBC_CS3,
AESEncryptCFB,
AESDecryptCFB,
AESEncryptOFB,
AESDecryptOFB,
AESEncryptCTR,
AESDecryptCTR,
AES_CCMEncrypt,
AES_CCMDecrypt,
AES_CCMStart,
AES_CCMGetTag,
AES_GCMEncrypt,
AES_GCMDecrypt,
AES_GCMProcessIV,
AES_GCMProcessAAD,
AES_GCMStart,
AES_GCMGetTag,
RSASign_PKCS1v15_rmf,
RSAVerify_PKCS1v15_rmf,
RSASign_PSS_rmf,
RSAVerify_PSS_rmf,
RSA_GenerateKeys,
GFpECSignDSA,
GFpECVerifyDSA,
GFpECSharedSecretDH,
GFpECPublicKey,
GFpECPrivateKey,
HashUpdate_rmf,
HashGetTag_rmf,
HashFinal_rmf,
HashMessage_rmf,
AES_CMACUpdate,
AES_CMACFinal,
AES_CMACGetTag,
HMACUpdate_rmf,
HMACFinal_rmf,
HMACGetTag_rmf,
HMACMessage_rmf,
RSAEncrypt_OAEP_rmf,
RSADecrypt_OAEP_rmf,
LMSVerify,
/* Not approved functions or
* FIPS-mode is not yet implemented, < 0
*/
SMS4EncryptCBC = -0xFFF,
SMS4EncryptCBC_CS1,
SMS4EncryptCBC_CS2,
SMS4EncryptCBC_CS3,
SMS4DecryptCBC,
SMS4DecryptCBC_CS1,
SMS4DecryptCBC_CS2,
SMS4DecryptCBC_CS3,
SMS4EncryptCFB,
SMS4DecryptCFB,
SMS4EncryptOFB,
SMS4DecryptOFB,
SMS4EncryptCTR,
SMS4DecryptCTR,
SMS4_CCMStart,
SMS4_CCMEncrypt,
SMS4_CCMDecrypt,
SMS4_CCMGetTag,
/* XTS APIs didn't pass CAVP testing */
AES_XTSEncrypt,
AES_XTSDecrypt,
AESEncryptXTS_Direct,
AESDecryptXTS_Direct,
MGF1_rmf,
MGF2_rmf,
AES_EncryptCFB16_MB,
AES_S2V_CMAC,
AES_SIVEncrypt,
AES_SIVDecrypt,
PRNGen,
PRNGen_BN,
PRNGenRDRAND,
PRNGenRDRAND_BN,
TRNGenRDSEED,
TRNGenRDSEED_BN,
PrimeGen,
PrimeGen_BN,
RSA_Encrypt,
RSA_Decrypt,
DLPGenKeyPair,
DLPPublicKey,
DLPSignDSA,
DLPVerifyDSA,
DLPSharedSecretDH,
DLPGenerateDSA,
DLPGenerateDH,
GFpECVerify,
GFpECSharedSecretDHC,
GFpECSignNR,
GFpECVerifyNR,
GFpECSignSM2,
GFpECVerifySM2,
GFpECUserIDHashSM2,
GFpECKeyExchangeSM2_SharedKey,
GFpECEncryptSM2_Ext,
GFpECDecryptSM2_Ext,
GFpECESStart_SM2,
GFpECESEncrypt_SM2,
GFpECESDecrypt_SM2,
GFpECESFinal_SM2,
XMSSVerify
};
/**
* \brief
*
* An indicator if a function is FIPS-approved or not
*
* \param[in] function member of FIPS_IPPCP_FUNC enumerator
* that corresponds to API being checked.
* \return func_fips_approved equal to 1 if FIPS-approved algorithm is used
*
* Example:
* Library API FIPS_IPPCP_FUNC
* ippsAESEncryptCBC -> AESEncryptCBC
* ippsGFpECSignDSA -> GFpECSignDSA
* ipps<functionality> -> <functionality>
*
*/
IPPAPI(func_fips_approved, ippcp_is_fips_approved_func, (enum FIPS_IPPCP_FUNC function))
#if defined( __cplusplus )
}
#endif
#endif // IPPCP_FIPS_CERT_H