]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Private/Protocol/Crypto.h
CryptoPkg: Add new hmac definition to cryptlib
[mirror_edk2.git] / CryptoPkg / Private / Protocol / Crypto.h
1 /** @file
2 This Protocol provides Crypto services to DXE modules
3
4 Copyright (C) Microsoft Corporation. All rights reserved.
5 Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __EDKII_CRYPTO_PROTOCOL_H__
11 #define __EDKII_CRYPTO_PROTOCOL_H__
12
13 #include <Base.h>
14 #include <Library/BaseCryptLib.h>
15 #include <Library/PcdLib.h>
16
17 ///
18 /// The version of the EDK II Crypto Protocol.
19 /// As APIs are added to BaseCryptLib, the EDK II Crypto Protocol is extended
20 /// with new APIs at the end of the EDK II Crypto Protocol structure. Each time
21 /// the EDK II Crypto Protocol is extended, this version define must be
22 /// increased.
23 ///
24 #define EDKII_CRYPTO_VERSION 9
25
26 ///
27 /// EDK II Crypto Protocol forward declaration
28 ///
29 typedef struct _EDKII_CRYPTO_PROTOCOL EDKII_CRYPTO_PROTOCOL;
30
31 /**
32 Returns the version of the EDK II Crypto Protocol.
33
34 @return The version of the EDK II Crypto Protocol.
35
36 **/
37 typedef
38 UINTN
39 (EFIAPI *EDKII_CRYPTO_GET_VERSION)(
40 VOID
41 );
42
43 // =====================================================================================
44 // MAC (Message Authentication Code) Primitive
45 // =====================================================================================
46
47 /**
48 HMAC MD5 is deprecated and unsupported any longer.
49 Keep the function field for binary compability.
50
51 **/
52 typedef
53 VOID *
54 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_NEW)(
55 VOID
56 );
57
58 typedef
59 VOID
60 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_FREE)(
61 IN VOID *HmacMd5Ctx
62 );
63
64 typedef
65 BOOLEAN
66 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_SET_KEY)(
67 OUT VOID *HmacMd5Context,
68 IN CONST UINT8 *Key,
69 IN UINTN KeySize
70 );
71
72 typedef
73 BOOLEAN
74 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_DUPLICATE)(
75 IN CONST VOID *HmacMd5Context,
76 OUT VOID *NewHmacMd5Context
77 );
78
79 typedef
80 BOOLEAN
81 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_UPDATE)(
82 IN OUT VOID *HmacMd5Context,
83 IN CONST VOID *Data,
84 IN UINTN DataSize
85 );
86
87 typedef
88 BOOLEAN
89 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_MD5_FINAL)(
90 IN OUT VOID *HmacMd5Context,
91 OUT UINT8 *HmacValue
92 );
93
94 /**
95 HMAC SHA1 is deprecated and unsupported any longer.
96 Keep the function field for binary compability.
97
98 **/
99 typedef
100 VOID *
101 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_NEW)(
102 VOID
103 );
104
105 typedef
106 VOID
107 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_FREE)(
108 IN VOID *HmacSha1Ctx
109 );
110
111 typedef
112 BOOLEAN
113 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_SET_KEY)(
114 OUT VOID *HmacSha1Context,
115 IN CONST UINT8 *Key,
116 IN UINTN KeySize
117 );
118
119 typedef
120 BOOLEAN
121 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_DUPLICATE)(
122 IN CONST VOID *HmacSha1Context,
123 OUT VOID *NewHmacSha1Context
124 );
125
126 typedef
127 BOOLEAN
128 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_UPDATE)(
129 IN OUT VOID *HmacSha1Context,
130 IN CONST VOID *Data,
131 IN UINTN DataSize
132 );
133
134 typedef
135 BOOLEAN
136 (EFIAPI *DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_FINAL)(
137 IN OUT VOID *HmacSha1Context,
138 OUT UINT8 *HmacValue
139 );
140
141 /**
142 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.
143
144 @return Pointer to the HMAC_CTX context that has been initialized.
145 If the allocations fails, HmacSha256New() returns NULL.
146
147 **/
148 typedef
149 VOID *
150 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_NEW)(
151 VOID
152 );
153
154 /**
155 Release the specified HMAC_CTX context.
156
157 @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.
158
159 **/
160 typedef
161 VOID
162 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_FREE)(
163 IN VOID *HmacSha256Ctx
164 );
165
166 /**
167 Set user-supplied key for subsequent use. It must be done before any
168 calling to HmacSha256Update().
169
170 If HmacSha256Context is NULL, then return FALSE.
171 If this interface is not supported, then return FALSE.
172
173 @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.
174 @param[in] Key Pointer to the user-supplied key.
175 @param[in] KeySize Key size in bytes.
176
177 @retval TRUE The Key is set successfully.
178 @retval FALSE The Key is set unsuccessfully.
179 @retval FALSE This interface is not supported.
180
181 **/
182 typedef
183 BOOLEAN
184 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_SET_KEY)(
185 OUT VOID *HmacSha256Context,
186 IN CONST UINT8 *Key,
187 IN UINTN KeySize
188 );
189
190 /**
191 Makes a copy of an existing HMAC-SHA256 context.
192
193 If HmacSha256Context is NULL, then return FALSE.
194 If NewHmacSha256Context is NULL, then return FALSE.
195 If this interface is not supported, then return FALSE.
196
197 @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.
198 @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.
199
200 @retval TRUE HMAC-SHA256 context copy succeeded.
201 @retval FALSE HMAC-SHA256 context copy failed.
202 @retval FALSE This interface is not supported.
203
204 **/
205 typedef
206 BOOLEAN
207 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_DUPLICATE)(
208 IN CONST VOID *HmacSha256Context,
209 OUT VOID *NewHmacSha256Context
210 );
211
212 /**
213 Digests the input data and updates HMAC-SHA256 context.
214
215 This function performs HMAC-SHA256 digest on a data buffer of the specified size.
216 It can be called multiple times to compute the digest of long or discontinuous data streams.
217 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
218 by HmacSha256Final(). Behavior with invalid context is undefined.
219
220 If HmacSha256Context is NULL, then return FALSE.
221 If this interface is not supported, then return FALSE.
222
223 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
224 @param[in] Data Pointer to the buffer containing the data to be digested.
225 @param[in] DataSize Size of Data buffer in bytes.
226
227 @retval TRUE HMAC-SHA256 data digest succeeded.
228 @retval FALSE HMAC-SHA256 data digest failed.
229 @retval FALSE This interface is not supported.
230
231 **/
232 typedef
233 BOOLEAN
234 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_UPDATE)(
235 IN OUT VOID *HmacSha256Context,
236 IN CONST VOID *Data,
237 IN UINTN DataSize
238 );
239
240 /**
241 Completes computation of the HMAC-SHA256 digest value.
242
243 This function completes HMAC-SHA256 hash computation and retrieves the digest value into
244 the specified memory. After this function has been called, the HMAC-SHA256 context cannot
245 be used again.
246 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
247 by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
248
249 If HmacSha256Context is NULL, then return FALSE.
250 If HmacValue is NULL, then return FALSE.
251 If this interface is not supported, then return FALSE.
252
253 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
254 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
255 value (32 bytes).
256
257 @retval TRUE HMAC-SHA256 digest computation succeeded.
258 @retval FALSE HMAC-SHA256 digest computation failed.
259 @retval FALSE This interface is not supported.
260
261 **/
262 typedef
263 BOOLEAN
264 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_FINAL)(
265 IN OUT VOID *HmacSha256Context,
266 OUT UINT8 *HmacValue
267 );
268
269 /**
270 Computes the HMAC-SHA256 digest of a input data buffer.
271
272 This function performs the HMAC-SHA256 digest of a given data buffer, and places
273 the digest value into the specified memory.
274
275 If this interface is not supported, then return FALSE.
276
277 @param[in] Data Pointer to the buffer containing the data to be digested.
278 @param[in] DataSize Size of Data buffer in bytes.
279 @param[in] Key Pointer to the user-supplied key.
280 @param[in] KeySize Key size in bytes.
281 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
282 value (32 bytes).
283
284 @retval TRUE HMAC-SHA256 digest computation succeeded.
285 @retval FALSE HMAC-SHA256 digest computation failed.
286 @retval FALSE This interface is not supported.
287
288 **/
289 typedef
290 BOOLEAN
291 (EFIAPI *EDKII_CRYPTO_HMAC_SHA256_ALL)(
292 IN CONST VOID *Data,
293 IN UINTN DataSize,
294 IN CONST UINT8 *Key,
295 IN UINTN KeySize,
296 OUT UINT8 *HmacValue
297 );
298
299 /**
300 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.
301
302 @return Pointer to the HMAC_CTX context that has been initialized.
303 If the allocations fails, HmacSha384New() returns NULL.
304
305 **/
306 typedef
307 VOID *
308 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_NEW)(
309 VOID
310 );
311
312 /**
313 Release the specified HMAC_CTX context.
314
315 @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.
316
317 **/
318 typedef
319 VOID
320 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_FREE)(
321 IN VOID *HmacSha384Ctx
322 );
323
324 /**
325 Set user-supplied key for subsequent use. It must be done before any
326 calling to HmacSha384Update().
327
328 If HmacSha384Context is NULL, then return FALSE.
329 If this interface is not supported, then return FALSE.
330
331 @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.
332 @param[in] Key Pointer to the user-supplied key.
333 @param[in] KeySize Key size in bytes.
334
335 @retval TRUE The Key is set successfully.
336 @retval FALSE The Key is set unsuccessfully.
337 @retval FALSE This interface is not supported.
338
339 **/
340 typedef
341 BOOLEAN
342 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_SET_KEY)(
343 OUT VOID *HmacSha384Context,
344 IN CONST UINT8 *Key,
345 IN UINTN KeySize
346 );
347
348 /**
349 Makes a copy of an existing HMAC-SHA384 context.
350
351 If HmacSha384Context is NULL, then return FALSE.
352 If NewHmacSha384Context is NULL, then return FALSE.
353 If this interface is not supported, then return FALSE.
354
355 @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.
356 @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.
357
358 @retval TRUE HMAC-SHA384 context copy succeeded.
359 @retval FALSE HMAC-SHA384 context copy failed.
360 @retval FALSE This interface is not supported.
361
362 **/
363 typedef
364 BOOLEAN
365 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_DUPLICATE)(
366 IN CONST VOID *HmacSha384Context,
367 OUT VOID *NewHmacSha384Context
368 );
369
370 /**
371 Digests the input data and updates HMAC-SHA384 context.
372
373 This function performs HMAC-SHA384 digest on a data buffer of the specified size.
374 It can be called multiple times to compute the digest of long or discontinuous data streams.
375 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
376 by HmacSha384Final(). Behavior with invalid context is undefined.
377
378 If HmacSha384Context is NULL, then return FALSE.
379 If this interface is not supported, then return FALSE.
380
381 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
382 @param[in] Data Pointer to the buffer containing the data to be digested.
383 @param[in] DataSize Size of Data buffer in bytes.
384
385 @retval TRUE HMAC-SHA384 data digest succeeded.
386 @retval FALSE HMAC-SHA384 data digest failed.
387 @retval FALSE This interface is not supported.
388
389 **/
390 typedef
391 BOOLEAN
392 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_UPDATE)(
393 IN OUT VOID *HmacSha384Context,
394 IN CONST VOID *Data,
395 IN UINTN DataSize
396 );
397
398 /**
399 Completes computation of the HMAC-SHA384 digest value.
400
401 This function completes HMAC-SHA384 hash computation and retrieves the digest value into
402 the specified memory. After this function has been called, the HMAC-SHA384 context cannot
403 be used again.
404 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
405 by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.
406
407 If HmacSha384Context is NULL, then return FALSE.
408 If HmacValue is NULL, then return FALSE.
409 If this interface is not supported, then return FALSE.
410
411 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
412 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
413 value (48 bytes).
414
415 @retval TRUE HMAC-SHA384 digest computation succeeded.
416 @retval FALSE HMAC-SHA384 digest computation failed.
417 @retval FALSE This interface is not supported.
418
419 **/
420 typedef
421 BOOLEAN
422 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_FINAL)(
423 IN OUT VOID *HmacSha384Context,
424 OUT UINT8 *HmacValue
425 );
426
427 /**
428 Computes the HMAC-SHA384 digest of a input data buffer.
429
430 This function performs the HMAC-SHA384 digest of a given data buffer, and places
431 the digest value into the specified memory.
432
433 If this interface is not supported, then return FALSE.
434
435 @param[in] Data Pointer to the buffer containing the data to be digested.
436 @param[in] DataSize Size of Data buffer in bytes.
437 @param[in] Key Pointer to the user-supplied key.
438 @param[in] KeySize Key size in bytes.
439 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
440 value (48 bytes).
441
442 @retval TRUE HMAC-SHA384 digest computation succeeded.
443 @retval FALSE HMAC-SHA384 digest computation failed.
444 @retval FALSE This interface is not supported.
445
446 **/
447 typedef
448 BOOLEAN
449 (EFIAPI *EDKII_CRYPTO_HMAC_SHA384_ALL)(
450 IN CONST VOID *Data,
451 IN UINTN DataSize,
452 IN CONST UINT8 *Key,
453 IN UINTN KeySize,
454 OUT UINT8 *HmacValue
455 );
456
457 // =====================================================================================
458 // One-Way Cryptographic Hash Primitives
459 // =====================================================================================
460
461 /**
462 MD4 is deprecated and unsupported any longer.
463 Keep the function field for binary compability.
464
465 **/
466 typedef
467 UINTN
468 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_GET_CONTEXT_SIZE)(
469 VOID
470 );
471
472 typedef
473 BOOLEAN
474 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_INIT)(
475 OUT VOID *Md4Context
476 );
477
478 typedef
479 BOOLEAN
480 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_DUPLICATE)(
481 IN CONST VOID *Md4Context,
482 OUT VOID *NewMd4Context
483 );
484
485 typedef
486 BOOLEAN
487 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_UPDATE)(
488 IN OUT VOID *Md4Context,
489 IN CONST VOID *Data,
490 IN UINTN DataSize
491 );
492
493 typedef
494 BOOLEAN
495 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_FINAL)(
496 IN OUT VOID *Md4Context,
497 OUT UINT8 *HashValue
498 );
499
500 typedef
501 BOOLEAN
502 (EFIAPI *DEPRECATED_EDKII_CRYPTO_MD4_HASH_ALL)(
503 IN CONST VOID *Data,
504 IN UINTN DataSize,
505 OUT UINT8 *HashValue
506 );
507
508 // ----------------------------------------------------------------------------
509
510 /**
511 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
512
513 If this interface is not supported, then return zero.
514
515 @return The size, in bytes, of the context buffer required for MD5 hash operations.
516 @retval 0 This interface is not supported.
517
518 **/
519 typedef
520 UINTN
521 (EFIAPI *EDKII_CRYPTO_MD5_GET_CONTEXT_SIZE)(
522 VOID
523 );
524
525 /**
526 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
527 subsequent use.
528
529 If Md5Context is NULL, then return FALSE.
530 If this interface is not supported, then return FALSE.
531
532 @param[out] Md5Context Pointer to MD5 context being initialized.
533
534 @retval TRUE MD5 context initialization succeeded.
535 @retval FALSE MD5 context initialization failed.
536 @retval FALSE This interface is not supported.
537
538 **/
539 typedef
540 BOOLEAN
541 (EFIAPI *EDKII_CRYPTO_MD5_INIT)(
542 OUT VOID *Md5Context
543 );
544
545 /**
546 Makes a copy of an existing MD5 context.
547
548 If Md5Context is NULL, then return FALSE.
549 If NewMd5Context is NULL, then return FALSE.
550 If this interface is not supported, then return FALSE.
551
552 @param[in] Md5Context Pointer to MD5 context being copied.
553 @param[out] NewMd5Context Pointer to new MD5 context.
554
555 @retval TRUE MD5 context copy succeeded.
556 @retval FALSE MD5 context copy failed.
557 @retval FALSE This interface is not supported.
558
559 **/
560 typedef
561 BOOLEAN
562 (EFIAPI *EDKII_CRYPTO_MD5_DUPLICATE)(
563 IN CONST VOID *Md5Context,
564 OUT VOID *NewMd5Context
565 );
566
567 /**
568 Digests the input data and updates MD5 context.
569
570 This function performs MD5 digest on a data buffer of the specified size.
571 It can be called multiple times to compute the digest of long or discontinuous data streams.
572 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
573 by Md5Final(). Behavior with invalid context is undefined.
574
575 If Md5Context is NULL, then return FALSE.
576 If this interface is not supported, then return FALSE.
577
578 @param[in, out] Md5Context Pointer to the MD5 context.
579 @param[in] Data Pointer to the buffer containing the data to be hashed.
580 @param[in] DataSize Size of Data buffer in bytes.
581
582 @retval TRUE MD5 data digest succeeded.
583 @retval FALSE MD5 data digest failed.
584 @retval FALSE This interface is not supported.
585
586 **/
587 typedef
588 BOOLEAN
589 (EFIAPI *EDKII_CRYPTO_MD5_UPDATE)(
590 IN OUT VOID *Md5Context,
591 IN CONST VOID *Data,
592 IN UINTN DataSize
593 );
594
595 /**
596 Completes computation of the MD5 digest value.
597
598 This function completes MD5 hash computation and retrieves the digest value into
599 the specified memory. After this function has been called, the MD5 context cannot
600 be used again.
601 MD5 context should be already correctly initialized by Md5Init(), and should not be
602 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
603
604 If Md5Context is NULL, then return FALSE.
605 If HashValue is NULL, then return FALSE.
606 If this interface is not supported, then return FALSE.
607
608 @param[in, out] Md5Context Pointer to the MD5 context.
609 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
610 value (16 bytes).
611
612 @retval TRUE MD5 digest computation succeeded.
613 @retval FALSE MD5 digest computation failed.
614 @retval FALSE This interface is not supported.
615
616 **/
617 typedef
618 BOOLEAN
619 (EFIAPI *EDKII_CRYPTO_MD5_FINAL)(
620 IN OUT VOID *Md5Context,
621 OUT UINT8 *HashValue
622 );
623
624 /**
625 Computes the MD5 message digest of a input data buffer.
626
627 This function performs the MD5 message digest of a given data buffer, and places
628 the digest value into the specified memory.
629
630 If this interface is not supported, then return FALSE.
631
632 @param[in] Data Pointer to the buffer containing the data to be hashed.
633 @param[in] DataSize Size of Data buffer in bytes.
634 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
635 value (16 bytes).
636
637 @retval TRUE MD5 digest computation succeeded.
638 @retval FALSE MD5 digest computation failed.
639 @retval FALSE This interface is not supported.
640
641 **/
642 typedef
643 BOOLEAN
644 (EFIAPI *EDKII_CRYPTO_MD5_HASH_ALL)(
645 IN CONST VOID *Data,
646 IN UINTN DataSize,
647 OUT UINT8 *HashValue
648 );
649
650 // =====================================================================================
651 // PKCS
652 // =====================================================================================
653
654 /**
655 Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the encrypted message in
656 in a newly allocated buffer.
657
658 Things that can cause a failure include:
659 - X509 key size does not match any known key size.
660 - Fail to parse X509 certificate.
661 - Fail to allocate an intermediate buffer.
662 - NULL pointer provided for a non-optional parameter.
663 - Data size is too large for the provided key size (max size is a function of key size and hash digest size).
664
665 @param[in] PublicKey A pointer to the DER-encoded X509 certificate that will be used to encrypt the data.
666 @param[in] PublicKeySize Size of the X509 cert buffer.
667 @param[in] InData Data to be encrypted.
668 @param[in] InDataSize Size of the data buffer.
669 @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer to be used when initializing the PRNG. NULL otherwise.
670 @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer. 0 otherwise.
671 @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted message.
672 @param[out] EncryptedDataSize Size of the encrypted message buffer.
673
674 @retval TRUE Encryption was successful.
675 @retval FALSE Encryption failed.
676
677 **/
678 typedef
679 BOOLEAN
680 (EFIAPI *EDKII_CRYPTO_PKCS1_ENCRYPT_V2)(
681 IN CONST UINT8 *PublicKey,
682 IN UINTN PublicKeySize,
683 IN UINT8 *InData,
684 IN UINTN InDataSize,
685 IN CONST UINT8 *PrngSeed OPTIONAL,
686 IN UINTN PrngSeedSize OPTIONAL,
687 OUT UINT8 **EncryptedData,
688 OUT UINTN *EncryptedDataSize
689 );
690
691 // ---------------------------------------------
692 // PKCS5
693
694 /**
695 Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0
696 password based encryption key derivation function PBKDF2, as specified in RFC 2898.
697
698 If Password or Salt or OutKey is NULL, then return FALSE.
699 If the hash algorithm could not be determined, then return FALSE.
700 If this interface is not supported, then return FALSE.
701
702 @param[in] PasswordLength Length of input password in bytes.
703 @param[in] Password Pointer to the array for the password.
704 @param[in] SaltLength Size of the Salt in bytes.
705 @param[in] Salt Pointer to the Salt.
706 @param[in] IterationCount Number of iterations to perform. Its value should be
707 greater than or equal to 1.
708 @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).
709 NOTE: DigestSize will be used to determine the hash algorithm.
710 Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.
711 @param[in] KeyLength Size of the derived key buffer in bytes.
712 @param[out] OutKey Pointer to the output derived key buffer.
713
714 @retval TRUE A key was derived successfully.
715 @retval FALSE One of the pointers was NULL or one of the sizes was too large.
716 @retval FALSE The hash algorithm could not be determined from the digest size.
717 @retval FALSE The key derivation operation failed.
718 @retval FALSE This interface is not supported.
719
720 **/
721 typedef
722 BOOLEAN
723 (EFIAPI *EDKII_CRYPTO_PKCS5_PW_HASH)(
724 IN UINTN PasswordSize,
725 IN CONST CHAR8 *Password,
726 IN UINTN SaltSize,
727 IN CONST UINT8 *Salt,
728 IN UINTN IterationCount,
729 IN UINTN DigestSize,
730 IN UINTN OutputSize,
731 OUT UINT8 *Output
732 );
733
734 // ---------------------------------------------
735 // PKCS7
736
737 /**
738 Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:
739 Cryptographic Message Syntax Standard". The input signed data could be wrapped
740 in a ContentInfo structure.
741
742 If P7Data, TrustedCert or InData is NULL, then return FALSE.
743 If P7Length, CertLength or DataLength overflow, then return FALSE.
744 If this interface is not supported, then return FALSE.
745
746 @param[in] P7Data Pointer to the PKCS#7 message to verify.
747 @param[in] P7Length Length of the PKCS#7 message in bytes.
748 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
749 is used for certificate chain verification.
750 @param[in] CertLength Length of the trusted certificate in bytes.
751 @param[in] InData Pointer to the content to be verified.
752 @param[in] DataLength Length of InData in bytes.
753
754 @retval TRUE The specified PKCS#7 signed data is valid.
755 @retval FALSE Invalid PKCS#7 signed data.
756 @retval FALSE This interface is not supported.
757
758 **/
759 typedef
760 BOOLEAN
761 (EFIAPI *EDKII_CRYPTO_PKCS7_VERIFY)(
762 IN CONST UINT8 *P7Data,
763 IN UINTN P7DataLength,
764 IN CONST UINT8 *TrustedCert,
765 IN UINTN TrustedCertLength,
766 IN CONST UINT8 *Data,
767 IN UINTN DataLength
768 );
769
770 /**
771 VerifyEKUsInPkcs7Signature()
772
773 This function receives a PKCS7 formatted signature, and then verifies that
774 the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity
775 leaf signing certificate.
776
777 Note that this function does not validate the certificate chain.
778
779 Applications for custom EKU's are quite flexible. For example, a policy EKU
780 may be present in an Issuing Certificate Authority (CA), and any sub-ordinate
781 certificate issued might also contain this EKU, thus constraining the
782 sub-ordinate certificate. Other applications might allow a certificate
783 embedded in a device to specify that other Object Identifiers (OIDs) are
784 present which contains binary data specifying custom capabilities that
785 the device is able to do.
786
787 @param[in] Pkcs7Signature - The PKCS#7 signed information content block. An array
788 containing the content block with both the signature,
789 the signer's certificate, and any necessary intermediate
790 certificates.
791
792 @param[in] Pkcs7SignatureSize - Number of bytes in Pkcs7Signature.
793
794 @param[in] RequiredEKUs - Array of null-terminated strings listing OIDs of
795 required EKUs that must be present in the signature.
796
797 @param[in] RequiredEKUsSize - Number of elements in the RequiredEKUs string array.
798
799 @param[in] RequireAllPresent - If this is TRUE, then all of the specified EKU's
800 must be present in the leaf signer. If it is
801 FALSE, then we will succeed if we find any
802 of the specified EKU's.
803
804 @retval EFI_SUCCESS - The required EKUs were found in the signature.
805 @retval EFI_INVALID_PARAMETER - A parameter was invalid.
806 @retval EFI_NOT_FOUND - One or more EKU's were not found in the signature.
807
808 **/
809 typedef
810 EFI_STATUS
811 (EFIAPI *EDKII_CRYPTO_PKCS7_VERIFY_EKU)(
812 IN CONST UINT8 *Pkcs7Signature,
813 IN CONST UINT32 SignatureSize,
814 IN CONST CHAR8 *RequiredEKUs[],
815 IN CONST UINT32 RequiredEKUsSize,
816 IN BOOLEAN RequireAllPresent
817 );
818
819 /**
820 Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:
821 Cryptographic Message Syntax Standard". The input signed data could be wrapped
822 in a ContentInfo structure.
823
824 If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then
825 return FALSE. If P7Length overflow, then return FALSE.
826 If this interface is not supported, then return FALSE.
827
828 @param[in] P7Data Pointer to the PKCS#7 message to verify.
829 @param[in] P7Length Length of the PKCS#7 message in bytes.
830 @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.
831 It's caller's responsibility to free the buffer with
832 Pkcs7FreeSigners().
833 This data structure is EFI_CERT_STACK type.
834 @param[out] StackLength Length of signer's certificates in bytes.
835 @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.
836 It's caller's responsibility to free the buffer with
837 Pkcs7FreeSigners().
838 @param[out] CertLength Length of the trusted certificate in bytes.
839
840 @retval TRUE The operation is finished successfully.
841 @retval FALSE Error occurs during the operation.
842 @retval FALSE This interface is not supported.
843
844 **/
845 typedef
846 BOOLEAN
847 (EFIAPI *EDKII_CRYPTO_PKCS7_GET_SIGNERS)(
848 IN CONST UINT8 *P7Data,
849 IN UINTN P7Length,
850 OUT UINT8 **CertStack,
851 OUT UINTN *StackLength,
852 OUT UINT8 **TrustedCert,
853 OUT UINTN *CertLength
854 );
855
856 /**
857 Wrap function to use free() to free allocated memory for certificates.
858
859 If this interface is not supported, then ASSERT().
860
861 @param[in] Certs Pointer to the certificates to be freed.
862
863 **/
864 typedef
865 VOID
866 (EFIAPI *EDKII_CRYPTO_PKCS7_FREE_SIGNERS)(
867 IN UINT8 *Certs
868 );
869
870 /**
871 Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message
872 Syntax Standard, version 1.5". This interface is only intended to be used for
873 application to perform PKCS#7 functionality validation.
874
875 If this interface is not supported, then return FALSE.
876
877 @param[in] PrivateKey Pointer to the PEM-formatted private key data for
878 data signing.
879 @param[in] PrivateKeySize Size of the PEM private key data in bytes.
880 @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM
881 key data.
882 @param[in] InData Pointer to the content to be signed.
883 @param[in] InDataSize Size of InData in bytes.
884 @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.
885 @param[in] OtherCerts Pointer to an optional additional set of certificates to
886 include in the PKCS#7 signedData (e.g. any intermediate
887 CAs in the chain).
888 @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's
889 responsibility to free the buffer with FreePool().
890 @param[out] SignedDataSize Size of SignedData in bytes.
891
892 @retval TRUE PKCS#7 data signing succeeded.
893 @retval FALSE PKCS#7 data signing failed.
894 @retval FALSE This interface is not supported.
895
896 **/
897 typedef
898 BOOLEAN
899 (EFIAPI *EDKII_CRYPTO_PKCS7_SIGN)(
900 IN CONST UINT8 *PrivateKey,
901 IN UINTN PrivateKeySize,
902 IN CONST UINT8 *KeyPassword,
903 IN UINT8 *InData,
904 IN UINTN InDataSize,
905 IN UINT8 *SignCert,
906 IN UINT8 *OtherCerts OPTIONAL,
907 OUT UINT8 **SignedData,
908 OUT UINTN *SignedDataSize
909 );
910
911 /**
912 Extracts the attached content from a PKCS#7 signed data if existed. The input signed
913 data could be wrapped in a ContentInfo structure.
914
915 If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,
916 then return FALSE. If the P7Data is not correctly formatted, then return FALSE.
917
918 Caution: This function may receive untrusted input. So this function will do
919 basic check for PKCS#7 data structure.
920
921 @param[in] P7Data Pointer to the PKCS#7 signed data to process.
922 @param[in] P7Length Length of the PKCS#7 signed data in bytes.
923 @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.
924 It's caller's responsibility to free the buffer with FreePool().
925 @param[out] ContentSize The size of the extracted content in bytes.
926
927 @retval TRUE The P7Data was correctly formatted for processing.
928 @retval FALSE The P7Data was not correctly formatted for processing.
929
930
931 **/
932 typedef
933 BOOLEAN
934 (EFIAPI *EDKII_CRYPTO_PKCS7_GET_ATTACHED_CONTENT)(
935 IN CONST UINT8 *P7Data,
936 IN UINTN P7Length,
937 OUT VOID **Content,
938 OUT UINTN *ContentSize
939 );
940
941 /**
942 Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:
943 Cryptographic Message Syntax Standard", and outputs two certificate lists chained and
944 unchained to the signer's certificates.
945 The input signed data could be wrapped in a ContentInfo structure.
946
947 @param[in] P7Data Pointer to the PKCS#7 message.
948 @param[in] P7Length Length of the PKCS#7 message in bytes.
949 @param[out] SignerChainCerts Pointer to the certificates list chained to signer's
950 certificate. It's caller's responsibility to free the buffer
951 with Pkcs7FreeSigners().
952 This data structure is EFI_CERT_STACK type.
953 @param[out] ChainLength Length of the chained certificates list buffer in bytes.
954 @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's
955 responsibility to free the buffer with Pkcs7FreeSigners().
956 This data structure is EFI_CERT_STACK type.
957 @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.
958
959 @retval TRUE The operation is finished successfully.
960 @retval FALSE Error occurs during the operation.
961
962 **/
963 typedef
964 BOOLEAN
965 (EFIAPI *EDKII_CRYPTO_PKCS7_GET_CERTIFICATES_LIST)(
966 IN CONST UINT8 *P7Data,
967 IN UINTN P7Length,
968 OUT UINT8 **SignerChainCerts,
969 OUT UINTN *ChainLength,
970 OUT UINT8 **UnchainCerts,
971 OUT UINTN *UnchainLength
972 );
973
974 /**
975 Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows
976 Authenticode Portable Executable Signature Format".
977
978 If AuthData is NULL, then return FALSE.
979 If ImageHash is NULL, then return FALSE.
980 If this interface is not supported, then return FALSE.
981
982 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
983 PE/COFF image to be verified.
984 @param[in] DataSize Size of the Authenticode Signature in bytes.
985 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
986 is used for certificate chain verification.
987 @param[in] CertSize Size of the trusted certificate in bytes.
988 @param[in] ImageHash Pointer to the original image file hash value. The procedure
989 for calculating the image hash value is described in Authenticode
990 specification.
991 @param[in] HashSize Size of Image hash value in bytes.
992
993 @retval TRUE The specified Authenticode Signature is valid.
994 @retval FALSE Invalid Authenticode Signature.
995 @retval FALSE This interface is not supported.
996
997 **/
998 typedef
999 BOOLEAN
1000 (EFIAPI *EDKII_CRYPTO_AUTHENTICODE_VERIFY)(
1001 IN CONST UINT8 *AuthData,
1002 IN UINTN DataSize,
1003 IN CONST UINT8 *TrustedCert,
1004 IN UINTN CertSize,
1005 IN CONST UINT8 *ImageHash,
1006 IN UINTN HashSize
1007 );
1008
1009 /**
1010 Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode
1011 signature.
1012
1013 If AuthData is NULL, then return FALSE.
1014 If this interface is not supported, then return FALSE.
1015
1016 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
1017 PE/COFF image to be verified.
1018 @param[in] DataSize Size of the Authenticode Signature in bytes.
1019 @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which
1020 is used for TSA certificate chain verification.
1021 @param[in] CertSize Size of the trusted certificate in bytes.
1022 @param[out] SigningTime Return the time of timestamp generation time if the timestamp
1023 signature is valid.
1024
1025 @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.
1026 @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.
1027
1028 **/
1029 typedef
1030 BOOLEAN
1031 (EFIAPI *EDKII_CRYPTO_IMAGE_TIMESTAMP_VERIFY)(
1032 IN CONST UINT8 *AuthData,
1033 IN UINTN DataSize,
1034 IN CONST UINT8 *TsaCert,
1035 IN UINTN CertSize,
1036 OUT EFI_TIME *SigningTime
1037 );
1038
1039 // =====================================================================================
1040 // DH Key Exchange Primitive
1041 // =====================================================================================
1042
1043 /**
1044 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
1045
1046 @return Pointer to the Diffie-Hellman Context that has been initialized.
1047 If the allocations fails, DhNew() returns NULL.
1048 If the interface is not supported, DhNew() returns NULL.
1049
1050 **/
1051 typedef
1052 VOID *
1053 (EFIAPI *EDKII_CRYPTO_DH_NEW)(
1054 VOID
1055 );
1056
1057 /**
1058 Release the specified DH context.
1059
1060 If the interface is not supported, then ASSERT().
1061
1062 @param[in] DhContext Pointer to the DH context to be released.
1063
1064 **/
1065 typedef
1066 VOID
1067 (EFIAPI *EDKII_CRYPTO_DH_FREE)(
1068 IN VOID *DhContext
1069 );
1070
1071 /**
1072 Generates DH parameter.
1073
1074 Given generator g, and length of prime number p in bits, this function generates p,
1075 and sets DH context according to value of g and p.
1076
1077 Before this function can be invoked, pseudorandom number generator must be correctly
1078 initialized by RandomSeed().
1079
1080 If DhContext is NULL, then return FALSE.
1081 If Prime is NULL, then return FALSE.
1082 If this interface is not supported, then return FALSE.
1083
1084 @param[in, out] DhContext Pointer to the DH context.
1085 @param[in] Generator Value of generator.
1086 @param[in] PrimeLength Length in bits of prime to be generated.
1087 @param[out] Prime Pointer to the buffer to receive the generated prime number.
1088
1089 @retval TRUE DH parameter generation succeeded.
1090 @retval FALSE Value of Generator is not supported.
1091 @retval FALSE PRNG fails to generate random prime number with PrimeLength.
1092 @retval FALSE This interface is not supported.
1093
1094 **/
1095 typedef
1096 BOOLEAN
1097 (EFIAPI *EDKII_CRYPTO_DH_GENERATE_PARAMETER)(
1098 IN OUT VOID *DhContext,
1099 IN UINTN Generator,
1100 IN UINTN PrimeLength,
1101 OUT UINT8 *Prime
1102 );
1103
1104 /**
1105 Sets generator and prime parameters for DH.
1106
1107 Given generator g, and prime number p, this function and sets DH
1108 context accordingly.
1109
1110 If DhContext is NULL, then return FALSE.
1111 If Prime is NULL, then return FALSE.
1112 If this interface is not supported, then return FALSE.
1113
1114 @param[in, out] DhContext Pointer to the DH context.
1115 @param[in] Generator Value of generator.
1116 @param[in] PrimeLength Length in bits of prime to be generated.
1117 @param[in] Prime Pointer to the prime number.
1118
1119 @retval TRUE DH parameter setting succeeded.
1120 @retval FALSE Value of Generator is not supported.
1121 @retval FALSE Value of Generator is not suitable for the Prime.
1122 @retval FALSE Value of Prime is not a prime number.
1123 @retval FALSE Value of Prime is not a safe prime number.
1124 @retval FALSE This interface is not supported.
1125
1126 **/
1127 typedef
1128 BOOLEAN
1129 (EFIAPI *EDKII_CRYPTO_DH_SET_PARAMETER)(
1130 IN OUT VOID *DhContext,
1131 IN UINTN Generator,
1132 IN UINTN PrimeLength,
1133 IN CONST UINT8 *Prime
1134 );
1135
1136 /**
1137 Generates DH public key.
1138
1139 This function generates random secret exponent, and computes the public key, which is
1140 returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.
1141 If the PublicKey buffer is too small to hold the public key, FALSE is returned and
1142 PublicKeySize is set to the required buffer size to obtain the public key.
1143
1144 If DhContext is NULL, then return FALSE.
1145 If PublicKeySize is NULL, then return FALSE.
1146 If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.
1147 If this interface is not supported, then return FALSE.
1148
1149 @param[in, out] DhContext Pointer to the DH context.
1150 @param[out] PublicKey Pointer to the buffer to receive generated public key.
1151 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
1152 On output, the size of data returned in PublicKey buffer in bytes.
1153
1154 @retval TRUE DH public key generation succeeded.
1155 @retval FALSE DH public key generation failed.
1156 @retval FALSE PublicKeySize is not large enough.
1157 @retval FALSE This interface is not supported.
1158
1159 **/
1160 typedef
1161 BOOLEAN
1162 (EFIAPI *EDKII_CRYPTO_DH_GENERATE_KEY)(
1163 IN OUT VOID *DhContext,
1164 OUT UINT8 *PublicKey,
1165 IN OUT UINTN *PublicKeySize
1166 );
1167
1168 /**
1169 Computes exchanged common key.
1170
1171 Given peer's public key, this function computes the exchanged common key, based on its own
1172 context including value of prime modulus and random secret exponent.
1173
1174 If DhContext is NULL, then return FALSE.
1175 If PeerPublicKey is NULL, then return FALSE.
1176 If KeySize is NULL, then return FALSE.
1177 If Key is NULL, then return FALSE.
1178 If KeySize is not large enough, then return FALSE.
1179 If this interface is not supported, then return FALSE.
1180
1181 @param[in, out] DhContext Pointer to the DH context.
1182 @param[in] PeerPublicKey Pointer to the peer's public key.
1183 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
1184 @param[out] Key Pointer to the buffer to receive generated key.
1185 @param[in, out] KeySize On input, the size of Key buffer in bytes.
1186 On output, the size of data returned in Key buffer in bytes.
1187
1188 @retval TRUE DH exchanged key generation succeeded.
1189 @retval FALSE DH exchanged key generation failed.
1190 @retval FALSE KeySize is not large enough.
1191 @retval FALSE This interface is not supported.
1192
1193 **/
1194 typedef
1195 BOOLEAN
1196 (EFIAPI *EDKII_CRYPTO_DH_COMPUTE_KEY)(
1197 IN OUT VOID *DhContext,
1198 IN CONST UINT8 *PeerPublicKey,
1199 IN UINTN PeerPublicKeySize,
1200 OUT UINT8 *Key,
1201 IN OUT UINTN *KeySize
1202 );
1203
1204 // =====================================================================================
1205 // Pseudo-Random Generation Primitive
1206 // =====================================================================================
1207
1208 /**
1209 Sets up the seed value for the pseudorandom number generator.
1210
1211 This function sets up the seed value for the pseudorandom number generator.
1212 If Seed is not NULL, then the seed passed in is used.
1213 If Seed is NULL, then default seed is used.
1214 If this interface is not supported, then return FALSE.
1215
1216 @param[in] Seed Pointer to seed value.
1217 If NULL, default seed is used.
1218 @param[in] SeedSize Size of seed value.
1219 If Seed is NULL, this parameter is ignored.
1220
1221 @retval TRUE Pseudorandom number generator has enough entropy for random generation.
1222 @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.
1223 @retval FALSE This interface is not supported.
1224
1225 **/
1226 typedef
1227 BOOLEAN
1228 (EFIAPI *EDKII_CRYPTO_RANDOM_SEED)(
1229 IN CONST UINT8 *Seed OPTIONAL,
1230 IN UINTN SeedSize
1231 );
1232
1233 /**
1234 Generates a pseudorandom byte stream of the specified size.
1235
1236 If Output is NULL, then return FALSE.
1237 If this interface is not supported, then return FALSE.
1238
1239 @param[out] Output Pointer to buffer to receive random value.
1240 @param[in] Size Size of random bytes to generate.
1241
1242 @retval TRUE Pseudorandom byte stream generated successfully.
1243 @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.
1244 @retval FALSE This interface is not supported.
1245
1246 **/
1247 typedef
1248 BOOLEAN
1249 (EFIAPI *EDKII_CRYPTO_RANDOM_BYTES)(
1250 OUT UINT8 *Output,
1251 IN UINTN Size
1252 );
1253
1254 /**
1255 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
1256 RSA PKCS#1.
1257
1258 If RsaContext is NULL, then return FALSE.
1259 If MessageHash is NULL, then return FALSE.
1260 If Signature is NULL, then return FALSE.
1261 If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.
1262
1263 @param[in] RsaContext Pointer to RSA context for signature verification.
1264 @param[in] MessageHash Pointer to octet message hash to be checked.
1265 @param[in] HashSize Size of the message hash in bytes.
1266 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
1267 @param[in] SigSize Size of signature in bytes.
1268
1269 @retval TRUE Valid signature encoded in PKCS1-v1_5.
1270 @retval FALSE Invalid signature or invalid RSA context.
1271
1272 **/
1273 typedef
1274 BOOLEAN
1275 (EFIAPI *EDKII_CRYPTO_RSA_VERIFY_PKCS1)(
1276 IN VOID *RsaContext,
1277 IN CONST UINT8 *MessageHash,
1278 IN UINTN HashSize,
1279 IN CONST UINT8 *Signature,
1280 IN UINTN SigSize
1281 );
1282
1283 /**
1284 Allocates and initializes one RSA context for subsequent use.
1285
1286 @return Pointer to the RSA context that has been initialized.
1287 If the allocations fails, RsaNew() returns NULL.
1288
1289 **/
1290 typedef
1291 VOID *
1292 (EFIAPI *EDKII_CRYPTO_RSA_NEW)(
1293 VOID
1294 );
1295
1296 /**
1297 Release the specified RSA context.
1298
1299 If RsaContext is NULL, then return FALSE.
1300
1301 @param[in] RsaContext Pointer to the RSA context to be released.
1302
1303 **/
1304 typedef
1305 VOID
1306 (EFIAPI *EDKII_CRYPTO_RSA_FREE)(
1307 IN VOID *RsaContext
1308 );
1309
1310 /**
1311 Sets the tag-designated key component into the established RSA context.
1312
1313 This function sets the tag-designated RSA key component into the established
1314 RSA context from the user-specified non-negative integer (octet string format
1315 represented in RSA PKCS#1).
1316 If BigNumber is NULL, then the specified key component in RSA context is cleared.
1317
1318 If RsaContext is NULL, then return FALSE.
1319
1320 @param[in, out] RsaContext Pointer to RSA context being set.
1321 @param[in] KeyTag Tag of RSA key component being set.
1322 @param[in] BigNumber Pointer to octet integer buffer.
1323 If NULL, then the specified key component in RSA
1324 context is cleared.
1325 @param[in] BnSize Size of big number buffer in bytes.
1326 If BigNumber is NULL, then it is ignored.
1327
1328 @retval TRUE RSA key component was set successfully.
1329 @retval FALSE Invalid RSA key component tag.
1330
1331 **/
1332 typedef
1333 BOOLEAN
1334 (EFIAPI *EDKII_CRYPTO_RSA_SET_KEY)(
1335 IN OUT VOID *RsaContext,
1336 IN RSA_KEY_TAG KeyTag,
1337 IN CONST UINT8 *BigNumber,
1338 IN UINTN BnSize
1339 );
1340
1341 /**
1342 Gets the tag-designated RSA key component from the established RSA context.
1343
1344 This function retrieves the tag-designated RSA key component from the
1345 established RSA context as a non-negative integer (octet string format
1346 represented in RSA PKCS#1).
1347 If specified key component has not been set or has been cleared, then returned
1348 BnSize is set to 0.
1349 If the BigNumber buffer is too small to hold the contents of the key, FALSE
1350 is returned and BnSize is set to the required buffer size to obtain the key.
1351
1352 If RsaContext is NULL, then return FALSE.
1353 If BnSize is NULL, then return FALSE.
1354 If BnSize is large enough but BigNumber is NULL, then return FALSE.
1355 If this interface is not supported, then return FALSE.
1356
1357 @param[in, out] RsaContext Pointer to RSA context being set.
1358 @param[in] KeyTag Tag of RSA key component being set.
1359 @param[out] BigNumber Pointer to octet integer buffer.
1360 @param[in, out] BnSize On input, the size of big number buffer in bytes.
1361 On output, the size of data returned in big number buffer in bytes.
1362
1363 @retval TRUE RSA key component was retrieved successfully.
1364 @retval FALSE Invalid RSA key component tag.
1365 @retval FALSE BnSize is too small.
1366 @retval FALSE This interface is not supported.
1367
1368 **/
1369 typedef
1370 BOOLEAN
1371 (EFIAPI *EDKII_CRYPTO_RSA_GET_KEY)(
1372 IN OUT VOID *RsaContext,
1373 IN RSA_KEY_TAG KeyTag,
1374 OUT UINT8 *BigNumber,
1375 IN OUT UINTN *BnSize
1376 );
1377
1378 /**
1379 Generates RSA key components.
1380
1381 This function generates RSA key components. It takes RSA public exponent E and
1382 length in bits of RSA modulus N as input, and generates all key components.
1383 If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.
1384
1385 Before this function can be invoked, pseudorandom number generator must be correctly
1386 initialized by RandomSeed().
1387
1388 If RsaContext is NULL, then return FALSE.
1389 If this interface is not supported, then return FALSE.
1390
1391 @param[in, out] RsaContext Pointer to RSA context being set.
1392 @param[in] ModulusLength Length of RSA modulus N in bits.
1393 @param[in] PublicExponent Pointer to RSA public exponent.
1394 @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.
1395
1396 @retval TRUE RSA key component was generated successfully.
1397 @retval FALSE Invalid RSA key component tag.
1398 @retval FALSE This interface is not supported.
1399
1400 **/
1401 typedef
1402 BOOLEAN
1403 (EFIAPI *EDKII_CRYPTO_RSA_GENERATE_KEY)(
1404 IN OUT VOID *RsaContext,
1405 IN UINTN ModulusLength,
1406 IN CONST UINT8 *PublicExponent,
1407 IN UINTN PublicExponentSize
1408 );
1409
1410 /**
1411 Validates key components of RSA context.
1412 NOTE: This function performs integrity checks on all the RSA key material, so
1413 the RSA key structure must contain all the private key data.
1414
1415 This function validates key components of RSA context in following aspects:
1416 - Whether p is a prime
1417 - Whether q is a prime
1418 - Whether n = p * q
1419 - Whether d*e = 1 mod lcm(p-1,q-1)
1420
1421 If RsaContext is NULL, then return FALSE.
1422 If this interface is not supported, then return FALSE.
1423
1424 @param[in] RsaContext Pointer to RSA context to check.
1425
1426 @retval TRUE RSA key components are valid.
1427 @retval FALSE RSA key components are not valid.
1428 @retval FALSE This interface is not supported.
1429
1430 **/
1431 typedef
1432 BOOLEAN
1433 (EFIAPI *EDKII_CRYPTO_RSA_CHECK_KEY)(
1434 IN VOID *RsaContext
1435 );
1436
1437 /**
1438 Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
1439
1440 This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in
1441 RSA PKCS#1.
1442 If the Signature buffer is too small to hold the contents of signature, FALSE
1443 is returned and SigSize is set to the required buffer size to obtain the signature.
1444
1445 If RsaContext is NULL, then return FALSE.
1446 If MessageHash is NULL, then return FALSE.
1447 If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
1448 If SigSize is large enough but Signature is NULL, then return FALSE.
1449 If this interface is not supported, then return FALSE.
1450
1451 @param[in] RsaContext Pointer to RSA context for signature generation.
1452 @param[in] MessageHash Pointer to octet message hash to be signed.
1453 @param[in] HashSize Size of the message hash in bytes.
1454 @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.
1455 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
1456 On output, the size of data returned in Signature buffer in bytes.
1457
1458 @retval TRUE Signature successfully generated in PKCS1-v1_5.
1459 @retval FALSE Signature generation failed.
1460 @retval FALSE SigSize is too small.
1461 @retval FALSE This interface is not supported.
1462
1463 **/
1464 typedef
1465 BOOLEAN
1466 (EFIAPI *EDKII_CRYPTO_RSA_PKCS1_SIGN)(
1467 IN VOID *RsaContext,
1468 IN CONST UINT8 *MessageHash,
1469 IN UINTN HashSize,
1470 OUT UINT8 *Signature,
1471 IN OUT UINTN *SigSize
1472 );
1473
1474 /**
1475 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
1476 RSA PKCS#1.
1477
1478 If RsaContext is NULL, then return FALSE.
1479 If MessageHash is NULL, then return FALSE.
1480 If Signature is NULL, then return FALSE.
1481 If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.
1482
1483 @param[in] RsaContext Pointer to RSA context for signature verification.
1484 @param[in] MessageHash Pointer to octet message hash to be checked.
1485 @param[in] HashSize Size of the message hash in bytes.
1486 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
1487 @param[in] SigSize Size of signature in bytes.
1488
1489 @retval TRUE Valid signature encoded in PKCS1-v1_5.
1490 @retval FALSE Invalid signature or invalid RSA context.
1491
1492 **/
1493 typedef
1494 BOOLEAN
1495 (EFIAPI *EDKII_CRYPTO_RSA_PKCS1_VERIFY)(
1496 IN VOID *RsaContext,
1497 IN CONST UINT8 *MessageHash,
1498 IN UINTN HashSize,
1499 IN CONST UINT8 *Signature,
1500 IN UINTN SigSize
1501 );
1502
1503 /**
1504 Retrieve the RSA Private Key from the password-protected PEM key data.
1505
1506 If PemData is NULL, then return FALSE.
1507 If RsaContext is NULL, then return FALSE.
1508 If this interface is not supported, then return FALSE.
1509
1510 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
1511 @param[in] PemSize Size of the PEM key data in bytes.
1512 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
1513 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
1514 RSA private key component. Use RsaFree() function to free the
1515 resource.
1516
1517 @retval TRUE RSA Private Key was retrieved successfully.
1518 @retval FALSE Invalid PEM key data or incorrect password.
1519 @retval FALSE This interface is not supported.
1520
1521 **/
1522 typedef
1523 BOOLEAN
1524 (EFIAPI *EDKII_CRYPTO_RSA_GET_PRIVATE_KEY_FROM_PEM)(
1525 IN CONST UINT8 *PemData,
1526 IN UINTN PemSize,
1527 IN CONST CHAR8 *Password,
1528 OUT VOID **RsaContext
1529 );
1530
1531 /**
1532 Retrieve the RSA Public Key from one DER-encoded X509 certificate.
1533
1534 If Cert is NULL, then return FALSE.
1535 If RsaContext is NULL, then return FALSE.
1536 If this interface is not supported, then return FALSE.
1537
1538 @param[in] Cert Pointer to the DER-encoded X509 certificate.
1539 @param[in] CertSize Size of the X509 certificate in bytes.
1540 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
1541 RSA public key component. Use RsaFree() function to free the
1542 resource.
1543
1544 @retval TRUE RSA Public Key was retrieved successfully.
1545 @retval FALSE Fail to retrieve RSA public key from X509 certificate.
1546 @retval FALSE This interface is not supported.
1547
1548 **/
1549 typedef
1550 BOOLEAN
1551 (EFIAPI *EDKII_CRYPTO_RSA_GET_PUBLIC_KEY_FROM_X509)(
1552 IN CONST UINT8 *Cert,
1553 IN UINTN CertSize,
1554 OUT VOID **RsaContext
1555 );
1556
1557 // ----------------------------------------
1558 // SHA
1559 // ----------------------------------------
1560
1561 /**
1562 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
1563
1564 If this interface is not supported, then return zero.
1565
1566 @return The size, in bytes, of the context buffer required for SHA-1 hash operations.
1567 @retval 0 This interface is not supported.
1568
1569 **/
1570 typedef
1571 UINTN
1572 (EFIAPI *EDKII_CRYPTO_SHA1_GET_CONTEXT_SIZE)(
1573 VOID
1574 );
1575
1576 /**
1577 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
1578 subsequent use.
1579
1580 If Sha1Context is NULL, then return FALSE.
1581 If this interface is not supported, then return FALSE.
1582
1583 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
1584
1585 @retval TRUE SHA-1 context initialization succeeded.
1586 @retval FALSE SHA-1 context initialization failed.
1587 @retval FALSE This interface is not supported.
1588
1589 **/
1590 typedef
1591 BOOLEAN
1592 (EFIAPI *EDKII_CRYPTO_SHA1_INIT)(
1593 OUT VOID *Sha1Context
1594 );
1595
1596 /**
1597 Makes a copy of an existing SHA-1 context.
1598
1599 If Sha1Context is NULL, then return FALSE.
1600 If NewSha1Context is NULL, then return FALSE.
1601 If this interface is not supported, then return FALSE.
1602
1603 @param[in] Sha1Context Pointer to SHA-1 context being copied.
1604 @param[out] NewSha1Context Pointer to new SHA-1 context.
1605
1606 @retval TRUE SHA-1 context copy succeeded.
1607 @retval FALSE SHA-1 context copy failed.
1608 @retval FALSE This interface is not supported.
1609
1610 **/
1611 typedef
1612 BOOLEAN
1613 (EFIAPI *EDKII_CRYPTO_SHA1_DUPLICATE)(
1614 IN CONST VOID *Sha1Context,
1615 OUT VOID *NewSha1Context
1616 );
1617
1618 /**
1619 Digests the input data and updates SHA-1 context.
1620
1621 This function performs SHA-1 digest on a data buffer of the specified size.
1622 It can be called multiple times to compute the digest of long or discontinuous data streams.
1623 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
1624 by Sha1Final(). Behavior with invalid context is undefined.
1625
1626 If Sha1Context is NULL, then return FALSE.
1627 If this interface is not supported, then return FALSE.
1628
1629 @param[in, out] Sha1Context Pointer to the SHA-1 context.
1630 @param[in] Data Pointer to the buffer containing the data to be hashed.
1631 @param[in] DataSize Size of Data buffer in bytes.
1632
1633 @retval TRUE SHA-1 data digest succeeded.
1634 @retval FALSE SHA-1 data digest failed.
1635 @retval FALSE This interface is not supported.
1636
1637 **/
1638 typedef
1639 BOOLEAN
1640 (EFIAPI *EDKII_CRYPTO_SHA1_UPDATE)(
1641 IN OUT VOID *Sha1Context,
1642 IN CONST VOID *Data,
1643 IN UINTN DataSize
1644 );
1645
1646 /**
1647 Completes computation of the SHA-1 digest value.
1648
1649 This function completes SHA-1 hash computation and retrieves the digest value into
1650 the specified memory. After this function has been called, the SHA-1 context cannot
1651 be used again.
1652 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
1653 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
1654
1655 If Sha1Context is NULL, then return FALSE.
1656 If HashValue is NULL, then return FALSE.
1657 If this interface is not supported, then return FALSE.
1658
1659 @param[in, out] Sha1Context Pointer to the SHA-1 context.
1660 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
1661 value (20 bytes).
1662
1663 @retval TRUE SHA-1 digest computation succeeded.
1664 @retval FALSE SHA-1 digest computation failed.
1665 @retval FALSE This interface is not supported.
1666
1667 **/
1668 typedef
1669 BOOLEAN
1670 (EFIAPI *EDKII_CRYPTO_SHA1_FINAL)(
1671 IN OUT VOID *Sha1Context,
1672 OUT UINT8 *HashValue
1673 );
1674
1675 /**
1676 Computes the SHA-1 message digest of a input data buffer.
1677
1678 This function performs the SHA-1 message digest of a given data buffer, and places
1679 the digest value into the specified memory.
1680
1681 If this interface is not supported, then return FALSE.
1682
1683 @param[in] Data Pointer to the buffer containing the data to be hashed.
1684 @param[in] DataSize Size of Data buffer in bytes.
1685 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
1686 value (20 bytes).
1687
1688 @retval TRUE SHA-1 digest computation succeeded.
1689 @retval FALSE SHA-1 digest computation failed.
1690 @retval FALSE This interface is not supported.
1691
1692 **/
1693 typedef
1694 BOOLEAN
1695 (EFIAPI *EDKII_CRYPTO_SHA1_HASH_ALL)(
1696 IN CONST VOID *Data,
1697 IN UINTN DataSize,
1698 OUT UINT8 *HashValue
1699 );
1700
1701 /**
1702 Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
1703
1704 @return The size, in bytes, of the context buffer required for SHA-256 hash operations.
1705
1706 **/
1707 typedef
1708 UINTN
1709 (EFIAPI *EDKII_CRYPTO_SHA256_GET_CONTEXT_SIZE)(
1710 VOID
1711 );
1712
1713 /**
1714 Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
1715 subsequent use.
1716
1717 If Sha256Context is NULL, then return FALSE.
1718
1719 @param[out] Sha256Context Pointer to SHA-256 context being initialized.
1720
1721 @retval TRUE SHA-256 context initialization succeeded.
1722 @retval FALSE SHA-256 context initialization failed.
1723
1724 **/
1725 typedef
1726 BOOLEAN
1727 (EFIAPI *EDKII_CRYPTO_SHA256_INIT)(
1728 OUT VOID *Sha256Context
1729 );
1730
1731 /**
1732 Makes a copy of an existing SHA-256 context.
1733
1734 If Sha256Context is NULL, then return FALSE.
1735 If NewSha256Context is NULL, then return FALSE.
1736 If this interface is not supported, then return FALSE.
1737
1738 @param[in] Sha256Context Pointer to SHA-256 context being copied.
1739 @param[out] NewSha256Context Pointer to new SHA-256 context.
1740
1741 @retval TRUE SHA-256 context copy succeeded.
1742 @retval FALSE SHA-256 context copy failed.
1743 @retval FALSE This interface is not supported.
1744
1745 **/
1746 typedef
1747 BOOLEAN
1748 (EFIAPI *EDKII_CRYPTO_SHA256_DUPLICATE)(
1749 IN CONST VOID *Sha256Context,
1750 OUT VOID *NewSha256Context
1751 );
1752
1753 /**
1754 Digests the input data and updates SHA-256 context.
1755
1756 This function performs SHA-256 digest on a data buffer of the specified size.
1757 It can be called multiple times to compute the digest of long or discontinuous data streams.
1758 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized
1759 by Sha256Final(). Behavior with invalid context is undefined.
1760
1761 If Sha256Context is NULL, then return FALSE.
1762
1763 @param[in, out] Sha256Context Pointer to the SHA-256 context.
1764 @param[in] Data Pointer to the buffer containing the data to be hashed.
1765 @param[in] DataSize Size of Data buffer in bytes.
1766
1767 @retval TRUE SHA-256 data digest succeeded.
1768 @retval FALSE SHA-256 data digest failed.
1769
1770 **/
1771 typedef
1772 BOOLEAN
1773 (EFIAPI *EDKII_CRYPTO_SHA256_UPDATE)(
1774 IN OUT VOID *Sha256Context,
1775 IN CONST VOID *Data,
1776 IN UINTN DataSize
1777 );
1778
1779 /**
1780 Completes computation of the SHA-256 digest value.
1781
1782 This function completes SHA-256 hash computation and retrieves the digest value into
1783 the specified memory. After this function has been called, the SHA-256 context cannot
1784 be used again.
1785 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be
1786 finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
1787
1788 If Sha256Context is NULL, then return FALSE.
1789 If HashValue is NULL, then return FALSE.
1790
1791 @param[in, out] Sha256Context Pointer to the SHA-256 context.
1792 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
1793 value (32 bytes).
1794
1795 @retval TRUE SHA-256 digest computation succeeded.
1796 @retval FALSE SHA-256 digest computation failed.
1797
1798 **/
1799 typedef
1800 BOOLEAN
1801 (EFIAPI *EDKII_CRYPTO_SHA256_FINAL)(
1802 IN OUT VOID *Sha256Context,
1803 OUT UINT8 *HashValue
1804 );
1805
1806 /**
1807 Computes the SHA-256 message digest of a input data buffer.
1808
1809 This function performs the SHA-256 message digest of a given data buffer, and places
1810 the digest value into the specified memory.
1811
1812 If this interface is not supported, then return FALSE.
1813
1814 @param[in] Data Pointer to the buffer containing the data to be hashed.
1815 @param[in] DataSize Size of Data buffer in bytes.
1816 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
1817 value (32 bytes).
1818
1819 @retval TRUE SHA-256 digest computation succeeded.
1820 @retval FALSE SHA-256 digest computation failed.
1821 @retval FALSE This interface is not supported.
1822
1823 **/
1824 typedef
1825 BOOLEAN
1826 (EFIAPI *EDKII_CRYPTO_SHA256_HASH_ALL)(
1827 IN CONST VOID *Data,
1828 IN UINTN DataSize,
1829 OUT UINT8 *HashValue
1830 );
1831
1832 /**
1833 Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
1834 If this interface is not supported, then return zero.
1835
1836 @return The size, in bytes, of the context buffer required for SHA-384 hash operations.
1837 @retval 0 This interface is not supported.
1838
1839 **/
1840 typedef
1841 UINTN
1842 (EFIAPI *EDKII_CRYPTO_SHA384_GET_CONTEXT_SIZE)(
1843 VOID
1844 );
1845
1846 /**
1847 Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for
1848 subsequent use.
1849
1850 If Sha384Context is NULL, then return FALSE.
1851
1852 @param[out] Sha384Context Pointer to SHA-384 context being initialized.
1853
1854 @retval TRUE SHA-384 context initialization succeeded.
1855 @retval FALSE SHA-384 context initialization failed.
1856
1857 **/
1858 typedef
1859 BOOLEAN
1860 (EFIAPI *EDKII_CRYPTO_SHA384_INIT)(
1861 OUT VOID *Sha384Context
1862 );
1863
1864 /**
1865 Makes a copy of an existing SHA-384 context.
1866
1867 If Sha384Context is NULL, then return FALSE.
1868 If NewSha384Context is NULL, then return FALSE.
1869 If this interface is not supported, then return FALSE.
1870
1871 @param[in] Sha384Context Pointer to SHA-384 context being copied.
1872 @param[out] NewSha384Context Pointer to new SHA-384 context.
1873
1874 @retval TRUE SHA-384 context copy succeeded.
1875 @retval FALSE SHA-384 context copy failed.
1876 @retval FALSE This interface is not supported.
1877
1878 **/
1879 typedef
1880 BOOLEAN
1881 (EFIAPI *EDKII_CRYPTO_SHA384_DUPLICATE)(
1882 IN CONST VOID *Sha384Context,
1883 OUT VOID *NewSha384Context
1884 );
1885
1886 /**
1887 Digests the input data and updates SHA-384 context.
1888
1889 This function performs SHA-384 digest on a data buffer of the specified size.
1890 It can be called multiple times to compute the digest of long or discontinuous data streams.
1891 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized
1892 by Sha384Final(). Behavior with invalid context is undefined.
1893
1894 If Sha384Context is NULL, then return FALSE.
1895
1896 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1897 @param[in] Data Pointer to the buffer containing the data to be hashed.
1898 @param[in] DataSize Size of Data buffer in bytes.
1899
1900 @retval TRUE SHA-384 data digest succeeded.
1901 @retval FALSE SHA-384 data digest failed.
1902
1903 **/
1904 typedef
1905 BOOLEAN
1906 (EFIAPI *EDKII_CRYPTO_SHA384_UPDATE)(
1907 IN OUT VOID *Sha384Context,
1908 IN CONST VOID *Data,
1909 IN UINTN DataSize
1910 );
1911
1912 /**
1913 Completes computation of the SHA-384 digest value.
1914
1915 This function completes SHA-384 hash computation and retrieves the digest value into
1916 the specified memory. After this function has been called, the SHA-384 context cannot
1917 be used again.
1918 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be
1919 finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.
1920
1921 If Sha384Context is NULL, then return FALSE.
1922 If HashValue is NULL, then return FALSE.
1923
1924 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1925 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1926 value (48 bytes).
1927
1928 @retval TRUE SHA-384 digest computation succeeded.
1929 @retval FALSE SHA-384 digest computation failed.
1930
1931 **/
1932 typedef
1933 BOOLEAN
1934 (EFIAPI *EDKII_CRYPTO_SHA384_FINAL)(
1935 IN OUT VOID *Sha384Context,
1936 OUT UINT8 *HashValue
1937 );
1938
1939 /**
1940 Computes the SHA-384 message digest of a input data buffer.
1941
1942 This function performs the SHA-384 message digest of a given data buffer, and places
1943 the digest value into the specified memory.
1944
1945 If this interface is not supported, then return FALSE.
1946
1947 @param[in] Data Pointer to the buffer containing the data to be hashed.
1948 @param[in] DataSize Size of Data buffer in bytes.
1949 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1950 value (48 bytes).
1951
1952 @retval TRUE SHA-384 digest computation succeeded.
1953 @retval FALSE SHA-384 digest computation failed.
1954 @retval FALSE This interface is not supported.
1955
1956 **/
1957 typedef
1958 BOOLEAN
1959 (EFIAPI *EDKII_CRYPTO_SHA384_HASH_ALL)(
1960 IN CONST VOID *Data,
1961 IN UINTN DataSize,
1962 OUT UINT8 *HashValue
1963 );
1964
1965 /**
1966 Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.
1967
1968 @return The size, in bytes, of the context buffer required for SHA-512 hash operations.
1969
1970 **/
1971 typedef
1972 UINTN
1973 (EFIAPI *EDKII_CRYPTO_SHA512_GET_CONTEXT_SIZE)(
1974 VOID
1975 );
1976
1977 /**
1978 Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for
1979 subsequent use.
1980
1981 If Sha512Context is NULL, then return FALSE.
1982
1983 @param[out] Sha512Context Pointer to SHA-512 context being initialized.
1984
1985 @retval TRUE SHA-512 context initialization succeeded.
1986 @retval FALSE SHA-512 context initialization failed.
1987
1988 **/
1989 typedef
1990 BOOLEAN
1991 (EFIAPI *EDKII_CRYPTO_SHA512_INIT)(
1992 OUT VOID *Sha512Context
1993 );
1994
1995 /**
1996 Makes a copy of an existing SHA-512 context.
1997
1998 If Sha512Context is NULL, then return FALSE.
1999 If NewSha512Context is NULL, then return FALSE.
2000 If this interface is not supported, then return FALSE.
2001
2002 @param[in] Sha512Context Pointer to SHA-512 context being copied.
2003 @param[out] NewSha512Context Pointer to new SHA-512 context.
2004
2005 @retval TRUE SHA-512 context copy succeeded.
2006 @retval FALSE SHA-512 context copy failed.
2007 @retval FALSE This interface is not supported.
2008
2009 **/
2010 typedef
2011 BOOLEAN
2012 (EFIAPI *EDKII_CRYPTO_SHA512_DUPLICATE)(
2013 IN CONST VOID *Sha512Context,
2014 OUT VOID *NewSha512Context
2015 );
2016
2017 /**
2018 Digests the input data and updates SHA-512 context.
2019
2020 This function performs SHA-512 digest on a data buffer of the specified size.
2021 It can be called multiple times to compute the digest of long or discontinuous data streams.
2022 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized
2023 by Sha512Final(). Behavior with invalid context is undefined.
2024
2025 If Sha512Context is NULL, then return FALSE.
2026
2027 @param[in, out] Sha512Context Pointer to the SHA-512 context.
2028 @param[in] Data Pointer to the buffer containing the data to be hashed.
2029 @param[in] DataSize Size of Data buffer in bytes.
2030
2031 @retval TRUE SHA-512 data digest succeeded.
2032 @retval FALSE SHA-512 data digest failed.
2033
2034 **/
2035 typedef
2036 BOOLEAN
2037 (EFIAPI *EDKII_CRYPTO_SHA512_UPDATE)(
2038 IN OUT VOID *Sha512Context,
2039 IN CONST VOID *Data,
2040 IN UINTN DataSize
2041 );
2042
2043 /**
2044 Completes computation of the SHA-512 digest value.
2045
2046 This function completes SHA-512 hash computation and retrieves the digest value into
2047 the specified memory. After this function has been called, the SHA-512 context cannot
2048 be used again.
2049 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be
2050 finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.
2051
2052 If Sha512Context is NULL, then return FALSE.
2053 If HashValue is NULL, then return FALSE.
2054
2055 @param[in, out] Sha512Context Pointer to the SHA-512 context.
2056 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
2057 value (64 bytes).
2058
2059 @retval TRUE SHA-512 digest computation succeeded.
2060 @retval FALSE SHA-512 digest computation failed.
2061
2062 **/
2063 typedef
2064 BOOLEAN
2065 (EFIAPI *EDKII_CRYPTO_SHA512_FINAL)(
2066 IN OUT VOID *Sha512Context,
2067 OUT UINT8 *HashValue
2068 );
2069
2070 /**
2071 Computes the SHA-512 message digest of a input data buffer.
2072
2073 This function performs the SHA-512 message digest of a given data buffer, and places
2074 the digest value into the specified memory.
2075
2076 If this interface is not supported, then return FALSE.
2077
2078 @param[in] Data Pointer to the buffer containing the data to be hashed.
2079 @param[in] DataSize Size of Data buffer in bytes.
2080 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
2081 value (64 bytes).
2082
2083 @retval TRUE SHA-512 digest computation succeeded.
2084 @retval FALSE SHA-512 digest computation failed.
2085 @retval FALSE This interface is not supported.
2086
2087 **/
2088 typedef
2089 BOOLEAN
2090 (EFIAPI *EDKII_CRYPTO_SHA512_HASH_ALL)(
2091 IN CONST VOID *Data,
2092 IN UINTN DataSize,
2093 OUT UINT8 *HashValue
2094 );
2095
2096 // ----------------------------------------------------------------------------
2097 // X509
2098 // ----------------------------------------------------------------------------
2099
2100 /**
2101 Retrieve the subject bytes from one X.509 certificate.
2102
2103 If Cert is NULL, then return FALSE.
2104 If SubjectSize is NULL, then return FALSE.
2105 If this interface is not supported, then return FALSE.
2106
2107 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2108 @param[in] CertSize Size of the X509 certificate in bytes.
2109 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.
2110 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,
2111 and the size of buffer returned CertSubject on output.
2112
2113 @retval TRUE The certificate subject retrieved successfully.
2114 @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.
2115 The SubjectSize will be updated with the required size.
2116 @retval FALSE This interface is not supported.
2117
2118 **/
2119 typedef
2120 BOOLEAN
2121 (EFIAPI *EDKII_CRYPTO_X509_GET_SUBJECT_NAME)(
2122 IN CONST UINT8 *Cert,
2123 IN UINTN CertSize,
2124 OUT UINT8 *CertSubject,
2125 IN OUT UINTN *SubjectSize
2126 );
2127
2128 /**
2129 Retrieve the common name (CN) string from one X.509 certificate.
2130
2131 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2132 @param[in] CertSize Size of the X509 certificate in bytes.
2133 @param[out] CommonName Buffer to contain the retrieved certificate common
2134 name string (UTF8). At most CommonNameSize bytes will be
2135 written and the string will be null terminated. May be
2136 NULL in order to determine the size buffer needed.
2137 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
2138 and the size of buffer returned CommonName on output.
2139 If CommonName is NULL then the amount of space needed
2140 in buffer (including the final null) is returned.
2141
2142 @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.
2143 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2144 If CommonNameSize is NULL.
2145 If CommonName is not NULL and *CommonNameSize is 0.
2146 If Certificate is invalid.
2147 @retval RETURN_NOT_FOUND If no CommonName entry exists.
2148 @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
2149 (including the final null) is returned in the
2150 CommonNameSize parameter.
2151 @retval RETURN_UNSUPPORTED The operation is not supported.
2152
2153 **/
2154 typedef
2155 EFI_STATUS
2156 (EFIAPI *EDKII_CRYPTO_X509_GET_COMMON_NAME)(
2157 IN CONST UINT8 *Cert,
2158 IN UINTN CertSize,
2159 OUT CHAR8 *CommonName OPTIONAL,
2160 IN OUT UINTN *CommonNameSize
2161 );
2162
2163 /**
2164 Retrieve the organization name (O) string from one X.509 certificate.
2165
2166 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2167 @param[in] CertSize Size of the X509 certificate in bytes.
2168 @param[out] NameBuffer Buffer to contain the retrieved certificate organization
2169 name string. At most NameBufferSize bytes will be
2170 written and the string will be null terminated. May be
2171 NULL in order to determine the size buffer needed.
2172 @param[in,out] NameBufferSiz e The size in bytes of the Name buffer on input,
2173 and the size of buffer returned Name on output.
2174 If NameBuffer is NULL then the amount of space needed
2175 in buffer (including the final null) is returned.
2176
2177 @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.
2178 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2179 If NameBufferSize is NULL.
2180 If NameBuffer is not NULL and *CommonNameSize is 0.
2181 If Certificate is invalid.
2182 @retval RETURN_NOT_FOUND If no Organization Name entry exists.
2183 @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size
2184 (including the final null) is returned in the
2185 CommonNameSize parameter.
2186 @retval RETURN_UNSUPPORTED The operation is not supported.
2187
2188 **/
2189 typedef
2190 EFI_STATUS
2191 (EFIAPI *EDKII_CRYPTO_X509_GET_ORGANIZATION_NAME)(
2192 IN CONST UINT8 *Cert,
2193 IN UINTN CertSize,
2194 OUT CHAR8 *NameBuffer OPTIONAL,
2195 IN OUT UINTN *NameBufferSize
2196 );
2197
2198 /**
2199 Verify one X509 certificate was issued by the trusted CA.
2200
2201 If Cert is NULL, then return FALSE.
2202 If CACert is NULL, then return FALSE.
2203 If this interface is not supported, then return FALSE.
2204
2205 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.
2206 @param[in] CertSize Size of the X509 certificate in bytes.
2207 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.
2208 @param[in] CACertSize Size of the CA Certificate in bytes.
2209
2210 @retval TRUE The certificate was issued by the trusted CA.
2211 @retval FALSE Invalid certificate or the certificate was not issued by the given
2212 trusted CA.
2213 @retval FALSE This interface is not supported.
2214
2215 **/
2216 typedef
2217 BOOLEAN
2218 (EFIAPI *EDKII_CRYPTO_X509_VERIFY_CERT)(
2219 IN CONST UINT8 *Cert,
2220 IN UINTN CertSize,
2221 IN CONST UINT8 *CACert,
2222 IN UINTN CACertSize
2223 );
2224
2225 /**
2226 Construct a X509 object from DER-encoded certificate data.
2227
2228 If Cert is NULL, then return FALSE.
2229 If SingleX509Cert is NULL, then return FALSE.
2230 If this interface is not supported, then return FALSE.
2231
2232 @param[in] Cert Pointer to the DER-encoded certificate data.
2233 @param[in] CertSize The size of certificate data in bytes.
2234 @param[out] SingleX509Cert The generated X509 object.
2235
2236 @retval TRUE The X509 object generation succeeded.
2237 @retval FALSE The operation failed.
2238 @retval FALSE This interface is not supported.
2239
2240 **/
2241 typedef
2242 BOOLEAN
2243 (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE)(
2244 IN CONST UINT8 *Cert,
2245 IN UINTN CertSize,
2246 OUT UINT8 **SingleX509Cert
2247 );
2248
2249 /**
2250 Construct a X509 stack object from a list of DER-encoded certificate data.
2251
2252 If X509Stack is NULL, then return FALSE.
2253 If this interface is not supported, then return FALSE.
2254
2255 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2256 On output, pointer to the X509 stack object with new
2257 inserted X509 certificate.
2258 @param ... A list of DER-encoded single certificate data followed
2259 by certificate size. A NULL terminates the list. The
2260 pairs are the arguments to X509ConstructCertificate().
2261
2262 @retval TRUE The X509 stack construction succeeded.
2263 @retval FALSE The construction operation failed.
2264 @retval FALSE This interface is not supported.
2265
2266 **/
2267 typedef
2268 BOOLEAN
2269 (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK)(
2270 IN OUT UINT8 **X509Stack,
2271 ...
2272 );
2273
2274 /**
2275 Construct a X509 stack object from a list of DER-encoded certificate data.
2276
2277 If X509Stack is NULL, then return FALSE.
2278 If this interface is not supported, then return FALSE.
2279
2280 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2281 On output, pointer to the X509 stack object with new
2282 inserted X509 certificate.
2283 @param[in] Args VA_LIST marker for the variable argument list.
2284 A list of DER-encoded single certificate data followed
2285 by certificate size. A NULL terminates the list. The
2286 pairs are the arguments to X509ConstructCertificate().
2287
2288 @retval TRUE The X509 stack construction succeeded.
2289 @retval FALSE The construction operation failed.
2290 @retval FALSE This interface is not supported.
2291
2292 **/
2293 typedef
2294 BOOLEAN
2295 (EFIAPI *EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK_V)(
2296 IN OUT UINT8 **X509Stack,
2297 IN VA_LIST Args
2298 );
2299
2300 /**
2301 Release the specified X509 object.
2302
2303 If the interface is not supported, then ASSERT().
2304
2305 @param[in] X509Cert Pointer to the X509 object to be released.
2306
2307 **/
2308 typedef
2309 VOID
2310 (EFIAPI *EDKII_CRYPTO_X509_FREE)(
2311 IN VOID *X509Cert
2312 );
2313
2314 /**
2315 Release the specified X509 stack object.
2316
2317 If the interface is not supported, then ASSERT().
2318
2319 @param[in] X509Stack Pointer to the X509 stack object to be released.
2320
2321 **/
2322 typedef
2323 VOID
2324 (EFIAPI *EDKII_CRYPTO_X509_STACK_FREE)(
2325 IN VOID *X509Stack
2326 );
2327
2328 /**
2329 Retrieve the TBSCertificate from one given X.509 certificate.
2330
2331 @param[in] Cert Pointer to the given DER-encoded X509 certificate.
2332 @param[in] CertSize Size of the X509 certificate in bytes.
2333 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.
2334 @param[out] TBSCertSize Size of the TBS certificate in bytes.
2335
2336 If Cert is NULL, then return FALSE.
2337 If TBSCert is NULL, then return FALSE.
2338 If TBSCertSize is NULL, then return FALSE.
2339 If this interface is not supported, then return FALSE.
2340
2341 @retval TRUE The TBSCertificate was retrieved successfully.
2342 @retval FALSE Invalid X.509 certificate.
2343
2344 **/
2345 typedef
2346 BOOLEAN
2347 (EFIAPI *EDKII_CRYPTO_X509_GET_TBS_CERT)(
2348 IN CONST UINT8 *Cert,
2349 IN UINTN CertSize,
2350 OUT UINT8 **TBSCert,
2351 OUT UINTN *TBSCertSize
2352 );
2353
2354 // =====================================================================================
2355 // Symmetric Cryptography Primitive
2356 // =====================================================================================
2357
2358 /**
2359 TDES is deprecated and unsupported any longer.
2360 Keep the function field for binary compability.
2361
2362 **/
2363 typedef
2364 UINTN
2365 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_GET_CONTEXT_SIZE)(
2366 VOID
2367 );
2368
2369 typedef
2370 BOOLEAN
2371 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_INIT)(
2372 OUT VOID *TdesContext,
2373 IN CONST UINT8 *Key,
2374 IN UINTN KeyLength
2375 );
2376
2377 typedef
2378 BOOLEAN
2379 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_ECB_ENCRYPT)(
2380 IN VOID *TdesContext,
2381 IN CONST UINT8 *Input,
2382 IN UINTN InputSize,
2383 OUT UINT8 *Output
2384 );
2385
2386 typedef
2387 BOOLEAN
2388 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_ECB_DECRYPT)(
2389 IN VOID *TdesContext,
2390 IN CONST UINT8 *Input,
2391 IN UINTN InputSize,
2392 OUT UINT8 *Output
2393 );
2394
2395 typedef
2396 BOOLEAN
2397 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_CBC_ENCRYPT)(
2398 IN VOID *TdesContext,
2399 IN CONST UINT8 *Input,
2400 IN UINTN InputSize,
2401 IN CONST UINT8 *Ivec,
2402 OUT UINT8 *Output
2403 );
2404
2405 typedef
2406 BOOLEAN
2407 (EFIAPI *DEPRECATED_EDKII_CRYPTO_TDES_CBC_DECRYPT)(
2408 IN VOID *TdesContext,
2409 IN CONST UINT8 *Input,
2410 IN UINTN InputSize,
2411 IN CONST UINT8 *Ivec,
2412 OUT UINT8 *Output
2413 );
2414
2415 /**
2416 Retrieves the size, in bytes, of the context buffer required for AES operations.
2417
2418 If this interface is not supported, then return zero.
2419
2420 @return The size, in bytes, of the context buffer required for AES operations.
2421 @retval 0 This interface is not supported.
2422
2423 **/
2424 typedef
2425 UINTN
2426 (EFIAPI *EDKII_CRYPTO_AES_GET_CONTEXT_SIZE)(
2427 VOID
2428 );
2429
2430 /**
2431 Initializes user-supplied memory as AES context for subsequent use.
2432
2433 This function initializes user-supplied memory pointed by AesContext as AES context.
2434 In addition, it sets up all AES key materials for subsequent encryption and decryption
2435 operations.
2436 There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
2437
2438 If AesContext is NULL, then return FALSE.
2439 If Key is NULL, then return FALSE.
2440 If KeyLength is not valid, then return FALSE.
2441 If this interface is not supported, then return FALSE.
2442
2443 @param[out] AesContext Pointer to AES context being initialized.
2444 @param[in] Key Pointer to the user-supplied AES key.
2445 @param[in] KeyLength Length of AES key in bits.
2446
2447 @retval TRUE AES context initialization succeeded.
2448 @retval FALSE AES context initialization failed.
2449 @retval FALSE This interface is not supported.
2450
2451 **/
2452 typedef
2453 BOOLEAN
2454 (EFIAPI *EDKII_CRYPTO_AES_INIT)(
2455 OUT VOID *AesContext,
2456 IN CONST UINT8 *Key,
2457 IN UINTN KeyLength
2458 );
2459
2460 /**
2461 AES ECB Mode is deprecated and unsupported any longer.
2462 Keep the function field for binary compability.
2463
2464 **/
2465 typedef
2466 BOOLEAN
2467 (EFIAPI *DEPRECATED_EDKII_CRYPTO_AES_ECB_ENCRYPT)(
2468 IN VOID *AesContext,
2469 IN CONST UINT8 *Input,
2470 IN UINTN InputSize,
2471 OUT UINT8 *Output
2472 );
2473
2474 typedef
2475 BOOLEAN
2476 (EFIAPI *DEPRECATED_EDKII_CRYPTO_AES_ECB_DECRYPT)(
2477 IN VOID *AesContext,
2478 IN CONST UINT8 *Input,
2479 IN UINTN InputSize,
2480 OUT UINT8 *Output
2481 );
2482
2483 /**
2484 Performs AES encryption on a data buffer of the specified size in CBC mode.
2485
2486 This function performs AES encryption on data buffer pointed by Input, of specified
2487 size of InputSize, in CBC mode.
2488 InputSize must be multiple of block size (16 bytes). This function does not perform
2489 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2490 Initialization vector should be one block size (16 bytes).
2491 AesContext should be already correctly initialized by AesInit(). Behavior with
2492 invalid AES context is undefined.
2493
2494 If AesContext is NULL, then return FALSE.
2495 If Input is NULL, then return FALSE.
2496 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2497 If Ivec is NULL, then return FALSE.
2498 If Output is NULL, then return FALSE.
2499 If this interface is not supported, then return FALSE.
2500
2501 @param[in] AesContext Pointer to the AES context.
2502 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2503 @param[in] InputSize Size of the Input buffer in bytes.
2504 @param[in] Ivec Pointer to initialization vector.
2505 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2506
2507 @retval TRUE AES encryption succeeded.
2508 @retval FALSE AES encryption failed.
2509 @retval FALSE This interface is not supported.
2510
2511 **/
2512 typedef
2513 BOOLEAN
2514 (EFIAPI *EDKII_CRYPTO_AES_CBC_ENCRYPT)(
2515 IN VOID *AesContext,
2516 IN CONST UINT8 *Input,
2517 IN UINTN InputSize,
2518 IN CONST UINT8 *Ivec,
2519 OUT UINT8 *Output
2520 );
2521
2522 /**
2523 Performs AES decryption on a data buffer of the specified size in CBC mode.
2524
2525 This function performs AES decryption on data buffer pointed by Input, of specified
2526 size of InputSize, in CBC mode.
2527 InputSize must be multiple of block size (16 bytes). This function does not perform
2528 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2529 Initialization vector should be one block size (16 bytes).
2530 AesContext should be already correctly initialized by AesInit(). Behavior with
2531 invalid AES context is undefined.
2532
2533 If AesContext is NULL, then return FALSE.
2534 If Input is NULL, then return FALSE.
2535 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2536 If Ivec is NULL, then return FALSE.
2537 If Output is NULL, then return FALSE.
2538 If this interface is not supported, then return FALSE.
2539
2540 @param[in] AesContext Pointer to the AES context.
2541 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2542 @param[in] InputSize Size of the Input buffer in bytes.
2543 @param[in] Ivec Pointer to initialization vector.
2544 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2545
2546 @retval TRUE AES decryption succeeded.
2547 @retval FALSE AES decryption failed.
2548 @retval FALSE This interface is not supported.
2549
2550 **/
2551 typedef
2552 BOOLEAN
2553 (EFIAPI *EDKII_CRYPTO_AES_CBC_DECRYPT)(
2554 IN VOID *AesContext,
2555 IN CONST UINT8 *Input,
2556 IN UINTN InputSize,
2557 IN CONST UINT8 *Ivec,
2558 OUT UINT8 *Output
2559 );
2560
2561 /**
2562 ARC4 is deprecated and unsupported any longer.
2563 Keep the function field for binary compability.
2564
2565 **/
2566 typedef
2567 UINTN
2568 (EFIAPI *DEPRECATED_EDKII_CRYPTO_ARC4_GET_CONTEXT_SIZE)(
2569 VOID
2570 );
2571
2572 typedef
2573 BOOLEAN
2574 (EFIAPI *DEPRECATED_EDKII_CRYPTO_ARC4_INIT)(
2575 OUT VOID *Arc4Context,
2576 IN CONST UINT8 *Key,
2577 IN UINTN KeySize
2578 );
2579
2580 typedef
2581 BOOLEAN
2582 (EFIAPI *DEPRECATED_EDKII_CRYPTO_ARC4_ENCRYPT)(
2583 IN OUT VOID *Arc4Context,
2584 IN CONST UINT8 *Input,
2585 IN UINTN InputSize,
2586 OUT UINT8 *Output
2587 );
2588
2589 typedef
2590 BOOLEAN
2591 (EFIAPI *DEPRECATED_EDKII_CRYPTO_ARC4_DECRYPT)(
2592 IN OUT VOID *Arc4Context,
2593 IN UINT8 *Input,
2594 IN UINTN InputSize,
2595 OUT UINT8 *Output
2596 );
2597
2598 typedef
2599 BOOLEAN
2600 (EFIAPI *DEPRECATED_EDKII_CRYPTO_ARC4_RESET)(
2601 IN OUT VOID *Arc4Context
2602 );
2603
2604 /**
2605 Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.
2606
2607 If this interface is not supported, then return zero.
2608
2609 @return The size, in bytes, of the context buffer required for SM3 hash operations.
2610 @retval 0 This interface is not supported.
2611
2612 **/
2613 typedef
2614 UINTN
2615 (EFIAPI *EDKII_CRYPTO_SM3_GET_CONTEXT_SIZE)(
2616 VOID
2617 );
2618
2619 /**
2620 Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for
2621 subsequent use.
2622
2623 If Sm3Context is NULL, then return FALSE.
2624 If this interface is not supported, then return FALSE.
2625
2626 @param[out] Sm3Context Pointer to SM3 context being initialized.
2627
2628 @retval TRUE SM3 context initialization succeeded.
2629 @retval FALSE SM3 context initialization failed.
2630 @retval FALSE This interface is not supported.
2631
2632 **/
2633 typedef
2634 BOOLEAN
2635 (EFIAPI *EDKII_CRYPTO_SM3_INIT)(
2636 OUT VOID *Sm3Context
2637 );
2638
2639 /**
2640 Makes a copy of an existing SM3 context.
2641
2642 If Sm3Context is NULL, then return FALSE.
2643 If NewSm3Context is NULL, then return FALSE.
2644 If this interface is not supported, then return FALSE.
2645
2646 @param[in] Sm3Context Pointer to SM3 context being copied.
2647 @param[out] NewSm3Context Pointer to new SM3 context.
2648
2649 @retval TRUE SM3 context copy succeeded.
2650 @retval FALSE SM3 context copy failed.
2651 @retval FALSE This interface is not supported.
2652
2653 **/
2654 typedef
2655 BOOLEAN
2656 (EFIAPI *EDKII_CRYPTO_SM3_DUPLICATE)(
2657 IN CONST VOID *Sm3Context,
2658 OUT VOID *NewSm3Context
2659 );
2660
2661 /**
2662 Digests the input data and updates SM3 context.
2663
2664 This function performs SM3 digest on a data buffer of the specified size.
2665 It can be called multiple times to compute the digest of long or discontinuous data streams.
2666 SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized
2667 by Sm3Final(). Behavior with invalid context is undefined.
2668
2669 If Sm3Context is NULL, then return FALSE.
2670 If this interface is not supported, then return FALSE.
2671
2672 @param[in, out] Sm3Context Pointer to the SM3 context.
2673 @param[in] Data Pointer to the buffer containing the data to be hashed.
2674 @param[in] DataSize Size of Data buffer in bytes.
2675
2676 @retval TRUE SM3 data digest succeeded.
2677 @retval FALSE SM3 data digest failed.
2678 @retval FALSE This interface is not supported.
2679
2680 **/
2681 typedef
2682 BOOLEAN
2683 (EFIAPI *EDKII_CRYPTO_SM3_UPDATE)(
2684 IN OUT VOID *Sm3Context,
2685 IN CONST VOID *Data,
2686 IN UINTN DataSize
2687 );
2688
2689 /**
2690 Completes computation of the SM3 digest value.
2691
2692 This function completes SM3 hash computation and retrieves the digest value into
2693 the specified memory. After this function has been called, the SM3 context cannot
2694 be used again.
2695 SM3 context should be already correctly initialized by Sm3Init(), and should not be
2696 finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.
2697
2698 If Sm3Context is NULL, then return FALSE.
2699 If HashValue is NULL, then return FALSE.
2700 If this interface is not supported, then return FALSE.
2701
2702 @param[in, out] Sm3Context Pointer to the SM3 context.
2703 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
2704 value (16 bytes).
2705
2706 @retval TRUE SM3 digest computation succeeded.
2707 @retval FALSE SM3 digest computation failed.
2708 @retval FALSE This interface is not supported.
2709
2710 **/
2711 typedef
2712 BOOLEAN
2713 (EFIAPI *EDKII_CRYPTO_SM3_FINAL)(
2714 IN OUT VOID *Sm3Context,
2715 OUT UINT8 *HashValue
2716 );
2717
2718 /**
2719 Computes the SM3 message digest of a input data buffer.
2720
2721 This function performs the SM3 message digest of a given data buffer, and places
2722 the digest value into the specified memory.
2723
2724 If this interface is not supported, then return FALSE.
2725
2726 @param[in] Data Pointer to the buffer containing the data to be hashed.
2727 @param[in] DataSize Size of Data buffer in bytes.
2728 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
2729 value (16 bytes).
2730
2731 @retval TRUE SM3 digest computation succeeded.
2732 @retval FALSE SM3 digest computation failed.
2733 @retval FALSE This interface is not supported.
2734
2735 **/
2736 typedef
2737 BOOLEAN
2738 (EFIAPI *EDKII_CRYPTO_SM3_HASH_ALL)(
2739 IN CONST VOID *Data,
2740 IN UINTN DataSize,
2741 OUT UINT8 *HashValue
2742 );
2743
2744 /**
2745 Derive key data using HMAC-SHA256 based KDF.
2746
2747 @param[in] Key Pointer to the user-supplied key.
2748 @param[in] KeySize Key size in bytes.
2749 @param[in] Salt Pointer to the salt(non-secret) value.
2750 @param[in] SaltSize Salt size in bytes.
2751 @param[in] Info Pointer to the application specific info.
2752 @param[in] InfoSize Info size in bytes.
2753 @param[out] Out Pointer to buffer to receive hkdf value.
2754 @param[in] OutSize Size of hkdf bytes to generate.
2755
2756 @retval TRUE Hkdf generated successfully.
2757 @retval FALSE Hkdf generation failed.
2758
2759 **/
2760 typedef
2761 BOOLEAN
2762 (EFIAPI *EDKII_CRYPTO_HKDF_SHA_256_EXTRACT_AND_EXPAND)(
2763 IN CONST UINT8 *Key,
2764 IN UINTN KeySize,
2765 IN CONST UINT8 *Salt,
2766 IN UINTN SaltSize,
2767 IN CONST UINT8 *Info,
2768 IN UINTN InfoSize,
2769 OUT UINT8 *Out,
2770 IN UINTN OutSize
2771 );
2772
2773 /**
2774 Initializes the OpenSSL library.
2775
2776 This function registers ciphers and digests used directly and indirectly
2777 by SSL/TLS, and initializes the readable error messages.
2778 This function must be called before any other action takes places.
2779
2780 @retval TRUE The OpenSSL library has been initialized.
2781 @retval FALSE Failed to initialize the OpenSSL library.
2782
2783 **/
2784 typedef
2785 BOOLEAN
2786 (EFIAPI *EDKII_CRYPTO_TLS_INITIALIZE)(
2787 VOID
2788 );
2789
2790 /**
2791 Free an allocated SSL_CTX object.
2792
2793 @param[in] TlsCtx Pointer to the SSL_CTX object to be released.
2794
2795 **/
2796 typedef
2797 VOID
2798 (EFIAPI *EDKII_CRYPTO_TLS_CTX_FREE)(
2799 IN VOID *TlsCtx
2800 );
2801
2802 /**
2803 Creates a new SSL_CTX object as framework to establish TLS/SSL enabled
2804 connections.
2805
2806 @param[in] MajorVer Major Version of TLS/SSL Protocol.
2807 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
2808
2809 @return Pointer to an allocated SSL_CTX object.
2810 If the creation failed, TlsCtxNew() returns NULL.
2811
2812 **/
2813 typedef
2814 VOID *
2815 (EFIAPI *EDKII_CRYPTO_TLS_CTX_NEW)(
2816 IN UINT8 MajorVer,
2817 IN UINT8 MinorVer
2818 );
2819
2820 /**
2821 Free an allocated TLS object.
2822
2823 This function removes the TLS object pointed to by Tls and frees up the
2824 allocated memory. If Tls is NULL, nothing is done.
2825
2826 @param[in] Tls Pointer to the TLS object to be freed.
2827
2828 **/
2829 typedef
2830 VOID
2831 (EFIAPI *EDKII_CRYPTO_TLS_FREE)(
2832 IN VOID *Tls
2833 );
2834
2835 /**
2836 Create a new TLS object for a connection.
2837
2838 This function creates a new TLS object for a connection. The new object
2839 inherits the setting of the underlying context TlsCtx: connection method,
2840 options, verification setting.
2841
2842 @param[in] TlsCtx Pointer to the SSL_CTX object.
2843
2844 @return Pointer to an allocated SSL object.
2845 If the creation failed, TlsNew() returns NULL.
2846
2847 **/
2848 typedef
2849 VOID *
2850 (EFIAPI *EDKII_CRYPTO_TLS_NEW)(
2851 IN VOID *TlsCtx
2852 );
2853
2854 /**
2855 Checks if the TLS handshake was done.
2856
2857 This function will check if the specified TLS handshake was done.
2858
2859 @param[in] Tls Pointer to the TLS object for handshake state checking.
2860
2861 @retval TRUE The TLS handshake was done.
2862 @retval FALSE The TLS handshake was not done.
2863
2864 **/
2865 typedef
2866 BOOLEAN
2867 (EFIAPI *EDKII_CRYPTO_TLS_IN_HANDSHAKE)(
2868 IN VOID *Tls
2869 );
2870
2871 /**
2872 Perform a TLS/SSL handshake.
2873
2874 This function will perform a TLS/SSL handshake.
2875
2876 @param[in] Tls Pointer to the TLS object for handshake operation.
2877 @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
2878 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
2879 Handshake packet.
2880 @param[out] BufferOut Pointer to the buffer to hold the built packet.
2881 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
2882 the buffer size provided by the caller. On output, it
2883 is the buffer size in fact needed to contain the
2884 packet.
2885
2886 @retval EFI_SUCCESS The required TLS packet is built successfully.
2887 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
2888 Tls is NULL.
2889 BufferIn is NULL but BufferInSize is NOT 0.
2890 BufferInSize is 0 but BufferIn is NOT NULL.
2891 BufferOutSize is NULL.
2892 BufferOut is NULL if *BufferOutSize is not zero.
2893 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
2894 @retval EFI_ABORTED Something wrong during handshake.
2895
2896 **/
2897 typedef
2898 EFI_STATUS
2899 (EFIAPI *EDKII_CRYPTO_TLS_DO_HANDSHAKE)(
2900 IN VOID *Tls,
2901 IN UINT8 *BufferIn OPTIONAL,
2902 IN UINTN BufferInSize OPTIONAL,
2903 OUT UINT8 *BufferOut OPTIONAL,
2904 IN OUT UINTN *BufferOutSize
2905 );
2906
2907 /**
2908 Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
2909 TLS session has errors and the response packet needs to be Alert message based on error type.
2910
2911 @param[in] Tls Pointer to the TLS object for state checking.
2912 @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
2913 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
2914 Alert packet.
2915 @param[out] BufferOut Pointer to the buffer to hold the built packet.
2916 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
2917 the buffer size provided by the caller. On output, it
2918 is the buffer size in fact needed to contain the
2919 packet.
2920
2921 @retval EFI_SUCCESS The required TLS packet is built successfully.
2922 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
2923 Tls is NULL.
2924 BufferIn is NULL but BufferInSize is NOT 0.
2925 BufferInSize is 0 but BufferIn is NOT NULL.
2926 BufferOutSize is NULL.
2927 BufferOut is NULL if *BufferOutSize is not zero.
2928 @retval EFI_ABORTED An error occurred.
2929 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
2930
2931 **/
2932 typedef
2933 EFI_STATUS
2934 (EFIAPI *EDKII_CRYPTO_TLS_HANDLE_ALERT)(
2935 IN VOID *Tls,
2936 IN UINT8 *BufferIn OPTIONAL,
2937 IN UINTN BufferInSize OPTIONAL,
2938 OUT UINT8 *BufferOut OPTIONAL,
2939 IN OUT UINTN *BufferOutSize
2940 );
2941
2942 /**
2943 Build the CloseNotify packet.
2944
2945 @param[in] Tls Pointer to the TLS object for state checking.
2946 @param[in, out] Buffer Pointer to the buffer to hold the built packet.
2947 @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
2948 the buffer size provided by the caller. On output, it
2949 is the buffer size in fact needed to contain the
2950 packet.
2951
2952 @retval EFI_SUCCESS The required TLS packet is built successfully.
2953 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
2954 Tls is NULL.
2955 BufferSize is NULL.
2956 Buffer is NULL if *BufferSize is not zero.
2957 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
2958
2959 **/
2960 typedef
2961 EFI_STATUS
2962 (EFIAPI *EDKII_CRYPTO_TLS_CLOSE_NOTIFY)(
2963 IN VOID *Tls,
2964 IN OUT UINT8 *Buffer,
2965 IN OUT UINTN *BufferSize
2966 );
2967
2968 /**
2969 Attempts to read bytes from one TLS object and places the data in Buffer.
2970
2971 This function will attempt to read BufferSize bytes from the TLS object
2972 and places the data in Buffer.
2973
2974 @param[in] Tls Pointer to the TLS object.
2975 @param[in,out] Buffer Pointer to the buffer to store the data.
2976 @param[in] BufferSize The size of Buffer in bytes.
2977
2978 @retval >0 The amount of data successfully read from the TLS object.
2979 @retval <=0 No data was successfully read.
2980
2981 **/
2982 typedef
2983 INTN
2984 (EFIAPI *EDKII_CRYPTO_TLS_CTRL_TRAFFIC_OUT)(
2985 IN VOID *Tls,
2986 IN OUT VOID *Buffer,
2987 IN UINTN BufferSize
2988 );
2989
2990 /**
2991 Attempts to write data from the buffer to TLS object.
2992
2993 This function will attempt to write BufferSize bytes data from the Buffer
2994 to the TLS object.
2995
2996 @param[in] Tls Pointer to the TLS object.
2997 @param[in] Buffer Pointer to the data buffer.
2998 @param[in] BufferSize The size of Buffer in bytes.
2999
3000 @retval >0 The amount of data successfully written to the TLS object.
3001 @retval <=0 No data was successfully written.
3002
3003 **/
3004 typedef
3005 INTN
3006 (EFIAPI *EDKII_CRYPTO_TLS_CTRL_TRAFFIC_IN)(
3007 IN VOID *Tls,
3008 IN VOID *Buffer,
3009 IN UINTN BufferSize
3010 );
3011
3012 /**
3013 Attempts to read bytes from the specified TLS connection into the buffer.
3014
3015 This function tries to read BufferSize bytes data from the specified TLS
3016 connection into the Buffer.
3017
3018 @param[in] Tls Pointer to the TLS connection for data reading.
3019 @param[in,out] Buffer Pointer to the data buffer.
3020 @param[in] BufferSize The size of Buffer in bytes.
3021
3022 @retval >0 The read operation was successful, and return value is the
3023 number of bytes actually read from the TLS connection.
3024 @retval <=0 The read operation was not successful.
3025
3026 **/
3027 typedef
3028 INTN
3029 (EFIAPI *EDKII_CRYPTO_TLS_READ)(
3030 IN VOID *Tls,
3031 IN OUT VOID *Buffer,
3032 IN UINTN BufferSize
3033 );
3034
3035 /**
3036 Attempts to write data to a TLS connection.
3037
3038 This function tries to write BufferSize bytes data from the Buffer into the
3039 specified TLS connection.
3040
3041 @param[in] Tls Pointer to the TLS connection for data writing.
3042 @param[in] Buffer Pointer to the data buffer.
3043 @param[in] BufferSize The size of Buffer in bytes.
3044
3045 @retval >0 The write operation was successful, and return value is the
3046 number of bytes actually written to the TLS connection.
3047 @retval <=0 The write operation was not successful.
3048
3049 **/
3050 typedef
3051 INTN
3052 (EFIAPI *EDKII_CRYPTO_TLS_WRITE)(
3053 IN VOID *Tls,
3054 IN VOID *Buffer,
3055 IN UINTN BufferSize
3056 );
3057
3058 /**
3059 Set a new TLS/SSL method for a particular TLS object.
3060
3061 This function sets a new TLS/SSL method for a particular TLS object.
3062
3063 @param[in] Tls Pointer to a TLS object.
3064 @param[in] MajorVer Major Version of TLS/SSL Protocol.
3065 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
3066
3067 @retval EFI_SUCCESS The TLS/SSL method was set successfully.
3068 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3069 @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
3070
3071 **/
3072 typedef
3073 EFI_STATUS
3074 (EFIAPI *EDKII_CRYPTO_TLS_SET_VERSION)(
3075 IN VOID *Tls,
3076 IN UINT8 MajorVer,
3077 IN UINT8 MinorVer
3078 );
3079
3080 /**
3081 Set TLS object to work in client or server mode.
3082
3083 This function prepares a TLS object to work in client or server mode.
3084
3085 @param[in] Tls Pointer to a TLS object.
3086 @param[in] IsServer Work in server mode.
3087
3088 @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
3089 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3090 @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
3091
3092 **/
3093 typedef
3094 EFI_STATUS
3095 (EFIAPI *EDKII_CRYPTO_TLS_SET_CONNECTION_END)(
3096 IN VOID *Tls,
3097 IN BOOLEAN IsServer
3098 );
3099
3100 /**
3101 Set the ciphers list to be used by the TLS object.
3102
3103 This function sets the ciphers for use by a specified TLS object.
3104
3105 @param[in] Tls Pointer to a TLS object.
3106 @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
3107 cipher identifier comes from the TLS Cipher Suite
3108 Registry of the IANA, interpreting Byte1 and Byte2
3109 in network (big endian) byte order.
3110 @param[in] CipherNum The number of cipher in the list.
3111
3112 @retval EFI_SUCCESS The ciphers list was set successfully.
3113 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3114 @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
3115 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
3116
3117 **/
3118 typedef
3119 EFI_STATUS
3120 (EFIAPI *EDKII_CRYPTO_TLS_SET_CIPHER_LIST)(
3121 IN VOID *Tls,
3122 IN UINT16 *CipherId,
3123 IN UINTN CipherNum
3124 );
3125
3126 /**
3127 Set the compression method for TLS/SSL operations.
3128
3129 This function handles TLS/SSL integrated compression methods.
3130
3131 @param[in] CompMethod The compression method ID.
3132
3133 @retval EFI_SUCCESS The compression method for the communication was
3134 set successfully.
3135 @retval EFI_UNSUPPORTED Unsupported compression method.
3136
3137 **/
3138 typedef
3139 EFI_STATUS
3140 (EFIAPI *EDKII_CRYPTO_TLS_SET_COMPRESSION_METHOD)(
3141 IN UINT8 CompMethod
3142 );
3143
3144 /**
3145 Set peer certificate verification mode for the TLS connection.
3146
3147 This function sets the verification mode flags for the TLS connection.
3148
3149 @param[in] Tls Pointer to the TLS object.
3150 @param[in] VerifyMode A set of logically or'ed verification mode flags.
3151
3152 **/
3153 typedef
3154 VOID
3155 (EFIAPI *EDKII_CRYPTO_TLS_SET_VERIFY)(
3156 IN VOID *Tls,
3157 IN UINT32 VerifyMode
3158 );
3159
3160 /**
3161 Set the specified host name to be verified.
3162
3163 @param[in] Tls Pointer to the TLS object.
3164 @param[in] Flags The setting flags during the validation.
3165 @param[in] HostName The specified host name to be verified.
3166
3167 @retval EFI_SUCCESS The HostName setting was set successfully.
3168 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3169 @retval EFI_ABORTED Invalid HostName setting.
3170
3171 **/
3172 typedef
3173 EFI_STATUS
3174 (EFIAPI *EDKII_CRYPTO_TLS_SET_VERIFY_HOST)(
3175 IN VOID *Tls,
3176 IN UINT32 Flags,
3177 IN CHAR8 *HostName
3178 );
3179
3180 /**
3181 Sets a TLS/SSL session ID to be used during TLS/SSL connect.
3182
3183 This function sets a session ID to be used when the TLS/SSL connection is
3184 to be established.
3185
3186 @param[in] Tls Pointer to the TLS object.
3187 @param[in] SessionId Session ID data used for session resumption.
3188 @param[in] SessionIdLen Length of Session ID in bytes.
3189
3190 @retval EFI_SUCCESS Session ID was set successfully.
3191 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3192 @retval EFI_UNSUPPORTED No available session for ID setting.
3193
3194 **/
3195 typedef
3196 EFI_STATUS
3197 (EFIAPI *EDKII_CRYPTO_TLS_SET_SESSIONID)(
3198 IN VOID *Tls,
3199 IN UINT8 *SessionId,
3200 IN UINT16 SessionIdLen
3201 );
3202
3203 /**
3204 Adds the CA to the cert store when requesting Server or Client authentication.
3205
3206 This function adds the CA certificate to the list of CAs when requesting
3207 Server or Client authentication for the chosen TLS connection.
3208
3209 @param[in] Tls Pointer to the TLS object.
3210 @param[in] Data Pointer to the data buffer of a DER-encoded binary
3211 X.509 certificate or PEM-encoded X.509 certificate.
3212 @param[in] DataSize The size of data buffer in bytes.
3213
3214 @retval EFI_SUCCESS The operation succeeded.
3215 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3216 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
3217 @retval EFI_ABORTED Invalid X.509 certificate.
3218
3219 **/
3220 typedef
3221 EFI_STATUS
3222 (EFIAPI *EDKII_CRYPTO_TLS_SET_CA_CERTIFICATE)(
3223 IN VOID *Tls,
3224 IN VOID *Data,
3225 IN UINTN DataSize
3226 );
3227
3228 /**
3229 Loads the local public certificate into the specified TLS object.
3230
3231 This function loads the X.509 certificate into the specified TLS object
3232 for TLS negotiation.
3233
3234 @param[in] Tls Pointer to the TLS object.
3235 @param[in] Data Pointer to the data buffer of a DER-encoded binary
3236 X.509 certificate or PEM-encoded X.509 certificate.
3237 @param[in] DataSize The size of data buffer in bytes.
3238
3239 @retval EFI_SUCCESS The operation succeeded.
3240 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3241 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
3242 @retval EFI_ABORTED Invalid X.509 certificate.
3243
3244 **/
3245 typedef
3246 EFI_STATUS
3247 (EFIAPI *EDKII_CRYPTO_TLS_SET_HOST_PUBLIC_CERT)(
3248 IN VOID *Tls,
3249 IN VOID *Data,
3250 IN UINTN DataSize
3251 );
3252
3253 /**
3254 Adds the local private key to the specified TLS object.
3255
3256 This function adds the local private key (PEM-encoded RSA or PKCS#8 private
3257 key) into the specified TLS object for TLS negotiation.
3258
3259 @param[in] Tls Pointer to the TLS object.
3260 @param[in] Data Pointer to the data buffer of a PEM-encoded RSA
3261 or PKCS#8 private key.
3262 @param[in] DataSize The size of data buffer in bytes.
3263
3264 @retval EFI_SUCCESS The operation succeeded.
3265 @retval EFI_UNSUPPORTED This function is not supported.
3266 @retval EFI_ABORTED Invalid private key data.
3267
3268 **/
3269 typedef
3270 EFI_STATUS
3271 (EFIAPI *EDKII_CRYPTO_TLS_SET_HOST_PRIVATE_KEY)(
3272 IN VOID *Tls,
3273 IN VOID *Data,
3274 IN UINTN DataSize
3275 );
3276
3277 /**
3278 Adds the CA-supplied certificate revocation list for certificate validation.
3279
3280 This function adds the CA-supplied certificate revocation list data for
3281 certificate validity checking.
3282
3283 @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
3284 @param[in] DataSize The size of data buffer in bytes.
3285
3286 @retval EFI_SUCCESS The operation succeeded.
3287 @retval EFI_UNSUPPORTED This function is not supported.
3288 @retval EFI_ABORTED Invalid CRL data.
3289
3290 **/
3291 typedef
3292 EFI_STATUS
3293 (EFIAPI *EDKII_CRYPTO_TLS_SET_CERT_REVOCATION_LIST)(
3294 IN VOID *Data,
3295 IN UINTN DataSize
3296 );
3297
3298 /**
3299 Gets the protocol version used by the specified TLS connection.
3300
3301 This function returns the protocol version used by the specified TLS
3302 connection.
3303
3304 If Tls is NULL, then ASSERT().
3305
3306 @param[in] Tls Pointer to the TLS object.
3307
3308 @return The protocol version of the specified TLS connection.
3309
3310 **/
3311 typedef
3312 UINT16
3313 (EFIAPI *EDKII_CRYPTO_TLS_GET_VERSION)(
3314 IN VOID *Tls
3315 );
3316
3317 /**
3318 Gets the connection end of the specified TLS connection.
3319
3320 This function returns the connection end (as client or as server) used by
3321 the specified TLS connection.
3322
3323 If Tls is NULL, then ASSERT().
3324
3325 @param[in] Tls Pointer to the TLS object.
3326
3327 @return The connection end used by the specified TLS connection.
3328
3329 **/
3330 typedef
3331 UINT8
3332 (EFIAPI *EDKII_CRYPTO_TLS_GET_CONNECTION_END)(
3333 IN VOID *Tls
3334 );
3335
3336 /**
3337 Gets the cipher suite used by the specified TLS connection.
3338
3339 This function returns current cipher suite used by the specified
3340 TLS connection.
3341
3342 @param[in] Tls Pointer to the TLS object.
3343 @param[in,out] CipherId The cipher suite used by the TLS object.
3344
3345 @retval EFI_SUCCESS The cipher suite was returned successfully.
3346 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3347 @retval EFI_UNSUPPORTED Unsupported cipher suite.
3348
3349 **/
3350 typedef
3351 EFI_STATUS
3352 (EFIAPI *EDKII_CRYPTO_TLS_GET_CURRENT_CIPHER)(
3353 IN VOID *Tls,
3354 IN OUT UINT16 *CipherId
3355 );
3356
3357 /**
3358 Gets the compression methods used by the specified TLS connection.
3359
3360 This function returns current integrated compression methods used by
3361 the specified TLS connection.
3362
3363 @param[in] Tls Pointer to the TLS object.
3364 @param[in,out] CompressionId The current compression method used by
3365 the TLS object.
3366
3367 @retval EFI_SUCCESS The compression method was returned successfully.
3368 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3369 @retval EFI_ABORTED Invalid Compression method.
3370 @retval EFI_UNSUPPORTED This function is not supported.
3371
3372 **/
3373 typedef
3374 EFI_STATUS
3375 (EFIAPI *EDKII_CRYPTO_TLS_GET_CURRENT_COMPRESSION_ID)(
3376 IN VOID *Tls,
3377 IN OUT UINT8 *CompressionId
3378 );
3379
3380 /**
3381 Gets the verification mode currently set in the TLS connection.
3382
3383 This function returns the peer verification mode currently set in the
3384 specified TLS connection.
3385
3386 If Tls is NULL, then ASSERT().
3387
3388 @param[in] Tls Pointer to the TLS object.
3389
3390 @return The verification mode set in the specified TLS connection.
3391
3392 **/
3393 typedef
3394 UINT32
3395 (EFIAPI *EDKII_CRYPTO_TLS_GET_VERIFY)(
3396 IN VOID *Tls
3397 );
3398
3399 /**
3400 Gets the session ID used by the specified TLS connection.
3401
3402 This function returns the TLS/SSL session ID currently used by the
3403 specified TLS connection.
3404
3405 @param[in] Tls Pointer to the TLS object.
3406 @param[in,out] SessionId Buffer to contain the returned session ID.
3407 @param[in,out] SessionIdLen The length of Session ID in bytes.
3408
3409 @retval EFI_SUCCESS The Session ID was returned successfully.
3410 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3411 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
3412
3413 **/
3414 typedef
3415 EFI_STATUS
3416 (EFIAPI *EDKII_CRYPTO_TLS_GET_SESSION_ID)(
3417 IN VOID *Tls,
3418 IN OUT UINT8 *SessionId,
3419 IN OUT UINT16 *SessionIdLen
3420 );
3421
3422 /**
3423 Gets the client random data used in the specified TLS connection.
3424
3425 This function returns the TLS/SSL client random data currently used in
3426 the specified TLS connection.
3427
3428 @param[in] Tls Pointer to the TLS object.
3429 @param[in,out] ClientRandom Buffer to contain the returned client
3430 random data (32 bytes).
3431
3432 **/
3433 typedef
3434 VOID
3435 (EFIAPI *EDKII_CRYPTO_TLS_GET_CLIENT_RANDOM)(
3436 IN VOID *Tls,
3437 IN OUT UINT8 *ClientRandom
3438 );
3439
3440 /**
3441 Gets the server random data used in the specified TLS connection.
3442
3443 This function returns the TLS/SSL server random data currently used in
3444 the specified TLS connection.
3445
3446 @param[in] Tls Pointer to the TLS object.
3447 @param[in,out] ServerRandom Buffer to contain the returned server
3448 random data (32 bytes).
3449
3450 **/
3451 typedef
3452 VOID
3453 (EFIAPI *EDKII_CRYPTO_TLS_GET_SERVER_RANDOM)(
3454 IN VOID *Tls,
3455 IN OUT UINT8 *ServerRandom
3456 );
3457
3458 /**
3459 Gets the master key data used in the specified TLS connection.
3460
3461 This function returns the TLS/SSL master key material currently used in
3462 the specified TLS connection.
3463
3464 @param[in] Tls Pointer to the TLS object.
3465 @param[in,out] KeyMaterial Buffer to contain the returned key material.
3466
3467 @retval EFI_SUCCESS Key material was returned successfully.
3468 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3469 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
3470
3471 **/
3472 typedef
3473 EFI_STATUS
3474 (EFIAPI *EDKII_CRYPTO_TLS_GET_KEY_MATERIAL)(
3475 IN VOID *Tls,
3476 IN OUT UINT8 *KeyMaterial
3477 );
3478
3479 /**
3480 Gets the CA Certificate from the cert store.
3481
3482 This function returns the CA certificate for the chosen
3483 TLS connection.
3484
3485 @param[in] Tls Pointer to the TLS object.
3486 @param[out] Data Pointer to the data buffer to receive the CA
3487 certificate data sent to the client.
3488 @param[in,out] DataSize The size of data buffer in bytes.
3489
3490 @retval EFI_SUCCESS The operation succeeded.
3491 @retval EFI_UNSUPPORTED This function is not supported.
3492 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
3493
3494 **/
3495 typedef
3496 EFI_STATUS
3497 (EFIAPI *EDKII_CRYPTO_TLS_GET_CA_CERTIFICATE)(
3498 IN VOID *Tls,
3499 OUT VOID *Data,
3500 IN OUT UINTN *DataSize
3501 );
3502
3503 /**
3504 Gets the local public Certificate set in the specified TLS object.
3505
3506 This function returns the local public certificate which was currently set
3507 in the specified TLS object.
3508
3509 @param[in] Tls Pointer to the TLS object.
3510 @param[out] Data Pointer to the data buffer to receive the local
3511 public certificate.
3512 @param[in,out] DataSize The size of data buffer in bytes.
3513
3514 @retval EFI_SUCCESS The operation succeeded.
3515 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3516 @retval EFI_NOT_FOUND The certificate is not found.
3517 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
3518
3519 **/
3520 typedef
3521 EFI_STATUS
3522 (EFIAPI *EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT)(
3523 IN VOID *Tls,
3524 OUT VOID *Data,
3525 IN OUT UINTN *DataSize
3526 );
3527
3528 /**
3529 Gets the local private key set in the specified TLS object.
3530
3531 This function returns the local private key data which was currently set
3532 in the specified TLS object.
3533
3534 @param[in] Tls Pointer to the TLS object.
3535 @param[out] Data Pointer to the data buffer to receive the local
3536 private key data.
3537 @param[in,out] DataSize The size of data buffer in bytes.
3538
3539 @retval EFI_SUCCESS The operation succeeded.
3540 @retval EFI_UNSUPPORTED This function is not supported.
3541 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
3542
3543 **/
3544 typedef
3545 EFI_STATUS
3546 (EFIAPI *EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY)(
3547 IN VOID *Tls,
3548 OUT VOID *Data,
3549 IN OUT UINTN *DataSize
3550 );
3551
3552 /**
3553 Gets the CA-supplied certificate revocation list data set in the specified
3554 TLS object.
3555
3556 This function returns the CA-supplied certificate revocation list data which
3557 was currently set in the specified TLS object.
3558
3559 @param[out] Data Pointer to the data buffer to receive the CRL data.
3560 @param[in,out] DataSize The size of data buffer in bytes.
3561
3562 @retval EFI_SUCCESS The operation succeeded.
3563 @retval EFI_UNSUPPORTED This function is not supported.
3564 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
3565
3566 **/
3567 typedef
3568 EFI_STATUS
3569 (EFIAPI *EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST)(
3570 OUT VOID *DATA,
3571 IN OUT UINTN *DataSize
3572 );
3573
3574 /**
3575 Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.
3576
3577 This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in
3578 RFC 8017.
3579 Mask generation function is the same as the message digest algorithm.
3580 If the Signature buffer is too small to hold the contents of signature, FALSE
3581 is returned and SigSize is set to the required buffer size to obtain the signature.
3582
3583 If RsaContext is NULL, then return FALSE.
3584 If Message is NULL, then return FALSE.
3585 If MsgSize is zero or > INT_MAX, then return FALSE.
3586 If DigestLen is NOT 32, 48 or 64, return FALSE.
3587 If SaltLen is not equal to DigestLen, then return FALSE.
3588 If SigSize is large enough but Signature is NULL, then return FALSE.
3589 If this interface is not supported, then return FALSE.
3590
3591 @param[in] RsaContext Pointer to RSA context for signature generation.
3592 @param[in] Message Pointer to octet message to be signed.
3593 @param[in] MsgSize Size of the message in bytes.
3594 @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.
3595 @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.
3596 @param[out] Signature Pointer to buffer to receive RSA PSS signature.
3597 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
3598 On output, the size of data returned in Signature buffer in bytes.
3599
3600 @retval TRUE Signature successfully generated in RSASSA-PSS.
3601 @retval FALSE Signature generation failed.
3602 @retval FALSE SigSize is too small.
3603 @retval FALSE This interface is not supported.
3604
3605 **/
3606 typedef
3607 BOOLEAN
3608 (EFIAPI *EDKII_CRYPTO_RSA_PSS_SIGN)(
3609 IN VOID *RsaContext,
3610 IN CONST UINT8 *Message,
3611 IN UINTN MsgSize,
3612 IN UINT16 DigestLen,
3613 IN UINT16 SaltLen,
3614 OUT UINT8 *Signature,
3615 IN OUT UINTN *SigSize
3616 );
3617
3618 /**
3619 Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.
3620 Implementation determines salt length automatically from the signature encoding.
3621 Mask generation function is the same as the message digest algorithm.
3622 Salt length should be equal to digest length.
3623
3624 @param[in] RsaContext Pointer to RSA context for signature verification.
3625 @param[in] Message Pointer to octet message to be verified.
3626 @param[in] MsgSize Size of the message in bytes.
3627 @param[in] Signature Pointer to RSASSA-PSS signature to be verified.
3628 @param[in] SigSize Size of signature in bytes.
3629 @param[in] DigestLen Length of digest for RSA operation.
3630 @param[in] SaltLen Salt length for PSS encoding.
3631
3632 @retval TRUE Valid signature encoded in RSASSA-PSS.
3633 @retval FALSE Invalid signature or invalid RSA context.
3634
3635 **/
3636 typedef
3637 BOOLEAN
3638 (EFIAPI *EDKII_CRYPTO_RSA_PSS_VERIFY)(
3639 IN VOID *RsaContext,
3640 IN CONST UINT8 *Message,
3641 IN UINTN MsgSize,
3642 IN CONST UINT8 *Signature,
3643 IN UINTN SigSize,
3644 IN UINT16 DigestLen,
3645 IN UINT16 SaltLen
3646 );
3647
3648 /**
3649 Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,
3650 published December 2016.
3651
3652 @param[in] Input Pointer to the input message (X).
3653 @param[in] InputByteLen The number(>0) of input bytes provided for the input data.
3654 @param[in] BlockSize The size of each block (B).
3655 @param[out] Output Pointer to the output buffer.
3656 @param[in] OutputByteLen The desired number of output bytes (L).
3657 @param[in] Customization Pointer to the customization string (S).
3658 @param[in] CustomByteLen The length of the customization string in bytes.
3659
3660 @retval TRUE ParallelHash256 digest computation succeeded.
3661 @retval FALSE ParallelHash256 digest computation failed.
3662 @retval FALSE This interface is not supported.
3663
3664 **/
3665 typedef
3666 BOOLEAN
3667 (EFIAPI *EDKII_CRYPTO_PARALLEL_HASH_ALL)(
3668 IN CONST VOID *Input,
3669 IN UINTN InputByteLen,
3670 IN UINTN BlockSize,
3671 OUT VOID *Output,
3672 IN UINTN OutputByteLen,
3673 IN CONST VOID *Customization,
3674 IN UINTN CustomByteLen
3675 );
3676
3677 ///
3678 /// EDK II Crypto Protocol
3679 ///
3680 struct _EDKII_CRYPTO_PROTOCOL {
3681 /// Version
3682 EDKII_CRYPTO_GET_VERSION GetVersion;
3683 /// HMAC MD5 - deprecated and unsupported
3684 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_NEW DeprecatedHmacMd5New;
3685 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_FREE DeprecatedHmacMd5Free;
3686 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_SET_KEY DeprecatedHmacMd5SetKey;
3687 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_DUPLICATE DeprecatedHmacMd5Duplicate;
3688 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_UPDATE DeprecatedHmacMd5Update;
3689 DEPRECATED_EDKII_CRYPTO_HMAC_MD5_FINAL DeprecatedHmacMd5Final;
3690 /// HMAC SHA1 - deprecated and unsupported
3691 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_NEW DeprecatedHmacSha1New;
3692 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_FREE DeprecatedHmacSha1Free;
3693 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_SET_KEY DeprecatedHmacSha1SetKey;
3694 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_DUPLICATE DeprecatedHmacSha1Duplicate;
3695 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_UPDATE DeprecatedHmacSha1Update;
3696 DEPRECATED_EDKII_CRYPTO_HMAC_SHA1_FINAL DeprecatedHmacSha1Final;
3697 /// HMAC SHA256
3698 EDKII_CRYPTO_HMAC_SHA256_NEW HmacSha256New;
3699 EDKII_CRYPTO_HMAC_SHA256_FREE HmacSha256Free;
3700 EDKII_CRYPTO_HMAC_SHA256_SET_KEY HmacSha256SetKey;
3701 EDKII_CRYPTO_HMAC_SHA256_DUPLICATE HmacSha256Duplicate;
3702 EDKII_CRYPTO_HMAC_SHA256_UPDATE HmacSha256Update;
3703 EDKII_CRYPTO_HMAC_SHA256_FINAL HmacSha256Final;
3704 /// Md4 - deprecated and unsupported
3705 DEPRECATED_EDKII_CRYPTO_MD4_GET_CONTEXT_SIZE DeprecatedMd4GetContextSize;
3706 DEPRECATED_EDKII_CRYPTO_MD4_INIT DeprecatedMd4Init;
3707 DEPRECATED_EDKII_CRYPTO_MD4_DUPLICATE DeprecatedMd4Duplicate;
3708 DEPRECATED_EDKII_CRYPTO_MD4_UPDATE DeprecatedMd4Update;
3709 DEPRECATED_EDKII_CRYPTO_MD4_FINAL DeprecatedMd4Final;
3710 DEPRECATED_EDKII_CRYPTO_MD4_HASH_ALL DeprecatedMd4HashAll;
3711 /// Md5
3712 EDKII_CRYPTO_MD5_GET_CONTEXT_SIZE Md5GetContextSize;
3713 EDKII_CRYPTO_MD5_INIT Md5Init;
3714 EDKII_CRYPTO_MD5_DUPLICATE Md5Duplicate;
3715 EDKII_CRYPTO_MD5_UPDATE Md5Update;
3716 EDKII_CRYPTO_MD5_FINAL Md5Final;
3717 EDKII_CRYPTO_MD5_HASH_ALL Md5HashAll;
3718 /// Pkcs
3719 EDKII_CRYPTO_PKCS1_ENCRYPT_V2 Pkcs1v2Encrypt;
3720 EDKII_CRYPTO_PKCS5_PW_HASH Pkcs5HashPassword;
3721 EDKII_CRYPTO_PKCS7_VERIFY Pkcs7Verify;
3722 EDKII_CRYPTO_PKCS7_VERIFY_EKU VerifyEKUsInPkcs7Signature;
3723 EDKII_CRYPTO_PKCS7_GET_SIGNERS Pkcs7GetSigners;
3724 EDKII_CRYPTO_PKCS7_FREE_SIGNERS Pkcs7FreeSigners;
3725 EDKII_CRYPTO_PKCS7_SIGN Pkcs7Sign;
3726 EDKII_CRYPTO_PKCS7_GET_ATTACHED_CONTENT Pkcs7GetAttachedContent;
3727 EDKII_CRYPTO_PKCS7_GET_CERTIFICATES_LIST Pkcs7GetCertificatesList;
3728 EDKII_CRYPTO_AUTHENTICODE_VERIFY AuthenticodeVerify;
3729 EDKII_CRYPTO_IMAGE_TIMESTAMP_VERIFY ImageTimestampVerify;
3730 /// DH
3731 EDKII_CRYPTO_DH_NEW DhNew;
3732 EDKII_CRYPTO_DH_FREE DhFree;
3733 EDKII_CRYPTO_DH_GENERATE_PARAMETER DhGenerateParameter;
3734 EDKII_CRYPTO_DH_SET_PARAMETER DhSetParameter;
3735 EDKII_CRYPTO_DH_GENERATE_KEY DhGenerateKey;
3736 EDKII_CRYPTO_DH_COMPUTE_KEY DhComputeKey;
3737 /// Random
3738 EDKII_CRYPTO_RANDOM_SEED RandomSeed;
3739 EDKII_CRYPTO_RANDOM_BYTES RandomBytes;
3740 /// RSA
3741 EDKII_CRYPTO_RSA_VERIFY_PKCS1 RsaVerifyPkcs1;
3742 EDKII_CRYPTO_RSA_NEW RsaNew;
3743 EDKII_CRYPTO_RSA_FREE RsaFree;
3744 EDKII_CRYPTO_RSA_SET_KEY RsaSetKey;
3745 EDKII_CRYPTO_RSA_GET_KEY RsaGetKey;
3746 EDKII_CRYPTO_RSA_GENERATE_KEY RsaGenerateKey;
3747 EDKII_CRYPTO_RSA_CHECK_KEY RsaCheckKey;
3748 EDKII_CRYPTO_RSA_PKCS1_SIGN RsaPkcs1Sign;
3749 EDKII_CRYPTO_RSA_PKCS1_VERIFY RsaPkcs1Verify;
3750 EDKII_CRYPTO_RSA_GET_PRIVATE_KEY_FROM_PEM RsaGetPrivateKeyFromPem;
3751 EDKII_CRYPTO_RSA_GET_PUBLIC_KEY_FROM_X509 RsaGetPublicKeyFromX509;
3752 /// Sha1
3753 EDKII_CRYPTO_SHA1_GET_CONTEXT_SIZE Sha1GetContextSize;
3754 EDKII_CRYPTO_SHA1_INIT Sha1Init;
3755 EDKII_CRYPTO_SHA1_DUPLICATE Sha1Duplicate;
3756 EDKII_CRYPTO_SHA1_UPDATE Sha1Update;
3757 EDKII_CRYPTO_SHA1_FINAL Sha1Final;
3758 EDKII_CRYPTO_SHA1_HASH_ALL Sha1HashAll;
3759 /// Sha256
3760 EDKII_CRYPTO_SHA256_GET_CONTEXT_SIZE Sha256GetContextSize;
3761 EDKII_CRYPTO_SHA256_INIT Sha256Init;
3762 EDKII_CRYPTO_SHA256_DUPLICATE Sha256Duplicate;
3763 EDKII_CRYPTO_SHA256_UPDATE Sha256Update;
3764 EDKII_CRYPTO_SHA256_FINAL Sha256Final;
3765 EDKII_CRYPTO_SHA256_HASH_ALL Sha256HashAll;
3766 /// Sha384
3767 EDKII_CRYPTO_SHA384_GET_CONTEXT_SIZE Sha384GetContextSize;
3768 EDKII_CRYPTO_SHA384_INIT Sha384Init;
3769 EDKII_CRYPTO_SHA384_DUPLICATE Sha384Duplicate;
3770 EDKII_CRYPTO_SHA384_UPDATE Sha384Update;
3771 EDKII_CRYPTO_SHA384_FINAL Sha384Final;
3772 EDKII_CRYPTO_SHA384_HASH_ALL Sha384HashAll;
3773 /// Sha512
3774 EDKII_CRYPTO_SHA512_GET_CONTEXT_SIZE Sha512GetContextSize;
3775 EDKII_CRYPTO_SHA512_INIT Sha512Init;
3776 EDKII_CRYPTO_SHA512_DUPLICATE Sha512Duplicate;
3777 EDKII_CRYPTO_SHA512_UPDATE Sha512Update;
3778 EDKII_CRYPTO_SHA512_FINAL Sha512Final;
3779 EDKII_CRYPTO_SHA512_HASH_ALL Sha512HashAll;
3780 /// X509
3781 EDKII_CRYPTO_X509_GET_SUBJECT_NAME X509GetSubjectName;
3782 EDKII_CRYPTO_X509_GET_COMMON_NAME X509GetCommonName;
3783 EDKII_CRYPTO_X509_GET_ORGANIZATION_NAME X509GetOrganizationName;
3784 EDKII_CRYPTO_X509_VERIFY_CERT X509VerifyCert;
3785 EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE X509ConstructCertificate;
3786 EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK X509ConstructCertificateStack;
3787 EDKII_CRYPTO_X509_FREE X509Free;
3788 EDKII_CRYPTO_X509_STACK_FREE X509StackFree;
3789 EDKII_CRYPTO_X509_GET_TBS_CERT X509GetTBSCert;
3790 /// TDES - deprecated and unsupported
3791 DEPRECATED_EDKII_CRYPTO_TDES_GET_CONTEXT_SIZE DeprecatedTdesGetContextSize;
3792 DEPRECATED_EDKII_CRYPTO_TDES_INIT DeprecatedTdesInit;
3793 DEPRECATED_EDKII_CRYPTO_TDES_ECB_ENCRYPT DeprecatedTdesEcbEncrypt;
3794 DEPRECATED_EDKII_CRYPTO_TDES_ECB_DECRYPT DeprecatedTdesEcbDecrypt;
3795 DEPRECATED_EDKII_CRYPTO_TDES_CBC_ENCRYPT DeprecatedTdesCbcEncrypt;
3796 DEPRECATED_EDKII_CRYPTO_TDES_CBC_DECRYPT DeprecatedTdesCbcDecrypt;
3797 /// AES - ECB Mode is deprecated and unsupported
3798 EDKII_CRYPTO_AES_GET_CONTEXT_SIZE AesGetContextSize;
3799 EDKII_CRYPTO_AES_INIT AesInit;
3800 DEPRECATED_EDKII_CRYPTO_AES_ECB_ENCRYPT DeprecatedAesEcbEncrypt;
3801 DEPRECATED_EDKII_CRYPTO_AES_ECB_DECRYPT DeprecatedAesEcbDecrypt;
3802 EDKII_CRYPTO_AES_CBC_ENCRYPT AesCbcEncrypt;
3803 EDKII_CRYPTO_AES_CBC_DECRYPT AesCbcDecrypt;
3804 /// Arc4 - deprecated and unsupported
3805 DEPRECATED_EDKII_CRYPTO_ARC4_GET_CONTEXT_SIZE DeprecatedArc4GetContextSize;
3806 DEPRECATED_EDKII_CRYPTO_ARC4_INIT DeprecatedArc4Init;
3807 DEPRECATED_EDKII_CRYPTO_ARC4_ENCRYPT DeprecatedArc4Encrypt;
3808 DEPRECATED_EDKII_CRYPTO_ARC4_DECRYPT DeprecatedArc4Decrypt;
3809 DEPRECATED_EDKII_CRYPTO_ARC4_RESET DeprecatedArc4Reset;
3810 /// SM3
3811 EDKII_CRYPTO_SM3_GET_CONTEXT_SIZE Sm3GetContextSize;
3812 EDKII_CRYPTO_SM3_INIT Sm3Init;
3813 EDKII_CRYPTO_SM3_DUPLICATE Sm3Duplicate;
3814 EDKII_CRYPTO_SM3_UPDATE Sm3Update;
3815 EDKII_CRYPTO_SM3_FINAL Sm3Final;
3816 EDKII_CRYPTO_SM3_HASH_ALL Sm3HashAll;
3817 /// HKDF
3818 EDKII_CRYPTO_HKDF_SHA_256_EXTRACT_AND_EXPAND HkdfSha256ExtractAndExpand;
3819 /// X509 (Continued)
3820 EDKII_CRYPTO_X509_CONSTRUCT_CERTIFICATE_STACK_V X509ConstructCertificateStackV;
3821 /// TLS
3822 EDKII_CRYPTO_TLS_INITIALIZE TlsInitialize;
3823 EDKII_CRYPTO_TLS_CTX_FREE TlsCtxFree;
3824 EDKII_CRYPTO_TLS_CTX_NEW TlsCtxNew;
3825 EDKII_CRYPTO_TLS_FREE TlsFree;
3826 EDKII_CRYPTO_TLS_NEW TlsNew;
3827 EDKII_CRYPTO_TLS_IN_HANDSHAKE TlsInHandshake;
3828 EDKII_CRYPTO_TLS_DO_HANDSHAKE TlsDoHandshake;
3829 EDKII_CRYPTO_TLS_HANDLE_ALERT TlsHandleAlert;
3830 EDKII_CRYPTO_TLS_CLOSE_NOTIFY TlsCloseNotify;
3831 EDKII_CRYPTO_TLS_CTRL_TRAFFIC_OUT TlsCtrlTrafficOut;
3832 EDKII_CRYPTO_TLS_CTRL_TRAFFIC_IN TlsCtrlTrafficIn;
3833 EDKII_CRYPTO_TLS_READ TlsRead;
3834 EDKII_CRYPTO_TLS_WRITE TlsWrite;
3835 /// TLS Set
3836 EDKII_CRYPTO_TLS_SET_VERSION TlsSetVersion;
3837 EDKII_CRYPTO_TLS_SET_CONNECTION_END TlsSetConnectionEnd;
3838 EDKII_CRYPTO_TLS_SET_CIPHER_LIST TlsSetCipherList;
3839 EDKII_CRYPTO_TLS_SET_COMPRESSION_METHOD TlsSetCompressionMethod;
3840 EDKII_CRYPTO_TLS_SET_VERIFY TlsSetVerify;
3841 EDKII_CRYPTO_TLS_SET_VERIFY_HOST TlsSetVerifyHost;
3842 EDKII_CRYPTO_TLS_SET_SESSIONID TlsSetSessionId;
3843 EDKII_CRYPTO_TLS_SET_CA_CERTIFICATE TlsSetCaCertificate;
3844 EDKII_CRYPTO_TLS_SET_HOST_PUBLIC_CERT TlsSetHostPublicCert;
3845 EDKII_CRYPTO_TLS_SET_HOST_PRIVATE_KEY TlsSetHostPrivateKey;
3846 EDKII_CRYPTO_TLS_SET_CERT_REVOCATION_LIST TlsSetCertRevocationList;
3847 /// TLS Get
3848 EDKII_CRYPTO_TLS_GET_VERSION TlsGetVersion;
3849 EDKII_CRYPTO_TLS_GET_CONNECTION_END TlsGetConnectionEnd;
3850 EDKII_CRYPTO_TLS_GET_CURRENT_CIPHER TlsGetCurrentCipher;
3851 EDKII_CRYPTO_TLS_GET_CURRENT_COMPRESSION_ID TlsGetCurrentCompressionId;
3852 EDKII_CRYPTO_TLS_GET_VERIFY TlsGetVerify;
3853 EDKII_CRYPTO_TLS_GET_SESSION_ID TlsGetSessionId;
3854 EDKII_CRYPTO_TLS_GET_CLIENT_RANDOM TlsGetClientRandom;
3855 EDKII_CRYPTO_TLS_GET_SERVER_RANDOM TlsGetServerRandom;
3856 EDKII_CRYPTO_TLS_GET_KEY_MATERIAL TlsGetKeyMaterial;
3857 EDKII_CRYPTO_TLS_GET_CA_CERTIFICATE TlsGetCaCertificate;
3858 EDKII_CRYPTO_TLS_GET_HOST_PUBLIC_CERT TlsGetHostPublicCert;
3859 EDKII_CRYPTO_TLS_GET_HOST_PRIVATE_KEY TlsGetHostPrivateKey;
3860 EDKII_CRYPTO_TLS_GET_CERT_REVOCATION_LIST TlsGetCertRevocationList;
3861 /// RSA PSS
3862 EDKII_CRYPTO_RSA_PSS_SIGN RsaPssSign;
3863 EDKII_CRYPTO_RSA_PSS_VERIFY RsaPssVerify;
3864 /// Parallel hash
3865 EDKII_CRYPTO_PARALLEL_HASH_ALL ParallelHash256HashAll;
3866 /// HMAC SHA256 (continued)
3867 EDKII_CRYPTO_HMAC_SHA256_ALL HmacSha256All;
3868 /// HMAC SHA384
3869 EDKII_CRYPTO_HMAC_SHA384_NEW HmacSha384New;
3870 EDKII_CRYPTO_HMAC_SHA384_FREE HmacSha384Free;
3871 EDKII_CRYPTO_HMAC_SHA384_SET_KEY HmacSha384SetKey;
3872 EDKII_CRYPTO_HMAC_SHA384_DUPLICATE HmacSha384Duplicate;
3873 EDKII_CRYPTO_HMAC_SHA384_UPDATE HmacSha384Update;
3874 EDKII_CRYPTO_HMAC_SHA384_FINAL HmacSha384Final;
3875 EDKII_CRYPTO_HMAC_SHA384_ALL HmacSha384All;
3876 };
3877
3878 extern GUID gEdkiiCryptoProtocolGuid;
3879
3880 #endif