]>
Commit | Line | Data |
---|---|---|
97f98500 HT |
1 | /** @file\r |
2 | Defines base cryptographic library APIs.\r | |
3 | The Base Cryptographic Library provides implementations of basic cryptography\r | |
a8c44645 | 4 | primitives (Hash Serials, HMAC, RSA, Diffie-Hellman, etc) for UEFI security\r |
5 | functionality enabling.\r | |
97f98500 | 6 | \r |
c1e66210 | 7 | Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.<BR>\r |
2009f6b4 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
97f98500 HT |
9 | \r |
10 | **/\r | |
11 | \r | |
12 | #ifndef __BASE_CRYPT_LIB_H__\r | |
13 | #define __BASE_CRYPT_LIB_H__\r | |
14 | \r | |
9e8841b4 QL |
15 | #include <Uefi/UefiBaseType.h>\r |
16 | \r | |
97f98500 HT |
17 | ///\r |
18 | /// MD5 digest size in bytes\r | |
19 | ///\r | |
7c342378 | 20 | #define MD5_DIGEST_SIZE 16\r |
97f98500 HT |
21 | \r |
22 | ///\r | |
23 | /// SHA-1 digest size in bytes.\r | |
24 | ///\r | |
7c342378 | 25 | #define SHA1_DIGEST_SIZE 20\r |
97f98500 HT |
26 | \r |
27 | ///\r | |
28 | /// SHA-256 digest size in bytes\r | |
29 | ///\r | |
30 | #define SHA256_DIGEST_SIZE 32\r | |
31 | \r | |
2ac68e8b QL |
32 | ///\r |
33 | /// SHA-384 digest size in bytes\r | |
34 | ///\r | |
35 | #define SHA384_DIGEST_SIZE 48\r | |
36 | \r | |
37 | ///\r | |
38 | /// SHA-512 digest size in bytes\r | |
39 | ///\r | |
40 | #define SHA512_DIGEST_SIZE 64\r | |
41 | \r | |
f0718d1d LX |
42 | ///\r |
43 | /// SM3 digest size in bytes\r | |
44 | ///\r | |
7c342378 | 45 | #define SM3_256_DIGEST_SIZE 32\r |
f0718d1d | 46 | \r |
a8c44645 | 47 | ///\r |
48 | /// TDES block size in bytes\r | |
49 | ///\r | |
7c342378 | 50 | #define TDES_BLOCK_SIZE 8\r |
a8c44645 | 51 | \r |
52 | ///\r | |
53 | /// AES block size in bytes\r | |
54 | ///\r | |
7c342378 | 55 | #define AES_BLOCK_SIZE 16\r |
a8c44645 | 56 | \r |
97f98500 HT |
57 | ///\r |
58 | /// RSA Key Tags Definition used in RsaSetKey() function for key component identification.\r | |
59 | ///\r | |
60 | typedef enum {\r | |
61 | RsaKeyN, ///< RSA public Modulus (N)\r | |
62 | RsaKeyE, ///< RSA Public exponent (e)\r | |
63 | RsaKeyD, ///< RSA Private exponent (d)\r | |
64 | RsaKeyP, ///< RSA secret prime factor of Modulus (p)\r | |
65 | RsaKeyQ, ///< RSA secret prime factor of Modules (q)\r | |
66 | RsaKeyDp, ///< p's CRT exponent (== d mod (p - 1))\r | |
67 | RsaKeyDq, ///< q's CRT exponent (== d mod (q - 1))\r | |
68 | RsaKeyQInv ///< The CRT coefficient (== 1/q mod p)\r | |
69 | } RSA_KEY_TAG;\r | |
70 | \r | |
7c342378 | 71 | // =====================================================================================\r |
97f98500 | 72 | // One-Way Cryptographic Hash Primitives\r |
7c342378 | 73 | // =====================================================================================\r |
97f98500 | 74 | \r |
e6a12a0f | 75 | #ifdef ENABLE_MD5_DEPRECATED_INTERFACES\r |
7c342378 | 76 | \r |
97f98500 HT |
77 | /**\r |
78 | Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.\r | |
79 | \r | |
532616bb | 80 | If this interface is not supported, then return zero.\r |
81 | \r | |
97f98500 | 82 | @return The size, in bytes, of the context buffer required for MD5 hash operations.\r |
532616bb | 83 | @retval 0 This interface is not supported.\r |
97f98500 HT |
84 | \r |
85 | **/\r | |
86 | UINTN\r | |
87 | EFIAPI\r | |
88 | Md5GetContextSize (\r | |
89 | VOID\r | |
90 | );\r | |
91 | \r | |
97f98500 HT |
92 | /**\r |
93 | Initializes user-supplied memory pointed by Md5Context as MD5 hash context for\r | |
94 | subsequent use.\r | |
95 | \r | |
16d2c32c | 96 | If Md5Context is NULL, then return FALSE.\r |
532616bb | 97 | If this interface is not supported, then return FALSE.\r |
97f98500 | 98 | \r |
a8c44645 | 99 | @param[out] Md5Context Pointer to MD5 context being initialized.\r |
97f98500 HT |
100 | \r |
101 | @retval TRUE MD5 context initialization succeeded.\r | |
102 | @retval FALSE MD5 context initialization failed.\r | |
532616bb | 103 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
104 | \r |
105 | **/\r | |
106 | BOOLEAN\r | |
107 | EFIAPI\r | |
108 | Md5Init (\r | |
a8c44645 | 109 | OUT VOID *Md5Context\r |
97f98500 HT |
110 | );\r |
111 | \r | |
a8c44645 | 112 | /**\r |
113 | Makes a copy of an existing MD5 context.\r | |
114 | \r | |
16d2c32c | 115 | If Md5Context is NULL, then return FALSE.\r |
116 | If NewMd5Context is NULL, then return FALSE.\r | |
532616bb | 117 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 118 | \r |
119 | @param[in] Md5Context Pointer to MD5 context being copied.\r | |
120 | @param[out] NewMd5Context Pointer to new MD5 context.\r | |
121 | \r | |
122 | @retval TRUE MD5 context copy succeeded.\r | |
123 | @retval FALSE MD5 context copy failed.\r | |
532616bb | 124 | @retval FALSE This interface is not supported.\r |
a8c44645 | 125 | \r |
126 | **/\r | |
127 | BOOLEAN\r | |
128 | EFIAPI\r | |
129 | Md5Duplicate (\r | |
130 | IN CONST VOID *Md5Context,\r | |
131 | OUT VOID *NewMd5Context\r | |
132 | );\r | |
97f98500 HT |
133 | \r |
134 | /**\r | |
a8c44645 | 135 | Digests the input data and updates MD5 context.\r |
136 | \r | |
137 | This function performs MD5 digest on a data buffer of the specified size.\r | |
138 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2998af86 | 139 | MD5 context should be already correctly initialized by Md5Init(), and should not be finalized\r |
a8c44645 | 140 | by Md5Final(). Behavior with invalid context is undefined.\r |
97f98500 | 141 | \r |
16d2c32c | 142 | If Md5Context is NULL, then return FALSE.\r |
532616bb | 143 | If this interface is not supported, then return FALSE.\r |
97f98500 HT |
144 | \r |
145 | @param[in, out] Md5Context Pointer to the MD5 context.\r | |
146 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
a8c44645 | 147 | @param[in] DataSize Size of Data buffer in bytes.\r |
97f98500 HT |
148 | \r |
149 | @retval TRUE MD5 data digest succeeded.\r | |
a8c44645 | 150 | @retval FALSE MD5 data digest failed.\r |
532616bb | 151 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
152 | \r |
153 | **/\r | |
154 | BOOLEAN\r | |
155 | EFIAPI\r | |
156 | Md5Update (\r | |
157 | IN OUT VOID *Md5Context,\r | |
158 | IN CONST VOID *Data,\r | |
a8c44645 | 159 | IN UINTN DataSize\r |
97f98500 HT |
160 | );\r |
161 | \r | |
97f98500 | 162 | /**\r |
a8c44645 | 163 | Completes computation of the MD5 digest value.\r |
164 | \r | |
165 | This function completes MD5 hash computation and retrieves the digest value into\r | |
166 | the specified memory. After this function has been called, the MD5 context cannot\r | |
167 | be used again.\r | |
2998af86 | 168 | MD5 context should be already correctly initialized by Md5Init(), and should not be\r |
a8c44645 | 169 | finalized by Md5Final(). Behavior with invalid MD5 context is undefined.\r |
97f98500 | 170 | \r |
16d2c32c | 171 | If Md5Context is NULL, then return FALSE.\r |
172 | If HashValue is NULL, then return FALSE.\r | |
532616bb | 173 | If this interface is not supported, then return FALSE.\r |
97f98500 | 174 | \r |
a8c44645 | 175 | @param[in, out] Md5Context Pointer to the MD5 context.\r |
97f98500 HT |
176 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r |
177 | value (16 bytes).\r | |
178 | \r | |
179 | @retval TRUE MD5 digest computation succeeded.\r | |
180 | @retval FALSE MD5 digest computation failed.\r | |
532616bb | 181 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
182 | \r |
183 | **/\r | |
184 | BOOLEAN\r | |
185 | EFIAPI\r | |
186 | Md5Final (\r | |
187 | IN OUT VOID *Md5Context,\r | |
188 | OUT UINT8 *HashValue\r | |
189 | );\r | |
190 | \r | |
b7d1ba0a QL |
191 | /**\r |
192 | Computes the MD5 message digest of a input data buffer.\r | |
193 | \r | |
194 | This function performs the MD5 message digest of a given data buffer, and places\r | |
195 | the digest value into the specified memory.\r | |
196 | \r | |
197 | If this interface is not supported, then return FALSE.\r | |
198 | \r | |
199 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
200 | @param[in] DataSize Size of Data buffer in bytes.\r | |
201 | @param[out] HashValue Pointer to a buffer that receives the MD5 digest\r | |
202 | value (16 bytes).\r | |
203 | \r | |
204 | @retval TRUE MD5 digest computation succeeded.\r | |
205 | @retval FALSE MD5 digest computation failed.\r | |
206 | @retval FALSE This interface is not supported.\r | |
207 | \r | |
208 | **/\r | |
209 | BOOLEAN\r | |
210 | EFIAPI\r | |
211 | Md5HashAll (\r | |
212 | IN CONST VOID *Data,\r | |
213 | IN UINTN DataSize,\r | |
214 | OUT UINT8 *HashValue\r | |
215 | );\r | |
7c342378 | 216 | \r |
acfd5557 | 217 | #endif\r |
b7d1ba0a | 218 | \r |
0f01cec5 | 219 | #ifndef DISABLE_SHA1_DEPRECATED_INTERFACES\r |
7c342378 | 220 | \r |
97f98500 HT |
221 | /**\r |
222 | Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.\r | |
223 | \r | |
532616bb | 224 | If this interface is not supported, then return zero.\r |
225 | \r | |
97f98500 | 226 | @return The size, in bytes, of the context buffer required for SHA-1 hash operations.\r |
532616bb | 227 | @retval 0 This interface is not supported.\r |
97f98500 HT |
228 | \r |
229 | **/\r | |
230 | UINTN\r | |
231 | EFIAPI\r | |
232 | Sha1GetContextSize (\r | |
233 | VOID\r | |
234 | );\r | |
235 | \r | |
97f98500 | 236 | /**\r |
a8c44645 | 237 | Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for\r |
97f98500 HT |
238 | subsequent use.\r |
239 | \r | |
16d2c32c | 240 | If Sha1Context is NULL, then return FALSE.\r |
532616bb | 241 | If this interface is not supported, then return FALSE.\r |
97f98500 | 242 | \r |
a8c44645 | 243 | @param[out] Sha1Context Pointer to SHA-1 context being initialized.\r |
97f98500 | 244 | \r |
a8c44645 | 245 | @retval TRUE SHA-1 context initialization succeeded.\r |
246 | @retval FALSE SHA-1 context initialization failed.\r | |
532616bb | 247 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
248 | \r |
249 | **/\r | |
250 | BOOLEAN\r | |
251 | EFIAPI\r | |
252 | Sha1Init (\r | |
a8c44645 | 253 | OUT VOID *Sha1Context\r |
97f98500 HT |
254 | );\r |
255 | \r | |
a8c44645 | 256 | /**\r |
257 | Makes a copy of an existing SHA-1 context.\r | |
258 | \r | |
16d2c32c | 259 | If Sha1Context is NULL, then return FALSE.\r |
260 | If NewSha1Context is NULL, then return FALSE.\r | |
532616bb | 261 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 262 | \r |
263 | @param[in] Sha1Context Pointer to SHA-1 context being copied.\r | |
264 | @param[out] NewSha1Context Pointer to new SHA-1 context.\r | |
265 | \r | |
266 | @retval TRUE SHA-1 context copy succeeded.\r | |
267 | @retval FALSE SHA-1 context copy failed.\r | |
532616bb | 268 | @retval FALSE This interface is not supported.\r |
a8c44645 | 269 | \r |
270 | **/\r | |
271 | BOOLEAN\r | |
272 | EFIAPI\r | |
273 | Sha1Duplicate (\r | |
274 | IN CONST VOID *Sha1Context,\r | |
275 | OUT VOID *NewSha1Context\r | |
276 | );\r | |
97f98500 HT |
277 | \r |
278 | /**\r | |
a8c44645 | 279 | Digests the input data and updates SHA-1 context.\r |
280 | \r | |
281 | This function performs SHA-1 digest on a data buffer of the specified size.\r | |
282 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2998af86 | 283 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized\r |
a8c44645 | 284 | by Sha1Final(). Behavior with invalid context is undefined.\r |
97f98500 | 285 | \r |
16d2c32c | 286 | If Sha1Context is NULL, then return FALSE.\r |
532616bb | 287 | If this interface is not supported, then return FALSE.\r |
97f98500 HT |
288 | \r |
289 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r | |
290 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
a8c44645 | 291 | @param[in] DataSize Size of Data buffer in bytes.\r |
97f98500 HT |
292 | \r |
293 | @retval TRUE SHA-1 data digest succeeded.\r | |
a8c44645 | 294 | @retval FALSE SHA-1 data digest failed.\r |
532616bb | 295 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
296 | \r |
297 | **/\r | |
298 | BOOLEAN\r | |
299 | EFIAPI\r | |
300 | Sha1Update (\r | |
301 | IN OUT VOID *Sha1Context,\r | |
302 | IN CONST VOID *Data,\r | |
a8c44645 | 303 | IN UINTN DataSize\r |
97f98500 HT |
304 | );\r |
305 | \r | |
97f98500 | 306 | /**\r |
a8c44645 | 307 | Completes computation of the SHA-1 digest value.\r |
308 | \r | |
309 | This function completes SHA-1 hash computation and retrieves the digest value into\r | |
310 | the specified memory. After this function has been called, the SHA-1 context cannot\r | |
311 | be used again.\r | |
2998af86 | 312 | SHA-1 context should be already correctly initialized by Sha1Init(), and should not be\r |
a8c44645 | 313 | finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.\r |
97f98500 | 314 | \r |
16d2c32c | 315 | If Sha1Context is NULL, then return FALSE.\r |
316 | If HashValue is NULL, then return FALSE.\r | |
532616bb | 317 | If this interface is not supported, then return FALSE.\r |
97f98500 | 318 | \r |
a8c44645 | 319 | @param[in, out] Sha1Context Pointer to the SHA-1 context.\r |
97f98500 HT |
320 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r |
321 | value (20 bytes).\r | |
322 | \r | |
323 | @retval TRUE SHA-1 digest computation succeeded.\r | |
324 | @retval FALSE SHA-1 digest computation failed.\r | |
532616bb | 325 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
326 | \r |
327 | **/\r | |
328 | BOOLEAN\r | |
329 | EFIAPI\r | |
330 | Sha1Final (\r | |
331 | IN OUT VOID *Sha1Context,\r | |
332 | OUT UINT8 *HashValue\r | |
333 | );\r | |
334 | \r | |
b7d1ba0a QL |
335 | /**\r |
336 | Computes the SHA-1 message digest of a input data buffer.\r | |
337 | \r | |
338 | This function performs the SHA-1 message digest of a given data buffer, and places\r | |
339 | the digest value into the specified memory.\r | |
340 | \r | |
341 | If this interface is not supported, then return FALSE.\r | |
342 | \r | |
343 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
344 | @param[in] DataSize Size of Data buffer in bytes.\r | |
345 | @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest\r | |
346 | value (20 bytes).\r | |
347 | \r | |
348 | @retval TRUE SHA-1 digest computation succeeded.\r | |
349 | @retval FALSE SHA-1 digest computation failed.\r | |
350 | @retval FALSE This interface is not supported.\r | |
351 | \r | |
352 | **/\r | |
353 | BOOLEAN\r | |
354 | EFIAPI\r | |
355 | Sha1HashAll (\r | |
356 | IN CONST VOID *Data,\r | |
357 | IN UINTN DataSize,\r | |
358 | OUT UINT8 *HashValue\r | |
359 | );\r | |
7c342378 | 360 | \r |
0f01cec5 | 361 | #endif\r |
b7d1ba0a | 362 | \r |
97f98500 | 363 | /**\r |
a8c44645 | 364 | Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.\r |
97f98500 | 365 | \r |
a8c44645 | 366 | @return The size, in bytes, of the context buffer required for SHA-256 hash operations.\r |
97f98500 HT |
367 | \r |
368 | **/\r | |
369 | UINTN\r | |
370 | EFIAPI\r | |
371 | Sha256GetContextSize (\r | |
372 | VOID\r | |
373 | );\r | |
374 | \r | |
97f98500 HT |
375 | /**\r |
376 | Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for\r | |
377 | subsequent use.\r | |
378 | \r | |
16d2c32c | 379 | If Sha256Context is NULL, then return FALSE.\r |
97f98500 | 380 | \r |
a8c44645 | 381 | @param[out] Sha256Context Pointer to SHA-256 context being initialized.\r |
97f98500 HT |
382 | \r |
383 | @retval TRUE SHA-256 context initialization succeeded.\r | |
384 | @retval FALSE SHA-256 context initialization failed.\r | |
385 | \r | |
386 | **/\r | |
387 | BOOLEAN\r | |
388 | EFIAPI\r | |
389 | Sha256Init (\r | |
a8c44645 | 390 | OUT VOID *Sha256Context\r |
97f98500 HT |
391 | );\r |
392 | \r | |
a8c44645 | 393 | /**\r |
394 | Makes a copy of an existing SHA-256 context.\r | |
395 | \r | |
16d2c32c | 396 | If Sha256Context is NULL, then return FALSE.\r |
397 | If NewSha256Context is NULL, then return FALSE.\r | |
532616bb | 398 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 399 | \r |
400 | @param[in] Sha256Context Pointer to SHA-256 context being copied.\r | |
401 | @param[out] NewSha256Context Pointer to new SHA-256 context.\r | |
402 | \r | |
403 | @retval TRUE SHA-256 context copy succeeded.\r | |
404 | @retval FALSE SHA-256 context copy failed.\r | |
532616bb | 405 | @retval FALSE This interface is not supported.\r |
a8c44645 | 406 | \r |
407 | **/\r | |
408 | BOOLEAN\r | |
409 | EFIAPI\r | |
410 | Sha256Duplicate (\r | |
411 | IN CONST VOID *Sha256Context,\r | |
412 | OUT VOID *NewSha256Context\r | |
413 | );\r | |
97f98500 HT |
414 | \r |
415 | /**\r | |
a8c44645 | 416 | Digests the input data and updates SHA-256 context.\r |
417 | \r | |
418 | This function performs SHA-256 digest on a data buffer of the specified size.\r | |
419 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2998af86 | 420 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized\r |
a8c44645 | 421 | by Sha256Final(). Behavior with invalid context is undefined.\r |
97f98500 | 422 | \r |
16d2c32c | 423 | If Sha256Context is NULL, then return FALSE.\r |
97f98500 HT |
424 | \r |
425 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r | |
426 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
a8c44645 | 427 | @param[in] DataSize Size of Data buffer in bytes.\r |
97f98500 HT |
428 | \r |
429 | @retval TRUE SHA-256 data digest succeeded.\r | |
a8c44645 | 430 | @retval FALSE SHA-256 data digest failed.\r |
97f98500 HT |
431 | \r |
432 | **/\r | |
433 | BOOLEAN\r | |
434 | EFIAPI\r | |
435 | Sha256Update (\r | |
436 | IN OUT VOID *Sha256Context,\r | |
437 | IN CONST VOID *Data,\r | |
a8c44645 | 438 | IN UINTN DataSize\r |
97f98500 HT |
439 | );\r |
440 | \r | |
97f98500 | 441 | /**\r |
a8c44645 | 442 | Completes computation of the SHA-256 digest value.\r |
443 | \r | |
444 | This function completes SHA-256 hash computation and retrieves the digest value into\r | |
445 | the specified memory. After this function has been called, the SHA-256 context cannot\r | |
446 | be used again.\r | |
2998af86 | 447 | SHA-256 context should be already correctly initialized by Sha256Init(), and should not be\r |
a8c44645 | 448 | finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.\r |
97f98500 | 449 | \r |
16d2c32c | 450 | If Sha256Context is NULL, then return FALSE.\r |
451 | If HashValue is NULL, then return FALSE.\r | |
97f98500 | 452 | \r |
a8c44645 | 453 | @param[in, out] Sha256Context Pointer to the SHA-256 context.\r |
97f98500 HT |
454 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r |
455 | value (32 bytes).\r | |
456 | \r | |
457 | @retval TRUE SHA-256 digest computation succeeded.\r | |
458 | @retval FALSE SHA-256 digest computation failed.\r | |
459 | \r | |
460 | **/\r | |
461 | BOOLEAN\r | |
462 | EFIAPI\r | |
463 | Sha256Final (\r | |
464 | IN OUT VOID *Sha256Context,\r | |
465 | OUT UINT8 *HashValue\r | |
466 | );\r | |
467 | \r | |
b7d1ba0a QL |
468 | /**\r |
469 | Computes the SHA-256 message digest of a input data buffer.\r | |
470 | \r | |
471 | This function performs the SHA-256 message digest of a given data buffer, and places\r | |
472 | the digest value into the specified memory.\r | |
473 | \r | |
474 | If this interface is not supported, then return FALSE.\r | |
475 | \r | |
476 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
477 | @param[in] DataSize Size of Data buffer in bytes.\r | |
478 | @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest\r | |
479 | value (32 bytes).\r | |
480 | \r | |
481 | @retval TRUE SHA-256 digest computation succeeded.\r | |
482 | @retval FALSE SHA-256 digest computation failed.\r | |
483 | @retval FALSE This interface is not supported.\r | |
484 | \r | |
485 | **/\r | |
486 | BOOLEAN\r | |
487 | EFIAPI\r | |
488 | Sha256HashAll (\r | |
489 | IN CONST VOID *Data,\r | |
490 | IN UINTN DataSize,\r | |
491 | OUT UINT8 *HashValue\r | |
492 | );\r | |
493 | \r | |
2ac68e8b QL |
494 | /**\r |
495 | Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
496 | \r | |
497 | @return The size, in bytes, of the context buffer required for SHA-384 hash operations.\r | |
498 | \r | |
499 | **/\r | |
500 | UINTN\r | |
501 | EFIAPI\r | |
502 | Sha384GetContextSize (\r | |
503 | VOID\r | |
504 | );\r | |
505 | \r | |
506 | /**\r | |
507 | Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for\r | |
508 | subsequent use.\r | |
509 | \r | |
510 | If Sha384Context is NULL, then return FALSE.\r | |
511 | \r | |
512 | @param[out] Sha384Context Pointer to SHA-384 context being initialized.\r | |
513 | \r | |
514 | @retval TRUE SHA-384 context initialization succeeded.\r | |
515 | @retval FALSE SHA-384 context initialization failed.\r | |
516 | \r | |
517 | **/\r | |
518 | BOOLEAN\r | |
519 | EFIAPI\r | |
520 | Sha384Init (\r | |
521 | OUT VOID *Sha384Context\r | |
522 | );\r | |
523 | \r | |
524 | /**\r | |
525 | Makes a copy of an existing SHA-384 context.\r | |
526 | \r | |
527 | If Sha384Context is NULL, then return FALSE.\r | |
528 | If NewSha384Context is NULL, then return FALSE.\r | |
529 | If this interface is not supported, then return FALSE.\r | |
530 | \r | |
531 | @param[in] Sha384Context Pointer to SHA-384 context being copied.\r | |
532 | @param[out] NewSha384Context Pointer to new SHA-384 context.\r | |
533 | \r | |
534 | @retval TRUE SHA-384 context copy succeeded.\r | |
535 | @retval FALSE SHA-384 context copy failed.\r | |
536 | @retval FALSE This interface is not supported.\r | |
537 | \r | |
538 | **/\r | |
539 | BOOLEAN\r | |
540 | EFIAPI\r | |
541 | Sha384Duplicate (\r | |
542 | IN CONST VOID *Sha384Context,\r | |
543 | OUT VOID *NewSha384Context\r | |
544 | );\r | |
545 | \r | |
546 | /**\r | |
547 | Digests the input data and updates SHA-384 context.\r | |
548 | \r | |
549 | This function performs SHA-384 digest on a data buffer of the specified size.\r | |
550 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2998af86 | 551 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized\r |
2ac68e8b QL |
552 | by Sha384Final(). Behavior with invalid context is undefined.\r |
553 | \r | |
554 | If Sha384Context is NULL, then return FALSE.\r | |
555 | \r | |
556 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
557 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
558 | @param[in] DataSize Size of Data buffer in bytes.\r | |
559 | \r | |
560 | @retval TRUE SHA-384 data digest succeeded.\r | |
561 | @retval FALSE SHA-384 data digest failed.\r | |
562 | \r | |
563 | **/\r | |
564 | BOOLEAN\r | |
565 | EFIAPI\r | |
566 | Sha384Update (\r | |
567 | IN OUT VOID *Sha384Context,\r | |
568 | IN CONST VOID *Data,\r | |
569 | IN UINTN DataSize\r | |
570 | );\r | |
571 | \r | |
572 | /**\r | |
573 | Completes computation of the SHA-384 digest value.\r | |
574 | \r | |
575 | This function completes SHA-384 hash computation and retrieves the digest value into\r | |
576 | the specified memory. After this function has been called, the SHA-384 context cannot\r | |
577 | be used again.\r | |
2998af86 | 578 | SHA-384 context should be already correctly initialized by Sha384Init(), and should not be\r |
2ac68e8b QL |
579 | finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.\r |
580 | \r | |
581 | If Sha384Context is NULL, then return FALSE.\r | |
582 | If HashValue is NULL, then return FALSE.\r | |
583 | \r | |
584 | @param[in, out] Sha384Context Pointer to the SHA-384 context.\r | |
585 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
586 | value (48 bytes).\r | |
587 | \r | |
588 | @retval TRUE SHA-384 digest computation succeeded.\r | |
589 | @retval FALSE SHA-384 digest computation failed.\r | |
590 | \r | |
591 | **/\r | |
592 | BOOLEAN\r | |
593 | EFIAPI\r | |
594 | Sha384Final (\r | |
595 | IN OUT VOID *Sha384Context,\r | |
596 | OUT UINT8 *HashValue\r | |
597 | );\r | |
598 | \r | |
b7d1ba0a QL |
599 | /**\r |
600 | Computes the SHA-384 message digest of a input data buffer.\r | |
601 | \r | |
602 | This function performs the SHA-384 message digest of a given data buffer, and places\r | |
603 | the digest value into the specified memory.\r | |
604 | \r | |
605 | If this interface is not supported, then return FALSE.\r | |
606 | \r | |
607 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
608 | @param[in] DataSize Size of Data buffer in bytes.\r | |
609 | @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest\r | |
610 | value (48 bytes).\r | |
611 | \r | |
612 | @retval TRUE SHA-384 digest computation succeeded.\r | |
613 | @retval FALSE SHA-384 digest computation failed.\r | |
614 | @retval FALSE This interface is not supported.\r | |
615 | \r | |
616 | **/\r | |
617 | BOOLEAN\r | |
618 | EFIAPI\r | |
619 | Sha384HashAll (\r | |
620 | IN CONST VOID *Data,\r | |
621 | IN UINTN DataSize,\r | |
622 | OUT UINT8 *HashValue\r | |
623 | );\r | |
624 | \r | |
2ac68e8b QL |
625 | /**\r |
626 | Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
627 | \r | |
628 | @return The size, in bytes, of the context buffer required for SHA-512 hash operations.\r | |
629 | \r | |
630 | **/\r | |
631 | UINTN\r | |
632 | EFIAPI\r | |
633 | Sha512GetContextSize (\r | |
634 | VOID\r | |
635 | );\r | |
636 | \r | |
637 | /**\r | |
638 | Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for\r | |
639 | subsequent use.\r | |
640 | \r | |
641 | If Sha512Context is NULL, then return FALSE.\r | |
642 | \r | |
643 | @param[out] Sha512Context Pointer to SHA-512 context being initialized.\r | |
644 | \r | |
645 | @retval TRUE SHA-512 context initialization succeeded.\r | |
646 | @retval FALSE SHA-512 context initialization failed.\r | |
647 | \r | |
648 | **/\r | |
649 | BOOLEAN\r | |
650 | EFIAPI\r | |
651 | Sha512Init (\r | |
652 | OUT VOID *Sha512Context\r | |
653 | );\r | |
654 | \r | |
655 | /**\r | |
656 | Makes a copy of an existing SHA-512 context.\r | |
657 | \r | |
658 | If Sha512Context is NULL, then return FALSE.\r | |
659 | If NewSha512Context is NULL, then return FALSE.\r | |
660 | If this interface is not supported, then return FALSE.\r | |
661 | \r | |
662 | @param[in] Sha512Context Pointer to SHA-512 context being copied.\r | |
663 | @param[out] NewSha512Context Pointer to new SHA-512 context.\r | |
664 | \r | |
665 | @retval TRUE SHA-512 context copy succeeded.\r | |
666 | @retval FALSE SHA-512 context copy failed.\r | |
667 | @retval FALSE This interface is not supported.\r | |
668 | \r | |
669 | **/\r | |
670 | BOOLEAN\r | |
671 | EFIAPI\r | |
672 | Sha512Duplicate (\r | |
673 | IN CONST VOID *Sha512Context,\r | |
674 | OUT VOID *NewSha512Context\r | |
675 | );\r | |
676 | \r | |
677 | /**\r | |
678 | Digests the input data and updates SHA-512 context.\r | |
679 | \r | |
680 | This function performs SHA-512 digest on a data buffer of the specified size.\r | |
681 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
2998af86 | 682 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized\r |
2ac68e8b QL |
683 | by Sha512Final(). Behavior with invalid context is undefined.\r |
684 | \r | |
685 | If Sha512Context is NULL, then return FALSE.\r | |
686 | \r | |
687 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
688 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
689 | @param[in] DataSize Size of Data buffer in bytes.\r | |
690 | \r | |
691 | @retval TRUE SHA-512 data digest succeeded.\r | |
692 | @retval FALSE SHA-512 data digest failed.\r | |
693 | \r | |
694 | **/\r | |
695 | BOOLEAN\r | |
696 | EFIAPI\r | |
697 | Sha512Update (\r | |
698 | IN OUT VOID *Sha512Context,\r | |
699 | IN CONST VOID *Data,\r | |
700 | IN UINTN DataSize\r | |
701 | );\r | |
702 | \r | |
703 | /**\r | |
704 | Completes computation of the SHA-512 digest value.\r | |
705 | \r | |
706 | This function completes SHA-512 hash computation and retrieves the digest value into\r | |
707 | the specified memory. After this function has been called, the SHA-512 context cannot\r | |
708 | be used again.\r | |
2998af86 | 709 | SHA-512 context should be already correctly initialized by Sha512Init(), and should not be\r |
2ac68e8b QL |
710 | finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.\r |
711 | \r | |
712 | If Sha512Context is NULL, then return FALSE.\r | |
713 | If HashValue is NULL, then return FALSE.\r | |
714 | \r | |
715 | @param[in, out] Sha512Context Pointer to the SHA-512 context.\r | |
716 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
717 | value (64 bytes).\r | |
718 | \r | |
719 | @retval TRUE SHA-512 digest computation succeeded.\r | |
720 | @retval FALSE SHA-512 digest computation failed.\r | |
721 | \r | |
722 | **/\r | |
723 | BOOLEAN\r | |
724 | EFIAPI\r | |
725 | Sha512Final (\r | |
726 | IN OUT VOID *Sha512Context,\r | |
727 | OUT UINT8 *HashValue\r | |
728 | );\r | |
97f98500 | 729 | \r |
b7d1ba0a QL |
730 | /**\r |
731 | Computes the SHA-512 message digest of a input data buffer.\r | |
732 | \r | |
733 | This function performs the SHA-512 message digest of a given data buffer, and places\r | |
734 | the digest value into the specified memory.\r | |
735 | \r | |
736 | If this interface is not supported, then return FALSE.\r | |
737 | \r | |
738 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
739 | @param[in] DataSize Size of Data buffer in bytes.\r | |
740 | @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest\r | |
741 | value (64 bytes).\r | |
742 | \r | |
743 | @retval TRUE SHA-512 digest computation succeeded.\r | |
744 | @retval FALSE SHA-512 digest computation failed.\r | |
745 | @retval FALSE This interface is not supported.\r | |
746 | \r | |
747 | **/\r | |
748 | BOOLEAN\r | |
749 | EFIAPI\r | |
750 | Sha512HashAll (\r | |
751 | IN CONST VOID *Data,\r | |
752 | IN UINTN DataSize,\r | |
753 | OUT UINT8 *HashValue\r | |
754 | );\r | |
755 | \r | |
c1e66210 ZL |
756 | /**\r |
757 | Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,\r | |
758 | published December 2016.\r | |
759 | \r | |
760 | @param[in] Input Pointer to the input message (X).\r | |
761 | @param[in] InputByteLen The number(>0) of input bytes provided for the input data.\r | |
762 | @param[in] BlockSize The size of each block (B).\r | |
763 | @param[out] Output Pointer to the output buffer.\r | |
764 | @param[in] OutputByteLen The desired number of output bytes (L).\r | |
765 | @param[in] Customization Pointer to the customization string (S).\r | |
766 | @param[in] CustomByteLen The length of the customization string in bytes.\r | |
767 | \r | |
768 | @retval TRUE ParallelHash256 digest computation succeeded.\r | |
769 | @retval FALSE ParallelHash256 digest computation failed.\r | |
770 | @retval FALSE This interface is not supported.\r | |
771 | \r | |
772 | **/\r | |
773 | BOOLEAN\r | |
774 | EFIAPI\r | |
775 | ParallelHash256HashAll (\r | |
776 | IN CONST VOID *Input,\r | |
777 | IN UINTN InputByteLen,\r | |
778 | IN UINTN BlockSize,\r | |
779 | OUT VOID *Output,\r | |
780 | IN UINTN OutputByteLen,\r | |
781 | IN CONST VOID *Customization,\r | |
782 | IN UINTN CustomByteLen\r | |
783 | );\r | |
784 | \r | |
f0718d1d LX |
785 | /**\r |
786 | Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.\r | |
787 | \r | |
788 | @return The size, in bytes, of the context buffer required for SM3 hash operations.\r | |
789 | \r | |
790 | **/\r | |
791 | UINTN\r | |
792 | EFIAPI\r | |
793 | Sm3GetContextSize (\r | |
794 | VOID\r | |
795 | );\r | |
796 | \r | |
797 | /**\r | |
798 | Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for\r | |
799 | subsequent use.\r | |
800 | \r | |
801 | If Sm3Context is NULL, then return FALSE.\r | |
802 | \r | |
803 | @param[out] Sm3Context Pointer to SM3 context being initialized.\r | |
804 | \r | |
805 | @retval TRUE SM3 context initialization succeeded.\r | |
806 | @retval FALSE SM3 context initialization failed.\r | |
807 | \r | |
808 | **/\r | |
809 | BOOLEAN\r | |
810 | EFIAPI\r | |
811 | Sm3Init (\r | |
812 | OUT VOID *Sm3Context\r | |
813 | );\r | |
814 | \r | |
815 | /**\r | |
816 | Makes a copy of an existing SM3 context.\r | |
817 | \r | |
818 | If Sm3Context is NULL, then return FALSE.\r | |
819 | If NewSm3Context is NULL, then return FALSE.\r | |
820 | If this interface is not supported, then return FALSE.\r | |
821 | \r | |
822 | @param[in] Sm3Context Pointer to SM3 context being copied.\r | |
823 | @param[out] NewSm3Context Pointer to new SM3 context.\r | |
824 | \r | |
825 | @retval TRUE SM3 context copy succeeded.\r | |
826 | @retval FALSE SM3 context copy failed.\r | |
827 | @retval FALSE This interface is not supported.\r | |
828 | \r | |
829 | **/\r | |
830 | BOOLEAN\r | |
831 | EFIAPI\r | |
832 | Sm3Duplicate (\r | |
833 | IN CONST VOID *Sm3Context,\r | |
834 | OUT VOID *NewSm3Context\r | |
835 | );\r | |
836 | \r | |
837 | /**\r | |
838 | Digests the input data and updates SM3 context.\r | |
839 | \r | |
840 | This function performs SM3 digest on a data buffer of the specified size.\r | |
841 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
842 | SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized\r | |
843 | by Sm3Final(). Behavior with invalid context is undefined.\r | |
844 | \r | |
845 | If Sm3Context is NULL, then return FALSE.\r | |
846 | \r | |
847 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
848 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
849 | @param[in] DataSize Size of Data buffer in bytes.\r | |
850 | \r | |
851 | @retval TRUE SM3 data digest succeeded.\r | |
852 | @retval FALSE SM3 data digest failed.\r | |
853 | \r | |
854 | **/\r | |
855 | BOOLEAN\r | |
856 | EFIAPI\r | |
857 | Sm3Update (\r | |
858 | IN OUT VOID *Sm3Context,\r | |
859 | IN CONST VOID *Data,\r | |
860 | IN UINTN DataSize\r | |
861 | );\r | |
862 | \r | |
863 | /**\r | |
864 | Completes computation of the SM3 digest value.\r | |
865 | \r | |
866 | This function completes SM3 hash computation and retrieves the digest value into\r | |
867 | the specified memory. After this function has been called, the SM3 context cannot\r | |
868 | be used again.\r | |
869 | SM3 context should be already correctly initialized by Sm3Init(), and should not be\r | |
870 | finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.\r | |
871 | \r | |
872 | If Sm3Context is NULL, then return FALSE.\r | |
873 | If HashValue is NULL, then return FALSE.\r | |
874 | \r | |
875 | @param[in, out] Sm3Context Pointer to the SM3 context.\r | |
876 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
877 | value (32 bytes).\r | |
878 | \r | |
879 | @retval TRUE SM3 digest computation succeeded.\r | |
880 | @retval FALSE SM3 digest computation failed.\r | |
881 | \r | |
882 | **/\r | |
883 | BOOLEAN\r | |
884 | EFIAPI\r | |
885 | Sm3Final (\r | |
886 | IN OUT VOID *Sm3Context,\r | |
887 | OUT UINT8 *HashValue\r | |
888 | );\r | |
889 | \r | |
890 | /**\r | |
891 | Computes the SM3 message digest of a input data buffer.\r | |
892 | \r | |
893 | This function performs the SM3 message digest of a given data buffer, and places\r | |
894 | the digest value into the specified memory.\r | |
895 | \r | |
896 | If this interface is not supported, then return FALSE.\r | |
897 | \r | |
898 | @param[in] Data Pointer to the buffer containing the data to be hashed.\r | |
899 | @param[in] DataSize Size of Data buffer in bytes.\r | |
900 | @param[out] HashValue Pointer to a buffer that receives the SM3 digest\r | |
901 | value (32 bytes).\r | |
902 | \r | |
903 | @retval TRUE SM3 digest computation succeeded.\r | |
904 | @retval FALSE SM3 digest computation failed.\r | |
905 | @retval FALSE This interface is not supported.\r | |
906 | \r | |
907 | **/\r | |
908 | BOOLEAN\r | |
909 | EFIAPI\r | |
910 | Sm3HashAll (\r | |
911 | IN CONST VOID *Data,\r | |
912 | IN UINTN DataSize,\r | |
913 | OUT UINT8 *HashValue\r | |
914 | );\r | |
915 | \r | |
7c342378 | 916 | // =====================================================================================\r |
97f98500 | 917 | // MAC (Message Authentication Code) Primitive\r |
7c342378 | 918 | // =====================================================================================\r |
97f98500 | 919 | \r |
4c270243 QL |
920 | /**\r |
921 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.\r | |
922 | \r | |
923 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
924 | If the allocations fails, HmacSha256New() returns NULL.\r | |
925 | \r | |
926 | **/\r | |
927 | VOID *\r | |
928 | EFIAPI\r | |
929 | HmacSha256New (\r | |
930 | VOID\r | |
931 | );\r | |
932 | \r | |
933 | /**\r | |
934 | Release the specified HMAC_CTX context.\r | |
935 | \r | |
936 | @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.\r | |
937 | \r | |
938 | **/\r | |
939 | VOID\r | |
940 | EFIAPI\r | |
941 | HmacSha256Free (\r | |
942 | IN VOID *HmacSha256Ctx\r | |
943 | );\r | |
944 | \r | |
72009c62 | 945 | /**\r |
a23fdff6 JW |
946 | Set user-supplied key for subsequent use. It must be done before any\r |
947 | calling to HmacSha256Update().\r | |
72009c62 QL |
948 | \r |
949 | If HmacSha256Context is NULL, then return FALSE.\r | |
950 | If this interface is not supported, then return FALSE.\r | |
951 | \r | |
a23fdff6 | 952 | @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.\r |
72009c62 QL |
953 | @param[in] Key Pointer to the user-supplied key.\r |
954 | @param[in] KeySize Key size in bytes.\r | |
955 | \r | |
a23fdff6 JW |
956 | @retval TRUE The Key is set successfully.\r |
957 | @retval FALSE The Key is set unsuccessfully.\r | |
72009c62 QL |
958 | @retval FALSE This interface is not supported.\r |
959 | \r | |
960 | **/\r | |
961 | BOOLEAN\r | |
962 | EFIAPI\r | |
a23fdff6 | 963 | HmacSha256SetKey (\r |
72009c62 QL |
964 | OUT VOID *HmacSha256Context,\r |
965 | IN CONST UINT8 *Key,\r | |
966 | IN UINTN KeySize\r | |
967 | );\r | |
968 | \r | |
969 | /**\r | |
970 | Makes a copy of an existing HMAC-SHA256 context.\r | |
971 | \r | |
972 | If HmacSha256Context is NULL, then return FALSE.\r | |
973 | If NewHmacSha256Context is NULL, then return FALSE.\r | |
974 | If this interface is not supported, then return FALSE.\r | |
975 | \r | |
976 | @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.\r | |
977 | @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.\r | |
978 | \r | |
979 | @retval TRUE HMAC-SHA256 context copy succeeded.\r | |
980 | @retval FALSE HMAC-SHA256 context copy failed.\r | |
981 | @retval FALSE This interface is not supported.\r | |
982 | \r | |
983 | **/\r | |
984 | BOOLEAN\r | |
985 | EFIAPI\r | |
986 | HmacSha256Duplicate (\r | |
987 | IN CONST VOID *HmacSha256Context,\r | |
988 | OUT VOID *NewHmacSha256Context\r | |
989 | );\r | |
990 | \r | |
991 | /**\r | |
992 | Digests the input data and updates HMAC-SHA256 context.\r | |
993 | \r | |
994 | This function performs HMAC-SHA256 digest on a data buffer of the specified size.\r | |
995 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
a23fdff6 JW |
996 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r |
997 | by HmacSha256Final(). Behavior with invalid context is undefined.\r | |
72009c62 QL |
998 | \r |
999 | If HmacSha256Context is NULL, then return FALSE.\r | |
1000 | If this interface is not supported, then return FALSE.\r | |
1001 | \r | |
1002 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
1003 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1004 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1005 | \r | |
1006 | @retval TRUE HMAC-SHA256 data digest succeeded.\r | |
1007 | @retval FALSE HMAC-SHA256 data digest failed.\r | |
1008 | @retval FALSE This interface is not supported.\r | |
1009 | \r | |
1010 | **/\r | |
1011 | BOOLEAN\r | |
1012 | EFIAPI\r | |
1013 | HmacSha256Update (\r | |
1014 | IN OUT VOID *HmacSha256Context,\r | |
1015 | IN CONST VOID *Data,\r | |
1016 | IN UINTN DataSize\r | |
1017 | );\r | |
1018 | \r | |
1019 | /**\r | |
1020 | Completes computation of the HMAC-SHA256 digest value.\r | |
1021 | \r | |
1022 | This function completes HMAC-SHA256 hash computation and retrieves the digest value into\r | |
1023 | the specified memory. After this function has been called, the HMAC-SHA256 context cannot\r | |
1024 | be used again.\r | |
a23fdff6 JW |
1025 | HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized\r |
1026 | by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.\r | |
72009c62 QL |
1027 | \r |
1028 | If HmacSha256Context is NULL, then return FALSE.\r | |
68ae7cd6 | 1029 | If HmacValue is NULL, then return FALSE.\r |
72009c62 QL |
1030 | If this interface is not supported, then return FALSE.\r |
1031 | \r | |
1032 | @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.\r | |
68ae7cd6 | 1033 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest\r |
72009c62 QL |
1034 | value (32 bytes).\r |
1035 | \r | |
1036 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
1037 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
1038 | @retval FALSE This interface is not supported.\r | |
1039 | \r | |
1040 | **/\r | |
1041 | BOOLEAN\r | |
1042 | EFIAPI\r | |
1043 | HmacSha256Final (\r | |
1044 | IN OUT VOID *HmacSha256Context,\r | |
1045 | OUT UINT8 *HmacValue\r | |
1046 | );\r | |
1047 | \r | |
7bb42e32 QZ |
1048 | /**\r |
1049 | Computes the HMAC-SHA256 digest of a input data buffer.\r | |
1050 | \r | |
1051 | This function performs the HMAC-SHA256 digest of a given data buffer, and places\r | |
1052 | the digest value into the specified memory.\r | |
1053 | \r | |
1054 | If this interface is not supported, then return FALSE.\r | |
1055 | \r | |
1056 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1057 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1058 | @param[in] Key Pointer to the user-supplied key.\r | |
1059 | @param[in] KeySize Key size in bytes.\r | |
1060 | @param[out] HashValue Pointer to a buffer that receives the HMAC-SHA256 digest\r | |
1061 | value (32 bytes).\r | |
1062 | \r | |
1063 | @retval TRUE HMAC-SHA256 digest computation succeeded.\r | |
1064 | @retval FALSE HMAC-SHA256 digest computation failed.\r | |
1065 | @retval FALSE This interface is not supported.\r | |
1066 | \r | |
1067 | **/\r | |
1068 | BOOLEAN\r | |
1069 | EFIAPI\r | |
1070 | HmacSha256All (\r | |
1071 | IN CONST VOID *Data,\r | |
1072 | IN UINTN DataSize,\r | |
1073 | IN CONST UINT8 *Key,\r | |
1074 | IN UINTN KeySize,\r | |
1075 | OUT UINT8 *HmacValue\r | |
1076 | );\r | |
1077 | \r | |
1078 | /**\r | |
1079 | Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.\r | |
1080 | \r | |
1081 | @return Pointer to the HMAC_CTX context that has been initialized.\r | |
1082 | If the allocations fails, HmacSha384New() returns NULL.\r | |
1083 | \r | |
1084 | **/\r | |
1085 | VOID *\r | |
1086 | EFIAPI\r | |
1087 | HmacSha384New (\r | |
1088 | VOID\r | |
1089 | );\r | |
1090 | \r | |
1091 | /**\r | |
1092 | Release the specified HMAC_CTX context.\r | |
1093 | \r | |
1094 | @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.\r | |
1095 | \r | |
1096 | **/\r | |
1097 | VOID\r | |
1098 | EFIAPI\r | |
1099 | HmacSha384Free (\r | |
1100 | IN VOID *HmacSha384Ctx\r | |
1101 | );\r | |
1102 | \r | |
1103 | /**\r | |
1104 | Set user-supplied key for subsequent use. It must be done before any\r | |
1105 | calling to HmacSha384Update().\r | |
1106 | \r | |
1107 | If HmacSha384Context is NULL, then return FALSE.\r | |
1108 | If this interface is not supported, then return FALSE.\r | |
1109 | \r | |
1110 | @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.\r | |
1111 | @param[in] Key Pointer to the user-supplied key.\r | |
1112 | @param[in] KeySize Key size in bytes.\r | |
1113 | \r | |
1114 | @retval TRUE The Key is set successfully.\r | |
1115 | @retval FALSE The Key is set unsuccessfully.\r | |
1116 | @retval FALSE This interface is not supported.\r | |
1117 | \r | |
1118 | **/\r | |
1119 | BOOLEAN\r | |
1120 | EFIAPI\r | |
1121 | HmacSha384SetKey (\r | |
1122 | OUT VOID *HmacSha384Context,\r | |
1123 | IN CONST UINT8 *Key,\r | |
1124 | IN UINTN KeySize\r | |
1125 | );\r | |
1126 | \r | |
1127 | /**\r | |
1128 | Makes a copy of an existing HMAC-SHA384 context.\r | |
1129 | \r | |
1130 | If HmacSha384Context is NULL, then return FALSE.\r | |
1131 | If NewHmacSha384Context is NULL, then return FALSE.\r | |
1132 | If this interface is not supported, then return FALSE.\r | |
1133 | \r | |
1134 | @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.\r | |
1135 | @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.\r | |
1136 | \r | |
1137 | @retval TRUE HMAC-SHA384 context copy succeeded.\r | |
1138 | @retval FALSE HMAC-SHA384 context copy failed.\r | |
1139 | @retval FALSE This interface is not supported.\r | |
1140 | \r | |
1141 | **/\r | |
1142 | BOOLEAN\r | |
1143 | EFIAPI\r | |
1144 | HmacSha384Duplicate (\r | |
1145 | IN CONST VOID *HmacSha384Context,\r | |
1146 | OUT VOID *NewHmacSha384Context\r | |
1147 | );\r | |
1148 | \r | |
1149 | /**\r | |
1150 | Digests the input data and updates HMAC-SHA384 context.\r | |
1151 | \r | |
1152 | This function performs HMAC-SHA384 digest on a data buffer of the specified size.\r | |
1153 | It can be called multiple times to compute the digest of long or discontinuous data streams.\r | |
1154 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
1155 | by HmacSha384Final(). Behavior with invalid context is undefined.\r | |
1156 | \r | |
1157 | If HmacSha384Context is NULL, then return FALSE.\r | |
1158 | If this interface is not supported, then return FALSE.\r | |
1159 | \r | |
1160 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
1161 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1162 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1163 | \r | |
1164 | @retval TRUE HMAC-SHA384 data digest succeeded.\r | |
1165 | @retval FALSE HMAC-SHA384 data digest failed.\r | |
1166 | @retval FALSE This interface is not supported.\r | |
1167 | \r | |
1168 | **/\r | |
1169 | BOOLEAN\r | |
1170 | EFIAPI\r | |
1171 | HmacSha384Update (\r | |
1172 | IN OUT VOID *HmacSha384Context,\r | |
1173 | IN CONST VOID *Data,\r | |
1174 | IN UINTN DataSize\r | |
1175 | );\r | |
1176 | \r | |
1177 | /**\r | |
1178 | Completes computation of the HMAC-SHA384 digest value.\r | |
1179 | \r | |
1180 | This function completes HMAC-SHA384 hash computation and retrieves the digest value into\r | |
1181 | the specified memory. After this function has been called, the HMAC-SHA384 context cannot\r | |
1182 | be used again.\r | |
1183 | HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized\r | |
1184 | by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.\r | |
1185 | \r | |
1186 | If HmacSha384Context is NULL, then return FALSE.\r | |
1187 | If HmacValue is NULL, then return FALSE.\r | |
1188 | If this interface is not supported, then return FALSE.\r | |
1189 | \r | |
1190 | @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.\r | |
1191 | @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
1192 | value (48 bytes).\r | |
1193 | \r | |
1194 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
1195 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
1196 | @retval FALSE This interface is not supported.\r | |
1197 | \r | |
1198 | **/\r | |
1199 | BOOLEAN\r | |
1200 | EFIAPI\r | |
1201 | HmacSha384Final (\r | |
1202 | IN OUT VOID *HmacSha384Context,\r | |
1203 | OUT UINT8 *HmacValue\r | |
1204 | );\r | |
1205 | \r | |
1206 | /**\r | |
1207 | Computes the HMAC-SHA384 digest of a input data buffer.\r | |
1208 | \r | |
1209 | This function performs the HMAC-SHA384 digest of a given data buffer, and places\r | |
1210 | the digest value into the specified memory.\r | |
1211 | \r | |
1212 | If this interface is not supported, then return FALSE.\r | |
1213 | \r | |
1214 | @param[in] Data Pointer to the buffer containing the data to be digested.\r | |
1215 | @param[in] DataSize Size of Data buffer in bytes.\r | |
1216 | @param[in] Key Pointer to the user-supplied key.\r | |
1217 | @param[in] KeySize Key size in bytes.\r | |
1218 | @param[out] HashValue Pointer to a buffer that receives the HMAC-SHA384 digest\r | |
1219 | value (48 bytes).\r | |
1220 | \r | |
1221 | @retval TRUE HMAC-SHA384 digest computation succeeded.\r | |
1222 | @retval FALSE HMAC-SHA384 digest computation failed.\r | |
1223 | @retval FALSE This interface is not supported.\r | |
1224 | \r | |
1225 | **/\r | |
1226 | BOOLEAN\r | |
1227 | EFIAPI\r | |
1228 | HmacSha384All (\r | |
1229 | IN CONST VOID *Data,\r | |
1230 | IN UINTN DataSize,\r | |
1231 | IN CONST UINT8 *Key,\r | |
1232 | IN UINTN KeySize,\r | |
1233 | OUT UINT8 *HmacValue\r | |
1234 | );\r | |
1235 | \r | |
7c342378 | 1236 | // =====================================================================================\r |
97f98500 | 1237 | // Symmetric Cryptography Primitive\r |
7c342378 | 1238 | // =====================================================================================\r |
97f98500 | 1239 | \r |
a8c44645 | 1240 | /**\r |
1241 | Retrieves the size, in bytes, of the context buffer required for AES operations.\r | |
1242 | \r | |
532616bb | 1243 | If this interface is not supported, then return zero.\r |
1244 | \r | |
a8c44645 | 1245 | @return The size, in bytes, of the context buffer required for AES operations.\r |
532616bb | 1246 | @retval 0 This interface is not supported.\r |
a8c44645 | 1247 | \r |
1248 | **/\r | |
1249 | UINTN\r | |
1250 | EFIAPI\r | |
1251 | AesGetContextSize (\r | |
1252 | VOID\r | |
1253 | );\r | |
1254 | \r | |
1255 | /**\r | |
1256 | Initializes user-supplied memory as AES context for subsequent use.\r | |
1257 | \r | |
1258 | This function initializes user-supplied memory pointed by AesContext as AES context.\r | |
6b8ebcb8 | 1259 | In addition, it sets up all AES key materials for subsequent encryption and decryption\r |
a8c44645 | 1260 | operations.\r |
1261 | There are 3 options for key length, 128 bits, 192 bits, and 256 bits.\r | |
1262 | \r | |
16d2c32c | 1263 | If AesContext is NULL, then return FALSE.\r |
1264 | If Key is NULL, then return FALSE.\r | |
1265 | If KeyLength is not valid, then return FALSE.\r | |
532616bb | 1266 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1267 | \r |
1268 | @param[out] AesContext Pointer to AES context being initialized.\r | |
1269 | @param[in] Key Pointer to the user-supplied AES key.\r | |
1270 | @param[in] KeyLength Length of AES key in bits.\r | |
1271 | \r | |
1272 | @retval TRUE AES context initialization succeeded.\r | |
1273 | @retval FALSE AES context initialization failed.\r | |
532616bb | 1274 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1275 | \r |
1276 | **/\r | |
1277 | BOOLEAN\r | |
1278 | EFIAPI\r | |
1279 | AesInit (\r | |
1280 | OUT VOID *AesContext,\r | |
1281 | IN CONST UINT8 *Key,\r | |
1282 | IN UINTN KeyLength\r | |
1283 | );\r | |
1284 | \r | |
a8c44645 | 1285 | /**\r |
1286 | Performs AES encryption on a data buffer of the specified size in CBC mode.\r | |
1287 | \r | |
1288 | This function performs AES encryption on data buffer pointed by Input, of specified\r | |
1289 | size of InputSize, in CBC mode.\r | |
1290 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
1291 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
1292 | Initialization vector should be one block size (16 bytes).\r | |
1293 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
1294 | invalid AES context is undefined.\r | |
1295 | \r | |
16d2c32c | 1296 | If AesContext is NULL, then return FALSE.\r |
1297 | If Input is NULL, then return FALSE.\r | |
1298 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
1299 | If Ivec is NULL, then return FALSE.\r | |
1300 | If Output is NULL, then return FALSE.\r | |
532616bb | 1301 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1302 | \r |
1303 | @param[in] AesContext Pointer to the AES context.\r | |
1304 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
1305 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
1306 | @param[in] Ivec Pointer to initialization vector.\r | |
1307 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
1308 | \r | |
1309 | @retval TRUE AES encryption succeeded.\r | |
1310 | @retval FALSE AES encryption failed.\r | |
532616bb | 1311 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1312 | \r |
1313 | **/\r | |
1314 | BOOLEAN\r | |
1315 | EFIAPI\r | |
1316 | AesCbcEncrypt (\r | |
1317 | IN VOID *AesContext,\r | |
1318 | IN CONST UINT8 *Input,\r | |
1319 | IN UINTN InputSize,\r | |
1320 | IN CONST UINT8 *Ivec,\r | |
1321 | OUT UINT8 *Output\r | |
1322 | );\r | |
1323 | \r | |
1324 | /**\r | |
1325 | Performs AES decryption on a data buffer of the specified size in CBC mode.\r | |
1326 | \r | |
1327 | This function performs AES decryption on data buffer pointed by Input, of specified\r | |
1328 | size of InputSize, in CBC mode.\r | |
1329 | InputSize must be multiple of block size (16 bytes). This function does not perform\r | |
1330 | padding. Caller must perform padding, if necessary, to ensure valid input data size.\r | |
1331 | Initialization vector should be one block size (16 bytes).\r | |
1332 | AesContext should be already correctly initialized by AesInit(). Behavior with\r | |
1333 | invalid AES context is undefined.\r | |
1334 | \r | |
16d2c32c | 1335 | If AesContext is NULL, then return FALSE.\r |
1336 | If Input is NULL, then return FALSE.\r | |
1337 | If InputSize is not multiple of block size (16 bytes), then return FALSE.\r | |
1338 | If Ivec is NULL, then return FALSE.\r | |
1339 | If Output is NULL, then return FALSE.\r | |
532616bb | 1340 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1341 | \r |
1342 | @param[in] AesContext Pointer to the AES context.\r | |
1343 | @param[in] Input Pointer to the buffer containing the data to be encrypted.\r | |
1344 | @param[in] InputSize Size of the Input buffer in bytes.\r | |
1345 | @param[in] Ivec Pointer to initialization vector.\r | |
1346 | @param[out] Output Pointer to a buffer that receives the AES encryption output.\r | |
1347 | \r | |
1348 | @retval TRUE AES decryption succeeded.\r | |
1349 | @retval FALSE AES decryption failed.\r | |
532616bb | 1350 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1351 | \r |
1352 | **/\r | |
1353 | BOOLEAN\r | |
1354 | EFIAPI\r | |
1355 | AesCbcDecrypt (\r | |
1356 | IN VOID *AesContext,\r | |
1357 | IN CONST UINT8 *Input,\r | |
1358 | IN UINTN InputSize,\r | |
1359 | IN CONST UINT8 *Ivec,\r | |
1360 | OUT UINT8 *Output\r | |
1361 | );\r | |
1362 | \r | |
acbc5747 QZ |
1363 | // =====================================================================================\r |
1364 | // Authenticated Encryption with Associated Data (AEAD) Cryptography Primitive\r | |
1365 | // =====================================================================================\r | |
1366 | \r | |
1367 | /**\r | |
1368 | Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).\r | |
1369 | \r | |
1370 | IvSize must be 12, otherwise FALSE is returned.\r | |
1371 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
1372 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
1373 | \r | |
1374 | @param[in] Key Pointer to the encryption key.\r | |
1375 | @param[in] KeySize Size of the encryption key in bytes.\r | |
1376 | @param[in] Iv Pointer to the IV value.\r | |
1377 | @param[in] IvSize Size of the IV value in bytes.\r | |
1378 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
1379 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
1380 | @param[in] DataIn Pointer to the input data buffer to be encrypted.\r | |
1381 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
1382 | @param[out] TagOut Pointer to a buffer that receives the authentication tag output.\r | |
1383 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
1384 | @param[out] DataOut Pointer to a buffer that receives the encryption output.\r | |
1385 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
1386 | \r | |
1387 | @retval TRUE AEAD AES-GCM authenticated encryption succeeded.\r | |
1388 | @retval FALSE AEAD AES-GCM authenticated encryption failed.\r | |
1389 | \r | |
1390 | **/\r | |
1391 | BOOLEAN\r | |
1392 | EFIAPI\r | |
1393 | AeadAesGcmEncrypt (\r | |
1394 | IN CONST UINT8 *Key,\r | |
1395 | IN UINTN KeySize,\r | |
1396 | IN CONST UINT8 *Iv,\r | |
1397 | IN UINTN IvSize,\r | |
1398 | IN CONST UINT8 *AData,\r | |
1399 | IN UINTN ADataSize,\r | |
1400 | IN CONST UINT8 *DataIn,\r | |
1401 | IN UINTN DataInSize,\r | |
1402 | OUT UINT8 *TagOut,\r | |
1403 | IN UINTN TagSize,\r | |
1404 | OUT UINT8 *DataOut,\r | |
1405 | OUT UINTN *DataOutSize\r | |
1406 | );\r | |
1407 | \r | |
1408 | /**\r | |
1409 | Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).\r | |
1410 | \r | |
1411 | IvSize must be 12, otherwise FALSE is returned.\r | |
1412 | KeySize must be 16, 24 or 32, otherwise FALSE is returned.\r | |
1413 | TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.\r | |
1414 | If additional authenticated data verification fails, FALSE is returned.\r | |
1415 | \r | |
1416 | @param[in] Key Pointer to the encryption key.\r | |
1417 | @param[in] KeySize Size of the encryption key in bytes.\r | |
1418 | @param[in] Iv Pointer to the IV value.\r | |
1419 | @param[in] IvSize Size of the IV value in bytes.\r | |
1420 | @param[in] AData Pointer to the additional authenticated data (AAD).\r | |
1421 | @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.\r | |
1422 | @param[in] DataIn Pointer to the input data buffer to be decrypted.\r | |
1423 | @param[in] DataInSize Size of the input data buffer in bytes.\r | |
1424 | @param[in] Tag Pointer to a buffer that contains the authentication tag.\r | |
1425 | @param[in] TagSize Size of the authentication tag in bytes.\r | |
1426 | @param[out] DataOut Pointer to a buffer that receives the decryption output.\r | |
1427 | @param[out] DataOutSize Size of the output data buffer in bytes.\r | |
1428 | \r | |
1429 | @retval TRUE AEAD AES-GCM authenticated decryption succeeded.\r | |
1430 | @retval FALSE AEAD AES-GCM authenticated decryption failed.\r | |
1431 | \r | |
1432 | **/\r | |
1433 | BOOLEAN\r | |
1434 | EFIAPI\r | |
1435 | AeadAesGcmDecrypt (\r | |
1436 | IN CONST UINT8 *Key,\r | |
1437 | IN UINTN KeySize,\r | |
1438 | IN CONST UINT8 *Iv,\r | |
1439 | IN UINTN IvSize,\r | |
1440 | IN CONST UINT8 *AData,\r | |
1441 | IN UINTN ADataSize,\r | |
1442 | IN CONST UINT8 *DataIn,\r | |
1443 | IN UINTN DataInSize,\r | |
1444 | IN CONST UINT8 *Tag,\r | |
1445 | IN UINTN TagSize,\r | |
1446 | OUT UINT8 *DataOut,\r | |
1447 | OUT UINTN *DataOutSize\r | |
1448 | );\r | |
1449 | \r | |
7c342378 | 1450 | // =====================================================================================\r |
97f98500 | 1451 | // Asymmetric Cryptography Primitive\r |
7c342378 | 1452 | // =====================================================================================\r |
97f98500 HT |
1453 | \r |
1454 | /**\r | |
a8c44645 | 1455 | Allocates and initializes one RSA context for subsequent use.\r |
97f98500 | 1456 | \r |
a8c44645 | 1457 | @return Pointer to the RSA context that has been initialized.\r |
97f98500 HT |
1458 | If the allocations fails, RsaNew() returns NULL.\r |
1459 | \r | |
1460 | **/\r | |
1461 | VOID *\r | |
1462 | EFIAPI\r | |
1463 | RsaNew (\r | |
1464 | VOID\r | |
1465 | );\r | |
1466 | \r | |
97f98500 | 1467 | /**\r |
a8c44645 | 1468 | Release the specified RSA context.\r |
1469 | \r | |
16d2c32c | 1470 | If RsaContext is NULL, then return FALSE.\r |
97f98500 HT |
1471 | \r |
1472 | @param[in] RsaContext Pointer to the RSA context to be released.\r | |
1473 | \r | |
1474 | **/\r | |
1475 | VOID\r | |
1476 | EFIAPI\r | |
1477 | RsaFree (\r | |
1478 | IN VOID *RsaContext\r | |
1479 | );\r | |
1480 | \r | |
97f98500 | 1481 | /**\r |
a8c44645 | 1482 | Sets the tag-designated key component into the established RSA context.\r |
1483 | \r | |
1484 | This function sets the tag-designated RSA key component into the established\r | |
1485 | RSA context from the user-specified non-negative integer (octet string format\r | |
1486 | represented in RSA PKCS#1).\r | |
2998af86 | 1487 | If BigNumber is NULL, then the specified key component in RSA context is cleared.\r |
97f98500 | 1488 | \r |
16d2c32c | 1489 | If RsaContext is NULL, then return FALSE.\r |
97f98500 HT |
1490 | \r |
1491 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1492 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1493 | @param[in] BigNumber Pointer to octet integer buffer.\r | |
2998af86 | 1494 | If NULL, then the specified key component in RSA\r |
a8c44645 | 1495 | context is cleared.\r |
1496 | @param[in] BnSize Size of big number buffer in bytes.\r | |
1497 | If BigNumber is NULL, then it is ignored.\r | |
97f98500 | 1498 | \r |
a8c44645 | 1499 | @retval TRUE RSA key component was set successfully.\r |
1500 | @retval FALSE Invalid RSA key component tag.\r | |
97f98500 HT |
1501 | \r |
1502 | **/\r | |
1503 | BOOLEAN\r | |
1504 | EFIAPI\r | |
1505 | RsaSetKey (\r | |
a8c44645 | 1506 | IN OUT VOID *RsaContext,\r |
1507 | IN RSA_KEY_TAG KeyTag,\r | |
1508 | IN CONST UINT8 *BigNumber,\r | |
1509 | IN UINTN BnSize\r | |
1510 | );\r | |
1511 | \r | |
1512 | /**\r | |
1513 | Gets the tag-designated RSA key component from the established RSA context.\r | |
1514 | \r | |
1515 | This function retrieves the tag-designated RSA key component from the\r | |
1516 | established RSA context as a non-negative integer (octet string format\r | |
1517 | represented in RSA PKCS#1).\r | |
1518 | If specified key component has not been set or has been cleared, then returned\r | |
1519 | BnSize is set to 0.\r | |
1520 | If the BigNumber buffer is too small to hold the contents of the key, FALSE\r | |
1521 | is returned and BnSize is set to the required buffer size to obtain the key.\r | |
1522 | \r | |
16d2c32c | 1523 | If RsaContext is NULL, then return FALSE.\r |
1524 | If BnSize is NULL, then return FALSE.\r | |
1525 | If BnSize is large enough but BigNumber is NULL, then return FALSE.\r | |
532616bb | 1526 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1527 | \r |
1528 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1529 | @param[in] KeyTag Tag of RSA key component being set.\r | |
1530 | @param[out] BigNumber Pointer to octet integer buffer.\r | |
1531 | @param[in, out] BnSize On input, the size of big number buffer in bytes.\r | |
1532 | On output, the size of data returned in big number buffer in bytes.\r | |
1533 | \r | |
1534 | @retval TRUE RSA key component was retrieved successfully.\r | |
1535 | @retval FALSE Invalid RSA key component tag.\r | |
1536 | @retval FALSE BnSize is too small.\r | |
532616bb | 1537 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1538 | \r |
1539 | **/\r | |
1540 | BOOLEAN\r | |
1541 | EFIAPI\r | |
1542 | RsaGetKey (\r | |
1543 | IN OUT VOID *RsaContext,\r | |
1544 | IN RSA_KEY_TAG KeyTag,\r | |
1545 | OUT UINT8 *BigNumber,\r | |
1546 | IN OUT UINTN *BnSize\r | |
1547 | );\r | |
1548 | \r | |
1549 | /**\r | |
1550 | Generates RSA key components.\r | |
1551 | \r | |
1552 | This function generates RSA key components. It takes RSA public exponent E and\r | |
1553 | length in bits of RSA modulus N as input, and generates all key components.\r | |
1554 | If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.\r | |
1555 | \r | |
1556 | Before this function can be invoked, pseudorandom number generator must be correctly\r | |
1557 | initialized by RandomSeed().\r | |
1558 | \r | |
16d2c32c | 1559 | If RsaContext is NULL, then return FALSE.\r |
532616bb | 1560 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1561 | \r |
1562 | @param[in, out] RsaContext Pointer to RSA context being set.\r | |
1563 | @param[in] ModulusLength Length of RSA modulus N in bits.\r | |
1564 | @param[in] PublicExponent Pointer to RSA public exponent.\r | |
2ac68e8b | 1565 | @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.\r |
a8c44645 | 1566 | \r |
1567 | @retval TRUE RSA key component was generated successfully.\r | |
1568 | @retval FALSE Invalid RSA key component tag.\r | |
532616bb | 1569 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1570 | \r |
1571 | **/\r | |
1572 | BOOLEAN\r | |
1573 | EFIAPI\r | |
1574 | RsaGenerateKey (\r | |
1575 | IN OUT VOID *RsaContext,\r | |
1576 | IN UINTN ModulusLength,\r | |
1577 | IN CONST UINT8 *PublicExponent,\r | |
1578 | IN UINTN PublicExponentSize\r | |
1579 | );\r | |
1580 | \r | |
1581 | /**\r | |
1582 | Validates key components of RSA context.\r | |
952bd229 QL |
1583 | NOTE: This function performs integrity checks on all the RSA key material, so\r |
1584 | the RSA key structure must contain all the private key data.\r | |
a8c44645 | 1585 | \r |
2998af86 | 1586 | This function validates key components of RSA context in following aspects:\r |
a8c44645 | 1587 | - Whether p is a prime\r |
1588 | - Whether q is a prime\r | |
1589 | - Whether n = p * q\r | |
1590 | - Whether d*e = 1 mod lcm(p-1,q-1)\r | |
1591 | \r | |
16d2c32c | 1592 | If RsaContext is NULL, then return FALSE.\r |
532616bb | 1593 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1594 | \r |
1595 | @param[in] RsaContext Pointer to RSA context to check.\r | |
1596 | \r | |
1597 | @retval TRUE RSA key components are valid.\r | |
1598 | @retval FALSE RSA key components are not valid.\r | |
532616bb | 1599 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1600 | \r |
1601 | **/\r | |
1602 | BOOLEAN\r | |
1603 | EFIAPI\r | |
1604 | RsaCheckKey (\r | |
1605 | IN VOID *RsaContext\r | |
97f98500 HT |
1606 | );\r |
1607 | \r | |
a8c44645 | 1608 | /**\r |
1609 | Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.\r | |
1610 | \r | |
1611 | This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1612 | RSA PKCS#1.\r | |
1613 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
1614 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
1615 | \r | |
16d2c32c | 1616 | If RsaContext is NULL, then return FALSE.\r |
1617 | If MessageHash is NULL, then return FALSE.\r | |
1618 | If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.\r | |
1619 | If SigSize is large enough but Signature is NULL, then return FALSE.\r | |
532616bb | 1620 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 1621 | \r |
1622 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
1623 | @param[in] MessageHash Pointer to octet message hash to be signed.\r | |
1624 | @param[in] HashSize Size of the message hash in bytes.\r | |
1625 | @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.\r | |
1626 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
b7d320f8 | 1627 | On output, the size of data returned in Signature buffer in bytes.\r |
a8c44645 | 1628 | \r |
1629 | @retval TRUE Signature successfully generated in PKCS1-v1_5.\r | |
1630 | @retval FALSE Signature generation failed.\r | |
1631 | @retval FALSE SigSize is too small.\r | |
532616bb | 1632 | @retval FALSE This interface is not supported.\r |
a8c44645 | 1633 | \r |
1634 | **/\r | |
1635 | BOOLEAN\r | |
1636 | EFIAPI\r | |
1637 | RsaPkcs1Sign (\r | |
1638 | IN VOID *RsaContext,\r | |
1639 | IN CONST UINT8 *MessageHash,\r | |
1640 | IN UINTN HashSize,\r | |
1641 | OUT UINT8 *Signature,\r | |
1642 | IN OUT UINTN *SigSize\r | |
1643 | );\r | |
97f98500 HT |
1644 | \r |
1645 | /**\r | |
1646 | Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in\r | |
1647 | RSA PKCS#1.\r | |
1648 | \r | |
16d2c32c | 1649 | If RsaContext is NULL, then return FALSE.\r |
1650 | If MessageHash is NULL, then return FALSE.\r | |
1651 | If Signature is NULL, then return FALSE.\r | |
1652 | If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.\r | |
97f98500 HT |
1653 | \r |
1654 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
1655 | @param[in] MessageHash Pointer to octet message hash to be checked.\r | |
a8c44645 | 1656 | @param[in] HashSize Size of the message hash in bytes.\r |
97f98500 | 1657 | @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.\r |
a8c44645 | 1658 | @param[in] SigSize Size of signature in bytes.\r |
97f98500 | 1659 | \r |
a8c44645 | 1660 | @retval TRUE Valid signature encoded in PKCS1-v1_5.\r |
1661 | @retval FALSE Invalid signature or invalid RSA context.\r | |
97f98500 HT |
1662 | \r |
1663 | **/\r | |
1664 | BOOLEAN\r | |
1665 | EFIAPI\r | |
1666 | RsaPkcs1Verify (\r | |
1667 | IN VOID *RsaContext,\r | |
1668 | IN CONST UINT8 *MessageHash,\r | |
a8c44645 | 1669 | IN UINTN HashSize,\r |
8c5720b4 | 1670 | IN CONST UINT8 *Signature,\r |
a8c44645 | 1671 | IN UINTN SigSize\r |
97f98500 HT |
1672 | );\r |
1673 | \r | |
22ac5cc9 SA |
1674 | /**\r |
1675 | Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.\r | |
1676 | \r | |
1677 | This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in\r | |
1678 | RFC 8017.\r | |
1679 | Mask generation function is the same as the message digest algorithm.\r | |
1680 | If the Signature buffer is too small to hold the contents of signature, FALSE\r | |
1681 | is returned and SigSize is set to the required buffer size to obtain the signature.\r | |
1682 | \r | |
1683 | If RsaContext is NULL, then return FALSE.\r | |
1684 | If Message is NULL, then return FALSE.\r | |
1685 | If MsgSize is zero or > INT_MAX, then return FALSE.\r | |
1686 | If DigestLen is NOT 32, 48 or 64, return FALSE.\r | |
20ca5288 | 1687 | If SaltLen is not equal to DigestLen, then return FALSE.\r |
22ac5cc9 SA |
1688 | If SigSize is large enough but Signature is NULL, then return FALSE.\r |
1689 | If this interface is not supported, then return FALSE.\r | |
1690 | \r | |
1691 | @param[in] RsaContext Pointer to RSA context for signature generation.\r | |
1692 | @param[in] Message Pointer to octet message to be signed.\r | |
1693 | @param[in] MsgSize Size of the message in bytes.\r | |
1694 | @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.\r | |
1695 | @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.\r | |
1696 | @param[out] Signature Pointer to buffer to receive RSA PSS signature.\r | |
1697 | @param[in, out] SigSize On input, the size of Signature buffer in bytes.\r | |
1698 | On output, the size of data returned in Signature buffer in bytes.\r | |
1699 | \r | |
1700 | @retval TRUE Signature successfully generated in RSASSA-PSS.\r | |
1701 | @retval FALSE Signature generation failed.\r | |
1702 | @retval FALSE SigSize is too small.\r | |
1703 | @retval FALSE This interface is not supported.\r | |
1704 | \r | |
1705 | **/\r | |
1706 | BOOLEAN\r | |
1707 | EFIAPI\r | |
1708 | RsaPssSign (\r | |
1709 | IN VOID *RsaContext,\r | |
1710 | IN CONST UINT8 *Message,\r | |
1711 | IN UINTN MsgSize,\r | |
1712 | IN UINT16 DigestLen,\r | |
1713 | IN UINT16 SaltLen,\r | |
1714 | OUT UINT8 *Signature,\r | |
1715 | IN OUT UINTN *SigSize\r | |
1716 | );\r | |
1717 | \r | |
1718 | /**\r | |
1719 | Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.\r | |
1720 | Implementation determines salt length automatically from the signature encoding.\r | |
1721 | Mask generation function is the same as the message digest algorithm.\r | |
20ca5288 | 1722 | Salt length should be equal to digest length.\r |
22ac5cc9 SA |
1723 | \r |
1724 | @param[in] RsaContext Pointer to RSA context for signature verification.\r | |
1725 | @param[in] Message Pointer to octet message to be verified.\r | |
1726 | @param[in] MsgSize Size of the message in bytes.\r | |
1727 | @param[in] Signature Pointer to RSASSA-PSS signature to be verified.\r | |
1728 | @param[in] SigSize Size of signature in bytes.\r | |
1729 | @param[in] DigestLen Length of digest for RSA operation.\r | |
1730 | @param[in] SaltLen Salt length for PSS encoding.\r | |
1731 | \r | |
1732 | @retval TRUE Valid signature encoded in RSASSA-PSS.\r | |
1733 | @retval FALSE Invalid signature or invalid RSA context.\r | |
1734 | \r | |
1735 | **/\r | |
1736 | BOOLEAN\r | |
1737 | EFIAPI\r | |
1738 | RsaPssVerify (\r | |
1739 | IN VOID *RsaContext,\r | |
1740 | IN CONST UINT8 *Message,\r | |
1741 | IN UINTN MsgSize,\r | |
1742 | IN CONST UINT8 *Signature,\r | |
1743 | IN UINTN SigSize,\r | |
1744 | IN UINT16 DigestLen,\r | |
1745 | IN UINT16 SaltLen\r | |
1746 | );\r | |
1747 | \r | |
4a567c96 | 1748 | /**\r |
1749 | Retrieve the RSA Private Key from the password-protected PEM key data.\r | |
1750 | \r | |
532616bb | 1751 | If PemData is NULL, then return FALSE.\r |
1752 | If RsaContext is NULL, then return FALSE.\r | |
1753 | If this interface is not supported, then return FALSE.\r | |
1754 | \r | |
4a567c96 | 1755 | @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.\r |
1756 | @param[in] PemSize Size of the PEM key data in bytes.\r | |
1757 | @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.\r | |
1758 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1759 | RSA private key component. Use RsaFree() function to free the\r | |
1760 | resource.\r | |
1761 | \r | |
4a567c96 | 1762 | @retval TRUE RSA Private Key was retrieved successfully.\r |
1763 | @retval FALSE Invalid PEM key data or incorrect password.\r | |
532616bb | 1764 | @retval FALSE This interface is not supported.\r |
4a567c96 | 1765 | \r |
1766 | **/\r | |
1767 | BOOLEAN\r | |
1768 | EFIAPI\r | |
1769 | RsaGetPrivateKeyFromPem (\r | |
1770 | IN CONST UINT8 *PemData,\r | |
1771 | IN UINTN PemSize,\r | |
1772 | IN CONST CHAR8 *Password,\r | |
1773 | OUT VOID **RsaContext\r | |
1774 | );\r | |
1775 | \r | |
1776 | /**\r | |
1777 | Retrieve the RSA Public Key from one DER-encoded X509 certificate.\r | |
1778 | \r | |
532616bb | 1779 | If Cert is NULL, then return FALSE.\r |
1780 | If RsaContext is NULL, then return FALSE.\r | |
1781 | If this interface is not supported, then return FALSE.\r | |
1782 | \r | |
4a567c96 | 1783 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r |
1784 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1785 | @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved\r | |
1786 | RSA public key component. Use RsaFree() function to free the\r | |
1787 | resource.\r | |
1788 | \r | |
4a567c96 | 1789 | @retval TRUE RSA Public Key was retrieved successfully.\r |
1790 | @retval FALSE Fail to retrieve RSA public key from X509 certificate.\r | |
532616bb | 1791 | @retval FALSE This interface is not supported.\r |
4a567c96 | 1792 | \r |
1793 | **/\r | |
1794 | BOOLEAN\r | |
1795 | EFIAPI\r | |
1796 | RsaGetPublicKeyFromX509 (\r | |
1797 | IN CONST UINT8 *Cert,\r | |
1798 | IN UINTN CertSize,\r | |
1799 | OUT VOID **RsaContext\r | |
1800 | );\r | |
1801 | \r | |
1802 | /**\r | |
1803 | Retrieve the subject bytes from one X.509 certificate.\r | |
1804 | \r | |
532616bb | 1805 | If Cert is NULL, then return FALSE.\r |
1806 | If SubjectSize is NULL, then return FALSE.\r | |
1807 | If this interface is not supported, then return FALSE.\r | |
1808 | \r | |
4a567c96 | 1809 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r |
1810 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1811 | @param[out] CertSubject Pointer to the retrieved certificate subject bytes.\r | |
1812 | @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,\r | |
1813 | and the size of buffer returned CertSubject on output.\r | |
1814 | \r | |
4a567c96 | 1815 | @retval TRUE The certificate subject retrieved successfully.\r |
1816 | @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.\r | |
1817 | The SubjectSize will be updated with the required size.\r | |
532616bb | 1818 | @retval FALSE This interface is not supported.\r |
4a567c96 | 1819 | \r |
1820 | **/\r | |
1821 | BOOLEAN\r | |
1822 | EFIAPI\r | |
1823 | X509GetSubjectName (\r | |
1824 | IN CONST UINT8 *Cert,\r | |
1825 | IN UINTN CertSize,\r | |
1826 | OUT UINT8 *CertSubject,\r | |
1827 | IN OUT UINTN *SubjectSize\r | |
1828 | );\r | |
1829 | \r | |
5b7c2245 QL |
1830 | /**\r |
1831 | Retrieve the common name (CN) string from one X.509 certificate.\r | |
1832 | \r | |
1833 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1834 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1835 | @param[out] CommonName Buffer to contain the retrieved certificate common\r | |
0b6457ef | 1836 | name string (UTF8). At most CommonNameSize bytes will be\r |
5b7c2245 QL |
1837 | written and the string will be null terminated. May be\r |
1838 | NULL in order to determine the size buffer needed.\r | |
1839 | @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,\r | |
1840 | and the size of buffer returned CommonName on output.\r | |
1841 | If CommonName is NULL then the amount of space needed\r | |
1842 | in buffer (including the final null) is returned.\r | |
1843 | \r | |
1844 | @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.\r | |
1845 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
1846 | If CommonNameSize is NULL.\r | |
1847 | If CommonName is not NULL and *CommonNameSize is 0.\r | |
1848 | If Certificate is invalid.\r | |
1849 | @retval RETURN_NOT_FOUND If no CommonName entry exists.\r | |
1850 | @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size\r | |
630f67dd | 1851 | (including the final null) is returned in the\r |
5b7c2245 QL |
1852 | CommonNameSize parameter.\r |
1853 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
1854 | \r | |
1855 | **/\r | |
1856 | RETURN_STATUS\r | |
1857 | EFIAPI\r | |
1858 | X509GetCommonName (\r | |
1859 | IN CONST UINT8 *Cert,\r | |
1860 | IN UINTN CertSize,\r | |
c8f46130 | 1861 | OUT CHAR8 *CommonName OPTIONAL,\r |
5b7c2245 QL |
1862 | IN OUT UINTN *CommonNameSize\r |
1863 | );\r | |
1864 | \r | |
e2a673b8 BB |
1865 | /**\r |
1866 | Retrieve the organization name (O) string from one X.509 certificate.\r | |
1867 | \r | |
1868 | @param[in] Cert Pointer to the DER-encoded X509 certificate.\r | |
1869 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1870 | @param[out] NameBuffer Buffer to contain the retrieved certificate organization\r | |
1871 | name string. At most NameBufferSize bytes will be\r | |
1872 | written and the string will be null terminated. May be\r | |
1873 | NULL in order to determine the size buffer needed.\r | |
1874 | @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,\r | |
1875 | and the size of buffer returned Name on output.\r | |
1876 | If NameBuffer is NULL then the amount of space needed\r | |
1877 | in buffer (including the final null) is returned.\r | |
1878 | \r | |
1879 | @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.\r | |
1880 | @retval RETURN_INVALID_PARAMETER If Cert is NULL.\r | |
1881 | If NameBufferSize is NULL.\r | |
1882 | If NameBuffer is not NULL and *CommonNameSize is 0.\r | |
1883 | If Certificate is invalid.\r | |
1884 | @retval RETURN_NOT_FOUND If no Organization Name entry exists.\r | |
1885 | @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size\r | |
1886 | (including the final null) is returned in the\r | |
1887 | CommonNameSize parameter.\r | |
1888 | @retval RETURN_UNSUPPORTED The operation is not supported.\r | |
1889 | \r | |
1890 | **/\r | |
1891 | RETURN_STATUS\r | |
1892 | EFIAPI\r | |
1893 | X509GetOrganizationName (\r | |
7c342378 MK |
1894 | IN CONST UINT8 *Cert,\r |
1895 | IN UINTN CertSize,\r | |
1896 | OUT CHAR8 *NameBuffer OPTIONAL,\r | |
1897 | IN OUT UINTN *NameBufferSize\r | |
e2a673b8 BB |
1898 | );\r |
1899 | \r | |
4a567c96 | 1900 | /**\r |
1901 | Verify one X509 certificate was issued by the trusted CA.\r | |
1902 | \r | |
532616bb | 1903 | If Cert is NULL, then return FALSE.\r |
1904 | If CACert is NULL, then return FALSE.\r | |
1905 | If this interface is not supported, then return FALSE.\r | |
1906 | \r | |
4a567c96 | 1907 | @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.\r |
1908 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
1909 | @param[in] CACert Pointer to the DER-encoded trusted CA certificate.\r | |
1910 | @param[in] CACertSize Size of the CA Certificate in bytes.\r | |
1911 | \r | |
4a567c96 | 1912 | @retval TRUE The certificate was issued by the trusted CA.\r |
1913 | @retval FALSE Invalid certificate or the certificate was not issued by the given\r | |
1914 | trusted CA.\r | |
532616bb | 1915 | @retval FALSE This interface is not supported.\r |
4a567c96 | 1916 | \r |
1917 | **/\r | |
1918 | BOOLEAN\r | |
1919 | EFIAPI\r | |
1920 | X509VerifyCert (\r | |
1921 | IN CONST UINT8 *Cert,\r | |
1922 | IN UINTN CertSize,\r | |
1923 | IN CONST UINT8 *CACert,\r | |
1924 | IN UINTN CACertSize\r | |
1925 | );\r | |
1926 | \r | |
b7d320f8 | 1927 | /**\r |
1928 | Construct a X509 object from DER-encoded certificate data.\r | |
1929 | \r | |
16d2c32c | 1930 | If Cert is NULL, then return FALSE.\r |
1931 | If SingleX509Cert is NULL, then return FALSE.\r | |
532616bb | 1932 | If this interface is not supported, then return FALSE.\r |
b7d320f8 | 1933 | \r |
1934 | @param[in] Cert Pointer to the DER-encoded certificate data.\r | |
1935 | @param[in] CertSize The size of certificate data in bytes.\r | |
1936 | @param[out] SingleX509Cert The generated X509 object.\r | |
1937 | \r | |
1938 | @retval TRUE The X509 object generation succeeded.\r | |
1939 | @retval FALSE The operation failed.\r | |
532616bb | 1940 | @retval FALSE This interface is not supported.\r |
b7d320f8 | 1941 | \r |
1942 | **/\r | |
1943 | BOOLEAN\r | |
1944 | EFIAPI\r | |
1945 | X509ConstructCertificate (\r | |
1946 | IN CONST UINT8 *Cert,\r | |
1947 | IN UINTN CertSize,\r | |
1948 | OUT UINT8 **SingleX509Cert\r | |
1949 | );\r | |
1950 | \r | |
66862136 MK |
1951 | /**\r |
1952 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
1953 | \r | |
1954 | If X509Stack is NULL, then return FALSE.\r | |
1955 | If this interface is not supported, then return FALSE.\r | |
1956 | \r | |
1957 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r | |
1958 | On output, pointer to the X509 stack object with new\r | |
1959 | inserted X509 certificate.\r | |
1960 | @param[in] Args VA_LIST marker for the variable argument list.\r | |
1961 | A list of DER-encoded single certificate data followed\r | |
1962 | by certificate size. A NULL terminates the list. The\r | |
1963 | pairs are the arguments to X509ConstructCertificate().\r | |
1964 | \r | |
1965 | @retval TRUE The X509 stack construction succeeded.\r | |
1966 | @retval FALSE The construction operation failed.\r | |
1967 | @retval FALSE This interface is not supported.\r | |
1968 | \r | |
1969 | **/\r | |
1970 | BOOLEAN\r | |
1971 | EFIAPI\r | |
1972 | X509ConstructCertificateStackV (\r | |
1973 | IN OUT UINT8 **X509Stack,\r | |
1974 | IN VA_LIST Args\r | |
1975 | );\r | |
1976 | \r | |
b7d320f8 | 1977 | /**\r |
1978 | Construct a X509 stack object from a list of DER-encoded certificate data.\r | |
1979 | \r | |
16d2c32c | 1980 | If X509Stack is NULL, then return FALSE.\r |
532616bb | 1981 | If this interface is not supported, then return FALSE.\r |
b7d320f8 | 1982 | \r |
952bd229 | 1983 | @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.\r |
b7d320f8 | 1984 | On output, pointer to the X509 stack object with new\r |
1985 | inserted X509 certificate.\r | |
1986 | @param ... A list of DER-encoded single certificate data followed\r | |
1987 | by certificate size. A NULL terminates the list. The\r | |
1988 | pairs are the arguments to X509ConstructCertificate().\r | |
2ac68e8b | 1989 | \r |
b7d320f8 | 1990 | @retval TRUE The X509 stack construction succeeded.\r |
1991 | @retval FALSE The construction operation failed.\r | |
532616bb | 1992 | @retval FALSE This interface is not supported.\r |
b7d320f8 | 1993 | \r |
1994 | **/\r | |
1995 | BOOLEAN\r | |
1996 | EFIAPI\r | |
1997 | X509ConstructCertificateStack (\r | |
1998 | IN OUT UINT8 **X509Stack,\r | |
2ac68e8b | 1999 | ...\r |
b7d320f8 | 2000 | );\r |
2001 | \r | |
2002 | /**\r | |
2003 | Release the specified X509 object.\r | |
2004 | \r | |
532616bb | 2005 | If the interface is not supported, then ASSERT().\r |
b7d320f8 | 2006 | \r |
2007 | @param[in] X509Cert Pointer to the X509 object to be released.\r | |
2008 | \r | |
2009 | **/\r | |
2010 | VOID\r | |
2011 | EFIAPI\r | |
2012 | X509Free (\r | |
2013 | IN VOID *X509Cert\r | |
2014 | );\r | |
2015 | \r | |
2016 | /**\r | |
2017 | Release the specified X509 stack object.\r | |
2018 | \r | |
532616bb | 2019 | If the interface is not supported, then ASSERT().\r |
b7d320f8 | 2020 | \r |
2021 | @param[in] X509Stack Pointer to the X509 stack object to be released.\r | |
2022 | \r | |
2023 | **/\r | |
2024 | VOID\r | |
2025 | EFIAPI\r | |
2026 | X509StackFree (\r | |
2027 | IN VOID *X509Stack\r | |
2028 | );\r | |
2029 | \r | |
12d95665 LQ |
2030 | /**\r |
2031 | Retrieve the TBSCertificate from one given X.509 certificate.\r | |
2032 | \r | |
2033 | @param[in] Cert Pointer to the given DER-encoded X509 certificate.\r | |
2034 | @param[in] CertSize Size of the X509 certificate in bytes.\r | |
2035 | @param[out] TBSCert DER-Encoded To-Be-Signed certificate.\r | |
2036 | @param[out] TBSCertSize Size of the TBS certificate in bytes.\r | |
2037 | \r | |
2038 | If Cert is NULL, then return FALSE.\r | |
2039 | If TBSCert is NULL, then return FALSE.\r | |
2040 | If TBSCertSize is NULL, then return FALSE.\r | |
2041 | If this interface is not supported, then return FALSE.\r | |
2042 | \r | |
2043 | @retval TRUE The TBSCertificate was retrieved successfully.\r | |
2044 | @retval FALSE Invalid X.509 certificate.\r | |
2045 | \r | |
2046 | **/\r | |
2047 | BOOLEAN\r | |
2048 | EFIAPI\r | |
2049 | X509GetTBSCert (\r | |
2050 | IN CONST UINT8 *Cert,\r | |
2051 | IN UINTN CertSize,\r | |
2052 | OUT UINT8 **TBSCert,\r | |
2053 | OUT UINTN *TBSCertSize\r | |
2054 | );\r | |
2055 | \r | |
a8f37449 QL |
2056 | /**\r |
2057 | Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0\r | |
2058 | password based encryption key derivation function PBKDF2, as specified in RFC 2898.\r | |
2059 | \r | |
2060 | If Password or Salt or OutKey is NULL, then return FALSE.\r | |
2061 | If the hash algorithm could not be determined, then return FALSE.\r | |
2062 | If this interface is not supported, then return FALSE.\r | |
2063 | \r | |
2064 | @param[in] PasswordLength Length of input password in bytes.\r | |
2065 | @param[in] Password Pointer to the array for the password.\r | |
2066 | @param[in] SaltLength Size of the Salt in bytes.\r | |
2067 | @param[in] Salt Pointer to the Salt.\r | |
2068 | @param[in] IterationCount Number of iterations to perform. Its value should be\r | |
2069 | greater than or equal to 1.\r | |
2070 | @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).\r | |
2071 | NOTE: DigestSize will be used to determine the hash algorithm.\r | |
2072 | Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.\r | |
2073 | @param[in] KeyLength Size of the derived key buffer in bytes.\r | |
2074 | @param[out] OutKey Pointer to the output derived key buffer.\r | |
2075 | \r | |
2076 | @retval TRUE A key was derived successfully.\r | |
2077 | @retval FALSE One of the pointers was NULL or one of the sizes was too large.\r | |
2078 | @retval FALSE The hash algorithm could not be determined from the digest size.\r | |
2079 | @retval FALSE The key derivation operation failed.\r | |
2080 | @retval FALSE This interface is not supported.\r | |
2081 | \r | |
2082 | **/\r | |
2083 | BOOLEAN\r | |
2084 | EFIAPI\r | |
2085 | Pkcs5HashPassword (\r | |
2086 | IN UINTN PasswordLength,\r | |
2087 | IN CONST CHAR8 *Password,\r | |
2088 | IN UINTN SaltLength,\r | |
2089 | IN CONST UINT8 *Salt,\r | |
2090 | IN UINTN IterationCount,\r | |
2091 | IN UINTN DigestSize,\r | |
2092 | IN UINTN KeyLength,\r | |
2093 | OUT UINT8 *OutKey\r | |
2094 | );\r | |
2095 | \r | |
aed90bee BB |
2096 | /**\r |
2097 | Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the\r | |
2098 | encrypted message in a newly allocated buffer.\r | |
2099 | \r | |
2100 | Things that can cause a failure include:\r | |
2101 | - X509 key size does not match any known key size.\r | |
2102 | - Fail to parse X509 certificate.\r | |
2103 | - Fail to allocate an intermediate buffer.\r | |
2104 | - Null pointer provided for a non-optional parameter.\r | |
2105 | - Data size is too large for the provided key size (max size is a function of key size\r | |
2106 | and hash digest size).\r | |
2107 | \r | |
2108 | @param[in] PublicKey A pointer to the DER-encoded X509 certificate that\r | |
2109 | will be used to encrypt the data.\r | |
2110 | @param[in] PublicKeySize Size of the X509 cert buffer.\r | |
2111 | @param[in] InData Data to be encrypted.\r | |
2112 | @param[in] InDataSize Size of the data buffer.\r | |
2113 | @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer\r | |
2114 | to be used when initializing the PRNG. NULL otherwise.\r | |
2115 | @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.\r | |
2116 | 0 otherwise.\r | |
2117 | @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted\r | |
2118 | message.\r | |
2119 | @param[out] EncryptedDataSize Size of the encrypted message buffer.\r | |
2120 | \r | |
2121 | @retval TRUE Encryption was successful.\r | |
2122 | @retval FALSE Encryption failed.\r | |
2123 | \r | |
2124 | **/\r | |
2125 | BOOLEAN\r | |
2126 | EFIAPI\r | |
2127 | Pkcs1v2Encrypt (\r | |
2128 | IN CONST UINT8 *PublicKey,\r | |
2129 | IN UINTN PublicKeySize,\r | |
2130 | IN UINT8 *InData,\r | |
2131 | IN UINTN InDataSize,\r | |
c8f46130 MK |
2132 | IN CONST UINT8 *PrngSeed OPTIONAL,\r |
2133 | IN UINTN PrngSeedSize OPTIONAL,\r | |
aed90bee BB |
2134 | OUT UINT8 **EncryptedData,\r |
2135 | OUT UINTN *EncryptedDataSize\r | |
2136 | );\r | |
2137 | \r | |
3702637a | 2138 | /**\r |
2139 | The 3rd parameter of Pkcs7GetSigners will return all embedded\r | |
2140 | X.509 certificate in one given PKCS7 signature. The format is:\r | |
2141 | //\r | |
2142 | // UINT8 CertNumber;\r | |
2143 | // UINT32 Cert1Length;\r | |
2144 | // UINT8 Cert1[];\r | |
2145 | // UINT32 Cert2Length;\r | |
2146 | // UINT8 Cert2[];\r | |
2147 | // ...\r | |
2148 | // UINT32 CertnLength;\r | |
2149 | // UINT8 Certn[];\r | |
2150 | //\r | |
2151 | \r | |
2152 | The two following C-structure are used for parsing CertStack more clearly.\r | |
2153 | **/\r | |
2154 | #pragma pack(1)\r | |
2155 | \r | |
2156 | typedef struct {\r | |
2157 | UINT32 CertDataLength; // The length in bytes of X.509 certificate.\r | |
2158 | UINT8 CertDataBuffer[0]; // The X.509 certificate content (DER).\r | |
2159 | } EFI_CERT_DATA;\r | |
2160 | \r | |
2161 | typedef struct {\r | |
7c342378 MK |
2162 | UINT8 CertNumber; // Number of X.509 certificate.\r |
2163 | // EFI_CERT_DATA CertArray[]; // An array of X.509 certificate.\r | |
3702637a | 2164 | } EFI_CERT_STACK;\r |
2165 | \r | |
2166 | #pragma pack()\r | |
2167 | \r | |
e8b4eb04 | 2168 | /**\r |
2169 | Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
2170 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r | |
2171 | in a ContentInfo structure.\r | |
2172 | \r | |
2173 | If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then\r | |
2998af86 | 2174 | return FALSE. If P7Length overflow, then return FALSE.\r |
532616bb | 2175 | If this interface is not supported, then return FALSE.\r |
e8b4eb04 | 2176 | \r |
2177 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
2178 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
2179 | @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.\r | |
6fe575d0 LQ |
2180 | It's caller's responsibility to free the buffer with\r |
2181 | Pkcs7FreeSigners().\r | |
3702637a | 2182 | This data structure is EFI_CERT_STACK type.\r |
e8b4eb04 | 2183 | @param[out] StackLength Length of signer's certificates in bytes.\r |
2184 | @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.\r | |
6fe575d0 LQ |
2185 | It's caller's responsibility to free the buffer with\r |
2186 | Pkcs7FreeSigners().\r | |
e8b4eb04 | 2187 | @param[out] CertLength Length of the trusted certificate in bytes.\r |
2188 | \r | |
2189 | @retval TRUE The operation is finished successfully.\r | |
2190 | @retval FALSE Error occurs during the operation.\r | |
532616bb | 2191 | @retval FALSE This interface is not supported.\r |
e8b4eb04 | 2192 | \r |
2193 | **/\r | |
2194 | BOOLEAN\r | |
2195 | EFIAPI\r | |
2196 | Pkcs7GetSigners (\r | |
2197 | IN CONST UINT8 *P7Data,\r | |
2198 | IN UINTN P7Length,\r | |
2199 | OUT UINT8 **CertStack,\r | |
2200 | OUT UINTN *StackLength,\r | |
2201 | OUT UINT8 **TrustedCert,\r | |
2202 | OUT UINTN *CertLength\r | |
2203 | );\r | |
2204 | \r | |
2205 | /**\r | |
2206 | Wrap function to use free() to free allocated memory for certificates.\r | |
2207 | \r | |
532616bb | 2208 | If this interface is not supported, then ASSERT().\r |
2209 | \r | |
e8b4eb04 | 2210 | @param[in] Certs Pointer to the certificates to be freed.\r |
2211 | \r | |
2212 | **/\r | |
2213 | VOID\r | |
2214 | EFIAPI\r | |
2215 | Pkcs7FreeSigners (\r | |
7c342378 | 2216 | IN UINT8 *Certs\r |
45419de6 QL |
2217 | );\r |
2218 | \r | |
2219 | /**\r | |
2220 | Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:\r | |
2221 | Cryptographic Message Syntax Standard", and outputs two certificate lists chained and\r | |
2222 | unchained to the signer's certificates.\r | |
2223 | The input signed data could be wrapped in a ContentInfo structure.\r | |
2224 | \r | |
2225 | @param[in] P7Data Pointer to the PKCS#7 message.\r | |
2226 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r | |
0f5f6b3d | 2227 | @param[out] SignerChainCerts Pointer to the certificates list chained to signer's\r |
6fe575d0 LQ |
2228 | certificate. It's caller's responsibility to free the buffer\r |
2229 | with Pkcs7FreeSigners().\r | |
3702637a | 2230 | This data structure is EFI_CERT_STACK type.\r |
45419de6 QL |
2231 | @param[out] ChainLength Length of the chained certificates list buffer in bytes.\r |
2232 | @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's\r | |
6fe575d0 | 2233 | responsibility to free the buffer with Pkcs7FreeSigners().\r |
3702637a | 2234 | This data structure is EFI_CERT_STACK type.\r |
45419de6 QL |
2235 | @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.\r |
2236 | \r | |
2237 | @retval TRUE The operation is finished successfully.\r | |
2238 | @retval FALSE Error occurs during the operation.\r | |
2239 | \r | |
2240 | **/\r | |
2241 | BOOLEAN\r | |
2242 | EFIAPI\r | |
2243 | Pkcs7GetCertificatesList (\r | |
2244 | IN CONST UINT8 *P7Data,\r | |
2245 | IN UINTN P7Length,\r | |
2246 | OUT UINT8 **SignerChainCerts,\r | |
2247 | OUT UINTN *ChainLength,\r | |
2248 | OUT UINT8 **UnchainCerts,\r | |
2249 | OUT UINTN *UnchainLength\r | |
e8b4eb04 | 2250 | );\r |
2251 | \r | |
b7d320f8 | 2252 | /**\r |
2253 | Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message\r | |
2254 | Syntax Standard, version 1.5". This interface is only intended to be used for\r | |
2255 | application to perform PKCS#7 functionality validation.\r | |
2256 | \r | |
532616bb | 2257 | If this interface is not supported, then return FALSE.\r |
2258 | \r | |
b7d320f8 | 2259 | @param[in] PrivateKey Pointer to the PEM-formatted private key data for\r |
2260 | data signing.\r | |
2261 | @param[in] PrivateKeySize Size of the PEM private key data in bytes.\r | |
2262 | @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM\r | |
2263 | key data.\r | |
2264 | @param[in] InData Pointer to the content to be signed.\r | |
2265 | @param[in] InDataSize Size of InData in bytes.\r | |
2266 | @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.\r | |
2267 | @param[in] OtherCerts Pointer to an optional additional set of certificates to\r | |
2268 | include in the PKCS#7 signedData (e.g. any intermediate\r | |
2269 | CAs in the chain).\r | |
6fe575d0 LQ |
2270 | @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's\r |
2271 | responsibility to free the buffer with FreePool().\r | |
b7d320f8 | 2272 | @param[out] SignedDataSize Size of SignedData in bytes.\r |
2273 | \r | |
2274 | @retval TRUE PKCS#7 data signing succeeded.\r | |
2275 | @retval FALSE PKCS#7 data signing failed.\r | |
532616bb | 2276 | @retval FALSE This interface is not supported.\r |
b7d320f8 | 2277 | \r |
2278 | **/\r | |
2279 | BOOLEAN\r | |
2280 | EFIAPI\r | |
2281 | Pkcs7Sign (\r | |
2282 | IN CONST UINT8 *PrivateKey,\r | |
2283 | IN UINTN PrivateKeySize,\r | |
2284 | IN CONST UINT8 *KeyPassword,\r | |
2285 | IN UINT8 *InData,\r | |
2286 | IN UINTN InDataSize,\r | |
2287 | IN UINT8 *SignCert,\r | |
2288 | IN UINT8 *OtherCerts OPTIONAL,\r | |
2289 | OUT UINT8 **SignedData,\r | |
2290 | OUT UINTN *SignedDataSize\r | |
2291 | );\r | |
2292 | \r | |
97f98500 | 2293 | /**\r |
2998af86 | 2294 | Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:\r |
e8b4eb04 | 2295 | Cryptographic Message Syntax Standard". The input signed data could be wrapped\r |
2296 | in a ContentInfo structure.\r | |
97f98500 | 2297 | \r |
e8b4eb04 | 2298 | If P7Data, TrustedCert or InData is NULL, then return FALSE.\r |
2998af86 | 2299 | If P7Length, CertLength or DataLength overflow, then return FALSE.\r |
532616bb | 2300 | If this interface is not supported, then return FALSE.\r |
97f98500 HT |
2301 | \r |
2302 | @param[in] P7Data Pointer to the PKCS#7 message to verify.\r | |
e8b4eb04 | 2303 | @param[in] P7Length Length of the PKCS#7 message in bytes.\r |
97f98500 HT |
2304 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r |
2305 | is used for certificate chain verification.\r | |
e8b4eb04 | 2306 | @param[in] CertLength Length of the trusted certificate in bytes.\r |
97f98500 | 2307 | @param[in] InData Pointer to the content to be verified.\r |
e8b4eb04 | 2308 | @param[in] DataLength Length of InData in bytes.\r |
97f98500 | 2309 | \r |
a8c44645 | 2310 | @retval TRUE The specified PKCS#7 signed data is valid.\r |
2311 | @retval FALSE Invalid PKCS#7 signed data.\r | |
532616bb | 2312 | @retval FALSE This interface is not supported.\r |
97f98500 HT |
2313 | \r |
2314 | **/\r | |
2315 | BOOLEAN\r | |
2316 | EFIAPI\r | |
2317 | Pkcs7Verify (\r | |
2318 | IN CONST UINT8 *P7Data,\r | |
e8b4eb04 | 2319 | IN UINTN P7Length,\r |
97f98500 | 2320 | IN CONST UINT8 *TrustedCert,\r |
e8b4eb04 | 2321 | IN UINTN CertLength,\r |
97f98500 | 2322 | IN CONST UINT8 *InData,\r |
e8b4eb04 | 2323 | IN UINTN DataLength\r |
a8c44645 | 2324 | );\r |
2325 | \r | |
1796a394 BB |
2326 | /**\r |
2327 | This function receives a PKCS7 formatted signature, and then verifies that\r | |
2328 | the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity\r | |
2329 | leaf signing certificate.\r | |
2330 | Note that this function does not validate the certificate chain.\r | |
2331 | \r | |
2332 | Applications for custom EKU's are quite flexible. For example, a policy EKU\r | |
2333 | may be present in an Issuing Certificate Authority (CA), and any sub-ordinate\r | |
2334 | certificate issued might also contain this EKU, thus constraining the\r | |
2335 | sub-ordinate certificate. Other applications might allow a certificate\r | |
2336 | embedded in a device to specify that other Object Identifiers (OIDs) are\r | |
2337 | present which contains binary data specifying custom capabilities that\r | |
2338 | the device is able to do.\r | |
2339 | \r | |
2340 | @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array\r | |
2341 | containing the content block with both the signature,\r | |
2342 | the signer's certificate, and any necessary intermediate\r | |
2343 | certificates.\r | |
2344 | @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.\r | |
2345 | @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of\r | |
2346 | required EKUs that must be present in the signature.\r | |
2347 | @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.\r | |
2348 | @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's\r | |
2349 | must be present in the leaf signer. If it is\r | |
2350 | FALSE, then we will succeed if we find any\r | |
2351 | of the specified EKU's.\r | |
2352 | \r | |
2353 | @retval EFI_SUCCESS The required EKUs were found in the signature.\r | |
2354 | @retval EFI_INVALID_PARAMETER A parameter was invalid.\r | |
2355 | @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.\r | |
2356 | \r | |
2357 | **/\r | |
2358 | RETURN_STATUS\r | |
2359 | EFIAPI\r | |
2360 | VerifyEKUsInPkcs7Signature (\r | |
2361 | IN CONST UINT8 *Pkcs7Signature,\r | |
2362 | IN CONST UINT32 SignatureSize,\r | |
2363 | IN CONST CHAR8 *RequiredEKUs[],\r | |
2364 | IN CONST UINT32 RequiredEKUsSize,\r | |
2365 | IN BOOLEAN RequireAllPresent\r | |
2366 | );\r | |
2367 | \r | |
afeb55e4 QL |
2368 | /**\r |
2369 | Extracts the attached content from a PKCS#7 signed data if existed. The input signed\r | |
2370 | data could be wrapped in a ContentInfo structure.\r | |
2371 | \r | |
2372 | If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,\r | |
2998af86 | 2373 | then return FALSE. If the P7Data is not correctly formatted, then return FALSE.\r |
afeb55e4 QL |
2374 | \r |
2375 | Caution: This function may receive untrusted input. So this function will do\r | |
2376 | basic check for PKCS#7 data structure.\r | |
2377 | \r | |
2378 | @param[in] P7Data Pointer to the PKCS#7 signed data to process.\r | |
2379 | @param[in] P7Length Length of the PKCS#7 signed data in bytes.\r | |
2380 | @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.\r | |
6fe575d0 | 2381 | It's caller's responsibility to free the buffer with FreePool().\r |
afeb55e4 QL |
2382 | @param[out] ContentSize The size of the extracted content in bytes.\r |
2383 | \r | |
2384 | @retval TRUE The P7Data was correctly formatted for processing.\r | |
2385 | @retval FALSE The P7Data was not correctly formatted for processing.\r | |
2386 | \r | |
0c9fc4b1 | 2387 | **/\r |
afeb55e4 QL |
2388 | BOOLEAN\r |
2389 | EFIAPI\r | |
2390 | Pkcs7GetAttachedContent (\r | |
2391 | IN CONST UINT8 *P7Data,\r | |
2392 | IN UINTN P7Length,\r | |
2393 | OUT VOID **Content,\r | |
2394 | OUT UINTN *ContentSize\r | |
2395 | );\r | |
2396 | \r | |
b7d320f8 | 2397 | /**\r |
2998af86 | 2398 | Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows\r |
b7d320f8 | 2399 | Authenticode Portable Executable Signature Format".\r |
2400 | \r | |
16d2c32c | 2401 | If AuthData is NULL, then return FALSE.\r |
2402 | If ImageHash is NULL, then return FALSE.\r | |
532616bb | 2403 | If this interface is not supported, then return FALSE.\r |
b7d320f8 | 2404 | \r |
2405 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
2406 | PE/COFF image to be verified.\r | |
2407 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
2408 | @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which\r | |
2409 | is used for certificate chain verification.\r | |
2410 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
2998af86 | 2411 | @param[in] ImageHash Pointer to the original image file hash value. The procedure\r |
b7d320f8 | 2412 | for calculating the image hash value is described in Authenticode\r |
2413 | specification.\r | |
2414 | @param[in] HashSize Size of Image hash value in bytes.\r | |
2415 | \r | |
2416 | @retval TRUE The specified Authenticode Signature is valid.\r | |
2417 | @retval FALSE Invalid Authenticode Signature.\r | |
532616bb | 2418 | @retval FALSE This interface is not supported.\r |
b7d320f8 | 2419 | \r |
2420 | **/\r | |
2421 | BOOLEAN\r | |
2422 | EFIAPI\r | |
2423 | AuthenticodeVerify (\r | |
2424 | IN CONST UINT8 *AuthData,\r | |
2425 | IN UINTN DataSize,\r | |
2426 | IN CONST UINT8 *TrustedCert,\r | |
2427 | IN UINTN CertSize,\r | |
2428 | IN CONST UINT8 *ImageHash,\r | |
2429 | IN UINTN HashSize\r | |
2430 | );\r | |
2431 | \r | |
2ac68e8b | 2432 | /**\r |
2998af86 | 2433 | Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode\r |
2ac68e8b QL |
2434 | signature.\r |
2435 | \r | |
2436 | If AuthData is NULL, then return FALSE.\r | |
12d95665 | 2437 | If this interface is not supported, then return FALSE.\r |
2ac68e8b QL |
2438 | \r |
2439 | @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed\r | |
2440 | PE/COFF image to be verified.\r | |
2441 | @param[in] DataSize Size of the Authenticode Signature in bytes.\r | |
2442 | @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which\r | |
2443 | is used for TSA certificate chain verification.\r | |
2444 | @param[in] CertSize Size of the trusted certificate in bytes.\r | |
2445 | @param[out] SigningTime Return the time of timestamp generation time if the timestamp\r | |
2446 | signature is valid.\r | |
2447 | \r | |
2448 | @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.\r | |
2449 | @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.\r | |
2450 | \r | |
2451 | **/\r | |
2452 | BOOLEAN\r | |
2453 | EFIAPI\r | |
2454 | ImageTimestampVerify (\r | |
2455 | IN CONST UINT8 *AuthData,\r | |
2456 | IN UINTN DataSize,\r | |
2457 | IN CONST UINT8 *TsaCert,\r | |
2458 | IN UINTN CertSize,\r | |
2459 | OUT EFI_TIME *SigningTime\r | |
2460 | );\r | |
2461 | \r | |
7c342378 | 2462 | // =====================================================================================\r |
a8c44645 | 2463 | // DH Key Exchange Primitive\r |
7c342378 | 2464 | // =====================================================================================\r |
a8c44645 | 2465 | \r |
2466 | /**\r | |
2467 | Allocates and Initializes one Diffie-Hellman Context for subsequent use.\r | |
2468 | \r | |
2469 | @return Pointer to the Diffie-Hellman Context that has been initialized.\r | |
2470 | If the allocations fails, DhNew() returns NULL.\r | |
532616bb | 2471 | If the interface is not supported, DhNew() returns NULL.\r |
a8c44645 | 2472 | \r |
2473 | **/\r | |
2474 | VOID *\r | |
2475 | EFIAPI\r | |
2476 | DhNew (\r | |
2477 | VOID\r | |
2478 | );\r | |
2479 | \r | |
2480 | /**\r | |
2481 | Release the specified DH context.\r | |
2482 | \r | |
532616bb | 2483 | If the interface is not supported, then ASSERT().\r |
a8c44645 | 2484 | \r |
2485 | @param[in] DhContext Pointer to the DH context to be released.\r | |
2486 | \r | |
2487 | **/\r | |
2488 | VOID\r | |
2489 | EFIAPI\r | |
2490 | DhFree (\r | |
2491 | IN VOID *DhContext\r | |
2492 | );\r | |
2493 | \r | |
2494 | /**\r | |
2495 | Generates DH parameter.\r | |
2496 | \r | |
2497 | Given generator g, and length of prime number p in bits, this function generates p,\r | |
2498 | and sets DH context according to value of g and p.\r | |
2ac68e8b | 2499 | \r |
a8c44645 | 2500 | Before this function can be invoked, pseudorandom number generator must be correctly\r |
2501 | initialized by RandomSeed().\r | |
2502 | \r | |
16d2c32c | 2503 | If DhContext is NULL, then return FALSE.\r |
2504 | If Prime is NULL, then return FALSE.\r | |
532616bb | 2505 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2506 | \r |
2507 | @param[in, out] DhContext Pointer to the DH context.\r | |
2508 | @param[in] Generator Value of generator.\r | |
2509 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
2510 | @param[out] Prime Pointer to the buffer to receive the generated prime number.\r | |
2511 | \r | |
2998af86 | 2512 | @retval TRUE DH parameter generation succeeded.\r |
a8c44645 | 2513 | @retval FALSE Value of Generator is not supported.\r |
2514 | @retval FALSE PRNG fails to generate random prime number with PrimeLength.\r | |
532616bb | 2515 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2516 | \r |
2517 | **/\r | |
2518 | BOOLEAN\r | |
2519 | EFIAPI\r | |
2520 | DhGenerateParameter (\r | |
2521 | IN OUT VOID *DhContext,\r | |
2522 | IN UINTN Generator,\r | |
2523 | IN UINTN PrimeLength,\r | |
2524 | OUT UINT8 *Prime\r | |
2525 | );\r | |
2526 | \r | |
2527 | /**\r | |
2528 | Sets generator and prime parameters for DH.\r | |
2529 | \r | |
2530 | Given generator g, and prime number p, this function and sets DH\r | |
2531 | context accordingly.\r | |
2532 | \r | |
16d2c32c | 2533 | If DhContext is NULL, then return FALSE.\r |
2534 | If Prime is NULL, then return FALSE.\r | |
532616bb | 2535 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2536 | \r |
2537 | @param[in, out] DhContext Pointer to the DH context.\r | |
2538 | @param[in] Generator Value of generator.\r | |
2539 | @param[in] PrimeLength Length in bits of prime to be generated.\r | |
2540 | @param[in] Prime Pointer to the prime number.\r | |
2541 | \r | |
2998af86 | 2542 | @retval TRUE DH parameter setting succeeded.\r |
a8c44645 | 2543 | @retval FALSE Value of Generator is not supported.\r |
2544 | @retval FALSE Value of Generator is not suitable for the Prime.\r | |
2545 | @retval FALSE Value of Prime is not a prime number.\r | |
2546 | @retval FALSE Value of Prime is not a safe prime number.\r | |
532616bb | 2547 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2548 | \r |
2549 | **/\r | |
2550 | BOOLEAN\r | |
2551 | EFIAPI\r | |
2552 | DhSetParameter (\r | |
2553 | IN OUT VOID *DhContext,\r | |
2554 | IN UINTN Generator,\r | |
2555 | IN UINTN PrimeLength,\r | |
2556 | IN CONST UINT8 *Prime\r | |
97f98500 HT |
2557 | );\r |
2558 | \r | |
a8c44645 | 2559 | /**\r |
2560 | Generates DH public key.\r | |
2561 | \r | |
2ac68e8b | 2562 | This function generates random secret exponent, and computes the public key, which is\r |
a8c44645 | 2563 | returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.\r |
2564 | If the PublicKey buffer is too small to hold the public key, FALSE is returned and\r | |
2565 | PublicKeySize is set to the required buffer size to obtain the public key.\r | |
2566 | \r | |
16d2c32c | 2567 | If DhContext is NULL, then return FALSE.\r |
2568 | If PublicKeySize is NULL, then return FALSE.\r | |
2569 | If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.\r | |
532616bb | 2570 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2571 | \r |
2572 | @param[in, out] DhContext Pointer to the DH context.\r | |
2573 | @param[out] PublicKey Pointer to the buffer to receive generated public key.\r | |
2574 | @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.\r | |
2575 | On output, the size of data returned in PublicKey buffer in bytes.\r | |
2576 | \r | |
2577 | @retval TRUE DH public key generation succeeded.\r | |
2578 | @retval FALSE DH public key generation failed.\r | |
2579 | @retval FALSE PublicKeySize is not large enough.\r | |
532616bb | 2580 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2581 | \r |
2582 | **/\r | |
2583 | BOOLEAN\r | |
2584 | EFIAPI\r | |
2585 | DhGenerateKey (\r | |
2586 | IN OUT VOID *DhContext,\r | |
2587 | OUT UINT8 *PublicKey,\r | |
2588 | IN OUT UINTN *PublicKeySize\r | |
2589 | );\r | |
2590 | \r | |
2591 | /**\r | |
2592 | Computes exchanged common key.\r | |
2593 | \r | |
2594 | Given peer's public key, this function computes the exchanged common key, based on its own\r | |
dda39f3a | 2595 | context including value of prime modulus and random secret exponent.\r |
a8c44645 | 2596 | \r |
16d2c32c | 2597 | If DhContext is NULL, then return FALSE.\r |
2598 | If PeerPublicKey is NULL, then return FALSE.\r | |
2599 | If KeySize is NULL, then return FALSE.\r | |
dda39f3a | 2600 | If Key is NULL, then return FALSE.\r |
2601 | If KeySize is not large enough, then return FALSE.\r | |
532616bb | 2602 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2603 | \r |
2604 | @param[in, out] DhContext Pointer to the DH context.\r | |
2605 | @param[in] PeerPublicKey Pointer to the peer's public key.\r | |
2606 | @param[in] PeerPublicKeySize Size of peer's public key in bytes.\r | |
2607 | @param[out] Key Pointer to the buffer to receive generated key.\r | |
2608 | @param[in, out] KeySize On input, the size of Key buffer in bytes.\r | |
2609 | On output, the size of data returned in Key buffer in bytes.\r | |
2610 | \r | |
2611 | @retval TRUE DH exchanged key generation succeeded.\r | |
2612 | @retval FALSE DH exchanged key generation failed.\r | |
2613 | @retval FALSE KeySize is not large enough.\r | |
532616bb | 2614 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2615 | \r |
2616 | **/\r | |
2617 | BOOLEAN\r | |
2618 | EFIAPI\r | |
2619 | DhComputeKey (\r | |
2620 | IN OUT VOID *DhContext,\r | |
2621 | IN CONST UINT8 *PeerPublicKey,\r | |
2622 | IN UINTN PeerPublicKeySize,\r | |
2623 | OUT UINT8 *Key,\r | |
2624 | IN OUT UINTN *KeySize\r | |
2625 | );\r | |
2626 | \r | |
7c342378 | 2627 | // =====================================================================================\r |
a8c44645 | 2628 | // Pseudo-Random Generation Primitive\r |
7c342378 | 2629 | // =====================================================================================\r |
a8c44645 | 2630 | \r |
2631 | /**\r | |
2632 | Sets up the seed value for the pseudorandom number generator.\r | |
2633 | \r | |
2634 | This function sets up the seed value for the pseudorandom number generator.\r | |
2635 | If Seed is not NULL, then the seed passed in is used.\r | |
2636 | If Seed is NULL, then default seed is used.\r | |
532616bb | 2637 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2638 | \r |
2639 | @param[in] Seed Pointer to seed value.\r | |
2640 | If NULL, default seed is used.\r | |
2641 | @param[in] SeedSize Size of seed value.\r | |
2642 | If Seed is NULL, this parameter is ignored.\r | |
2643 | \r | |
2644 | @retval TRUE Pseudorandom number generator has enough entropy for random generation.\r | |
2645 | @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.\r | |
532616bb | 2646 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2647 | \r |
2648 | **/\r | |
2649 | BOOLEAN\r | |
2650 | EFIAPI\r | |
2651 | RandomSeed (\r | |
2652 | IN CONST UINT8 *Seed OPTIONAL,\r | |
2653 | IN UINTN SeedSize\r | |
2654 | );\r | |
2655 | \r | |
2656 | /**\r | |
2657 | Generates a pseudorandom byte stream of the specified size.\r | |
2658 | \r | |
16d2c32c | 2659 | If Output is NULL, then return FALSE.\r |
532616bb | 2660 | If this interface is not supported, then return FALSE.\r |
a8c44645 | 2661 | \r |
2662 | @param[out] Output Pointer to buffer to receive random value.\r | |
2998af86 | 2663 | @param[in] Size Size of random bytes to generate.\r |
a8c44645 | 2664 | \r |
2665 | @retval TRUE Pseudorandom byte stream generated successfully.\r | |
2666 | @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.\r | |
532616bb | 2667 | @retval FALSE This interface is not supported.\r |
a8c44645 | 2668 | \r |
2669 | **/\r | |
2670 | BOOLEAN\r | |
2671 | EFIAPI\r | |
2672 | RandomBytes (\r | |
2673 | OUT UINT8 *Output,\r | |
2674 | IN UINTN Size\r | |
2675 | );\r | |
97f98500 | 2676 | \r |
7c342378 | 2677 | // =====================================================================================\r |
4b1b7c19 | 2678 | // Key Derivation Function Primitive\r |
7c342378 | 2679 | // =====================================================================================\r |
4b1b7c19 GW |
2680 | \r |
2681 | /**\r | |
2682 | Derive key data using HMAC-SHA256 based KDF.\r | |
2683 | \r | |
2684 | @param[in] Key Pointer to the user-supplied key.\r | |
2685 | @param[in] KeySize Key size in bytes.\r | |
2686 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
2687 | @param[in] SaltSize Salt size in bytes.\r | |
2688 | @param[in] Info Pointer to the application specific info.\r | |
2689 | @param[in] InfoSize Info size in bytes.\r | |
944bd5cf | 2690 | @param[out] Out Pointer to buffer to receive hkdf value.\r |
4b1b7c19 GW |
2691 | @param[in] OutSize Size of hkdf bytes to generate.\r |
2692 | \r | |
2693 | @retval TRUE Hkdf generated successfully.\r | |
2694 | @retval FALSE Hkdf generation failed.\r | |
2695 | \r | |
2696 | **/\r | |
2697 | BOOLEAN\r | |
2698 | EFIAPI\r | |
2699 | HkdfSha256ExtractAndExpand (\r | |
2700 | IN CONST UINT8 *Key,\r | |
2701 | IN UINTN KeySize,\r | |
2702 | IN CONST UINT8 *Salt,\r | |
2703 | IN UINTN SaltSize,\r | |
2704 | IN CONST UINT8 *Info,\r | |
2705 | IN UINTN InfoSize,\r | |
2706 | OUT UINT8 *Out,\r | |
2707 | IN UINTN OutSize\r | |
2708 | );\r | |
2709 | \r | |
13364762 QZ |
2710 | /**\r |
2711 | Derive SHA256 HMAC-based Extract key Derivation Function (HKDF).\r | |
2712 | \r | |
2713 | @param[in] Key Pointer to the user-supplied key.\r | |
2714 | @param[in] KeySize key size in bytes.\r | |
2715 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
2716 | @param[in] SaltSize salt size in bytes.\r | |
2717 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
2718 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
2719 | \r | |
2720 | @retval true Hkdf generated successfully.\r | |
2721 | @retval false Hkdf generation failed.\r | |
2722 | \r | |
2723 | **/\r | |
2724 | BOOLEAN\r | |
2725 | EFIAPI\r | |
2726 | HkdfSha256Extract (\r | |
2727 | IN CONST UINT8 *Key,\r | |
2728 | IN UINTN KeySize,\r | |
2729 | IN CONST UINT8 *Salt,\r | |
2730 | IN UINTN SaltSize,\r | |
2731 | OUT UINT8 *PrkOut,\r | |
2732 | UINTN PrkOutSize\r | |
2733 | );\r | |
2734 | \r | |
2735 | /**\r | |
2736 | Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).\r | |
2737 | \r | |
2738 | @param[in] Prk Pointer to the user-supplied key.\r | |
2739 | @param[in] PrkSize Key size in bytes.\r | |
2740 | @param[in] Info Pointer to the application specific info.\r | |
2741 | @param[in] InfoSize Info size in bytes.\r | |
2742 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
2743 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
2744 | \r | |
2745 | @retval TRUE Hkdf generated successfully.\r | |
2746 | @retval FALSE Hkdf generation failed.\r | |
2747 | \r | |
2748 | **/\r | |
2749 | BOOLEAN\r | |
2750 | EFIAPI\r | |
2751 | HkdfSha256Expand (\r | |
2752 | IN CONST UINT8 *Prk,\r | |
2753 | IN UINTN PrkSize,\r | |
2754 | IN CONST UINT8 *Info,\r | |
2755 | IN UINTN InfoSize,\r | |
2756 | OUT UINT8 *Out,\r | |
2757 | IN UINTN OutSize\r | |
2758 | );\r | |
2759 | \r | |
2760 | /**\r | |
2761 | Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).\r | |
2762 | \r | |
2763 | @param[in] Key Pointer to the user-supplied key.\r | |
2764 | @param[in] KeySize Key size in bytes.\r | |
2765 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
2766 | @param[in] SaltSize Salt size in bytes.\r | |
2767 | @param[in] Info Pointer to the application specific info.\r | |
2768 | @param[in] InfoSize Info size in bytes.\r | |
2769 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
2770 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
2771 | \r | |
2772 | @retval TRUE Hkdf generated successfully.\r | |
2773 | @retval FALSE Hkdf generation failed.\r | |
2774 | \r | |
2775 | **/\r | |
2776 | BOOLEAN\r | |
2777 | EFIAPI\r | |
2778 | HkdfSha384ExtractAndExpand (\r | |
2779 | IN CONST UINT8 *Key,\r | |
2780 | IN UINTN KeySize,\r | |
2781 | IN CONST UINT8 *Salt,\r | |
2782 | IN UINTN SaltSize,\r | |
2783 | IN CONST UINT8 *Info,\r | |
2784 | IN UINTN InfoSize,\r | |
2785 | OUT UINT8 *Out,\r | |
2786 | IN UINTN OutSize\r | |
2787 | );\r | |
2788 | \r | |
2789 | /**\r | |
2790 | Derive SHA384 HMAC-based Extract key Derivation Function (HKDF).\r | |
2791 | \r | |
2792 | @param[in] Key Pointer to the user-supplied key.\r | |
2793 | @param[in] KeySize key size in bytes.\r | |
2794 | @param[in] Salt Pointer to the salt(non-secret) value.\r | |
2795 | @param[in] SaltSize salt size in bytes.\r | |
2796 | @param[out] PrkOut Pointer to buffer to receive hkdf value.\r | |
2797 | @param[in] PrkOutSize size of hkdf bytes to generate.\r | |
2798 | \r | |
2799 | @retval true Hkdf generated successfully.\r | |
2800 | @retval false Hkdf generation failed.\r | |
2801 | \r | |
2802 | **/\r | |
2803 | BOOLEAN\r | |
2804 | EFIAPI\r | |
2805 | HkdfSha384Extract (\r | |
2806 | IN CONST UINT8 *Key,\r | |
2807 | IN UINTN KeySize,\r | |
2808 | IN CONST UINT8 *Salt,\r | |
2809 | IN UINTN SaltSize,\r | |
2810 | OUT UINT8 *PrkOut,\r | |
2811 | UINTN PrkOutSize\r | |
2812 | );\r | |
2813 | \r | |
2814 | /**\r | |
2815 | Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).\r | |
2816 | \r | |
2817 | @param[in] Prk Pointer to the user-supplied key.\r | |
2818 | @param[in] PrkSize Key size in bytes.\r | |
2819 | @param[in] Info Pointer to the application specific info.\r | |
2820 | @param[in] InfoSize Info size in bytes.\r | |
2821 | @param[out] Out Pointer to buffer to receive hkdf value.\r | |
2822 | @param[in] OutSize Size of hkdf bytes to generate.\r | |
2823 | \r | |
2824 | @retval TRUE Hkdf generated successfully.\r | |
2825 | @retval FALSE Hkdf generation failed.\r | |
2826 | \r | |
2827 | **/\r | |
2828 | BOOLEAN\r | |
2829 | EFIAPI\r | |
2830 | HkdfSha384Expand (\r | |
2831 | IN CONST UINT8 *Prk,\r | |
2832 | IN UINTN PrkSize,\r | |
2833 | IN CONST UINT8 *Info,\r | |
2834 | IN UINTN InfoSize,\r | |
2835 | OUT UINT8 *Out,\r | |
2836 | IN UINTN OutSize\r | |
2837 | );\r | |
2838 | \r | |
afeb55e4 | 2839 | #endif // __BASE_CRYPT_LIB_H__\r |