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