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