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