]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Driver/Crypto.c
CryptoPkg: Add BigNum API to DXE and protocol
[mirror_edk2.git] / CryptoPkg / Driver / Crypto.c
1 /** @file
2 Implements the EDK II Crypto Protocol/PPI services using the library services
3 from BaseCryptLib and TlsLib.
4
5 Copyright (C) Microsoft Corporation. All rights reserved.
6 Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9 **/
10 #include <Base.h>
11 #include <Library/DebugLib.h>
12 #include <Library/BaseCryptLib.h>
13 #include <Library/TlsLib.h>
14 #include <Protocol/Crypto.h>
15 #include <Pcd/PcdCryptoServiceFamilyEnable.h>
16
17 /**
18 A macro used to retrieve the FixedAtBuild PcdCryptoServiceFamilyEnable with a
19 typecast to its associcted structure type PCD_CRYPTO_SERVICE_FAMILY_ENABLE.
20 **/
21 #define EDKII_CRYPTO_PCD ((const PCD_CRYPTO_SERVICE_FAMILY_ENABLE *)\
22 (FixedPcdGetPtr (PcdCryptoServiceFamilyEnable)))
23
24 /**
25 A macro used to call a non-void BaseCryptLib function if it is enabled.
26
27 If a BaseCryptLib function is not enabled, there will be no references to it
28 from this module and will be optimized away reducing the size of this module.
29
30 @param Enable The name of the enable field in PCD
31 PcdCryptoServiceFamilyEnable for the BaseCryptLib
32 function being called. If the value of this field
33 is non-zero, then the BaseCryptLib function is
34 enabled.
35 @param Function The name of the BaseCryptLib function.
36 @param Args The argument list to pass to Function.
37 @param ErrorReturnValue The value to return if the BaseCryptLib function is
38 not enabled.
39
40 **/
41 #define CALL_BASECRYPTLIB(Enable, Function, Args, ErrorReturnValue) \
42 EDKII_CRYPTO_PCD->Enable \
43 ? Function Args \
44 : (BaseCryptLibServiceNotEnabled (#Function), ErrorReturnValue)
45
46 /**
47 A macro used to call a void BaseCryptLib function if it is enabled.
48
49 If a BaseCryptLib function is not enabled, there will be no references to it
50 from this module and will be optimized away reducing the size of this module.
51
52 @param Enable The name of the enable field in PCD
53 PcdCryptoServiceFamilyEnable for the BaseCryptLib
54 function being called. If the value of this field
55 is non-zero, then the BaseCryptLib function is
56 enabled.
57 @param Function The name of the BaseCryptLib function.
58 @param Args The argument list to pass to Function.
59
60 **/
61 #define CALL_VOID_BASECRYPTLIB(Enable, Function, Args) \
62 EDKII_CRYPTO_PCD->Enable \
63 ? Function Args \
64 : BaseCryptLibServiceNotEnabled (#Function)
65
66 /**
67 Internal worker function that prints a debug message and asserts if a call is
68 made to a BaseCryptLib function that is not enabled in the EDK II Crypto
69 Protocol/PPI.
70
71 If this debug message and assert are observed, then a module is using
72 BaseCryptLib function that is not enabled in a Crypto driver. The
73 PcdCryptoServiceFamilyEnable should be updated to enable the missing service.
74
75 @param[in] FunctionName Null-terminated ASCII string that is the name of an
76 EDK II Crypto service.
77
78 **/
79 static
80 VOID
81 BaseCryptLibServiceNotEnabled (
82 IN CONST CHAR8 *FunctionName
83 )
84 {
85 DEBUG ((DEBUG_ERROR, "[%a] Function %a() is not enabled\n", gEfiCallerBaseName, FunctionName));
86 ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
87 }
88
89 /**
90 Internal worker function that prints a debug message and asserts if a call is
91 made to a BaseCryptLib function that is deprecated and unsupported any longer.
92
93 @param[in] FunctionName Null-terminated ASCII string that is the name of an
94 EDK II Crypto service.
95
96 **/
97 static
98 VOID
99 BaseCryptLibServiceDeprecated (
100 IN CONST CHAR8 *FunctionName
101 )
102 {
103 DEBUG ((DEBUG_ERROR, "[%a] Function %a() is deprecated and unsupported any longer\n", gEfiCallerBaseName, FunctionName));
104 ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
105 }
106
107 /**
108 Returns the version of the EDK II Crypto Protocol.
109
110 @return The version of the EDK II Crypto Protocol.
111
112 **/
113 UINTN
114 EFIAPI
115 CryptoServiceGetCryptoVersion (
116 VOID
117 )
118 {
119 return EDKII_CRYPTO_VERSION;
120 }
121
122 // =====================================================================================
123 // One-Way Cryptographic Hash Primitives
124 // =====================================================================================
125
126 /**
127 MD4 is deprecated and unsupported any longer.
128 Keep the function field for binary compability.
129
130 @retval 0 This interface is not supported.
131
132 **/
133 UINTN
134 EFIAPI
135 DeprecatedCryptoServiceMd4GetContextSize (
136 VOID
137 )
138 {
139 return BaseCryptLibServiceDeprecated ("Md4GetContextSize"), 0;
140 }
141
142 /**
143 MD4 is deprecated and unsupported any longer.
144 Keep the function field for binary compability.
145
146 @param[out] Md4Context Pointer to MD4 context being initialized.
147
148 @retval FALSE This interface is not supported.
149
150 **/
151 BOOLEAN
152 EFIAPI
153 DeprecatedCryptoServiceMd4Init (
154 OUT VOID *Md4Context
155 )
156 {
157 return BaseCryptLibServiceDeprecated ("Md4Init"), FALSE;
158 }
159
160 /**
161 MD4 is deprecated and unsupported any longer.
162 Keep the function field for binary compability.
163
164 @param[in] Md4Context Pointer to MD4 context being copied.
165 @param[out] NewMd4Context Pointer to new MD4 context.
166
167 @retval FALSE This interface is not supported.
168
169 **/
170 BOOLEAN
171 EFIAPI
172 DeprecatedCryptoServiceMd4Duplicate (
173 IN CONST VOID *Md4Context,
174 OUT VOID *NewMd4Context
175 )
176 {
177 return BaseCryptLibServiceDeprecated ("Md4Duplicate"), FALSE;
178 }
179
180 /**
181 MD4 is deprecated and unsupported any longer.
182 Keep the function field for binary compability.
183
184 @param[in, out] Md4Context Pointer to the MD4 context.
185 @param[in] Data Pointer to the buffer containing the data to be hashed.
186 @param[in] DataSize Size of Data buffer in bytes.
187
188 @retval FALSE This interface is not supported.
189
190 **/
191 BOOLEAN
192 EFIAPI
193 DeprecatedCryptoServiceMd4Update (
194 IN OUT VOID *Md4Context,
195 IN CONST VOID *Data,
196 IN UINTN DataSize
197 )
198 {
199 return BaseCryptLibServiceDeprecated ("Md4Update"), FALSE;
200 }
201
202 /**
203 MD4 is deprecated and unsupported any longer.
204 Keep the function field for binary compability.
205
206 @param[in, out] Md4Context Pointer to the MD4 context.
207 @param[out] HashValue Pointer to a buffer that receives the MD4 digest
208 value (16 bytes).
209
210 @retval FALSE This interface is not supported.
211
212 **/
213 BOOLEAN
214 EFIAPI
215 DeprecatedCryptoServiceMd4Final (
216 IN OUT VOID *Md4Context,
217 OUT UINT8 *HashValue
218 )
219 {
220 return BaseCryptLibServiceDeprecated ("Md4Final"), FALSE;
221 }
222
223 /**
224 MD4 is deprecated and unsupported any longer.
225 Keep the function field for binary compability.
226
227 @param[in] Data Pointer to the buffer containing the data to be hashed.
228 @param[in] DataSize Size of Data buffer in bytes.
229 @param[out] HashValue Pointer to a buffer that receives the MD4 digest
230 value (16 bytes).
231
232 @retval FALSE This interface is not supported.
233
234 **/
235 BOOLEAN
236 EFIAPI
237 DeprecatedCryptoServiceMd4HashAll (
238 IN CONST VOID *Data,
239 IN UINTN DataSize,
240 OUT UINT8 *HashValue
241 )
242 {
243 return BaseCryptLibServiceDeprecated ("Md4HashAll"), FALSE;
244 }
245
246 #ifndef ENABLE_MD5_DEPRECATED_INTERFACES
247
248 /**
249 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
250
251 If this interface is not supported, then return zero.
252
253 @retval 0 This interface is not supported.
254
255 **/
256 UINTN
257 EFIAPI
258 DeprecatedCryptoServiceMd5GetContextSize (
259 VOID
260 )
261 {
262 return BaseCryptLibServiceDeprecated ("Md5GetContextSize"), 0;
263 }
264
265 /**
266 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
267 subsequent use.
268
269 If Md5Context is NULL, then return FALSE.
270 If this interface is not supported, then return FALSE.
271
272 @param[out] Md5Context Pointer to MD5 context being initialized.
273
274 @retval FALSE This interface is not supported.
275
276 **/
277 BOOLEAN
278 EFIAPI
279 DeprecatedCryptoServiceMd5Init (
280 OUT VOID *Md5Context
281 )
282 {
283 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
284 }
285
286 /**
287 Makes a copy of an existing MD5 context.
288
289 If Md5Context is NULL, then return FALSE.
290 If NewMd5Context is NULL, then return FALSE.
291 If this interface is not supported, then return FALSE.
292
293 @param[in] Md5Context Pointer to MD5 context being copied.
294 @param[out] NewMd5Context Pointer to new MD5 context.
295
296 @retval FALSE This interface is not supported.
297
298 **/
299 BOOLEAN
300 EFIAPI
301 DeprecatedCryptoServiceMd5Duplicate (
302 IN CONST VOID *Md5Context,
303 OUT VOID *NewMd5Context
304 )
305 {
306 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
307 }
308
309 /**
310 Digests the input data and updates MD5 context.
311
312 This function performs MD5 digest on a data buffer of the specified size.
313 It can be called multiple times to compute the digest of long or discontinuous data streams.
314 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
315 by Md5Final(). Behavior with invalid context is undefined.
316
317 If Md5Context is NULL, then return FALSE.
318 If this interface is not supported, then return FALSE.
319
320 @param[in, out] Md5Context Pointer to the MD5 context.
321 @param[in] Data Pointer to the buffer containing the data to be hashed.
322 @param[in] DataSize Size of Data buffer in bytes.
323
324 @retval FALSE This interface is not supported.
325
326 **/
327 BOOLEAN
328 EFIAPI
329 DeprecatedCryptoServiceMd5Update (
330 IN OUT VOID *Md5Context,
331 IN CONST VOID *Data,
332 IN UINTN DataSize
333 )
334 {
335 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
336 }
337
338 /**
339 Completes computation of the MD5 digest value.
340
341 This function completes MD5 hash computation and retrieves the digest value into
342 the specified memory. After this function has been called, the MD5 context cannot
343 be used again.
344 MD5 context should be already correctly initialized by Md5Init(), and should not be
345 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
346
347 If Md5Context is NULL, then return FALSE.
348 If HashValue is NULL, then return FALSE.
349 If this interface is not supported, then return FALSE.
350
351 @param[in, out] Md5Context Pointer to the MD5 context.
352 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
353 value (16 bytes).
354
355 @retval FALSE This interface is not supported.
356
357 **/
358 BOOLEAN
359 EFIAPI
360 DeprecatedCryptoServiceMd5Final (
361 IN OUT VOID *Md5Context,
362 OUT UINT8 *HashValue
363 )
364 {
365 return BaseCryptLibServiceDeprecated ("Md5Final"), FALSE;
366 }
367
368 /**
369 Computes the MD5 message digest of a input data buffer.
370
371 This function performs the MD5 message digest of a given data buffer, and places
372 the digest value into the specified memory.
373
374 If this interface is not supported, then return FALSE.
375
376 @param[in] Data Pointer to the buffer containing the data to be hashed.
377 @param[in] DataSize Size of Data buffer in bytes.
378 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
379 value (16 bytes).
380
381 @retval FALSE This interface is not supported.
382
383 **/
384 BOOLEAN
385 EFIAPI
386 DeprecatedCryptoServiceMd5HashAll (
387 IN CONST VOID *Data,
388 IN UINTN DataSize,
389 OUT UINT8 *HashValue
390 )
391 {
392 return BaseCryptLibServiceDeprecated ("Md5HashAll"), FALSE;
393 }
394
395 #else
396
397 /**
398 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
399
400 If this interface is not supported, then return zero.
401
402 @return The size, in bytes, of the context buffer required for MD5 hash operations.
403 @retval 0 This interface is not supported.
404
405 **/
406 UINTN
407 EFIAPI
408 CryptoServiceMd5GetContextSize (
409 VOID
410 )
411 {
412 return CALL_BASECRYPTLIB (Md5.Services.GetContextSize, Md5GetContextSize, (), 0);
413 }
414
415 /**
416 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
417 subsequent use.
418
419 If Md5Context is NULL, then return FALSE.
420 If this interface is not supported, then return FALSE.
421
422 @param[out] Md5Context Pointer to MD5 context being initialized.
423
424 @retval TRUE MD5 context initialization succeeded.
425 @retval FALSE MD5 context initialization failed.
426 @retval FALSE This interface is not supported.
427
428 **/
429 BOOLEAN
430 EFIAPI
431 CryptoServiceMd5Init (
432 OUT VOID *Md5Context
433 )
434 {
435 return CALL_BASECRYPTLIB (Md5.Services.Init, Md5Init, (Md5Context), FALSE);
436 }
437
438 /**
439 Makes a copy of an existing MD5 context.
440
441 If Md5Context is NULL, then return FALSE.
442 If NewMd5Context is NULL, then return FALSE.
443 If this interface is not supported, then return FALSE.
444
445 @param[in] Md5Context Pointer to MD5 context being copied.
446 @param[out] NewMd5Context Pointer to new MD5 context.
447
448 @retval TRUE MD5 context copy succeeded.
449 @retval FALSE MD5 context copy failed.
450 @retval FALSE This interface is not supported.
451
452 **/
453 BOOLEAN
454 EFIAPI
455 CryptoServiceMd5Duplicate (
456 IN CONST VOID *Md5Context,
457 OUT VOID *NewMd5Context
458 )
459 {
460 return CALL_BASECRYPTLIB (Md5.Services.Duplicate, Md5Duplicate, (Md5Context, NewMd5Context), FALSE);
461 }
462
463 /**
464 Digests the input data and updates MD5 context.
465
466 This function performs MD5 digest on a data buffer of the specified size.
467 It can be called multiple times to compute the digest of long or discontinuous data streams.
468 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
469 by Md5Final(). Behavior with invalid context is undefined.
470
471 If Md5Context is NULL, then return FALSE.
472 If this interface is not supported, then return FALSE.
473
474 @param[in, out] Md5Context Pointer to the MD5 context.
475 @param[in] Data Pointer to the buffer containing the data to be hashed.
476 @param[in] DataSize Size of Data buffer in bytes.
477
478 @retval TRUE MD5 data digest succeeded.
479 @retval FALSE MD5 data digest failed.
480 @retval FALSE This interface is not supported.
481
482 **/
483 BOOLEAN
484 EFIAPI
485 CryptoServiceMd5Update (
486 IN OUT VOID *Md5Context,
487 IN CONST VOID *Data,
488 IN UINTN DataSize
489 )
490 {
491 return CALL_BASECRYPTLIB (Md5.Services.Update, Md5Update, (Md5Context, Data, DataSize), FALSE);
492 }
493
494 /**
495 Completes computation of the MD5 digest value.
496
497 This function completes MD5 hash computation and retrieves the digest value into
498 the specified memory. After this function has been called, the MD5 context cannot
499 be used again.
500 MD5 context should be already correctly initialized by Md5Init(), and should not be
501 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
502
503 If Md5Context is NULL, then return FALSE.
504 If HashValue is NULL, then return FALSE.
505 If this interface is not supported, then return FALSE.
506
507 @param[in, out] Md5Context Pointer to the MD5 context.
508 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
509 value (16 bytes).
510
511 @retval TRUE MD5 digest computation succeeded.
512 @retval FALSE MD5 digest computation failed.
513 @retval FALSE This interface is not supported.
514
515 **/
516 BOOLEAN
517 EFIAPI
518 CryptoServiceMd5Final (
519 IN OUT VOID *Md5Context,
520 OUT UINT8 *HashValue
521 )
522 {
523 return CALL_BASECRYPTLIB (Md5.Services.Final, Md5Final, (Md5Context, HashValue), FALSE);
524 }
525
526 /**
527 Computes the MD5 message digest of a input data buffer.
528
529 This function performs the MD5 message digest of a given data buffer, and places
530 the digest value into the specified memory.
531
532 If this interface is not supported, then return FALSE.
533
534 @param[in] Data Pointer to the buffer containing the data to be hashed.
535 @param[in] DataSize Size of Data buffer in bytes.
536 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
537 value (16 bytes).
538
539 @retval TRUE MD5 digest computation succeeded.
540 @retval FALSE MD5 digest computation failed.
541 @retval FALSE This interface is not supported.
542
543 **/
544 BOOLEAN
545 EFIAPI
546 CryptoServiceMd5HashAll (
547 IN CONST VOID *Data,
548 IN UINTN DataSize,
549 OUT UINT8 *HashValue
550 )
551 {
552 return CALL_BASECRYPTLIB (Md5.Services.HashAll, Md5HashAll, (Data, DataSize, HashValue), FALSE);
553 }
554
555 #endif
556
557 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
558
559 /**
560 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
561
562 If this interface is not supported, then return zero.
563
564 @retval 0 This interface is not supported.
565
566 **/
567 UINTN
568 EFIAPI
569 DeprecatedCryptoServiceSha1GetContextSize (
570 VOID
571 )
572 {
573 return BaseCryptLibServiceDeprecated ("Sha1GetContextSize"), 0;
574 }
575
576 /**
577 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
578 subsequent use.
579
580 If Sha1Context is NULL, then return FALSE.
581 If this interface is not supported, then return FALSE.
582
583 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
584
585 @retval TRUE SHA-1 context initialization succeeded.
586 @retval FALSE SHA-1 context initialization failed.
587 @retval FALSE This interface is not supported.
588
589 **/
590 BOOLEAN
591 EFIAPI
592 DeprecatedCryptoServiceSha1Init (
593 OUT VOID *Sha1Context
594 )
595 {
596 return BaseCryptLibServiceDeprecated ("Sha1Init"), FALSE;
597 }
598
599 /**
600 Makes a copy of an existing SHA-1 context.
601
602 If Sha1Context is NULL, then return FALSE.
603 If NewSha1Context is NULL, then return FALSE.
604 If this interface is not supported, then return FALSE.
605
606 @param[in] Sha1Context Pointer to SHA-1 context being copied.
607 @param[out] NewSha1Context Pointer to new SHA-1 context.
608
609 @retval FALSE This interface is not supported.
610
611 **/
612 BOOLEAN
613 EFIAPI
614 DeprecatedCryptoServiceSha1Duplicate (
615 IN CONST VOID *Sha1Context,
616 OUT VOID *NewSha1Context
617 )
618 {
619 return BaseCryptLibServiceDeprecated ("Sha1Duplicate"), FALSE;
620 }
621
622 /**
623 Digests the input data and updates SHA-1 context.
624
625 This function performs SHA-1 digest on a data buffer of the specified size.
626 It can be called multiple times to compute the digest of long or discontinuous data streams.
627 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
628 by Sha1Final(). Behavior with invalid context is undefined.
629
630 If Sha1Context is NULL, then return FALSE.
631 If this interface is not supported, then return FALSE.
632
633 @param[in, out] Sha1Context Pointer to the SHA-1 context.
634 @param[in] Data Pointer to the buffer containing the data to be hashed.
635 @param[in] DataSize Size of Data buffer in bytes.
636
637 @retval FALSE This interface is not supported.
638
639 **/
640 BOOLEAN
641 EFIAPI
642 DeprecatedCryptoServiceSha1Update (
643 IN OUT VOID *Sha1Context,
644 IN CONST VOID *Data,
645 IN UINTN DataSize
646 )
647 {
648 return BaseCryptLibServiceDeprecated ("Sha1Update"), FALSE;
649 }
650
651 /**
652 Completes computation of the SHA-1 digest value.
653
654 This function completes SHA-1 hash computation and retrieves the digest value into
655 the specified memory. After this function has been called, the SHA-1 context cannot
656 be used again.
657 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
658 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
659
660 If Sha1Context is NULL, then return FALSE.
661 If HashValue is NULL, then return FALSE.
662 If this interface is not supported, then return FALSE.
663
664 @param[in, out] Sha1Context Pointer to the SHA-1 context.
665 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
666 value (20 bytes).
667
668 @retval FALSE This interface is not supported.
669
670 **/
671 BOOLEAN
672 EFIAPI
673 DeprecatedCryptoServiceSha1Final (
674 IN OUT VOID *Sha1Context,
675 OUT UINT8 *HashValue
676 )
677 {
678 return BaseCryptLibServiceDeprecated ("Sha1Final"), FALSE;
679 }
680
681 /**
682 Computes the SHA-1 message digest of a input data buffer.
683
684 This function performs the SHA-1 message digest of a given data buffer, and places
685 the digest value into the specified memory.
686
687 If this interface is not supported, then return FALSE.
688
689 @param[in] Data Pointer to the buffer containing the data to be hashed.
690 @param[in] DataSize Size of Data buffer in bytes.
691 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
692 value (20 bytes).
693
694 @retval FALSE This interface is not supported.
695
696 **/
697 BOOLEAN
698 EFIAPI
699 DeprecatedCryptoServiceSha1HashAll (
700 IN CONST VOID *Data,
701 IN UINTN DataSize,
702 OUT UINT8 *HashValue
703 )
704 {
705 return BaseCryptLibServiceDeprecated ("Sha1HashAll"), FALSE;
706 }
707
708 #else
709
710 /**
711 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
712
713 If this interface is not supported, then return zero.
714
715 @return The size, in bytes, of the context buffer required for SHA-1 hash operations.
716 @retval 0 This interface is not supported.
717
718 **/
719 UINTN
720 EFIAPI
721 CryptoServiceSha1GetContextSize (
722 VOID
723 )
724 {
725 return CALL_BASECRYPTLIB (Sha1.Services.GetContextSize, Sha1GetContextSize, (), 0);
726 }
727
728 /**
729 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
730 subsequent use.
731
732 If Sha1Context is NULL, then return FALSE.
733 If this interface is not supported, then return FALSE.
734
735 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
736
737 @retval TRUE SHA-1 context initialization succeeded.
738 @retval FALSE SHA-1 context initialization failed.
739 @retval FALSE This interface is not supported.
740
741 **/
742 BOOLEAN
743 EFIAPI
744 CryptoServiceSha1Init (
745 OUT VOID *Sha1Context
746 )
747 {
748 return CALL_BASECRYPTLIB (Sha1.Services.Init, Sha1Init, (Sha1Context), FALSE);
749 }
750
751 /**
752 Makes a copy of an existing SHA-1 context.
753
754 If Sha1Context is NULL, then return FALSE.
755 If NewSha1Context is NULL, then return FALSE.
756 If this interface is not supported, then return FALSE.
757
758 @param[in] Sha1Context Pointer to SHA-1 context being copied.
759 @param[out] NewSha1Context Pointer to new SHA-1 context.
760
761 @retval TRUE SHA-1 context copy succeeded.
762 @retval FALSE SHA-1 context copy failed.
763 @retval FALSE This interface is not supported.
764
765 **/
766 BOOLEAN
767 EFIAPI
768 CryptoServiceSha1Duplicate (
769 IN CONST VOID *Sha1Context,
770 OUT VOID *NewSha1Context
771 )
772 {
773 return CALL_BASECRYPTLIB (Sha1.Services.Duplicate, Sha1Duplicate, (Sha1Context, NewSha1Context), FALSE);
774 }
775
776 /**
777 Digests the input data and updates SHA-1 context.
778
779 This function performs SHA-1 digest on a data buffer of the specified size.
780 It can be called multiple times to compute the digest of long or discontinuous data streams.
781 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
782 by Sha1Final(). Behavior with invalid context is undefined.
783
784 If Sha1Context is NULL, then return FALSE.
785 If this interface is not supported, then return FALSE.
786
787 @param[in, out] Sha1Context Pointer to the SHA-1 context.
788 @param[in] Data Pointer to the buffer containing the data to be hashed.
789 @param[in] DataSize Size of Data buffer in bytes.
790
791 @retval TRUE SHA-1 data digest succeeded.
792 @retval FALSE SHA-1 data digest failed.
793 @retval FALSE This interface is not supported.
794
795 **/
796 BOOLEAN
797 EFIAPI
798 CryptoServiceSha1Update (
799 IN OUT VOID *Sha1Context,
800 IN CONST VOID *Data,
801 IN UINTN DataSize
802 )
803 {
804 return CALL_BASECRYPTLIB (Sha1.Services.Update, Sha1Update, (Sha1Context, Data, DataSize), FALSE);
805 }
806
807 /**
808 Completes computation of the SHA-1 digest value.
809
810 This function completes SHA-1 hash computation and retrieves the digest value into
811 the specified memory. After this function has been called, the SHA-1 context cannot
812 be used again.
813 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
814 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
815
816 If Sha1Context is NULL, then return FALSE.
817 If HashValue is NULL, then return FALSE.
818 If this interface is not supported, then return FALSE.
819
820 @param[in, out] Sha1Context Pointer to the SHA-1 context.
821 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
822 value (20 bytes).
823
824 @retval TRUE SHA-1 digest computation succeeded.
825 @retval FALSE SHA-1 digest computation failed.
826 @retval FALSE This interface is not supported.
827
828 **/
829 BOOLEAN
830 EFIAPI
831 CryptoServiceSha1Final (
832 IN OUT VOID *Sha1Context,
833 OUT UINT8 *HashValue
834 )
835 {
836 return CALL_BASECRYPTLIB (Sha1.Services.Final, Sha1Final, (Sha1Context, HashValue), FALSE);
837 }
838
839 /**
840 Computes the SHA-1 message digest of a input data buffer.
841
842 This function performs the SHA-1 message digest of a given data buffer, and places
843 the digest value into the specified memory.
844
845 If this interface is not supported, then return FALSE.
846
847 @param[in] Data Pointer to the buffer containing the data to be hashed.
848 @param[in] DataSize Size of Data buffer in bytes.
849 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
850 value (20 bytes).
851
852 @retval TRUE SHA-1 digest computation succeeded.
853 @retval FALSE SHA-1 digest computation failed.
854 @retval FALSE This interface is not supported.
855
856 **/
857 BOOLEAN
858 EFIAPI
859 CryptoServiceSha1HashAll (
860 IN CONST VOID *Data,
861 IN UINTN DataSize,
862 OUT UINT8 *HashValue
863 )
864 {
865 return CALL_BASECRYPTLIB (Sha1.Services.HashAll, Sha1HashAll, (Data, DataSize, HashValue), FALSE);
866 }
867
868 #endif
869
870 /**
871 Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
872
873 @return The size, in bytes, of the context buffer required for SHA-256 hash operations.
874
875 **/
876 UINTN
877 EFIAPI
878 CryptoServiceSha256GetContextSize (
879 VOID
880 )
881 {
882 return CALL_BASECRYPTLIB (Sha256.Services.GetContextSize, Sha256GetContextSize, (), 0);
883 }
884
885 /**
886 Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
887 subsequent use.
888
889 If Sha256Context is NULL, then return FALSE.
890
891 @param[out] Sha256Context Pointer to SHA-256 context being initialized.
892
893 @retval TRUE SHA-256 context initialization succeeded.
894 @retval FALSE SHA-256 context initialization failed.
895
896 **/
897 BOOLEAN
898 EFIAPI
899 CryptoServiceSha256Init (
900 OUT VOID *Sha256Context
901 )
902 {
903 return CALL_BASECRYPTLIB (Sha256.Services.Init, Sha256Init, (Sha256Context), FALSE);
904 }
905
906 /**
907 Makes a copy of an existing SHA-256 context.
908
909 If Sha256Context is NULL, then return FALSE.
910 If NewSha256Context is NULL, then return FALSE.
911 If this interface is not supported, then return FALSE.
912
913 @param[in] Sha256Context Pointer to SHA-256 context being copied.
914 @param[out] NewSha256Context Pointer to new SHA-256 context.
915
916 @retval TRUE SHA-256 context copy succeeded.
917 @retval FALSE SHA-256 context copy failed.
918 @retval FALSE This interface is not supported.
919
920 **/
921 BOOLEAN
922 EFIAPI
923 CryptoServiceSha256Duplicate (
924 IN CONST VOID *Sha256Context,
925 OUT VOID *NewSha256Context
926 )
927 {
928 return CALL_BASECRYPTLIB (Sha256.Services.Duplicate, Sha256Duplicate, (Sha256Context, NewSha256Context), FALSE);
929 }
930
931 /**
932 Digests the input data and updates SHA-256 context.
933
934 This function performs SHA-256 digest on a data buffer of the specified size.
935 It can be called multiple times to compute the digest of long or discontinuous data streams.
936 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized
937 by Sha256Final(). Behavior with invalid context is undefined.
938
939 If Sha256Context is NULL, then return FALSE.
940
941 @param[in, out] Sha256Context Pointer to the SHA-256 context.
942 @param[in] Data Pointer to the buffer containing the data to be hashed.
943 @param[in] DataSize Size of Data buffer in bytes.
944
945 @retval TRUE SHA-256 data digest succeeded.
946 @retval FALSE SHA-256 data digest failed.
947
948 **/
949 BOOLEAN
950 EFIAPI
951 CryptoServiceSha256Update (
952 IN OUT VOID *Sha256Context,
953 IN CONST VOID *Data,
954 IN UINTN DataSize
955 )
956 {
957 return CALL_BASECRYPTLIB (Sha256.Services.Update, Sha256Update, (Sha256Context, Data, DataSize), FALSE);
958 }
959
960 /**
961 Completes computation of the SHA-256 digest value.
962
963 This function completes SHA-256 hash computation and retrieves the digest value into
964 the specified memory. After this function has been called, the SHA-256 context cannot
965 be used again.
966 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be
967 finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
968
969 If Sha256Context is NULL, then return FALSE.
970 If HashValue is NULL, then return FALSE.
971
972 @param[in, out] Sha256Context Pointer to the SHA-256 context.
973 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
974 value (32 bytes).
975
976 @retval TRUE SHA-256 digest computation succeeded.
977 @retval FALSE SHA-256 digest computation failed.
978
979 **/
980 BOOLEAN
981 EFIAPI
982 CryptoServiceSha256Final (
983 IN OUT VOID *Sha256Context,
984 OUT UINT8 *HashValue
985 )
986 {
987 return CALL_BASECRYPTLIB (Sha256.Services.Final, Sha256Final, (Sha256Context, HashValue), FALSE);
988 }
989
990 /**
991 Computes the SHA-256 message digest of a input data buffer.
992
993 This function performs the SHA-256 message digest of a given data buffer, and places
994 the digest value into the specified memory.
995
996 If this interface is not supported, then return FALSE.
997
998 @param[in] Data Pointer to the buffer containing the data to be hashed.
999 @param[in] DataSize Size of Data buffer in bytes.
1000 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
1001 value (32 bytes).
1002
1003 @retval TRUE SHA-256 digest computation succeeded.
1004 @retval FALSE SHA-256 digest computation failed.
1005 @retval FALSE This interface is not supported.
1006
1007 **/
1008 BOOLEAN
1009 EFIAPI
1010 CryptoServiceSha256HashAll (
1011 IN CONST VOID *Data,
1012 IN UINTN DataSize,
1013 OUT UINT8 *HashValue
1014 )
1015 {
1016 return CALL_BASECRYPTLIB (Sha256.Services.HashAll, Sha256HashAll, (Data, DataSize, HashValue), FALSE);
1017 }
1018
1019 /**
1020 Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
1021
1022 @return The size, in bytes, of the context buffer required for SHA-384 hash operations.
1023
1024 **/
1025 UINTN
1026 EFIAPI
1027 CryptoServiceSha384GetContextSize (
1028 VOID
1029 )
1030 {
1031 return CALL_BASECRYPTLIB (Sha384.Services.GetContextSize, Sha384GetContextSize, (), 0);
1032 }
1033
1034 /**
1035 Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for
1036 subsequent use.
1037
1038 If Sha384Context is NULL, then return FALSE.
1039
1040 @param[out] Sha384Context Pointer to SHA-384 context being initialized.
1041
1042 @retval TRUE SHA-384 context initialization succeeded.
1043 @retval FALSE SHA-384 context initialization failed.
1044
1045 **/
1046 BOOLEAN
1047 EFIAPI
1048 CryptoServiceSha384Init (
1049 OUT VOID *Sha384Context
1050 )
1051 {
1052 return CALL_BASECRYPTLIB (Sha384.Services.Init, Sha384Init, (Sha384Context), FALSE);
1053 }
1054
1055 /**
1056 Makes a copy of an existing SHA-384 context.
1057
1058 If Sha384Context is NULL, then return FALSE.
1059 If NewSha384Context is NULL, then return FALSE.
1060 If this interface is not supported, then return FALSE.
1061
1062 @param[in] Sha384Context Pointer to SHA-384 context being copied.
1063 @param[out] NewSha384Context Pointer to new SHA-384 context.
1064
1065 @retval TRUE SHA-384 context copy succeeded.
1066 @retval FALSE SHA-384 context copy failed.
1067 @retval FALSE This interface is not supported.
1068
1069 **/
1070 BOOLEAN
1071 EFIAPI
1072 CryptoServiceSha384Duplicate (
1073 IN CONST VOID *Sha384Context,
1074 OUT VOID *NewSha384Context
1075 )
1076 {
1077 return CALL_BASECRYPTLIB (Sha384.Services.Duplicate, Sha384Duplicate, (Sha384Context, NewSha384Context), FALSE);
1078 }
1079
1080 /**
1081 Digests the input data and updates SHA-384 context.
1082
1083 This function performs SHA-384 digest on a data buffer of the specified size.
1084 It can be called multiple times to compute the digest of long or discontinuous data streams.
1085 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized
1086 by Sha384Final(). Behavior with invalid context is undefined.
1087
1088 If Sha384Context is NULL, then return FALSE.
1089
1090 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1091 @param[in] Data Pointer to the buffer containing the data to be hashed.
1092 @param[in] DataSize Size of Data buffer in bytes.
1093
1094 @retval TRUE SHA-384 data digest succeeded.
1095 @retval FALSE SHA-384 data digest failed.
1096
1097 **/
1098 BOOLEAN
1099 EFIAPI
1100 CryptoServiceSha384Update (
1101 IN OUT VOID *Sha384Context,
1102 IN CONST VOID *Data,
1103 IN UINTN DataSize
1104 )
1105 {
1106 return CALL_BASECRYPTLIB (Sha384.Services.Update, Sha384Update, (Sha384Context, Data, DataSize), FALSE);
1107 }
1108
1109 /**
1110 Completes computation of the SHA-384 digest value.
1111
1112 This function completes SHA-384 hash computation and retrieves the digest value into
1113 the specified memory. After this function has been called, the SHA-384 context cannot
1114 be used again.
1115 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be
1116 finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.
1117
1118 If Sha384Context is NULL, then return FALSE.
1119 If HashValue is NULL, then return FALSE.
1120
1121 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1122 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1123 value (48 bytes).
1124
1125 @retval TRUE SHA-384 digest computation succeeded.
1126 @retval FALSE SHA-384 digest computation failed.
1127
1128 **/
1129 BOOLEAN
1130 EFIAPI
1131 CryptoServiceSha384Final (
1132 IN OUT VOID *Sha384Context,
1133 OUT UINT8 *HashValue
1134 )
1135 {
1136 return CALL_BASECRYPTLIB (Sha384.Services.Final, Sha384Final, (Sha384Context, HashValue), FALSE);
1137 }
1138
1139 /**
1140 Computes the SHA-384 message digest of a input data buffer.
1141
1142 This function performs the SHA-384 message digest of a given data buffer, and places
1143 the digest value into the specified memory.
1144
1145 If this interface is not supported, then return FALSE.
1146
1147 @param[in] Data Pointer to the buffer containing the data to be hashed.
1148 @param[in] DataSize Size of Data buffer in bytes.
1149 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1150 value (48 bytes).
1151
1152 @retval TRUE SHA-384 digest computation succeeded.
1153 @retval FALSE SHA-384 digest computation failed.
1154 @retval FALSE This interface is not supported.
1155
1156 **/
1157 BOOLEAN
1158 EFIAPI
1159 CryptoServiceSha384HashAll (
1160 IN CONST VOID *Data,
1161 IN UINTN DataSize,
1162 OUT UINT8 *HashValue
1163 )
1164 {
1165 return CALL_BASECRYPTLIB (Sha384.Services.HashAll, Sha384HashAll, (Data, DataSize, HashValue), FALSE);
1166 }
1167
1168 /**
1169 Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.
1170
1171 @return The size, in bytes, of the context buffer required for SHA-512 hash operations.
1172
1173 **/
1174 UINTN
1175 EFIAPI
1176 CryptoServiceSha512GetContextSize (
1177 VOID
1178 )
1179 {
1180 return CALL_BASECRYPTLIB (Sha512.Services.GetContextSize, Sha512GetContextSize, (), 0);
1181 }
1182
1183 /**
1184 Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for
1185 subsequent use.
1186
1187 If Sha512Context is NULL, then return FALSE.
1188
1189 @param[out] Sha512Context Pointer to SHA-512 context being initialized.
1190
1191 @retval TRUE SHA-512 context initialization succeeded.
1192 @retval FALSE SHA-512 context initialization failed.
1193
1194 **/
1195 BOOLEAN
1196 EFIAPI
1197 CryptoServiceSha512Init (
1198 OUT VOID *Sha512Context
1199 )
1200 {
1201 return CALL_BASECRYPTLIB (Sha512.Services.Init, Sha512Init, (Sha512Context), FALSE);
1202 }
1203
1204 /**
1205 Makes a copy of an existing SHA-512 context.
1206
1207 If Sha512Context is NULL, then return FALSE.
1208 If NewSha512Context is NULL, then return FALSE.
1209 If this interface is not supported, then return FALSE.
1210
1211 @param[in] Sha512Context Pointer to SHA-512 context being copied.
1212 @param[out] NewSha512Context Pointer to new SHA-512 context.
1213
1214 @retval TRUE SHA-512 context copy succeeded.
1215 @retval FALSE SHA-512 context copy failed.
1216 @retval FALSE This interface is not supported.
1217
1218 **/
1219 BOOLEAN
1220 EFIAPI
1221 CryptoServiceSha512Duplicate (
1222 IN CONST VOID *Sha512Context,
1223 OUT VOID *NewSha512Context
1224 )
1225 {
1226 return CALL_BASECRYPTLIB (Sha512.Services.Duplicate, Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);
1227 }
1228
1229 /**
1230 Digests the input data and updates SHA-512 context.
1231
1232 This function performs SHA-512 digest on a data buffer of the specified size.
1233 It can be called multiple times to compute the digest of long or discontinuous data streams.
1234 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized
1235 by Sha512Final(). Behavior with invalid context is undefined.
1236
1237 If Sha512Context is NULL, then return FALSE.
1238
1239 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1240 @param[in] Data Pointer to the buffer containing the data to be hashed.
1241 @param[in] DataSize Size of Data buffer in bytes.
1242
1243 @retval TRUE SHA-512 data digest succeeded.
1244 @retval FALSE SHA-512 data digest failed.
1245
1246 **/
1247 BOOLEAN
1248 EFIAPI
1249 CryptoServiceSha512Update (
1250 IN OUT VOID *Sha512Context,
1251 IN CONST VOID *Data,
1252 IN UINTN DataSize
1253 )
1254 {
1255 return CALL_BASECRYPTLIB (Sha512.Services.Update, Sha512Update, (Sha512Context, Data, DataSize), FALSE);
1256 }
1257
1258 /**
1259 Completes computation of the SHA-512 digest value.
1260
1261 This function completes SHA-512 hash computation and retrieves the digest value into
1262 the specified memory. After this function has been called, the SHA-512 context cannot
1263 be used again.
1264 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be
1265 finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.
1266
1267 If Sha512Context is NULL, then return FALSE.
1268 If HashValue is NULL, then return FALSE.
1269
1270 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1271 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1272 value (64 bytes).
1273
1274 @retval TRUE SHA-512 digest computation succeeded.
1275 @retval FALSE SHA-512 digest computation failed.
1276
1277 **/
1278 BOOLEAN
1279 EFIAPI
1280 CryptoServiceSha512Final (
1281 IN OUT VOID *Sha512Context,
1282 OUT UINT8 *HashValue
1283 )
1284 {
1285 return CALL_BASECRYPTLIB (Sha512.Services.Final, Sha512Final, (Sha512Context, HashValue), FALSE);
1286 }
1287
1288 /**
1289 Computes the SHA-512 message digest of a input data buffer.
1290
1291 This function performs the SHA-512 message digest of a given data buffer, and places
1292 the digest value into the specified memory.
1293
1294 If this interface is not supported, then return FALSE.
1295
1296 @param[in] Data Pointer to the buffer containing the data to be hashed.
1297 @param[in] DataSize Size of Data buffer in bytes.
1298 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1299 value (64 bytes).
1300
1301 @retval TRUE SHA-512 digest computation succeeded.
1302 @retval FALSE SHA-512 digest computation failed.
1303 @retval FALSE This interface is not supported.
1304
1305 **/
1306 BOOLEAN
1307 EFIAPI
1308 CryptoServiceSha512HashAll (
1309 IN CONST VOID *Data,
1310 IN UINTN DataSize,
1311 OUT UINT8 *HashValue
1312 )
1313 {
1314 return CALL_BASECRYPTLIB (Sha512.Services.HashAll, Sha512HashAll, (Data, DataSize, HashValue), FALSE);
1315 }
1316
1317 /**
1318 Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.
1319
1320 @return The size, in bytes, of the context buffer required for SM3 hash operations.
1321
1322 **/
1323 UINTN
1324 EFIAPI
1325 CryptoServiceSm3GetContextSize (
1326 VOID
1327 )
1328 {
1329 return CALL_BASECRYPTLIB (Sm3.Services.GetContextSize, Sm3GetContextSize, (), 0);
1330 }
1331
1332 /**
1333 Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for
1334 subsequent use.
1335
1336 If Sm3Context is NULL, then return FALSE.
1337
1338 @param[out] Sm3Context Pointer to SM3 context being initialized.
1339
1340 @retval TRUE SM3 context initialization succeeded.
1341 @retval FALSE SM3 context initialization failed.
1342
1343 **/
1344 BOOLEAN
1345 EFIAPI
1346 CryptoServiceSm3Init (
1347 OUT VOID *Sm3Context
1348 )
1349 {
1350 return CALL_BASECRYPTLIB (Sm3.Services.Init, Sm3Init, (Sm3Context), FALSE);
1351 }
1352
1353 /**
1354 Makes a copy of an existing SM3 context.
1355
1356 If Sm3Context is NULL, then return FALSE.
1357 If NewSm3Context is NULL, then return FALSE.
1358 If this interface is not supported, then return FALSE.
1359
1360 @param[in] Sm3Context Pointer to SM3 context being copied.
1361 @param[out] NewSm3Context Pointer to new SM3 context.
1362
1363 @retval TRUE SM3 context copy succeeded.
1364 @retval FALSE SM3 context copy failed.
1365 @retval FALSE This interface is not supported.
1366
1367 **/
1368 BOOLEAN
1369 EFIAPI
1370 CryptoServiceSm3Duplicate (
1371 IN CONST VOID *Sm3Context,
1372 OUT VOID *NewSm3Context
1373 )
1374 {
1375 return CALL_BASECRYPTLIB (Sm3.Services.Duplicate, Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE);
1376 }
1377
1378 /**
1379 Digests the input data and updates SM3 context.
1380
1381 This function performs SM3 digest on a data buffer of the specified size.
1382 It can be called multiple times to compute the digest of long or discontinuous data streams.
1383 SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized
1384 by Sm3Final(). Behavior with invalid context is undefined.
1385
1386 If Sm3Context is NULL, then return FALSE.
1387
1388 @param[in, out] Sm3Context Pointer to the SM3 context.
1389 @param[in] Data Pointer to the buffer containing the data to be hashed.
1390 @param[in] DataSize Size of Data buffer in bytes.
1391
1392 @retval TRUE SM3 data digest succeeded.
1393 @retval FALSE SM3 data digest failed.
1394
1395 **/
1396 BOOLEAN
1397 EFIAPI
1398 CryptoServiceSm3Update (
1399 IN OUT VOID *Sm3Context,
1400 IN CONST VOID *Data,
1401 IN UINTN DataSize
1402 )
1403 {
1404 return CALL_BASECRYPTLIB (Sm3.Services.Update, Sm3Update, (Sm3Context, Data, DataSize), FALSE);
1405 }
1406
1407 /**
1408 Completes computation of the SM3 digest value.
1409
1410 This function completes SM3 hash computation and retrieves the digest value into
1411 the specified memory. After this function has been called, the SM3 context cannot
1412 be used again.
1413 SM3 context should be already correctly initialized by Sm3Init(), and should not be
1414 finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.
1415
1416 If Sm3Context is NULL, then return FALSE.
1417 If HashValue is NULL, then return FALSE.
1418
1419 @param[in, out] Sm3Context Pointer to the SM3 context.
1420 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1421 value (32 bytes).
1422
1423 @retval TRUE SM3 digest computation succeeded.
1424 @retval FALSE SM3 digest computation failed.
1425
1426 **/
1427 BOOLEAN
1428 EFIAPI
1429 CryptoServiceSm3Final (
1430 IN OUT VOID *Sm3Context,
1431 OUT UINT8 *HashValue
1432 )
1433 {
1434 return CALL_BASECRYPTLIB (Sm3.Services.Final, Sm3Final, (Sm3Context, HashValue), FALSE);
1435 }
1436
1437 /**
1438 Computes the SM3 message digest of a input data buffer.
1439
1440 This function performs the SM3 message digest of a given data buffer, and places
1441 the digest value into the specified memory.
1442
1443 If this interface is not supported, then return FALSE.
1444
1445 @param[in] Data Pointer to the buffer containing the data to be hashed.
1446 @param[in] DataSize Size of Data buffer in bytes.
1447 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1448 value (32 bytes).
1449
1450 @retval TRUE SM3 digest computation succeeded.
1451 @retval FALSE SM3 digest computation failed.
1452 @retval FALSE This interface is not supported.
1453
1454 **/
1455 BOOLEAN
1456 EFIAPI
1457 CryptoServiceSm3HashAll (
1458 IN CONST VOID *Data,
1459 IN UINTN DataSize,
1460 OUT UINT8 *HashValue
1461 )
1462 {
1463 return CALL_BASECRYPTLIB (Sm3.Services.HashAll, Sm3HashAll, (Data, DataSize, HashValue), FALSE);
1464 }
1465
1466 // =====================================================================================
1467 // MAC (Message Authentication Code) Primitive
1468 // =====================================================================================
1469
1470 /**
1471 HMAC MD5 is deprecated and unsupported any longer.
1472 Keep the function field for binary compability.
1473
1474 @retval NULL This interface is not supported.
1475
1476 **/
1477 VOID *
1478 EFIAPI
1479 DeprecatedCryptoServiceHmacMd5New (
1480 VOID
1481 )
1482 {
1483 return BaseCryptLibServiceDeprecated ("HmacMd5New"), NULL;
1484 }
1485
1486 /**
1487 HMAC MD5 is deprecated and unsupported any longer.
1488 Keep the function field for binary compability.
1489
1490 @param[in] HmacMd5Ctx Pointer to the HMAC_CTX context to be released.
1491
1492 **/
1493 VOID
1494 EFIAPI
1495 DeprecatedCryptoServiceHmacMd5Free (
1496 IN VOID *HmacMd5Ctx
1497 )
1498 {
1499 BaseCryptLibServiceDeprecated ("HmacMd5Free");
1500 }
1501
1502 /**
1503 HMAC MD5 is deprecated and unsupported any longer.
1504 Keep the function field for binary compability.
1505
1506 @param[out] HmacMd5Context Pointer to HMAC-MD5 context.
1507 @param[in] Key Pointer to the user-supplied key.
1508 @param[in] KeySize Key size in bytes.
1509
1510 @retval FALSE This interface is not supported.
1511
1512 **/
1513 BOOLEAN
1514 EFIAPI
1515 DeprecatedCryptoServiceHmacMd5SetKey (
1516 OUT VOID *HmacMd5Context,
1517 IN CONST UINT8 *Key,
1518 IN UINTN KeySize
1519 )
1520 {
1521 return BaseCryptLibServiceDeprecated ("HmacMd5SetKey"), FALSE;
1522 }
1523
1524 /**
1525 HMAC MD5 is deprecated and unsupported any longer.
1526 Keep the function field for binary compability.
1527
1528 @param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied.
1529 @param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context.
1530
1531 @retval FALSE This interface is not supported.
1532
1533 **/
1534 BOOLEAN
1535 EFIAPI
1536 DeprecatedCryptoServiceHmacMd5Duplicate (
1537 IN CONST VOID *HmacMd5Context,
1538 OUT VOID *NewHmacMd5Context
1539 )
1540 {
1541 return BaseCryptLibServiceDeprecated ("HmacMd5Duplicate"), FALSE;
1542 }
1543
1544 /**
1545 HMAC MD5 is deprecated and unsupported any longer.
1546 Keep the function field for binary compability.
1547
1548 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1549 @param[in] Data Pointer to the buffer containing the data to be digested.
1550 @param[in] DataSize Size of Data buffer in bytes.
1551
1552 @retval FALSE This interface is not supported.
1553
1554 **/
1555 BOOLEAN
1556 EFIAPI
1557 DeprecatedCryptoServiceHmacMd5Update (
1558 IN OUT VOID *HmacMd5Context,
1559 IN CONST VOID *Data,
1560 IN UINTN DataSize
1561 )
1562 {
1563 return BaseCryptLibServiceDeprecated ("HmacMd5Update"), FALSE;
1564 }
1565
1566 /**
1567 HMAC MD5 is deprecated and unsupported any longer.
1568 Keep the function field for binary compability.
1569
1570 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1571 @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest
1572 value (16 bytes).
1573
1574 @retval FALSE This interface is not supported.
1575
1576 **/
1577 BOOLEAN
1578 EFIAPI
1579 DeprecatedCryptoServiceHmacMd5Final (
1580 IN OUT VOID *HmacMd5Context,
1581 OUT UINT8 *HmacValue
1582 )
1583 {
1584 return BaseCryptLibServiceDeprecated ("HmacMd5Final"), FALSE;
1585 }
1586
1587 /**
1588 HMAC SHA1 is deprecated and unsupported any longer.
1589 Keep the function field for binary compability.
1590
1591 @return NULL This interface is not supported.
1592
1593 **/
1594 VOID *
1595 EFIAPI
1596 DeprecatedCryptoServiceHmacSha1New (
1597 VOID
1598 )
1599 {
1600 return BaseCryptLibServiceDeprecated ("HmacSha1New"), NULL;
1601 }
1602
1603 /**
1604 HMAC SHA1 is deprecated and unsupported any longer.
1605 Keep the function field for binary compability.
1606
1607 @param[in] HmacSha1Ctx Pointer to the HMAC_CTX context to be released.
1608
1609 **/
1610 VOID
1611 EFIAPI
1612 DeprecatedCryptoServiceHmacSha1Free (
1613 IN VOID *HmacSha1Ctx
1614 )
1615 {
1616 BaseCryptLibServiceDeprecated ("HmacSha1Free");
1617 }
1618
1619 /**
1620 HMAC SHA1 is deprecated and unsupported any longer.
1621 Keep the function field for binary compability.
1622
1623 @param[out] HmacSha1Context Pointer to HMAC-SHA1 context.
1624 @param[in] Key Pointer to the user-supplied key.
1625 @param[in] KeySize Key size in bytes.
1626
1627 @retval FALSE This interface is not supported.
1628
1629 **/
1630 BOOLEAN
1631 EFIAPI
1632 DeprecatedCryptoServiceHmacSha1SetKey (
1633 OUT VOID *HmacSha1Context,
1634 IN CONST UINT8 *Key,
1635 IN UINTN KeySize
1636 )
1637 {
1638 return BaseCryptLibServiceDeprecated ("HmacSha1SetKey"), FALSE;
1639 }
1640
1641 /**
1642 HMAC SHA1 is deprecated and unsupported any longer.
1643 Keep the function field for binary compability.
1644
1645 @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied.
1646 @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context.
1647
1648 @retval FALSE This interface is not supported.
1649
1650 **/
1651 BOOLEAN
1652 EFIAPI
1653 DeprecatedCryptoServiceHmacSha1Duplicate (
1654 IN CONST VOID *HmacSha1Context,
1655 OUT VOID *NewHmacSha1Context
1656 )
1657 {
1658 return BaseCryptLibServiceDeprecated ("HmacSha1Duplicate"), FALSE;
1659 }
1660
1661 /**
1662 HMAC SHA1 is deprecated and unsupported any longer.
1663 Keep the function field for binary compability.
1664
1665 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1666 @param[in] Data Pointer to the buffer containing the data to be digested.
1667 @param[in] DataSize Size of Data buffer in bytes.
1668
1669 @retval FALSE This interface is not supported.
1670
1671 **/
1672 BOOLEAN
1673 EFIAPI
1674 DeprecatedCryptoServiceHmacSha1Update (
1675 IN OUT VOID *HmacSha1Context,
1676 IN CONST VOID *Data,
1677 IN UINTN DataSize
1678 )
1679 {
1680 return BaseCryptLibServiceDeprecated ("HmacSha1Update"), FALSE;
1681 }
1682
1683 /**
1684 HMAC SHA1 is deprecated and unsupported any longer.
1685 Keep the function field for binary compability.
1686
1687 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1688 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest
1689 value (20 bytes).
1690
1691 @retval FALSE This interface is not supported.
1692
1693 **/
1694 BOOLEAN
1695 EFIAPI
1696 DeprecatedCryptoServiceHmacSha1Final (
1697 IN OUT VOID *HmacSha1Context,
1698 OUT UINT8 *HmacValue
1699 )
1700 {
1701 return BaseCryptLibServiceDeprecated ("HmacSha1Final"), FALSE;
1702 }
1703
1704 /**
1705 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.
1706
1707 @return Pointer to the HMAC_CTX context that has been initialized.
1708 If the allocations fails, HmacSha256New() returns NULL.
1709
1710 **/
1711 VOID *
1712 EFIAPI
1713 CryptoServiceHmacSha256New (
1714 VOID
1715 )
1716 {
1717 return CALL_BASECRYPTLIB (HmacSha256.Services.New, HmacSha256New, (), NULL);
1718 }
1719
1720 /**
1721 Release the specified HMAC_CTX context.
1722
1723 @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.
1724
1725 **/
1726 VOID
1727 EFIAPI
1728 CryptoServiceHmacSha256Free (
1729 IN VOID *HmacSha256Ctx
1730 )
1731 {
1732 CALL_VOID_BASECRYPTLIB (HmacSha256.Services.Free, HmacSha256Free, (HmacSha256Ctx));
1733 }
1734
1735 /**
1736 Set user-supplied key for subsequent use. It must be done before any
1737 calling to HmacSha256Update().
1738
1739 If HmacSha256Context is NULL, then return FALSE.
1740 If this interface is not supported, then return FALSE.
1741
1742 @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.
1743 @param[in] Key Pointer to the user-supplied key.
1744 @param[in] KeySize Key size in bytes.
1745
1746 @retval TRUE The Key is set successfully.
1747 @retval FALSE The Key is set unsuccessfully.
1748 @retval FALSE This interface is not supported.
1749
1750 **/
1751 BOOLEAN
1752 EFIAPI
1753 CryptoServiceHmacSha256SetKey (
1754 OUT VOID *HmacSha256Context,
1755 IN CONST UINT8 *Key,
1756 IN UINTN KeySize
1757 )
1758 {
1759 return CALL_BASECRYPTLIB (HmacSha256.Services.SetKey, HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE);
1760 }
1761
1762 /**
1763 Makes a copy of an existing HMAC-SHA256 context.
1764
1765 If HmacSha256Context is NULL, then return FALSE.
1766 If NewHmacSha256Context is NULL, then return FALSE.
1767 If this interface is not supported, then return FALSE.
1768
1769 @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.
1770 @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.
1771
1772 @retval TRUE HMAC-SHA256 context copy succeeded.
1773 @retval FALSE HMAC-SHA256 context copy failed.
1774 @retval FALSE This interface is not supported.
1775
1776 **/
1777 BOOLEAN
1778 EFIAPI
1779 CryptoServiceHmacSha256Duplicate (
1780 IN CONST VOID *HmacSha256Context,
1781 OUT VOID *NewHmacSha256Context
1782 )
1783 {
1784 return CALL_BASECRYPTLIB (HmacSha256.Services.Duplicate, HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);
1785 }
1786
1787 /**
1788 Digests the input data and updates HMAC-SHA256 context.
1789
1790 This function performs HMAC-SHA256 digest on a data buffer of the specified size.
1791 It can be called multiple times to compute the digest of long or discontinuous data streams.
1792 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1793 by HmacSha256Final(). Behavior with invalid context is undefined.
1794
1795 If HmacSha256Context is NULL, then return FALSE.
1796 If this interface is not supported, then return FALSE.
1797
1798 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1799 @param[in] Data Pointer to the buffer containing the data to be digested.
1800 @param[in] DataSize Size of Data buffer in bytes.
1801
1802 @retval TRUE HMAC-SHA256 data digest succeeded.
1803 @retval FALSE HMAC-SHA256 data digest failed.
1804 @retval FALSE This interface is not supported.
1805
1806 **/
1807 BOOLEAN
1808 EFIAPI
1809 CryptoServiceHmacSha256Update (
1810 IN OUT VOID *HmacSha256Context,
1811 IN CONST VOID *Data,
1812 IN UINTN DataSize
1813 )
1814 {
1815 return CALL_BASECRYPTLIB (HmacSha256.Services.Update, HmacSha256Update, (HmacSha256Context, Data, DataSize), FALSE);
1816 }
1817
1818 /**
1819 Completes computation of the HMAC-SHA256 digest value.
1820
1821 This function completes HMAC-SHA256 hash computation and retrieves the digest value into
1822 the specified memory. After this function has been called, the HMAC-SHA256 context cannot
1823 be used again.
1824 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1825 by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
1826
1827 If HmacSha256Context is NULL, then return FALSE.
1828 If HmacValue is NULL, then return FALSE.
1829 If this interface is not supported, then return FALSE.
1830
1831 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1832 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
1833 value (32 bytes).
1834
1835 @retval TRUE HMAC-SHA256 digest computation succeeded.
1836 @retval FALSE HMAC-SHA256 digest computation failed.
1837 @retval FALSE This interface is not supported.
1838
1839 **/
1840 BOOLEAN
1841 EFIAPI
1842 CryptoServiceHmacSha256Final (
1843 IN OUT VOID *HmacSha256Context,
1844 OUT UINT8 *HmacValue
1845 )
1846 {
1847 return CALL_BASECRYPTLIB (HmacSha256.Services.Final, HmacSha256Final, (HmacSha256Context, HmacValue), FALSE);
1848 }
1849
1850 /**
1851 Computes the HMAC-SHA256 digest of a input data buffer.
1852
1853 This function performs the HMAC-SHA256 digest of a given data buffer, and places
1854 the digest value into the specified memory.
1855
1856 If this interface is not supported, then return FALSE.
1857
1858 @param[in] Data Pointer to the buffer containing the data to be digested.
1859 @param[in] DataSize Size of Data buffer in bytes.
1860 @param[in] Key Pointer to the user-supplied key.
1861 @param[in] KeySize Key size in bytes.
1862 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
1863 value (32 bytes).
1864
1865 @retval TRUE HMAC-SHA256 digest computation succeeded.
1866 @retval FALSE HMAC-SHA256 digest computation failed.
1867 @retval FALSE This interface is not supported.
1868
1869 **/
1870 BOOLEAN
1871 EFIAPI
1872 CryptoServiceHmacSha256All (
1873 IN CONST VOID *Data,
1874 IN UINTN DataSize,
1875 IN CONST UINT8 *Key,
1876 IN UINTN KeySize,
1877 OUT UINT8 *HmacValue
1878 )
1879 {
1880 return CALL_BASECRYPTLIB (HmacSha256.Services.All, HmacSha256All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);
1881 }
1882
1883 /**
1884 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.
1885
1886 @return Pointer to the HMAC_CTX context that has been initialized.
1887 If the allocations fails, HmacSha384New() returns NULL.
1888
1889 **/
1890 VOID *
1891 EFIAPI
1892 CryptoServiceHmacSha384New (
1893 VOID
1894 )
1895 {
1896 return CALL_BASECRYPTLIB (HmacSha384.Services.New, HmacSha384New, (), NULL);
1897 }
1898
1899 /**
1900 Release the specified HMAC_CTX context.
1901
1902 @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.
1903
1904 **/
1905 VOID
1906 EFIAPI
1907 CryptoServiceHmacSha384Free (
1908 IN VOID *HmacSha384Ctx
1909 )
1910 {
1911 CALL_VOID_BASECRYPTLIB (HmacSha384.Services.Free, HmacSha384Free, (HmacSha384Ctx));
1912 }
1913
1914 /**
1915 Set user-supplied key for subsequent use. It must be done before any
1916 calling to HmacSha384Update().
1917
1918 If HmacSha384Context is NULL, then return FALSE.
1919 If this interface is not supported, then return FALSE.
1920
1921 @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.
1922 @param[in] Key Pointer to the user-supplied key.
1923 @param[in] KeySize Key size in bytes.
1924
1925 @retval TRUE The Key is set successfully.
1926 @retval FALSE The Key is set unsuccessfully.
1927 @retval FALSE This interface is not supported.
1928
1929 **/
1930 BOOLEAN
1931 EFIAPI
1932 CryptoServiceHmacSha384SetKey (
1933 OUT VOID *HmacSha384Context,
1934 IN CONST UINT8 *Key,
1935 IN UINTN KeySize
1936 )
1937 {
1938 return CALL_BASECRYPTLIB (HmacSha384.Services.SetKey, HmacSha384SetKey, (HmacSha384Context, Key, KeySize), FALSE);
1939 }
1940
1941 /**
1942 Makes a copy of an existing HMAC-SHA384 context.
1943
1944 If HmacSha384Context is NULL, then return FALSE.
1945 If NewHmacSha384Context is NULL, then return FALSE.
1946 If this interface is not supported, then return FALSE.
1947
1948 @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.
1949 @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.
1950
1951 @retval TRUE HMAC-SHA384 context copy succeeded.
1952 @retval FALSE HMAC-SHA384 context copy failed.
1953 @retval FALSE This interface is not supported.
1954
1955 **/
1956 BOOLEAN
1957 EFIAPI
1958 CryptoServiceHmacSha384Duplicate (
1959 IN CONST VOID *HmacSha384Context,
1960 OUT VOID *NewHmacSha384Context
1961 )
1962 {
1963 return CALL_BASECRYPTLIB (HmacSha384.Services.Duplicate, HmacSha256Duplicate, (HmacSha384Context, NewHmacSha384Context), FALSE);
1964 }
1965
1966 /**
1967 Digests the input data and updates HMAC-SHA384 context.
1968
1969 This function performs HMAC-SHA384 digest on a data buffer of the specified size.
1970 It can be called multiple times to compute the digest of long or discontinuous data streams.
1971 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
1972 by HmacSha384Final(). Behavior with invalid context is undefined.
1973
1974 If HmacSha384Context is NULL, then return FALSE.
1975 If this interface is not supported, then return FALSE.
1976
1977 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
1978 @param[in] Data Pointer to the buffer containing the data to be digested.
1979 @param[in] DataSize Size of Data buffer in bytes.
1980
1981 @retval TRUE HMAC-SHA384 data digest succeeded.
1982 @retval FALSE HMAC-SHA384 data digest failed.
1983 @retval FALSE This interface is not supported.
1984
1985 **/
1986 BOOLEAN
1987 EFIAPI
1988 CryptoServiceHmacSha384Update (
1989 IN OUT VOID *HmacSha384Context,
1990 IN CONST VOID *Data,
1991 IN UINTN DataSize
1992 )
1993 {
1994 return CALL_BASECRYPTLIB (HmacSha384.Services.Update, HmacSha384Update, (HmacSha384Context, Data, DataSize), FALSE);
1995 }
1996
1997 /**
1998 Completes computation of the HMAC-SHA384 digest value.
1999
2000 This function completes HMAC-SHA384 hash computation and retrieves the digest value into
2001 the specified memory. After this function has been called, the HMAC-SHA384 context cannot
2002 be used again.
2003 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
2004 by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.
2005
2006 If HmacSha384Context is NULL, then return FALSE.
2007 If HmacValue is NULL, then return FALSE.
2008 If this interface is not supported, then return FALSE.
2009
2010 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
2011 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
2012 value (48 bytes).
2013
2014 @retval TRUE HMAC-SHA384 digest computation succeeded.
2015 @retval FALSE HMAC-SHA384 digest computation failed.
2016 @retval FALSE This interface is not supported.
2017
2018 **/
2019 BOOLEAN
2020 EFIAPI
2021 CryptoServiceHmacSha384Final (
2022 IN OUT VOID *HmacSha384Context,
2023 OUT UINT8 *HmacValue
2024 )
2025 {
2026 return CALL_BASECRYPTLIB (HmacSha384.Services.Final, HmacSha384Final, (HmacSha384Context, HmacValue), FALSE);
2027 }
2028
2029 /**
2030 Computes the HMAC-SHA384 digest of a input data buffer.
2031
2032 This function performs the HMAC-SHA384 digest of a given data buffer, and places
2033 the digest value into the specified memory.
2034
2035 If this interface is not supported, then return FALSE.
2036
2037 @param[in] Data Pointer to the buffer containing the data to be digested.
2038 @param[in] DataSize Size of Data buffer in bytes.
2039 @param[in] Key Pointer to the user-supplied key.
2040 @param[in] KeySize Key size in bytes.
2041 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
2042 value (48 bytes).
2043
2044 @retval TRUE HMAC-SHA384 digest computation succeeded.
2045 @retval FALSE HMAC-SHA384 digest computation failed.
2046 @retval FALSE This interface is not supported.
2047
2048 **/
2049 BOOLEAN
2050 EFIAPI
2051 CryptoServiceHmacSha384All (
2052 IN CONST VOID *Data,
2053 IN UINTN DataSize,
2054 IN CONST UINT8 *Key,
2055 IN UINTN KeySize,
2056 OUT UINT8 *HmacValue
2057 )
2058 {
2059 return CALL_BASECRYPTLIB (HmacSha384.Services.All, HmacSha384All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);
2060 }
2061
2062 // =====================================================================================
2063 // Symmetric Cryptography Primitive
2064 // =====================================================================================
2065
2066 /**
2067 TDES is deprecated and unsupported any longer.
2068 Keep the function field for binary compability.
2069
2070 @retval 0 This interface is not supported.
2071
2072 **/
2073 UINTN
2074 EFIAPI
2075 DeprecatedCryptoServiceTdesGetContextSize (
2076 VOID
2077 )
2078 {
2079 return BaseCryptLibServiceDeprecated ("TdesGetContextSize"), 0;
2080 }
2081
2082 /**
2083 TDES is deprecated and unsupported any longer.
2084 Keep the function field for binary compability.
2085
2086 @param[out] TdesContext Pointer to TDES context being initialized.
2087 @param[in] Key Pointer to the user-supplied TDES key.
2088 @param[in] KeyLength Length of TDES key in bits.
2089
2090 @retval FALSE This interface is not supported.
2091
2092 **/
2093 BOOLEAN
2094 EFIAPI
2095 DeprecatedCryptoServiceTdesInit (
2096 OUT VOID *TdesContext,
2097 IN CONST UINT8 *Key,
2098 IN UINTN KeyLength
2099 )
2100 {
2101 return BaseCryptLibServiceDeprecated ("TdesInit"), FALSE;
2102 }
2103
2104 /**
2105 TDES is deprecated and unsupported any longer.
2106 Keep the function field for binary compability.
2107
2108 @param[in] TdesContext Pointer to the TDES context.
2109 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2110 @param[in] InputSize Size of the Input buffer in bytes.
2111 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2112
2113 @retval FALSE This interface is not supported.
2114
2115 **/
2116 BOOLEAN
2117 EFIAPI
2118 DeprecatedCryptoServiceTdesEcbEncrypt (
2119 IN VOID *TdesContext,
2120 IN CONST UINT8 *Input,
2121 IN UINTN InputSize,
2122 OUT UINT8 *Output
2123 )
2124 {
2125 return BaseCryptLibServiceDeprecated ("TdesEcbEncrypt"), FALSE;
2126 }
2127
2128 /**
2129 TDES is deprecated and unsupported any longer.
2130 Keep the function field for binary compability.
2131
2132 @param[in] TdesContext Pointer to the TDES context.
2133 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2134 @param[in] InputSize Size of the Input buffer in bytes.
2135 @param[out] Output Pointer to a buffer that receives the TDES decryption output.
2136
2137 @retval FALSE This interface is not supported.
2138
2139 **/
2140 BOOLEAN
2141 EFIAPI
2142 DeprecatedCryptoServiceTdesEcbDecrypt (
2143 IN VOID *TdesContext,
2144 IN CONST UINT8 *Input,
2145 IN UINTN InputSize,
2146 OUT UINT8 *Output
2147 )
2148 {
2149 return BaseCryptLibServiceDeprecated ("TdesEcbDecrypt"), FALSE;
2150 }
2151
2152 /**
2153 TDES is deprecated and unsupported any longer.
2154 Keep the function field for binary compability.
2155
2156 @param[in] TdesContext Pointer to the TDES context.
2157 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2158 @param[in] InputSize Size of the Input buffer in bytes.
2159 @param[in] Ivec Pointer to initialization vector.
2160 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2161
2162 @retval FALSE This interface is not supported.
2163
2164 **/
2165 BOOLEAN
2166 EFIAPI
2167 DeprecatedCryptoServiceTdesCbcEncrypt (
2168 IN VOID *TdesContext,
2169 IN CONST UINT8 *Input,
2170 IN UINTN InputSize,
2171 IN CONST UINT8 *Ivec,
2172 OUT UINT8 *Output
2173 )
2174 {
2175 return BaseCryptLibServiceDeprecated ("TdesCbcEncrypt"), FALSE;
2176 }
2177
2178 /**
2179 TDES is deprecated and unsupported any longer.
2180 Keep the function field for binary compability.
2181
2182 @param[in] TdesContext Pointer to the TDES context.
2183 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2184 @param[in] InputSize Size of the Input buffer in bytes.
2185 @param[in] Ivec Pointer to initialization vector.
2186 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2187
2188 @retval FALSE This interface is not supported.
2189
2190 **/
2191 BOOLEAN
2192 EFIAPI
2193 DeprecatedCryptoServiceTdesCbcDecrypt (
2194 IN VOID *TdesContext,
2195 IN CONST UINT8 *Input,
2196 IN UINTN InputSize,
2197 IN CONST UINT8 *Ivec,
2198 OUT UINT8 *Output
2199 )
2200 {
2201 return BaseCryptLibServiceDeprecated ("TdesCbcDecrypt"), FALSE;
2202 }
2203
2204 /**
2205 Retrieves the size, in bytes, of the context buffer required for AES operations.
2206
2207 If this interface is not supported, then return zero.
2208
2209 @return The size, in bytes, of the context buffer required for AES operations.
2210 @retval 0 This interface is not supported.
2211
2212 **/
2213 UINTN
2214 EFIAPI
2215 CryptoServiceAesGetContextSize (
2216 VOID
2217 )
2218 {
2219 return CALL_BASECRYPTLIB (Aes.Services.GetContextSize, AesGetContextSize, (), 0);
2220 }
2221
2222 /**
2223 Initializes user-supplied memory as AES context for subsequent use.
2224
2225 This function initializes user-supplied memory pointed by AesContext as AES context.
2226 In addition, it sets up all AES key materials for subsequent encryption and decryption
2227 operations.
2228 There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
2229
2230 If AesContext is NULL, then return FALSE.
2231 If Key is NULL, then return FALSE.
2232 If KeyLength is not valid, then return FALSE.
2233 If this interface is not supported, then return FALSE.
2234
2235 @param[out] AesContext Pointer to AES context being initialized.
2236 @param[in] Key Pointer to the user-supplied AES key.
2237 @param[in] KeyLength Length of AES key in bits.
2238
2239 @retval TRUE AES context initialization succeeded.
2240 @retval FALSE AES context initialization failed.
2241 @retval FALSE This interface is not supported.
2242
2243 **/
2244 BOOLEAN
2245 EFIAPI
2246 CryptoServiceAesInit (
2247 OUT VOID *AesContext,
2248 IN CONST UINT8 *Key,
2249 IN UINTN KeyLength
2250 )
2251 {
2252 return CALL_BASECRYPTLIB (Aes.Services.Init, AesInit, (AesContext, Key, KeyLength), FALSE);
2253 }
2254
2255 /**
2256 AES ECB Mode is deprecated and unsupported any longer.
2257 Keep the function field for binary compability.
2258
2259 @param[in] AesContext Pointer to the AES context.
2260 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2261 @param[in] InputSize Size of the Input buffer in bytes.
2262 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2263
2264 @retval FALSE This interface is not supported.
2265
2266 **/
2267 BOOLEAN
2268 EFIAPI
2269 DeprecatedCryptoServiceAesEcbEncrypt (
2270 IN VOID *AesContext,
2271 IN CONST UINT8 *Input,
2272 IN UINTN InputSize,
2273 OUT UINT8 *Output
2274 )
2275 {
2276 return BaseCryptLibServiceDeprecated ("AesEcbEncrypt"), FALSE;
2277 }
2278
2279 /**
2280 AES ECB Mode is deprecated and unsupported any longer.
2281 Keep the function field for binary compability.
2282
2283 @param[in] AesContext Pointer to the AES context.
2284 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2285 @param[in] InputSize Size of the Input buffer in bytes.
2286 @param[out] Output Pointer to a buffer that receives the AES decryption output.
2287
2288 @retval FALSE This interface is not supported.
2289
2290 **/
2291 BOOLEAN
2292 EFIAPI
2293 DeprecatedCryptoServiceAesEcbDecrypt (
2294 IN VOID *AesContext,
2295 IN CONST UINT8 *Input,
2296 IN UINTN InputSize,
2297 OUT UINT8 *Output
2298 )
2299 {
2300 return BaseCryptLibServiceDeprecated ("AesEcbDecrypt"), FALSE;
2301 }
2302
2303 /**
2304 Performs AES encryption on a data buffer of the specified size in CBC mode.
2305
2306 This function performs AES encryption on data buffer pointed by Input, of specified
2307 size of InputSize, in CBC mode.
2308 InputSize must be multiple of block size (16 bytes). This function does not perform
2309 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2310 Initialization vector should be one block size (16 bytes).
2311 AesContext should be already correctly initialized by AesInit(). Behavior with
2312 invalid AES context is undefined.
2313
2314 If AesContext is NULL, then return FALSE.
2315 If Input is NULL, then return FALSE.
2316 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2317 If Ivec is NULL, then return FALSE.
2318 If Output is NULL, then return FALSE.
2319 If this interface is not supported, then return FALSE.
2320
2321 @param[in] AesContext Pointer to the AES context.
2322 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2323 @param[in] InputSize Size of the Input buffer in bytes.
2324 @param[in] Ivec Pointer to initialization vector.
2325 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2326
2327 @retval TRUE AES encryption succeeded.
2328 @retval FALSE AES encryption failed.
2329 @retval FALSE This interface is not supported.
2330
2331 **/
2332 BOOLEAN
2333 EFIAPI
2334 CryptoServiceAesCbcEncrypt (
2335 IN VOID *AesContext,
2336 IN CONST UINT8 *Input,
2337 IN UINTN InputSize,
2338 IN CONST UINT8 *Ivec,
2339 OUT UINT8 *Output
2340 )
2341 {
2342 return CALL_BASECRYPTLIB (Aes.Services.CbcEncrypt, AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2343 }
2344
2345 /**
2346 Performs AES decryption on a data buffer of the specified size in CBC mode.
2347
2348 This function performs AES decryption on data buffer pointed by Input, of specified
2349 size of InputSize, in CBC mode.
2350 InputSize must be multiple of block size (16 bytes). This function does not perform
2351 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2352 Initialization vector should be one block size (16 bytes).
2353 AesContext should be already correctly initialized by AesInit(). Behavior with
2354 invalid AES context is undefined.
2355
2356 If AesContext is NULL, then return FALSE.
2357 If Input is NULL, then return FALSE.
2358 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2359 If Ivec is NULL, then return FALSE.
2360 If Output is NULL, then return FALSE.
2361 If this interface is not supported, then return FALSE.
2362
2363 @param[in] AesContext Pointer to the AES context.
2364 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2365 @param[in] InputSize Size of the Input buffer in bytes.
2366 @param[in] Ivec Pointer to initialization vector.
2367 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2368
2369 @retval TRUE AES decryption succeeded.
2370 @retval FALSE AES decryption failed.
2371 @retval FALSE This interface is not supported.
2372
2373 **/
2374 BOOLEAN
2375 EFIAPI
2376 CryptoServiceAesCbcDecrypt (
2377 IN VOID *AesContext,
2378 IN CONST UINT8 *Input,
2379 IN UINTN InputSize,
2380 IN CONST UINT8 *Ivec,
2381 OUT UINT8 *Output
2382 )
2383 {
2384 return CALL_BASECRYPTLIB (Aes.Services.CbcDecrypt, AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2385 }
2386
2387 /**
2388 ARC4 is deprecated and unsupported any longer.
2389 Keep the function field for binary compability.
2390
2391 @retval 0 This interface is not supported.
2392
2393 **/
2394 UINTN
2395 EFIAPI
2396 DeprecatedCryptoServiceArc4GetContextSize (
2397 VOID
2398 )
2399 {
2400 return BaseCryptLibServiceDeprecated ("Arc4GetContextSize"), 0;
2401 }
2402
2403 /**
2404 ARC4 is deprecated and unsupported any longer.
2405 Keep the function field for binary compability.
2406
2407 @param[out] Arc4Context Pointer to ARC4 context being initialized.
2408 @param[in] Key Pointer to the user-supplied ARC4 key.
2409 @param[in] KeySize Size of ARC4 key in bytes.
2410
2411 @retval FALSE This interface is not supported.
2412
2413 **/
2414 BOOLEAN
2415 EFIAPI
2416 DeprecatedCryptoServiceArc4Init (
2417 OUT VOID *Arc4Context,
2418 IN CONST UINT8 *Key,
2419 IN UINTN KeySize
2420 )
2421 {
2422 return BaseCryptLibServiceDeprecated ("Arc4Init"), FALSE;
2423 }
2424
2425 /**
2426 ARC4 is deprecated and unsupported any longer.
2427 Keep the function field for binary compability.
2428
2429 @param[in, out] Arc4Context Pointer to the ARC4 context.
2430 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2431 @param[in] InputSize Size of the Input buffer in bytes.
2432 @param[out] Output Pointer to a buffer that receives the ARC4 encryption output.
2433
2434 @retval FALSE This interface is not supported.
2435
2436 **/
2437 BOOLEAN
2438 EFIAPI
2439 DeprecatedCryptoServiceArc4Encrypt (
2440 IN OUT VOID *Arc4Context,
2441 IN CONST UINT8 *Input,
2442 IN UINTN InputSize,
2443 OUT UINT8 *Output
2444 )
2445 {
2446 return BaseCryptLibServiceDeprecated ("Arc4Encrypt"), FALSE;
2447 }
2448
2449 /**
2450 ARC4 is deprecated and unsupported any longer.
2451 Keep the function field for binary compability.
2452
2453 @param[in, out] Arc4Context Pointer to the ARC4 context.
2454 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2455 @param[in] InputSize Size of the Input buffer in bytes.
2456 @param[out] Output Pointer to a buffer that receives the ARC4 decryption output.
2457
2458 @retval FALSE This interface is not supported.
2459
2460 **/
2461 BOOLEAN
2462 EFIAPI
2463 DeprecatedCryptoServiceArc4Decrypt (
2464 IN OUT VOID *Arc4Context,
2465 IN UINT8 *Input,
2466 IN UINTN InputSize,
2467 OUT UINT8 *Output
2468 )
2469 {
2470 return BaseCryptLibServiceDeprecated ("Arc4Decrypt"), FALSE;
2471 }
2472
2473 /**
2474 ARC4 is deprecated and unsupported any longer.
2475 Keep the function field for binary compability.
2476
2477 @param[in, out] Arc4Context Pointer to the ARC4 context.
2478
2479 @retval FALSE This interface is not supported.
2480
2481 **/
2482 BOOLEAN
2483 EFIAPI
2484 DeprecatedCryptoServiceArc4Reset (
2485 IN OUT VOID *Arc4Context
2486 )
2487 {
2488 return BaseCryptLibServiceDeprecated ("Arc4Reset"), FALSE;
2489 }
2490
2491 // =====================================================================================
2492 // Asymmetric Cryptography Primitive
2493 // =====================================================================================
2494
2495 /**
2496 Allocates and initializes one RSA context for subsequent use.
2497
2498 @return Pointer to the RSA context that has been initialized.
2499 If the allocations fails, RsaNew() returns NULL.
2500
2501 **/
2502 VOID *
2503 EFIAPI
2504 CryptoServiceRsaNew (
2505 VOID
2506 )
2507 {
2508 return CALL_BASECRYPTLIB (Rsa.Services.New, RsaNew, (), NULL);
2509 }
2510
2511 /**
2512 Release the specified RSA context.
2513
2514 If RsaContext is NULL, then return FALSE.
2515
2516 @param[in] RsaContext Pointer to the RSA context to be released.
2517
2518 **/
2519 VOID
2520 EFIAPI
2521 CryptoServiceRsaFree (
2522 IN VOID *RsaContext
2523 )
2524 {
2525 CALL_VOID_BASECRYPTLIB (Rsa.Services.Free, RsaFree, (RsaContext));
2526 }
2527
2528 /**
2529 Sets the tag-designated key component into the established RSA context.
2530
2531 This function sets the tag-designated RSA key component into the established
2532 RSA context from the user-specified non-negative integer (octet string format
2533 represented in RSA PKCS#1).
2534 If BigNumber is NULL, then the specified key component in RSA context is cleared.
2535
2536 If RsaContext is NULL, then return FALSE.
2537
2538 @param[in, out] RsaContext Pointer to RSA context being set.
2539 @param[in] KeyTag Tag of RSA key component being set.
2540 @param[in] BigNumber Pointer to octet integer buffer.
2541 If NULL, then the specified key component in RSA
2542 context is cleared.
2543 @param[in] BnSize Size of big number buffer in bytes.
2544 If BigNumber is NULL, then it is ignored.
2545
2546 @retval TRUE RSA key component was set successfully.
2547 @retval FALSE Invalid RSA key component tag.
2548
2549 **/
2550 BOOLEAN
2551 EFIAPI
2552 CryptoServiceRsaSetKey (
2553 IN OUT VOID *RsaContext,
2554 IN RSA_KEY_TAG KeyTag,
2555 IN CONST UINT8 *BigNumber,
2556 IN UINTN BnSize
2557 )
2558 {
2559 return CALL_BASECRYPTLIB (Rsa.Services.SetKey, RsaSetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2560 }
2561
2562 /**
2563 Gets the tag-designated RSA key component from the established RSA context.
2564
2565 This function retrieves the tag-designated RSA key component from the
2566 established RSA context as a non-negative integer (octet string format
2567 represented in RSA PKCS#1).
2568 If specified key component has not been set or has been cleared, then returned
2569 BnSize is set to 0.
2570 If the BigNumber buffer is too small to hold the contents of the key, FALSE
2571 is returned and BnSize is set to the required buffer size to obtain the key.
2572
2573 If RsaContext is NULL, then return FALSE.
2574 If BnSize is NULL, then return FALSE.
2575 If BnSize is large enough but BigNumber is NULL, then return FALSE.
2576 If this interface is not supported, then return FALSE.
2577
2578 @param[in, out] RsaContext Pointer to RSA context being set.
2579 @param[in] KeyTag Tag of RSA key component being set.
2580 @param[out] BigNumber Pointer to octet integer buffer.
2581 @param[in, out] BnSize On input, the size of big number buffer in bytes.
2582 On output, the size of data returned in big number buffer in bytes.
2583
2584 @retval TRUE RSA key component was retrieved successfully.
2585 @retval FALSE Invalid RSA key component tag.
2586 @retval FALSE BnSize is too small.
2587 @retval FALSE This interface is not supported.
2588
2589 **/
2590 BOOLEAN
2591 EFIAPI
2592 CryptoServiceRsaGetKey (
2593 IN OUT VOID *RsaContext,
2594 IN RSA_KEY_TAG KeyTag,
2595 OUT UINT8 *BigNumber,
2596 IN OUT UINTN *BnSize
2597 )
2598 {
2599 return CALL_BASECRYPTLIB (Rsa.Services.GetKey, RsaGetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2600 }
2601
2602 /**
2603 Generates RSA key components.
2604
2605 This function generates RSA key components. It takes RSA public exponent E and
2606 length in bits of RSA modulus N as input, and generates all key components.
2607 If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.
2608
2609 Before this function can be invoked, pseudorandom number generator must be correctly
2610 initialized by RandomSeed().
2611
2612 If RsaContext is NULL, then return FALSE.
2613 If this interface is not supported, then return FALSE.
2614
2615 @param[in, out] RsaContext Pointer to RSA context being set.
2616 @param[in] ModulusLength Length of RSA modulus N in bits.
2617 @param[in] PublicExponent Pointer to RSA public exponent.
2618 @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.
2619
2620 @retval TRUE RSA key component was generated successfully.
2621 @retval FALSE Invalid RSA key component tag.
2622 @retval FALSE This interface is not supported.
2623
2624 **/
2625 BOOLEAN
2626 EFIAPI
2627 CryptoServiceRsaGenerateKey (
2628 IN OUT VOID *RsaContext,
2629 IN UINTN ModulusLength,
2630 IN CONST UINT8 *PublicExponent,
2631 IN UINTN PublicExponentSize
2632 )
2633 {
2634 return CALL_BASECRYPTLIB (Rsa.Services.GenerateKey, RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE);
2635 }
2636
2637 /**
2638 Validates key components of RSA context.
2639 NOTE: This function performs integrity checks on all the RSA key material, so
2640 the RSA key structure must contain all the private key data.
2641
2642 This function validates key components of RSA context in following aspects:
2643 - Whether p is a prime
2644 - Whether q is a prime
2645 - Whether n = p * q
2646 - Whether d*e = 1 mod lcm(p-1,q-1)
2647
2648 If RsaContext is NULL, then return FALSE.
2649 If this interface is not supported, then return FALSE.
2650
2651 @param[in] RsaContext Pointer to RSA context to check.
2652
2653 @retval TRUE RSA key components are valid.
2654 @retval FALSE RSA key components are not valid.
2655 @retval FALSE This interface is not supported.
2656
2657 **/
2658 BOOLEAN
2659 EFIAPI
2660 CryptoServiceRsaCheckKey (
2661 IN VOID *RsaContext
2662 )
2663 {
2664 return CALL_BASECRYPTLIB (Rsa.Services.CheckKey, RsaCheckKey, (RsaContext), FALSE);
2665 }
2666
2667 /**
2668 Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
2669
2670 This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in
2671 RSA PKCS#1.
2672 If the Signature buffer is too small to hold the contents of signature, FALSE
2673 is returned and SigSize is set to the required buffer size to obtain the signature.
2674
2675 If RsaContext is NULL, then return FALSE.
2676 If MessageHash is NULL, then return FALSE.
2677 If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
2678 If SigSize is large enough but Signature is NULL, then return FALSE.
2679 If this interface is not supported, then return FALSE.
2680
2681 @param[in] RsaContext Pointer to RSA context for signature generation.
2682 @param[in] MessageHash Pointer to octet message hash to be signed.
2683 @param[in] HashSize Size of the message hash in bytes.
2684 @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.
2685 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
2686 On output, the size of data returned in Signature buffer in bytes.
2687
2688 @retval TRUE Signature successfully generated in PKCS1-v1_5.
2689 @retval FALSE Signature generation failed.
2690 @retval FALSE SigSize is too small.
2691 @retval FALSE This interface is not supported.
2692
2693 **/
2694 BOOLEAN
2695 EFIAPI
2696 CryptoServiceRsaPkcs1Sign (
2697 IN VOID *RsaContext,
2698 IN CONST UINT8 *MessageHash,
2699 IN UINTN HashSize,
2700 OUT UINT8 *Signature,
2701 IN OUT UINTN *SigSize
2702 )
2703 {
2704 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Sign, RsaPkcs1Sign, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2705 }
2706
2707 /**
2708 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
2709 RSA PKCS#1.
2710
2711 If RsaContext is NULL, then return FALSE.
2712 If MessageHash is NULL, then return FALSE.
2713 If Signature is NULL, then return FALSE.
2714 If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.
2715
2716 @param[in] RsaContext Pointer to RSA context for signature verification.
2717 @param[in] MessageHash Pointer to octet message hash to be checked.
2718 @param[in] HashSize Size of the message hash in bytes.
2719 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
2720 @param[in] SigSize Size of signature in bytes.
2721
2722 @retval TRUE Valid signature encoded in PKCS1-v1_5.
2723 @retval FALSE Invalid signature or invalid RSA context.
2724
2725 **/
2726 BOOLEAN
2727 EFIAPI
2728 CryptoServiceRsaPkcs1Verify (
2729 IN VOID *RsaContext,
2730 IN CONST UINT8 *MessageHash,
2731 IN UINTN HashSize,
2732 IN CONST UINT8 *Signature,
2733 IN UINTN SigSize
2734 )
2735 {
2736 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Verify, RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2737 }
2738
2739 /**
2740 Retrieve the RSA Private Key from the password-protected PEM key data.
2741
2742 If PemData is NULL, then return FALSE.
2743 If RsaContext is NULL, then return FALSE.
2744 If this interface is not supported, then return FALSE.
2745
2746 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
2747 @param[in] PemSize Size of the PEM key data in bytes.
2748 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
2749 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2750 RSA private key component. Use RsaFree() function to free the
2751 resource.
2752
2753 @retval TRUE RSA Private Key was retrieved successfully.
2754 @retval FALSE Invalid PEM key data or incorrect password.
2755 @retval FALSE This interface is not supported.
2756
2757 **/
2758 BOOLEAN
2759 EFIAPI
2760 CryptoServiceRsaGetPrivateKeyFromPem (
2761 IN CONST UINT8 *PemData,
2762 IN UINTN PemSize,
2763 IN CONST CHAR8 *Password,
2764 OUT VOID **RsaContext
2765 )
2766 {
2767 return CALL_BASECRYPTLIB (Rsa.Services.GetPrivateKeyFromPem, RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE);
2768 }
2769
2770 /**
2771 Retrieve the RSA Public Key from one DER-encoded X509 certificate.
2772
2773 If Cert is NULL, then return FALSE.
2774 If RsaContext is NULL, then return FALSE.
2775 If this interface is not supported, then return FALSE.
2776
2777 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2778 @param[in] CertSize Size of the X509 certificate in bytes.
2779 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2780 RSA public key component. Use RsaFree() function to free the
2781 resource.
2782
2783 @retval TRUE RSA Public Key was retrieved successfully.
2784 @retval FALSE Fail to retrieve RSA public key from X509 certificate.
2785 @retval FALSE This interface is not supported.
2786
2787 **/
2788 BOOLEAN
2789 EFIAPI
2790 CryptoServiceRsaGetPublicKeyFromX509 (
2791 IN CONST UINT8 *Cert,
2792 IN UINTN CertSize,
2793 OUT VOID **RsaContext
2794 )
2795 {
2796 return CALL_BASECRYPTLIB (Rsa.Services.GetPublicKeyFromX509, RsaGetPublicKeyFromX509, (Cert, CertSize, RsaContext), FALSE);
2797 }
2798
2799 /**
2800 Retrieve the subject bytes from one X.509 certificate.
2801
2802 If Cert is NULL, then return FALSE.
2803 If SubjectSize is NULL, then return FALSE.
2804 If this interface is not supported, then return FALSE.
2805
2806 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2807 @param[in] CertSize Size of the X509 certificate in bytes.
2808 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.
2809 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,
2810 and the size of buffer returned CertSubject on output.
2811
2812 @retval TRUE The certificate subject retrieved successfully.
2813 @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.
2814 The SubjectSize will be updated with the required size.
2815 @retval FALSE This interface is not supported.
2816
2817 **/
2818 BOOLEAN
2819 EFIAPI
2820 CryptoServiceX509GetSubjectName (
2821 IN CONST UINT8 *Cert,
2822 IN UINTN CertSize,
2823 OUT UINT8 *CertSubject,
2824 IN OUT UINTN *SubjectSize
2825 )
2826 {
2827 return CALL_BASECRYPTLIB (X509.Services.GetSubjectName, X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);
2828 }
2829
2830 /**
2831 Retrieve the common name (CN) string from one X.509 certificate.
2832
2833 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2834 @param[in] CertSize Size of the X509 certificate in bytes.
2835 @param[out] CommonName Buffer to contain the retrieved certificate common
2836 name string (UTF8). At most CommonNameSize bytes will be
2837 written and the string will be null terminated. May be
2838 NULL in order to determine the size buffer needed.
2839 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
2840 and the size of buffer returned CommonName on output.
2841 If CommonName is NULL then the amount of space needed
2842 in buffer (including the final null) is returned.
2843
2844 @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.
2845 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2846 If CommonNameSize is NULL.
2847 If CommonName is not NULL and *CommonNameSize is 0.
2848 If Certificate is invalid.
2849 @retval RETURN_NOT_FOUND If no CommonName entry exists.
2850 @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
2851 (including the final null) is returned in the
2852 CommonNameSize parameter.
2853 @retval RETURN_UNSUPPORTED The operation is not supported.
2854
2855 **/
2856 RETURN_STATUS
2857 EFIAPI
2858 CryptoServiceX509GetCommonName (
2859 IN CONST UINT8 *Cert,
2860 IN UINTN CertSize,
2861 OUT CHAR8 *CommonName OPTIONAL,
2862 IN OUT UINTN *CommonNameSize
2863 )
2864 {
2865 return CALL_BASECRYPTLIB (X509.Services.GetCommonName, X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED);
2866 }
2867
2868 /**
2869 Retrieve the organization name (O) string from one X.509 certificate.
2870
2871 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2872 @param[in] CertSize Size of the X509 certificate in bytes.
2873 @param[out] NameBuffer Buffer to contain the retrieved certificate organization
2874 name string. At most NameBufferSize bytes will be
2875 written and the string will be null terminated. May be
2876 NULL in order to determine the size buffer needed.
2877 @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,
2878 and the size of buffer returned Name on output.
2879 If NameBuffer is NULL then the amount of space needed
2880 in buffer (including the final null) is returned.
2881
2882 @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.
2883 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2884 If NameBufferSize is NULL.
2885 If NameBuffer is not NULL and *CommonNameSize is 0.
2886 If Certificate is invalid.
2887 @retval RETURN_NOT_FOUND If no Organization Name entry exists.
2888 @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size
2889 (including the final null) is returned in the
2890 CommonNameSize parameter.
2891 @retval RETURN_UNSUPPORTED The operation is not supported.
2892
2893 **/
2894 RETURN_STATUS
2895 EFIAPI
2896 CryptoServiceX509GetOrganizationName (
2897 IN CONST UINT8 *Cert,
2898 IN UINTN CertSize,
2899 OUT CHAR8 *NameBuffer OPTIONAL,
2900 IN OUT UINTN *NameBufferSize
2901 )
2902 {
2903 return CALL_BASECRYPTLIB (X509.Services.GetOrganizationName, X509GetOrganizationName, (Cert, CertSize, NameBuffer, NameBufferSize), RETURN_UNSUPPORTED);
2904 }
2905
2906 /**
2907 Verify one X509 certificate was issued by the trusted CA.
2908
2909 If Cert is NULL, then return FALSE.
2910 If CACert is NULL, then return FALSE.
2911 If this interface is not supported, then return FALSE.
2912
2913 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.
2914 @param[in] CertSize Size of the X509 certificate in bytes.
2915 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.
2916 @param[in] CACertSize Size of the CA Certificate in bytes.
2917
2918 @retval TRUE The certificate was issued by the trusted CA.
2919 @retval FALSE Invalid certificate or the certificate was not issued by the given
2920 trusted CA.
2921 @retval FALSE This interface is not supported.
2922
2923 **/
2924 BOOLEAN
2925 EFIAPI
2926 CryptoServiceX509VerifyCert (
2927 IN CONST UINT8 *Cert,
2928 IN UINTN CertSize,
2929 IN CONST UINT8 *CACert,
2930 IN UINTN CACertSize
2931 )
2932 {
2933 return CALL_BASECRYPTLIB (X509.Services.VerifyCert, X509VerifyCert, (Cert, CertSize, CACert, CACertSize), FALSE);
2934 }
2935
2936 /**
2937 Construct a X509 object from DER-encoded certificate data.
2938
2939 If Cert is NULL, then return FALSE.
2940 If SingleX509Cert is NULL, then return FALSE.
2941 If this interface is not supported, then return FALSE.
2942
2943 @param[in] Cert Pointer to the DER-encoded certificate data.
2944 @param[in] CertSize The size of certificate data in bytes.
2945 @param[out] SingleX509Cert The generated X509 object.
2946
2947 @retval TRUE The X509 object generation succeeded.
2948 @retval FALSE The operation failed.
2949 @retval FALSE This interface is not supported.
2950
2951 **/
2952 BOOLEAN
2953 EFIAPI
2954 CryptoServiceX509ConstructCertificate (
2955 IN CONST UINT8 *Cert,
2956 IN UINTN CertSize,
2957 OUT UINT8 **SingleX509Cert
2958 )
2959 {
2960 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificate, X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE);
2961 }
2962
2963 /**
2964 Construct a X509 stack object from a list of DER-encoded certificate data.
2965
2966 If X509Stack is NULL, then return FALSE.
2967 If this interface is not supported, then return FALSE.
2968
2969 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2970 On output, pointer to the X509 stack object with new
2971 inserted X509 certificate.
2972 @param[in] Args VA_LIST marker for the variable argument list.
2973 A list of DER-encoded single certificate data followed
2974 by certificate size. A NULL terminates the list. The
2975 pairs are the arguments to X509ConstructCertificate().
2976
2977 @retval TRUE The X509 stack construction succeeded.
2978 @retval FALSE The construction operation failed.
2979 @retval FALSE This interface is not supported.
2980
2981 **/
2982 BOOLEAN
2983 EFIAPI
2984 CryptoServiceX509ConstructCertificateStackV (
2985 IN OUT UINT8 **X509Stack,
2986 IN VA_LIST Args
2987 )
2988 {
2989 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificateStackV, X509ConstructCertificateStackV, (X509Stack, Args), FALSE);
2990 }
2991
2992 /**
2993 Construct a X509 stack object from a list of DER-encoded certificate data.
2994
2995 If X509Stack is NULL, then return FALSE.
2996 If this interface is not supported, then return FALSE.
2997
2998 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2999 On output, pointer to the X509 stack object with new
3000 inserted X509 certificate.
3001 @param ... A list of DER-encoded single certificate data followed
3002 by certificate size. A NULL terminates the list. The
3003 pairs are the arguments to X509ConstructCertificate().
3004
3005 @retval TRUE The X509 stack construction succeeded.
3006 @retval FALSE The construction operation failed.
3007 @retval FALSE This interface is not supported.
3008
3009 **/
3010 BOOLEAN
3011 EFIAPI
3012 CryptoServiceX509ConstructCertificateStack (
3013 IN OUT UINT8 **X509Stack,
3014 ...
3015 )
3016 {
3017 VA_LIST Args;
3018 BOOLEAN Result;
3019
3020 VA_START (Args, X509Stack);
3021 Result = CryptoServiceX509ConstructCertificateStackV (X509Stack, Args);
3022 VA_END (Args);
3023 return Result;
3024 }
3025
3026 /**
3027 Release the specified X509 object.
3028
3029 If the interface is not supported, then ASSERT().
3030
3031 @param[in] X509Cert Pointer to the X509 object to be released.
3032
3033 **/
3034 VOID
3035 EFIAPI
3036 CryptoServiceX509Free (
3037 IN VOID *X509Cert
3038 )
3039 {
3040 CALL_VOID_BASECRYPTLIB (X509.Services.Free, X509Free, (X509Cert));
3041 }
3042
3043 /**
3044 Release the specified X509 stack object.
3045
3046 If the interface is not supported, then ASSERT().
3047
3048 @param[in] X509Stack Pointer to the X509 stack object to be released.
3049
3050 **/
3051 VOID
3052 EFIAPI
3053 CryptoServiceX509StackFree (
3054 IN VOID *X509Stack
3055 )
3056 {
3057 CALL_VOID_BASECRYPTLIB (X509.Services.StackFree, X509StackFree, (X509Stack));
3058 }
3059
3060 /**
3061 Retrieve the TBSCertificate from one given X.509 certificate.
3062
3063 @param[in] Cert Pointer to the given DER-encoded X509 certificate.
3064 @param[in] CertSize Size of the X509 certificate in bytes.
3065 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.
3066 @param[out] TBSCertSize Size of the TBS certificate in bytes.
3067
3068 If Cert is NULL, then return FALSE.
3069 If TBSCert is NULL, then return FALSE.
3070 If TBSCertSize is NULL, then return FALSE.
3071 If this interface is not supported, then return FALSE.
3072
3073 @retval TRUE The TBSCertificate was retrieved successfully.
3074 @retval FALSE Invalid X.509 certificate.
3075
3076 **/
3077 BOOLEAN
3078 EFIAPI
3079 CryptoServiceX509GetTBSCert (
3080 IN CONST UINT8 *Cert,
3081 IN UINTN CertSize,
3082 OUT UINT8 **TBSCert,
3083 OUT UINTN *TBSCertSize
3084 )
3085 {
3086 return CALL_BASECRYPTLIB (X509.Services.GetTBSCert, X509GetTBSCert, (Cert, CertSize, TBSCert, TBSCertSize), FALSE);
3087 }
3088
3089 /**
3090 Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0
3091 password based encryption key derivation function PBKDF2, as specified in RFC 2898.
3092
3093 If Password or Salt or OutKey is NULL, then return FALSE.
3094 If the hash algorithm could not be determined, then return FALSE.
3095 If this interface is not supported, then return FALSE.
3096
3097 @param[in] PasswordLength Length of input password in bytes.
3098 @param[in] Password Pointer to the array for the password.
3099 @param[in] SaltLength Size of the Salt in bytes.
3100 @param[in] Salt Pointer to the Salt.
3101 @param[in] IterationCount Number of iterations to perform. Its value should be
3102 greater than or equal to 1.
3103 @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).
3104 NOTE: DigestSize will be used to determine the hash algorithm.
3105 Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.
3106 @param[in] KeyLength Size of the derived key buffer in bytes.
3107 @param[out] OutKey Pointer to the output derived key buffer.
3108
3109 @retval TRUE A key was derived successfully.
3110 @retval FALSE One of the pointers was NULL or one of the sizes was too large.
3111 @retval FALSE The hash algorithm could not be determined from the digest size.
3112 @retval FALSE The key derivation operation failed.
3113 @retval FALSE This interface is not supported.
3114
3115 **/
3116 BOOLEAN
3117 EFIAPI
3118 CryptoServicePkcs5HashPassword (
3119 IN UINTN PasswordLength,
3120 IN CONST CHAR8 *Password,
3121 IN UINTN SaltLength,
3122 IN CONST UINT8 *Salt,
3123 IN UINTN IterationCount,
3124 IN UINTN DigestSize,
3125 IN UINTN KeyLength,
3126 OUT UINT8 *OutKey
3127 )
3128 {
3129 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);
3130 }
3131
3132 /**
3133 Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
3134 encrypted message in a newly allocated buffer.
3135
3136 Things that can cause a failure include:
3137 - X509 key size does not match any known key size.
3138 - Fail to parse X509 certificate.
3139 - Fail to allocate an intermediate buffer.
3140 - Null pointer provided for a non-optional parameter.
3141 - Data size is too large for the provided key size (max size is a function of key size
3142 and hash digest size).
3143
3144 @param[in] PublicKey A pointer to the DER-encoded X509 certificate that
3145 will be used to encrypt the data.
3146 @param[in] PublicKeySize Size of the X509 cert buffer.
3147 @param[in] InData Data to be encrypted.
3148 @param[in] InDataSize Size of the data buffer.
3149 @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer
3150 to be used when initializing the PRNG. NULL otherwise.
3151 @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.
3152 0 otherwise.
3153 @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted
3154 message.
3155 @param[out] EncryptedDataSize Size of the encrypted message buffer.
3156
3157 @retval TRUE Encryption was successful.
3158 @retval FALSE Encryption failed.
3159
3160 **/
3161 BOOLEAN
3162 EFIAPI
3163 CryptoServicePkcs1v2Encrypt (
3164 IN CONST UINT8 *PublicKey,
3165 IN UINTN PublicKeySize,
3166 IN UINT8 *InData,
3167 IN UINTN InDataSize,
3168 IN CONST UINT8 *PrngSeed OPTIONAL,
3169 IN UINTN PrngSeedSize OPTIONAL,
3170 OUT UINT8 **EncryptedData,
3171 OUT UINTN *EncryptedDataSize
3172 )
3173 {
3174 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Encrypt, Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);
3175 }
3176
3177 /**
3178 Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:
3179 Cryptographic Message Syntax Standard". The input signed data could be wrapped
3180 in a ContentInfo structure.
3181
3182 If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then
3183 return FALSE. If P7Length overflow, then return FALSE.
3184 If this interface is not supported, then return FALSE.
3185
3186 @param[in] P7Data Pointer to the PKCS#7 message to verify.
3187 @param[in] P7Length Length of the PKCS#7 message in bytes.
3188 @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.
3189 It's caller's responsibility to free the buffer with
3190 Pkcs7FreeSigners().
3191 This data structure is EFI_CERT_STACK type.
3192 @param[out] StackLength Length of signer's certificates in bytes.
3193 @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.
3194 It's caller's responsibility to free the buffer with
3195 Pkcs7FreeSigners().
3196 @param[out] CertLength Length of the trusted certificate in bytes.
3197
3198 @retval TRUE The operation is finished successfully.
3199 @retval FALSE Error occurs during the operation.
3200 @retval FALSE This interface is not supported.
3201
3202 **/
3203 BOOLEAN
3204 EFIAPI
3205 CryptoServicePkcs7GetSigners (
3206 IN CONST UINT8 *P7Data,
3207 IN UINTN P7Length,
3208 OUT UINT8 **CertStack,
3209 OUT UINTN *StackLength,
3210 OUT UINT8 **TrustedCert,
3211 OUT UINTN *CertLength
3212 )
3213 {
3214 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetSigners, Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);
3215 }
3216
3217 /**
3218 Wrap function to use free() to free allocated memory for certificates.
3219
3220 If this interface is not supported, then ASSERT().
3221
3222 @param[in] Certs Pointer to the certificates to be freed.
3223
3224 **/
3225 VOID
3226 EFIAPI
3227 CryptoServicePkcs7FreeSigners (
3228 IN UINT8 *Certs
3229 )
3230 {
3231 CALL_VOID_BASECRYPTLIB (Pkcs.Services.Pkcs7FreeSigners, Pkcs7FreeSigners, (Certs));
3232 }
3233
3234 /**
3235 Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:
3236 Cryptographic Message Syntax Standard", and outputs two certificate lists chained and
3237 unchained to the signer's certificates.
3238 The input signed data could be wrapped in a ContentInfo structure.
3239
3240 @param[in] P7Data Pointer to the PKCS#7 message.
3241 @param[in] P7Length Length of the PKCS#7 message in bytes.
3242 @param[out] SignerChainCerts Pointer to the certificates list chained to signer's
3243 certificate. It's caller's responsibility to free the buffer
3244 with Pkcs7FreeSigners().
3245 This data structure is EFI_CERT_STACK type.
3246 @param[out] ChainLength Length of the chained certificates list buffer in bytes.
3247 @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's
3248 responsibility to free the buffer with Pkcs7FreeSigners().
3249 This data structure is EFI_CERT_STACK type.
3250 @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.
3251
3252 @retval TRUE The operation is finished successfully.
3253 @retval FALSE Error occurs during the operation.
3254
3255 **/
3256 BOOLEAN
3257 EFIAPI
3258 CryptoServicePkcs7GetCertificatesList (
3259 IN CONST UINT8 *P7Data,
3260 IN UINTN P7Length,
3261 OUT UINT8 **SignerChainCerts,
3262 OUT UINTN *ChainLength,
3263 OUT UINT8 **UnchainCerts,
3264 OUT UINTN *UnchainLength
3265 )
3266 {
3267 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetCertificatesList, Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);
3268 }
3269
3270 /**
3271 Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message
3272 Syntax Standard, version 1.5". This interface is only intended to be used for
3273 application to perform PKCS#7 functionality validation.
3274
3275 If this interface is not supported, then return FALSE.
3276
3277 @param[in] PrivateKey Pointer to the PEM-formatted private key data for
3278 data signing.
3279 @param[in] PrivateKeySize Size of the PEM private key data in bytes.
3280 @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM
3281 key data.
3282 @param[in] InData Pointer to the content to be signed.
3283 @param[in] InDataSize Size of InData in bytes.
3284 @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.
3285 @param[in] OtherCerts Pointer to an optional additional set of certificates to
3286 include in the PKCS#7 signedData (e.g. any intermediate
3287 CAs in the chain).
3288 @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's
3289 responsibility to free the buffer with FreePool().
3290 @param[out] SignedDataSize Size of SignedData in bytes.
3291
3292 @retval TRUE PKCS#7 data signing succeeded.
3293 @retval FALSE PKCS#7 data signing failed.
3294 @retval FALSE This interface is not supported.
3295
3296 **/
3297 BOOLEAN
3298 EFIAPI
3299 CryptoServicePkcs7Sign (
3300 IN CONST UINT8 *PrivateKey,
3301 IN UINTN PrivateKeySize,
3302 IN CONST UINT8 *KeyPassword,
3303 IN UINT8 *InData,
3304 IN UINTN InDataSize,
3305 IN UINT8 *SignCert,
3306 IN UINT8 *OtherCerts OPTIONAL,
3307 OUT UINT8 **SignedData,
3308 OUT UINTN *SignedDataSize
3309 )
3310 {
3311 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Sign, Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);
3312 }
3313
3314 /**
3315 Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:
3316 Cryptographic Message Syntax Standard". The input signed data could be wrapped
3317 in a ContentInfo structure.
3318
3319 If P7Data, TrustedCert or InData is NULL, then return FALSE.
3320 If P7Length, CertLength or DataLength overflow, then return FALSE.
3321 If this interface is not supported, then return FALSE.
3322
3323 @param[in] P7Data Pointer to the PKCS#7 message to verify.
3324 @param[in] P7Length Length of the PKCS#7 message in bytes.
3325 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3326 is used for certificate chain verification.
3327 @param[in] CertLength Length of the trusted certificate in bytes.
3328 @param[in] InData Pointer to the content to be verified.
3329 @param[in] DataLength Length of InData in bytes.
3330
3331 @retval TRUE The specified PKCS#7 signed data is valid.
3332 @retval FALSE Invalid PKCS#7 signed data.
3333 @retval FALSE This interface is not supported.
3334
3335 **/
3336 BOOLEAN
3337 EFIAPI
3338 CryptoServicePkcs7Verify (
3339 IN CONST UINT8 *P7Data,
3340 IN UINTN P7Length,
3341 IN CONST UINT8 *TrustedCert,
3342 IN UINTN CertLength,
3343 IN CONST UINT8 *InData,
3344 IN UINTN DataLength
3345 )
3346 {
3347 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Verify, Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);
3348 }
3349
3350 /**
3351 This function receives a PKCS7 formatted signature, and then verifies that
3352 the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity
3353 leaf signing certificate.
3354 Note that this function does not validate the certificate chain.
3355
3356 Applications for custom EKU's are quite flexible. For example, a policy EKU
3357 may be present in an Issuing Certificate Authority (CA), and any sub-ordinate
3358 certificate issued might also contain this EKU, thus constraining the
3359 sub-ordinate certificate. Other applications might allow a certificate
3360 embedded in a device to specify that other Object Identifiers (OIDs) are
3361 present which contains binary data specifying custom capabilities that
3362 the device is able to do.
3363
3364 @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array
3365 containing the content block with both the signature,
3366 the signer's certificate, and any necessary intermediate
3367 certificates.
3368 @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.
3369 @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of
3370 required EKUs that must be present in the signature.
3371 @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.
3372 @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's
3373 must be present in the leaf signer. If it is
3374 FALSE, then we will succeed if we find any
3375 of the specified EKU's.
3376
3377 @retval EFI_SUCCESS The required EKUs were found in the signature.
3378 @retval EFI_INVALID_PARAMETER A parameter was invalid.
3379 @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.
3380
3381 **/
3382 RETURN_STATUS
3383 EFIAPI
3384 CryptoServiceVerifyEKUsInPkcs7Signature (
3385 IN CONST UINT8 *Pkcs7Signature,
3386 IN CONST UINT32 SignatureSize,
3387 IN CONST CHAR8 *RequiredEKUs[],
3388 IN CONST UINT32 RequiredEKUsSize,
3389 IN BOOLEAN RequireAllPresent
3390 )
3391 {
3392 return CALL_BASECRYPTLIB (Pkcs.Services.VerifyEKUsInPkcs7Signature, VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);
3393 }
3394
3395 /**
3396 Extracts the attached content from a PKCS#7 signed data if existed. The input signed
3397 data could be wrapped in a ContentInfo structure.
3398
3399 If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,
3400 then return FALSE. If the P7Data is not correctly formatted, then return FALSE.
3401
3402 Caution: This function may receive untrusted input. So this function will do
3403 basic check for PKCS#7 data structure.
3404
3405 @param[in] P7Data Pointer to the PKCS#7 signed data to process.
3406 @param[in] P7Length Length of the PKCS#7 signed data in bytes.
3407 @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.
3408 It's caller's responsibility to free the buffer with FreePool().
3409 @param[out] ContentSize The size of the extracted content in bytes.
3410
3411 @retval TRUE The P7Data was correctly formatted for processing.
3412 @retval FALSE The P7Data was not correctly formatted for processing.
3413
3414 **/
3415 BOOLEAN
3416 EFIAPI
3417 CryptoServicePkcs7GetAttachedContent (
3418 IN CONST UINT8 *P7Data,
3419 IN UINTN P7Length,
3420 OUT VOID **Content,
3421 OUT UINTN *ContentSize
3422 )
3423 {
3424 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);
3425 }
3426
3427 /**
3428 Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows
3429 Authenticode Portable Executable Signature Format".
3430
3431 If AuthData is NULL, then return FALSE.
3432 If ImageHash is NULL, then return FALSE.
3433 If this interface is not supported, then return FALSE.
3434
3435 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
3436 PE/COFF image to be verified.
3437 @param[in] DataSize Size of the Authenticode Signature in bytes.
3438 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3439 is used for certificate chain verification.
3440 @param[in] CertSize Size of the trusted certificate in bytes.
3441 @param[in] ImageHash Pointer to the original image file hash value. The procedure
3442 for calculating the image hash value is described in Authenticode
3443 specification.
3444 @param[in] HashSize Size of Image hash value in bytes.
3445
3446 @retval TRUE The specified Authenticode Signature is valid.
3447 @retval FALSE Invalid Authenticode Signature.
3448 @retval FALSE This interface is not supported.
3449
3450 **/
3451 BOOLEAN
3452 EFIAPI
3453 CryptoServiceAuthenticodeVerify (
3454 IN CONST UINT8 *AuthData,
3455 IN UINTN DataSize,
3456 IN CONST UINT8 *TrustedCert,
3457 IN UINTN CertSize,
3458 IN CONST UINT8 *ImageHash,
3459 IN UINTN HashSize
3460 )
3461 {
3462 return CALL_BASECRYPTLIB (Pkcs.Services.AuthenticodeVerify, AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);
3463 }
3464
3465 /**
3466 Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode
3467 signature.
3468
3469 If AuthData is NULL, then return FALSE.
3470 If this interface is not supported, then return FALSE.
3471
3472 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
3473 PE/COFF image to be verified.
3474 @param[in] DataSize Size of the Authenticode Signature in bytes.
3475 @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which
3476 is used for TSA certificate chain verification.
3477 @param[in] CertSize Size of the trusted certificate in bytes.
3478 @param[out] SigningTime Return the time of timestamp generation time if the timestamp
3479 signature is valid.
3480
3481 @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.
3482 @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.
3483
3484 **/
3485 BOOLEAN
3486 EFIAPI
3487 CryptoServiceImageTimestampVerify (
3488 IN CONST UINT8 *AuthData,
3489 IN UINTN DataSize,
3490 IN CONST UINT8 *TsaCert,
3491 IN UINTN CertSize,
3492 OUT EFI_TIME *SigningTime
3493 )
3494 {
3495 return CALL_BASECRYPTLIB (Pkcs.Services.ImageTimestampVerify, ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);
3496 }
3497
3498 // =====================================================================================
3499 // DH Key Exchange Primitive
3500 // =====================================================================================
3501
3502 /**
3503 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
3504
3505 @return Pointer to the Diffie-Hellman Context that has been initialized.
3506 If the allocations fails, DhNew() returns NULL.
3507 If the interface is not supported, DhNew() returns NULL.
3508
3509 **/
3510 VOID *
3511 EFIAPI
3512 CryptoServiceDhNew (
3513 VOID
3514 )
3515 {
3516 return CALL_BASECRYPTLIB (Dh.Services.New, DhNew, (), NULL);
3517 }
3518
3519 /**
3520 Release the specified DH context.
3521
3522 If the interface is not supported, then ASSERT().
3523
3524 @param[in] DhContext Pointer to the DH context to be released.
3525
3526 **/
3527 VOID
3528 EFIAPI
3529 CryptoServiceDhFree (
3530 IN VOID *DhContext
3531 )
3532 {
3533 CALL_VOID_BASECRYPTLIB (Dh.Services.Free, DhFree, (DhContext));
3534 }
3535
3536 /**
3537 Generates DH parameter.
3538
3539 Given generator g, and length of prime number p in bits, this function generates p,
3540 and sets DH context according to value of g and p.
3541
3542 Before this function can be invoked, pseudorandom number generator must be correctly
3543 initialized by RandomSeed().
3544
3545 If DhContext is NULL, then return FALSE.
3546 If Prime is NULL, then return FALSE.
3547 If this interface is not supported, then return FALSE.
3548
3549 @param[in, out] DhContext Pointer to the DH context.
3550 @param[in] Generator Value of generator.
3551 @param[in] PrimeLength Length in bits of prime to be generated.
3552 @param[out] Prime Pointer to the buffer to receive the generated prime number.
3553
3554 @retval TRUE DH parameter generation succeeded.
3555 @retval FALSE Value of Generator is not supported.
3556 @retval FALSE PRNG fails to generate random prime number with PrimeLength.
3557 @retval FALSE This interface is not supported.
3558
3559 **/
3560 BOOLEAN
3561 EFIAPI
3562 CryptoServiceDhGenerateParameter (
3563 IN OUT VOID *DhContext,
3564 IN UINTN Generator,
3565 IN UINTN PrimeLength,
3566 OUT UINT8 *Prime
3567 )
3568 {
3569 return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
3570 }
3571
3572 /**
3573 Sets generator and prime parameters for DH.
3574
3575 Given generator g, and prime number p, this function and sets DH
3576 context accordingly.
3577
3578 If DhContext is NULL, then return FALSE.
3579 If Prime is NULL, then return FALSE.
3580 If this interface is not supported, then return FALSE.
3581
3582 @param[in, out] DhContext Pointer to the DH context.
3583 @param[in] Generator Value of generator.
3584 @param[in] PrimeLength Length in bits of prime to be generated.
3585 @param[in] Prime Pointer to the prime number.
3586
3587 @retval TRUE DH parameter setting succeeded.
3588 @retval FALSE Value of Generator is not supported.
3589 @retval FALSE Value of Generator is not suitable for the Prime.
3590 @retval FALSE Value of Prime is not a prime number.
3591 @retval FALSE Value of Prime is not a safe prime number.
3592 @retval FALSE This interface is not supported.
3593
3594 **/
3595 BOOLEAN
3596 EFIAPI
3597 CryptoServiceDhSetParameter (
3598 IN OUT VOID *DhContext,
3599 IN UINTN Generator,
3600 IN UINTN PrimeLength,
3601 IN CONST UINT8 *Prime
3602 )
3603 {
3604 return CALL_BASECRYPTLIB (Dh.Services.SetParameter, DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
3605 }
3606
3607 /**
3608 Generates DH public key.
3609
3610 This function generates random secret exponent, and computes the public key, which is
3611 returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.
3612 If the PublicKey buffer is too small to hold the public key, FALSE is returned and
3613 PublicKeySize is set to the required buffer size to obtain the public key.
3614
3615 If DhContext is NULL, then return FALSE.
3616 If PublicKeySize is NULL, then return FALSE.
3617 If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.
3618 If this interface is not supported, then return FALSE.
3619
3620 @param[in, out] DhContext Pointer to the DH context.
3621 @param[out] PublicKey Pointer to the buffer to receive generated public key.
3622 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
3623 On output, the size of data returned in PublicKey buffer in bytes.
3624
3625 @retval TRUE DH public key generation succeeded.
3626 @retval FALSE DH public key generation failed.
3627 @retval FALSE PublicKeySize is not large enough.
3628 @retval FALSE This interface is not supported.
3629
3630 **/
3631 BOOLEAN
3632 EFIAPI
3633 CryptoServiceDhGenerateKey (
3634 IN OUT VOID *DhContext,
3635 OUT UINT8 *PublicKey,
3636 IN OUT UINTN *PublicKeySize
3637 )
3638 {
3639 return CALL_BASECRYPTLIB (Dh.Services.GenerateKey, DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);
3640 }
3641
3642 /**
3643 Computes exchanged common key.
3644
3645 Given peer's public key, this function computes the exchanged common key, based on its own
3646 context including value of prime modulus and random secret exponent.
3647
3648 If DhContext is NULL, then return FALSE.
3649 If PeerPublicKey is NULL, then return FALSE.
3650 If KeySize is NULL, then return FALSE.
3651 If Key is NULL, then return FALSE.
3652 If KeySize is not large enough, then return FALSE.
3653 If this interface is not supported, then return FALSE.
3654
3655 @param[in, out] DhContext Pointer to the DH context.
3656 @param[in] PeerPublicKey Pointer to the peer's public key.
3657 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
3658 @param[out] Key Pointer to the buffer to receive generated key.
3659 @param[in, out] KeySize On input, the size of Key buffer in bytes.
3660 On output, the size of data returned in Key buffer in bytes.
3661
3662 @retval TRUE DH exchanged key generation succeeded.
3663 @retval FALSE DH exchanged key generation failed.
3664 @retval FALSE KeySize is not large enough.
3665 @retval FALSE This interface is not supported.
3666
3667 **/
3668 BOOLEAN
3669 EFIAPI
3670 CryptoServiceDhComputeKey (
3671 IN OUT VOID *DhContext,
3672 IN CONST UINT8 *PeerPublicKey,
3673 IN UINTN PeerPublicKeySize,
3674 OUT UINT8 *Key,
3675 IN OUT UINTN *KeySize
3676 )
3677 {
3678 return CALL_BASECRYPTLIB (Dh.Services.ComputeKey, DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);
3679 }
3680
3681 // =====================================================================================
3682 // Pseudo-Random Generation Primitive
3683 // =====================================================================================
3684
3685 /**
3686 Sets up the seed value for the pseudorandom number generator.
3687
3688 This function sets up the seed value for the pseudorandom number generator.
3689 If Seed is not NULL, then the seed passed in is used.
3690 If Seed is NULL, then default seed is used.
3691 If this interface is not supported, then return FALSE.
3692
3693 @param[in] Seed Pointer to seed value.
3694 If NULL, default seed is used.
3695 @param[in] SeedSize Size of seed value.
3696 If Seed is NULL, this parameter is ignored.
3697
3698 @retval TRUE Pseudorandom number generator has enough entropy for random generation.
3699 @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.
3700 @retval FALSE This interface is not supported.
3701
3702 **/
3703 BOOLEAN
3704 EFIAPI
3705 CryptoServiceRandomSeed (
3706 IN CONST UINT8 *Seed OPTIONAL,
3707 IN UINTN SeedSize
3708 )
3709 {
3710 return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);
3711 }
3712
3713 /**
3714 Generates a pseudorandom byte stream of the specified size.
3715
3716 If Output is NULL, then return FALSE.
3717 If this interface is not supported, then return FALSE.
3718
3719 @param[out] Output Pointer to buffer to receive random value.
3720 @param[in] Size Size of random bytes to generate.
3721
3722 @retval TRUE Pseudorandom byte stream generated successfully.
3723 @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.
3724 @retval FALSE This interface is not supported.
3725
3726 **/
3727 BOOLEAN
3728 EFIAPI
3729 CryptoServiceRandomBytes (
3730 OUT UINT8 *Output,
3731 IN UINTN Size
3732 )
3733 {
3734 return CALL_BASECRYPTLIB (Random.Services.Bytes, RandomBytes, (Output, Size), FALSE);
3735 }
3736
3737 // =====================================================================================
3738 // Key Derivation Function Primitive
3739 // =====================================================================================
3740
3741 /**
3742 Derive key data using HMAC-SHA256 based KDF.
3743
3744 @param[in] Key Pointer to the user-supplied key.
3745 @param[in] KeySize Key size in bytes.
3746 @param[in] Salt Pointer to the salt(non-secret) value.
3747 @param[in] SaltSize Salt size in bytes.
3748 @param[in] Info Pointer to the application specific info.
3749 @param[in] InfoSize Info size in bytes.
3750 @param[out] Out Pointer to buffer to receive hkdf value.
3751 @param[in] OutSize Size of hkdf bytes to generate.
3752
3753 @retval TRUE Hkdf generated successfully.
3754 @retval FALSE Hkdf generation failed.
3755
3756 **/
3757 BOOLEAN
3758 EFIAPI
3759 CryptoServiceHkdfSha256ExtractAndExpand (
3760 IN CONST UINT8 *Key,
3761 IN UINTN KeySize,
3762 IN CONST UINT8 *Salt,
3763 IN UINTN SaltSize,
3764 IN CONST UINT8 *Info,
3765 IN UINTN InfoSize,
3766 OUT UINT8 *Out,
3767 IN UINTN OutSize
3768 )
3769 {
3770 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256ExtractAndExpand, HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
3771 }
3772
3773 /**
3774 Derive SHA256 HMAC-based Extract key Derivation Function (HKDF).
3775
3776 @param[in] Key Pointer to the user-supplied key.
3777 @param[in] KeySize key size in bytes.
3778 @param[in] Salt Pointer to the salt(non-secret) value.
3779 @param[in] SaltSize salt size in bytes.
3780 @param[out] PrkOut Pointer to buffer to receive hkdf value.
3781 @param[in] PrkOutSize size of hkdf bytes to generate.
3782
3783 @retval true Hkdf generated successfully.
3784 @retval false Hkdf generation failed.
3785
3786 **/
3787 BOOLEAN
3788 EFIAPI
3789 CryptoServiceHkdfSha256Extract (
3790 IN CONST UINT8 *Key,
3791 IN UINTN KeySize,
3792 IN CONST UINT8 *Salt,
3793 IN UINTN SaltSize,
3794 OUT UINT8 *PrkOut,
3795 UINTN PrkOutSize
3796 )
3797 {
3798 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Extract, HkdfSha256Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);
3799 }
3800
3801 /**
3802 Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).
3803
3804 @param[in] Prk Pointer to the user-supplied key.
3805 @param[in] PrkSize Key size in bytes.
3806 @param[in] Info Pointer to the application specific info.
3807 @param[in] InfoSize Info size in bytes.
3808 @param[out] Out Pointer to buffer to receive hkdf value.
3809 @param[in] OutSize Size of hkdf bytes to generate.
3810
3811 @retval TRUE Hkdf generated successfully.
3812 @retval FALSE Hkdf generation failed.
3813
3814 **/
3815 BOOLEAN
3816 EFIAPI
3817 CryptoServiceHkdfSha256Expand (
3818 IN CONST UINT8 *Prk,
3819 IN UINTN PrkSize,
3820 IN CONST UINT8 *Info,
3821 IN UINTN InfoSize,
3822 OUT UINT8 *Out,
3823 IN UINTN OutSize
3824 )
3825 {
3826 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Expand, HkdfSha256Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);
3827 }
3828
3829 /**
3830 Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
3831
3832 @param[in] Key Pointer to the user-supplied key.
3833 @param[in] KeySize Key size in bytes.
3834 @param[in] Salt Pointer to the salt(non-secret) value.
3835 @param[in] SaltSize Salt size in bytes.
3836 @param[in] Info Pointer to the application specific info.
3837 @param[in] InfoSize Info size in bytes.
3838 @param[out] Out Pointer to buffer to receive hkdf value.
3839 @param[in] OutSize Size of hkdf bytes to generate.
3840
3841 @retval TRUE Hkdf generated successfully.
3842 @retval FALSE Hkdf generation failed.
3843
3844 **/
3845 BOOLEAN
3846 EFIAPI
3847 CryptoServiceHkdfSha384ExtractAndExpand (
3848 IN CONST UINT8 *Key,
3849 IN UINTN KeySize,
3850 IN CONST UINT8 *Salt,
3851 IN UINTN SaltSize,
3852 IN CONST UINT8 *Info,
3853 IN UINTN InfoSize,
3854 OUT UINT8 *Out,
3855 IN UINTN OutSize
3856 )
3857 {
3858 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384ExtractAndExpand, HkdfSha384ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
3859 }
3860
3861 /**
3862 Derive SHA384 HMAC-based Extract key Derivation Function (HKDF).
3863
3864 @param[in] Key Pointer to the user-supplied key.
3865 @param[in] KeySize key size in bytes.
3866 @param[in] Salt Pointer to the salt(non-secret) value.
3867 @param[in] SaltSize salt size in bytes.
3868 @param[out] PrkOut Pointer to buffer to receive hkdf value.
3869 @param[in] PrkOutSize size of hkdf bytes to generate.
3870
3871 @retval true Hkdf generated successfully.
3872 @retval false Hkdf generation failed.
3873
3874 **/
3875 BOOLEAN
3876 EFIAPI
3877 CryptoServiceHkdfSha384Extract (
3878 IN CONST UINT8 *Key,
3879 IN UINTN KeySize,
3880 IN CONST UINT8 *Salt,
3881 IN UINTN SaltSize,
3882 OUT UINT8 *PrkOut,
3883 UINTN PrkOutSize
3884 )
3885 {
3886 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Extract, HkdfSha384Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);
3887 }
3888
3889 /**
3890 Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).
3891
3892 @param[in] Prk Pointer to the user-supplied key.
3893 @param[in] PrkSize Key size in bytes.
3894 @param[in] Info Pointer to the application specific info.
3895 @param[in] InfoSize Info size in bytes.
3896 @param[out] Out Pointer to buffer to receive hkdf value.
3897 @param[in] OutSize Size of hkdf bytes to generate.
3898
3899 @retval TRUE Hkdf generated successfully.
3900 @retval FALSE Hkdf generation failed.
3901
3902 **/
3903 BOOLEAN
3904 EFIAPI
3905 CryptoServiceHkdfSha384Expand (
3906 IN CONST UINT8 *Prk,
3907 IN UINTN PrkSize,
3908 IN CONST UINT8 *Info,
3909 IN UINTN InfoSize,
3910 OUT UINT8 *Out,
3911 IN UINTN OutSize
3912 )
3913 {
3914 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Expand, HkdfSha384Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);
3915 }
3916
3917 /**
3918 Initializes the OpenSSL library.
3919
3920 This function registers ciphers and digests used directly and indirectly
3921 by SSL/TLS, and initializes the readable error messages.
3922 This function must be called before any other action takes places.
3923
3924 @retval TRUE The OpenSSL library has been initialized.
3925 @retval FALSE Failed to initialize the OpenSSL library.
3926
3927 **/
3928 BOOLEAN
3929 EFIAPI
3930 CryptoServiceTlsInitialize (
3931 VOID
3932 )
3933 {
3934 return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE);
3935 }
3936
3937 /**
3938 Free an allocated SSL_CTX object.
3939
3940 @param[in] TlsCtx Pointer to the SSL_CTX object to be released.
3941
3942 **/
3943 VOID
3944 EFIAPI
3945 CryptoServiceTlsCtxFree (
3946 IN VOID *TlsCtx
3947 )
3948 {
3949 CALL_VOID_BASECRYPTLIB (Tls.Services.CtxFree, TlsCtxFree, (TlsCtx));
3950 }
3951
3952 /**
3953 Creates a new SSL_CTX object as framework to establish TLS/SSL enabled
3954 connections.
3955
3956 @param[in] MajorVer Major Version of TLS/SSL Protocol.
3957 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
3958
3959 @return Pointer to an allocated SSL_CTX object.
3960 If the creation failed, TlsCtxNew() returns NULL.
3961
3962 **/
3963 VOID *
3964 EFIAPI
3965 CryptoServiceTlsCtxNew (
3966 IN UINT8 MajorVer,
3967 IN UINT8 MinorVer
3968 )
3969 {
3970 return CALL_BASECRYPTLIB (Tls.Services.CtxNew, TlsCtxNew, (MajorVer, MinorVer), NULL);
3971 }
3972
3973 /**
3974 Free an allocated TLS object.
3975
3976 This function removes the TLS object pointed to by Tls and frees up the
3977 allocated memory. If Tls is NULL, nothing is done.
3978
3979 @param[in] Tls Pointer to the TLS object to be freed.
3980
3981 **/
3982 VOID
3983 EFIAPI
3984 CryptoServiceTlsFree (
3985 IN VOID *Tls
3986 )
3987 {
3988 CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls));
3989 }
3990
3991 /**
3992 Create a new TLS object for a connection.
3993
3994 This function creates a new TLS object for a connection. The new object
3995 inherits the setting of the underlying context TlsCtx: connection method,
3996 options, verification setting.
3997
3998 @param[in] TlsCtx Pointer to the SSL_CTX object.
3999
4000 @return Pointer to an allocated SSL object.
4001 If the creation failed, TlsNew() returns NULL.
4002
4003 **/
4004 VOID *
4005 EFIAPI
4006 CryptoServiceTlsNew (
4007 IN VOID *TlsCtx
4008 )
4009 {
4010 return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);
4011 }
4012
4013 /**
4014 Checks if the TLS handshake was done.
4015
4016 This function will check if the specified TLS handshake was done.
4017
4018 @param[in] Tls Pointer to the TLS object for handshake state checking.
4019
4020 @retval TRUE The TLS handshake was done.
4021 @retval FALSE The TLS handshake was not done.
4022
4023 **/
4024 BOOLEAN
4025 EFIAPI
4026 CryptoServiceTlsInHandshake (
4027 IN VOID *Tls
4028 )
4029 {
4030 return CALL_BASECRYPTLIB (Tls.Services.InHandshake, TlsInHandshake, (Tls), FALSE);
4031 }
4032
4033 /**
4034 Perform a TLS/SSL handshake.
4035
4036 This function will perform a TLS/SSL handshake.
4037
4038 @param[in] Tls Pointer to the TLS object for handshake operation.
4039 @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
4040 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
4041 Handshake packet.
4042 @param[out] BufferOut Pointer to the buffer to hold the built packet.
4043 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
4044 the buffer size provided by the caller. On output, it
4045 is the buffer size in fact needed to contain the
4046 packet.
4047
4048 @retval EFI_SUCCESS The required TLS packet is built successfully.
4049 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4050 Tls is NULL.
4051 BufferIn is NULL but BufferInSize is NOT 0.
4052 BufferInSize is 0 but BufferIn is NOT NULL.
4053 BufferOutSize is NULL.
4054 BufferOut is NULL if *BufferOutSize is not zero.
4055 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
4056 @retval EFI_ABORTED Something wrong during handshake.
4057
4058 **/
4059 EFI_STATUS
4060 EFIAPI
4061 CryptoServiceTlsDoHandshake (
4062 IN VOID *Tls,
4063 IN UINT8 *BufferIn OPTIONAL,
4064 IN UINTN BufferInSize OPTIONAL,
4065 OUT UINT8 *BufferOut OPTIONAL,
4066 IN OUT UINTN *BufferOutSize
4067 )
4068 {
4069 return CALL_BASECRYPTLIB (Tls.Services.DoHandshake, TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
4070 }
4071
4072 /**
4073 Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
4074 TLS session has errors and the response packet needs to be Alert message based on error type.
4075
4076 @param[in] Tls Pointer to the TLS object for state checking.
4077 @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
4078 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
4079 Alert packet.
4080 @param[out] BufferOut Pointer to the buffer to hold the built packet.
4081 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
4082 the buffer size provided by the caller. On output, it
4083 is the buffer size in fact needed to contain the
4084 packet.
4085
4086 @retval EFI_SUCCESS The required TLS packet is built successfully.
4087 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4088 Tls is NULL.
4089 BufferIn is NULL but BufferInSize is NOT 0.
4090 BufferInSize is 0 but BufferIn is NOT NULL.
4091 BufferOutSize is NULL.
4092 BufferOut is NULL if *BufferOutSize is not zero.
4093 @retval EFI_ABORTED An error occurred.
4094 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
4095
4096 **/
4097 EFI_STATUS
4098 EFIAPI
4099 CryptoServiceTlsHandleAlert (
4100 IN VOID *Tls,
4101 IN UINT8 *BufferIn OPTIONAL,
4102 IN UINTN BufferInSize OPTIONAL,
4103 OUT UINT8 *BufferOut OPTIONAL,
4104 IN OUT UINTN *BufferOutSize
4105 )
4106 {
4107 return CALL_BASECRYPTLIB (Tls.Services.HandleAlert, TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
4108 }
4109
4110 /**
4111 Build the CloseNotify packet.
4112
4113 @param[in] Tls Pointer to the TLS object for state checking.
4114 @param[in, out] Buffer Pointer to the buffer to hold the built packet.
4115 @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
4116 the buffer size provided by the caller. On output, it
4117 is the buffer size in fact needed to contain the
4118 packet.
4119
4120 @retval EFI_SUCCESS The required TLS packet is built successfully.
4121 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4122 Tls is NULL.
4123 BufferSize is NULL.
4124 Buffer is NULL if *BufferSize is not zero.
4125 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
4126
4127 **/
4128 EFI_STATUS
4129 EFIAPI
4130 CryptoServiceTlsCloseNotify (
4131 IN VOID *Tls,
4132 IN OUT UINT8 *Buffer,
4133 IN OUT UINTN *BufferSize
4134 )
4135 {
4136 return CALL_BASECRYPTLIB (Tls.Services.CloseNotify, TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);
4137 }
4138
4139 /**
4140 Attempts to read bytes from one TLS object and places the data in Buffer.
4141
4142 This function will attempt to read BufferSize bytes from the TLS object
4143 and places the data in Buffer.
4144
4145 @param[in] Tls Pointer to the TLS object.
4146 @param[in,out] Buffer Pointer to the buffer to store the data.
4147 @param[in] BufferSize The size of Buffer in bytes.
4148
4149 @retval >0 The amount of data successfully read from the TLS object.
4150 @retval <=0 No data was successfully read.
4151
4152 **/
4153 INTN
4154 EFIAPI
4155 CryptoServiceTlsCtrlTrafficOut (
4156 IN VOID *Tls,
4157 IN OUT VOID *Buffer,
4158 IN UINTN BufferSize
4159 )
4160 {
4161 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);
4162 }
4163
4164 /**
4165 Attempts to write data from the buffer to TLS object.
4166
4167 This function will attempt to write BufferSize bytes data from the Buffer
4168 to the TLS object.
4169
4170 @param[in] Tls Pointer to the TLS object.
4171 @param[in] Buffer Pointer to the data buffer.
4172 @param[in] BufferSize The size of Buffer in bytes.
4173
4174 @retval >0 The amount of data successfully written to the TLS object.
4175 @retval <=0 No data was successfully written.
4176
4177 **/
4178 INTN
4179 EFIAPI
4180 CryptoServiceTlsCtrlTrafficIn (
4181 IN VOID *Tls,
4182 IN VOID *Buffer,
4183 IN UINTN BufferSize
4184 )
4185 {
4186 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficIn, TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);
4187 }
4188
4189 /**
4190 Attempts to read bytes from the specified TLS connection into the buffer.
4191
4192 This function tries to read BufferSize bytes data from the specified TLS
4193 connection into the Buffer.
4194
4195 @param[in] Tls Pointer to the TLS connection for data reading.
4196 @param[in,out] Buffer Pointer to the data buffer.
4197 @param[in] BufferSize The size of Buffer in bytes.
4198
4199 @retval >0 The read operation was successful, and return value is the
4200 number of bytes actually read from the TLS connection.
4201 @retval <=0 The read operation was not successful.
4202
4203 **/
4204 INTN
4205 EFIAPI
4206 CryptoServiceTlsRead (
4207 IN VOID *Tls,
4208 IN OUT VOID *Buffer,
4209 IN UINTN BufferSize
4210 )
4211 {
4212 return CALL_BASECRYPTLIB (Tls.Services.Read, TlsRead, (Tls, Buffer, BufferSize), 0);
4213 }
4214
4215 /**
4216 Attempts to write data to a TLS connection.
4217
4218 This function tries to write BufferSize bytes data from the Buffer into the
4219 specified TLS connection.
4220
4221 @param[in] Tls Pointer to the TLS connection for data writing.
4222 @param[in] Buffer Pointer to the data buffer.
4223 @param[in] BufferSize The size of Buffer in bytes.
4224
4225 @retval >0 The write operation was successful, and return value is the
4226 number of bytes actually written to the TLS connection.
4227 @retval <=0 The write operation was not successful.
4228
4229 **/
4230 INTN
4231 EFIAPI
4232 CryptoServiceTlsWrite (
4233 IN VOID *Tls,
4234 IN VOID *Buffer,
4235 IN UINTN BufferSize
4236 )
4237 {
4238 return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0);
4239 }
4240
4241 /**
4242 Set a new TLS/SSL method for a particular TLS object.
4243
4244 This function sets a new TLS/SSL method for a particular TLS object.
4245
4246 @param[in] Tls Pointer to a TLS object.
4247 @param[in] MajorVer Major Version of TLS/SSL Protocol.
4248 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
4249
4250 @retval EFI_SUCCESS The TLS/SSL method was set successfully.
4251 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4252 @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
4253
4254 **/
4255 EFI_STATUS
4256 EFIAPI
4257 CryptoServiceTlsSetVersion (
4258 IN VOID *Tls,
4259 IN UINT8 MajorVer,
4260 IN UINT8 MinorVer
4261 )
4262 {
4263 return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);
4264 }
4265
4266 /**
4267 Set TLS object to work in client or server mode.
4268
4269 This function prepares a TLS object to work in client or server mode.
4270
4271 @param[in] Tls Pointer to a TLS object.
4272 @param[in] IsServer Work in server mode.
4273
4274 @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
4275 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4276 @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
4277
4278 **/
4279 EFI_STATUS
4280 EFIAPI
4281 CryptoServiceTlsSetConnectionEnd (
4282 IN VOID *Tls,
4283 IN BOOLEAN IsServer
4284 )
4285 {
4286 return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);
4287 }
4288
4289 /**
4290 Set the ciphers list to be used by the TLS object.
4291
4292 This function sets the ciphers for use by a specified TLS object.
4293
4294 @param[in] Tls Pointer to a TLS object.
4295 @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
4296 cipher identifier comes from the TLS Cipher Suite
4297 Registry of the IANA, interpreting Byte1 and Byte2
4298 in network (big endian) byte order.
4299 @param[in] CipherNum The number of cipher in the list.
4300
4301 @retval EFI_SUCCESS The ciphers list was set successfully.
4302 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4303 @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
4304 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4305
4306 **/
4307 EFI_STATUS
4308 EFIAPI
4309 CryptoServiceTlsSetCipherList (
4310 IN VOID *Tls,
4311 IN UINT16 *CipherId,
4312 IN UINTN CipherNum
4313 )
4314 {
4315 return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);
4316 }
4317
4318 /**
4319 Set the compression method for TLS/SSL operations.
4320
4321 This function handles TLS/SSL integrated compression methods.
4322
4323 @param[in] CompMethod The compression method ID.
4324
4325 @retval EFI_SUCCESS The compression method for the communication was
4326 set successfully.
4327 @retval EFI_UNSUPPORTED Unsupported compression method.
4328
4329 **/
4330 EFI_STATUS
4331 EFIAPI
4332 CryptoServiceTlsSetCompressionMethod (
4333 IN UINT8 CompMethod
4334 )
4335 {
4336 return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);
4337 }
4338
4339 /**
4340 Set peer certificate verification mode for the TLS connection.
4341
4342 This function sets the verification mode flags for the TLS connection.
4343
4344 @param[in] Tls Pointer to the TLS object.
4345 @param[in] VerifyMode A set of logically or'ed verification mode flags.
4346
4347 **/
4348 VOID
4349 EFIAPI
4350 CryptoServiceTlsSetVerify (
4351 IN VOID *Tls,
4352 IN UINT32 VerifyMode
4353 )
4354 {
4355 CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));
4356 }
4357
4358 /**
4359 Set the specified host name to be verified.
4360
4361 @param[in] Tls Pointer to the TLS object.
4362 @param[in] Flags The setting flags during the validation.
4363 @param[in] HostName The specified host name to be verified.
4364
4365 @retval EFI_SUCCESS The HostName setting was set successfully.
4366 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4367 @retval EFI_ABORTED Invalid HostName setting.
4368
4369 **/
4370 EFI_STATUS
4371 EFIAPI
4372 CryptoServiceTlsSetVerifyHost (
4373 IN VOID *Tls,
4374 IN UINT32 Flags,
4375 IN CHAR8 *HostName
4376 )
4377 {
4378 return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);
4379 }
4380
4381 /**
4382 Sets a TLS/SSL session ID to be used during TLS/SSL connect.
4383
4384 This function sets a session ID to be used when the TLS/SSL connection is
4385 to be established.
4386
4387 @param[in] Tls Pointer to the TLS object.
4388 @param[in] SessionId Session ID data used for session resumption.
4389 @param[in] SessionIdLen Length of Session ID in bytes.
4390
4391 @retval EFI_SUCCESS Session ID was set successfully.
4392 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4393 @retval EFI_UNSUPPORTED No available session for ID setting.
4394
4395 **/
4396 EFI_STATUS
4397 EFIAPI
4398 CryptoServiceTlsSetSessionId (
4399 IN VOID *Tls,
4400 IN UINT8 *SessionId,
4401 IN UINT16 SessionIdLen
4402 )
4403 {
4404 return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4405 }
4406
4407 /**
4408 Adds the CA to the cert store when requesting Server or Client authentication.
4409
4410 This function adds the CA certificate to the list of CAs when requesting
4411 Server or Client authentication for the chosen TLS connection.
4412
4413 @param[in] Tls Pointer to the TLS object.
4414 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4415 X.509 certificate or PEM-encoded X.509 certificate.
4416 @param[in] DataSize The size of data buffer in bytes.
4417
4418 @retval EFI_SUCCESS The operation succeeded.
4419 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4420 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4421 @retval EFI_ABORTED Invalid X.509 certificate.
4422
4423 **/
4424 EFI_STATUS
4425 EFIAPI
4426 CryptoServiceTlsSetCaCertificate (
4427 IN VOID *Tls,
4428 IN VOID *Data,
4429 IN UINTN DataSize
4430 )
4431 {
4432 return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4433 }
4434
4435 /**
4436 Loads the local public certificate into the specified TLS object.
4437
4438 This function loads the X.509 certificate into the specified TLS object
4439 for TLS negotiation.
4440
4441 @param[in] Tls Pointer to the TLS object.
4442 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4443 X.509 certificate or PEM-encoded X.509 certificate.
4444 @param[in] DataSize The size of data buffer in bytes.
4445
4446 @retval EFI_SUCCESS The operation succeeded.
4447 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4448 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4449 @retval EFI_ABORTED Invalid X.509 certificate.
4450
4451 **/
4452 EFI_STATUS
4453 EFIAPI
4454 CryptoServiceTlsSetHostPublicCert (
4455 IN VOID *Tls,
4456 IN VOID *Data,
4457 IN UINTN DataSize
4458 )
4459 {
4460 return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4461 }
4462
4463 /**
4464 Adds the local private key to the specified TLS object.
4465
4466 This function adds the local private key (PEM-encoded RSA or PKCS#8 private
4467 key) into the specified TLS object for TLS negotiation.
4468
4469 @param[in] Tls Pointer to the TLS object.
4470 @param[in] Data Pointer to the data buffer of a PEM-encoded RSA
4471 or PKCS#8 private key.
4472 @param[in] DataSize The size of data buffer in bytes.
4473
4474 @retval EFI_SUCCESS The operation succeeded.
4475 @retval EFI_UNSUPPORTED This function is not supported.
4476 @retval EFI_ABORTED Invalid private key data.
4477
4478 **/
4479 EFI_STATUS
4480 EFIAPI
4481 CryptoServiceTlsSetHostPrivateKey (
4482 IN VOID *Tls,
4483 IN VOID *Data,
4484 IN UINTN DataSize
4485 )
4486 {
4487 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4488 }
4489
4490 /**
4491 Adds the CA-supplied certificate revocation list for certificate validation.
4492
4493 This function adds the CA-supplied certificate revocation list data for
4494 certificate validity checking.
4495
4496 @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
4497 @param[in] DataSize The size of data buffer in bytes.
4498
4499 @retval EFI_SUCCESS The operation succeeded.
4500 @retval EFI_UNSUPPORTED This function is not supported.
4501 @retval EFI_ABORTED Invalid CRL data.
4502
4503 **/
4504 EFI_STATUS
4505 EFIAPI
4506 CryptoServiceTlsSetCertRevocationList (
4507 IN VOID *Data,
4508 IN UINTN DataSize
4509 )
4510 {
4511 return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4512 }
4513
4514 /**
4515 Gets the protocol version used by the specified TLS connection.
4516
4517 This function returns the protocol version used by the specified TLS
4518 connection.
4519
4520 If Tls is NULL, then ASSERT().
4521
4522 @param[in] Tls Pointer to the TLS object.
4523
4524 @return The protocol version of the specified TLS connection.
4525
4526 **/
4527 UINT16
4528 EFIAPI
4529 CryptoServiceTlsGetVersion (
4530 IN VOID *Tls
4531 )
4532 {
4533 return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);
4534 }
4535
4536 /**
4537 Gets the connection end of the specified TLS connection.
4538
4539 This function returns the connection end (as client or as server) used by
4540 the specified TLS connection.
4541
4542 If Tls is NULL, then ASSERT().
4543
4544 @param[in] Tls Pointer to the TLS object.
4545
4546 @return The connection end used by the specified TLS connection.
4547
4548 **/
4549 UINT8
4550 EFIAPI
4551 CryptoServiceTlsGetConnectionEnd (
4552 IN VOID *Tls
4553 )
4554 {
4555 return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);
4556 }
4557
4558 /**
4559 Gets the cipher suite used by the specified TLS connection.
4560
4561 This function returns current cipher suite used by the specified
4562 TLS connection.
4563
4564 @param[in] Tls Pointer to the TLS object.
4565 @param[in,out] CipherId The cipher suite used by the TLS object.
4566
4567 @retval EFI_SUCCESS The cipher suite was returned successfully.
4568 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4569 @retval EFI_UNSUPPORTED Unsupported cipher suite.
4570
4571 **/
4572 EFI_STATUS
4573 EFIAPI
4574 CryptoServiceTlsGetCurrentCipher (
4575 IN VOID *Tls,
4576 IN OUT UINT16 *CipherId
4577 )
4578 {
4579 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);
4580 }
4581
4582 /**
4583 Gets the compression methods used by the specified TLS connection.
4584
4585 This function returns current integrated compression methods used by
4586 the specified TLS connection.
4587
4588 @param[in] Tls Pointer to the TLS object.
4589 @param[in,out] CompressionId The current compression method used by
4590 the TLS object.
4591
4592 @retval EFI_SUCCESS The compression method was returned successfully.
4593 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4594 @retval EFI_ABORTED Invalid Compression method.
4595 @retval EFI_UNSUPPORTED This function is not supported.
4596
4597 **/
4598 EFI_STATUS
4599 EFIAPI
4600 CryptoServiceTlsGetCurrentCompressionId (
4601 IN VOID *Tls,
4602 IN OUT UINT8 *CompressionId
4603 )
4604 {
4605 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);
4606 }
4607
4608 /**
4609 Gets the verification mode currently set in the TLS connection.
4610
4611 This function returns the peer verification mode currently set in the
4612 specified TLS connection.
4613
4614 If Tls is NULL, then ASSERT().
4615
4616 @param[in] Tls Pointer to the TLS object.
4617
4618 @return The verification mode set in the specified TLS connection.
4619
4620 **/
4621 UINT32
4622 EFIAPI
4623 CryptoServiceTlsGetVerify (
4624 IN VOID *Tls
4625 )
4626 {
4627 return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);
4628 }
4629
4630 /**
4631 Gets the session ID used by the specified TLS connection.
4632
4633 This function returns the TLS/SSL session ID currently used by the
4634 specified TLS connection.
4635
4636 @param[in] Tls Pointer to the TLS object.
4637 @param[in,out] SessionId Buffer to contain the returned session ID.
4638 @param[in,out] SessionIdLen The length of Session ID in bytes.
4639
4640 @retval EFI_SUCCESS The Session ID was returned successfully.
4641 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4642 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4643
4644 **/
4645 EFI_STATUS
4646 EFIAPI
4647 CryptoServiceTlsGetSessionId (
4648 IN VOID *Tls,
4649 IN OUT UINT8 *SessionId,
4650 IN OUT UINT16 *SessionIdLen
4651 )
4652 {
4653 return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4654 }
4655
4656 /**
4657 Gets the client random data used in the specified TLS connection.
4658
4659 This function returns the TLS/SSL client random data currently used in
4660 the specified TLS connection.
4661
4662 @param[in] Tls Pointer to the TLS object.
4663 @param[in,out] ClientRandom Buffer to contain the returned client
4664 random data (32 bytes).
4665
4666 **/
4667 VOID
4668 EFIAPI
4669 CryptoServiceTlsGetClientRandom (
4670 IN VOID *Tls,
4671 IN OUT UINT8 *ClientRandom
4672 )
4673 {
4674 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));
4675 }
4676
4677 /**
4678 Gets the server random data used in the specified TLS connection.
4679
4680 This function returns the TLS/SSL server random data currently used in
4681 the specified TLS connection.
4682
4683 @param[in] Tls Pointer to the TLS object.
4684 @param[in,out] ServerRandom Buffer to contain the returned server
4685 random data (32 bytes).
4686
4687 **/
4688 VOID
4689 EFIAPI
4690 CryptoServiceTlsGetServerRandom (
4691 IN VOID *Tls,
4692 IN OUT UINT8 *ServerRandom
4693 )
4694 {
4695 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));
4696 }
4697
4698 /**
4699 Gets the master key data used in the specified TLS connection.
4700
4701 This function returns the TLS/SSL master key material currently used in
4702 the specified TLS connection.
4703
4704 @param[in] Tls Pointer to the TLS object.
4705 @param[in,out] KeyMaterial Buffer to contain the returned key material.
4706
4707 @retval EFI_SUCCESS Key material was returned successfully.
4708 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4709 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4710
4711 **/
4712 EFI_STATUS
4713 EFIAPI
4714 CryptoServiceTlsGetKeyMaterial (
4715 IN VOID *Tls,
4716 IN OUT UINT8 *KeyMaterial
4717 )
4718 {
4719 return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);
4720 }
4721
4722 /**
4723 Gets the CA Certificate from the cert store.
4724
4725 This function returns the CA certificate for the chosen
4726 TLS connection.
4727
4728 @param[in] Tls Pointer to the TLS object.
4729 @param[out] Data Pointer to the data buffer to receive the CA
4730 certificate data sent to the client.
4731 @param[in,out] DataSize The size of data buffer in bytes.
4732
4733 @retval EFI_SUCCESS The operation succeeded.
4734 @retval EFI_UNSUPPORTED This function is not supported.
4735 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4736
4737 **/
4738 EFI_STATUS
4739 EFIAPI
4740 CryptoServiceTlsGetCaCertificate (
4741 IN VOID *Tls,
4742 OUT VOID *Data,
4743 IN OUT UINTN *DataSize
4744 )
4745 {
4746 return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4747 }
4748
4749 /**
4750 Gets the local public Certificate set in the specified TLS object.
4751
4752 This function returns the local public certificate which was currently set
4753 in the specified TLS object.
4754
4755 @param[in] Tls Pointer to the TLS object.
4756 @param[out] Data Pointer to the data buffer to receive the local
4757 public certificate.
4758 @param[in,out] DataSize The size of data buffer in bytes.
4759
4760 @retval EFI_SUCCESS The operation succeeded.
4761 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4762 @retval EFI_NOT_FOUND The certificate is not found.
4763 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4764
4765 **/
4766 EFI_STATUS
4767 EFIAPI
4768 CryptoServiceTlsGetHostPublicCert (
4769 IN VOID *Tls,
4770 OUT VOID *Data,
4771 IN OUT UINTN *DataSize
4772 )
4773 {
4774 return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4775 }
4776
4777 /**
4778 Gets the local private key set in the specified TLS object.
4779
4780 This function returns the local private key data which was currently set
4781 in the specified TLS object.
4782
4783 @param[in] Tls Pointer to the TLS object.
4784 @param[out] Data Pointer to the data buffer to receive the local
4785 private key data.
4786 @param[in,out] DataSize The size of data buffer in bytes.
4787
4788 @retval EFI_SUCCESS The operation succeeded.
4789 @retval EFI_UNSUPPORTED This function is not supported.
4790 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4791
4792 **/
4793 EFI_STATUS
4794 EFIAPI
4795 CryptoServiceTlsGetHostPrivateKey (
4796 IN VOID *Tls,
4797 OUT VOID *Data,
4798 IN OUT UINTN *DataSize
4799 )
4800 {
4801 return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4802 }
4803
4804 /**
4805 Gets the CA-supplied certificate revocation list data set in the specified
4806 TLS object.
4807
4808 This function returns the CA-supplied certificate revocation list data which
4809 was currently set in the specified TLS object.
4810
4811 @param[out] Data Pointer to the data buffer to receive the CRL data.
4812 @param[in,out] DataSize The size of data buffer in bytes.
4813
4814 @retval EFI_SUCCESS The operation succeeded.
4815 @retval EFI_UNSUPPORTED This function is not supported.
4816 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4817
4818 **/
4819 EFI_STATUS
4820 EFIAPI
4821 CryptoServiceTlsGetCertRevocationList (
4822 OUT VOID *Data,
4823 IN OUT UINTN *DataSize
4824 )
4825 {
4826 return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4827 }
4828
4829 /**
4830 Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.
4831
4832 This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in
4833 RFC 8017.
4834 Mask generation function is the same as the message digest algorithm.
4835 If the Signature buffer is too small to hold the contents of signature, FALSE
4836 is returned and SigSize is set to the required buffer size to obtain the signature.
4837
4838 If RsaContext is NULL, then return FALSE.
4839 If Message is NULL, then return FALSE.
4840 If MsgSize is zero or > INT_MAX, then return FALSE.
4841 If DigestLen is NOT 32, 48 or 64, return FALSE.
4842 If SaltLen is not equal to DigestLen, then return FALSE.
4843 If SigSize is large enough but Signature is NULL, then return FALSE.
4844 If this interface is not supported, then return FALSE.
4845
4846 @param[in] RsaContext Pointer to RSA context for signature generation.
4847 @param[in] Message Pointer to octet message to be signed.
4848 @param[in] MsgSize Size of the message in bytes.
4849 @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.
4850 @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.
4851 @param[out] Signature Pointer to buffer to receive RSA PSS signature.
4852 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
4853 On output, the size of data returned in Signature buffer in bytes.
4854
4855 @retval TRUE Signature successfully generated in RSASSA-PSS.
4856 @retval FALSE Signature generation failed.
4857 @retval FALSE SigSize is too small.
4858 @retval FALSE This interface is not supported.
4859
4860 **/
4861 BOOLEAN
4862 EFIAPI
4863 CryptoServiceRsaPssSign (
4864 IN VOID *RsaContext,
4865 IN CONST UINT8 *Message,
4866 IN UINTN MsgSize,
4867 IN UINT16 DigestLen,
4868 IN UINT16 SaltLen,
4869 OUT UINT8 *Signature,
4870 IN OUT UINTN *SigSize
4871 )
4872 {
4873 return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);
4874 }
4875
4876 /**
4877 Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.
4878 Implementation determines salt length automatically from the signature encoding.
4879 Mask generation function is the same as the message digest algorithm.
4880 Salt length should be equal to digest length.
4881
4882 @param[in] RsaContext Pointer to RSA context for signature verification.
4883 @param[in] Message Pointer to octet message to be verified.
4884 @param[in] MsgSize Size of the message in bytes.
4885 @param[in] Signature Pointer to RSASSA-PSS signature to be verified.
4886 @param[in] SigSize Size of signature in bytes.
4887 @param[in] DigestLen Length of digest for RSA operation.
4888 @param[in] SaltLen Salt length for PSS encoding.
4889
4890 @retval TRUE Valid signature encoded in RSASSA-PSS.
4891 @retval FALSE Invalid signature or invalid RSA context.
4892
4893 **/
4894 BOOLEAN
4895 EFIAPI
4896 CryptoServiceRsaPssVerify (
4897 IN VOID *RsaContext,
4898 IN CONST UINT8 *Message,
4899 IN UINTN MsgSize,
4900 IN CONST UINT8 *Signature,
4901 IN UINTN SigSize,
4902 IN UINT16 DigestLen,
4903 IN UINT16 SaltLen
4904 )
4905 {
4906 return CALL_BASECRYPTLIB (RsaPss.Services.Verify, RsaPssVerify, (RsaContext, Message, MsgSize, Signature, SigSize, DigestLen, SaltLen), FALSE);
4907 }
4908
4909 /**
4910 Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,
4911 published December 2016.
4912
4913 @param[in] Input Pointer to the input message (X).
4914 @param[in] InputByteLen The number(>0) of input bytes provided for the input data.
4915 @param[in] BlockSize The size of each block (B).
4916 @param[out] Output Pointer to the output buffer.
4917 @param[in] OutputByteLen The desired number of output bytes (L).
4918 @param[in] Customization Pointer to the customization string (S).
4919 @param[in] CustomByteLen The length of the customization string in bytes.
4920
4921 @retval TRUE ParallelHash256 digest computation succeeded.
4922 @retval FALSE ParallelHash256 digest computation failed.
4923 @retval FALSE This interface is not supported.
4924
4925 **/
4926 BOOLEAN
4927 EFIAPI
4928 CryptoServiceParallelHash256HashAll (
4929 IN CONST VOID *Input,
4930 IN UINTN InputByteLen,
4931 IN UINTN BlockSize,
4932 OUT VOID *Output,
4933 IN UINTN OutputByteLen,
4934 IN CONST VOID *Customization,
4935 IN UINTN CustomByteLen
4936 )
4937 {
4938 return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);
4939 }
4940
4941 /**
4942 Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).
4943
4944 IvSize must be 12, otherwise FALSE is returned.
4945 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
4946 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
4947
4948 @param[in] Key Pointer to the encryption key.
4949 @param[in] KeySize Size of the encryption key in bytes.
4950 @param[in] Iv Pointer to the IV value.
4951 @param[in] IvSize Size of the IV value in bytes.
4952 @param[in] AData Pointer to the additional authenticated data (AAD).
4953 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
4954 @param[in] DataIn Pointer to the input data buffer to be encrypted.
4955 @param[in] DataInSize Size of the input data buffer in bytes.
4956 @param[out] TagOut Pointer to a buffer that receives the authentication tag output.
4957 @param[in] TagSize Size of the authentication tag in bytes.
4958 @param[out] DataOut Pointer to a buffer that receives the encryption output.
4959 @param[out] DataOutSize Size of the output data buffer in bytes.
4960
4961 @retval TRUE AEAD AES-GCM authenticated encryption succeeded.
4962 @retval FALSE AEAD AES-GCM authenticated encryption failed.
4963
4964 **/
4965 BOOLEAN
4966 EFIAPI
4967 CryptoServiceAeadAesGcmEncrypt (
4968 IN CONST UINT8 *Key,
4969 IN UINTN KeySize,
4970 IN CONST UINT8 *Iv,
4971 IN UINTN IvSize,
4972 IN CONST UINT8 *AData,
4973 IN UINTN ADataSize,
4974 IN CONST UINT8 *DataIn,
4975 IN UINTN DataInSize,
4976 OUT UINT8 *TagOut,
4977 IN UINTN TagSize,
4978 OUT UINT8 *DataOut,
4979 OUT UINTN *DataOutSize
4980 )
4981 {
4982 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Encrypt, AeadAesGcmEncrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, TagOut, TagSize, DataOut, DataOutSize), FALSE);
4983 }
4984
4985 /**
4986 Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).
4987
4988 IvSize must be 12, otherwise FALSE is returned.
4989 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
4990 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
4991 If additional authenticated data verification fails, FALSE is returned.
4992
4993 @param[in] Key Pointer to the encryption key.
4994 @param[in] KeySize Size of the encryption key in bytes.
4995 @param[in] Iv Pointer to the IV value.
4996 @param[in] IvSize Size of the IV value in bytes.
4997 @param[in] AData Pointer to the additional authenticated data (AAD).
4998 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
4999 @param[in] DataIn Pointer to the input data buffer to be decrypted.
5000 @param[in] DataInSize Size of the input data buffer in bytes.
5001 @param[in] Tag Pointer to a buffer that contains the authentication tag.
5002 @param[in] TagSize Size of the authentication tag in bytes.
5003 @param[out] DataOut Pointer to a buffer that receives the decryption output.
5004 @param[out] DataOutSize Size of the output data buffer in bytes.
5005
5006 @retval TRUE AEAD AES-GCM authenticated decryption succeeded.
5007 @retval FALSE AEAD AES-GCM authenticated decryption failed.
5008
5009 **/
5010 BOOLEAN
5011 EFIAPI
5012 CryptoServiceAeadAesGcmDecrypt (
5013 IN CONST UINT8 *Key,
5014 IN UINTN KeySize,
5015 IN CONST UINT8 *Iv,
5016 IN UINTN IvSize,
5017 IN CONST UINT8 *AData,
5018 IN UINTN ADataSize,
5019 IN CONST UINT8 *DataIn,
5020 IN UINTN DataInSize,
5021 IN CONST UINT8 *Tag,
5022 IN UINTN TagSize,
5023 OUT UINT8 *DataOut,
5024 OUT UINTN *DataOutSize
5025 )
5026 {
5027 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);
5028 }
5029
5030 // =====================================================================================
5031 // Big number primitives
5032 // =====================================================================================
5033
5034 /**
5035 Allocate new Big Number.
5036
5037 @retval New BigNum opaque structure or NULL on failure.
5038 **/
5039 VOID *
5040 EFIAPI
5041 CryptoServiceBigNumInit (
5042 VOID
5043 )
5044 {
5045 return CALL_BASECRYPTLIB (Bn.Services.Init, BigNumInit, (), NULL);
5046 }
5047
5048 /**
5049 Allocate new Big Number and assign the provided value to it.
5050
5051 @param[in] Buf Big endian encoded buffer.
5052 @param[in] Len Buffer length.
5053
5054 @retval New BigNum opaque structure or NULL on failure.
5055 **/
5056 VOID *
5057 EFIAPI
5058 CryptoServiceBigNumFromBin (
5059 IN CONST UINT8 *Buf,
5060 IN UINTN Len
5061 )
5062 {
5063 return CALL_BASECRYPTLIB (Bn.Services.FromBin, BigNumFromBin, (Buf, Len), NULL);
5064 }
5065
5066 /**
5067 Convert the absolute value of Bn into big-endian form and store it at Buf.
5068 The Buf array should have at least BigNumBytes() in it.
5069
5070 @param[in] Bn Big number to convert.
5071 @param[out] Buf Output buffer.
5072
5073 @retval The length of the big-endian number placed at Buf or -1 on error.
5074 **/
5075 INTN
5076 EFIAPI
5077 CryptoServiceBigNumToBin (
5078 IN CONST VOID *Bn,
5079 OUT UINT8 *Buf
5080 )
5081 {
5082 return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1);
5083 }
5084
5085 /**
5086 Free the Big Number.
5087
5088 @param[in] Bn Big number to free.
5089 @param[in] Clear TRUE if the buffer should be cleared.
5090 **/
5091 VOID
5092 EFIAPI
5093 CryptoServiceBigNumFree (
5094 IN VOID *Bn,
5095 IN BOOLEAN Clear
5096 )
5097 {
5098 CALL_VOID_BASECRYPTLIB (Bn.Services.Free, BigNumFree, (Bn, Clear));
5099 }
5100
5101 /**
5102 Calculate the sum of two Big Numbers.
5103 Please note, all "out" Big number arguments should be properly initialized
5104 by calling to BigNumInit() or BigNumFromBin() functions.
5105
5106 @param[in] BnA Big number.
5107 @param[in] BnB Big number.
5108 @param[out] BnRes The result of BnA + BnB.
5109
5110 @retval TRUE On success.
5111 @retval FALSE Otherwise.
5112 **/
5113 BOOLEAN
5114 EFIAPI
5115 CryptoServiceBigNumAdd (
5116 IN CONST VOID *BnA,
5117 IN CONST VOID *BnB,
5118 OUT VOID *BnRes
5119 )
5120 {
5121 return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE);
5122 }
5123
5124 /**
5125 Subtract two Big Numbers.
5126 Please note, all "out" Big number arguments should be properly initialized
5127 by calling to BigNumInit() or BigNumFromBin() functions.
5128
5129 @param[in] BnA Big number.
5130 @param[in] BnB Big number.
5131 @param[out] BnRes The result of BnA - BnB.
5132
5133 @retval TRUE On success.
5134 @retval FALSE Otherwise.
5135 **/
5136 BOOLEAN
5137 EFIAPI
5138 CryptoServiceBigNumSub (
5139 IN CONST VOID *BnA,
5140 IN CONST VOID *BnB,
5141 OUT VOID *BnRes
5142 )
5143 {
5144 return CALL_BASECRYPTLIB (Bn.Services.Sub, BigNumSub, (BnA, BnB, BnRes), FALSE);
5145 }
5146
5147 /**
5148 Calculate remainder: BnRes = BnA % BnB.
5149 Please note, all "out" Big number arguments should be properly initialized
5150 by calling to BigNumInit() or BigNumFromBin() functions.
5151
5152 @param[in] BnA Big number.
5153 @param[in] BnB Big number.
5154 @param[out] BnRes The result of BnA % BnB.
5155
5156 @retval TRUE On success.
5157 @retval FALSE Otherwise.
5158 **/
5159 BOOLEAN
5160 EFIAPI
5161 CryptoServiceBigNumMod (
5162 IN CONST VOID *BnA,
5163 IN CONST VOID *BnB,
5164 OUT VOID *BnRes
5165 )
5166 {
5167 return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);
5168 }
5169
5170 /**
5171 Compute BnA to the BnP-th power modulo BnM.
5172 Please note, all "out" Big number arguments should be properly initialized.
5173 by calling to BigNumInit() or BigNumFromBin() functions.
5174
5175 @param[in] BnA Big number.
5176 @param[in] BnP Big number (power).
5177 @param[in] BnM Big number (modulo).
5178 @param[out] BnRes The result of (BnA ^ BnP) % BnM.
5179
5180 @retval TRUE On success.
5181 @retval FALSE Otherwise.
5182 **/
5183 BOOLEAN
5184 EFIAPI
5185 CryptoServiceBigNumExpMod (
5186 IN CONST VOID *BnA,
5187 IN CONST VOID *BnP,
5188 IN CONST VOID *BnM,
5189 OUT VOID *BnRes
5190 )
5191 {
5192 return CALL_BASECRYPTLIB (Bn.Services.ExpMod, BigNumExpMod, (BnA, BnP, BnM, BnRes), FALSE);
5193 }
5194
5195 /**
5196 Compute BnA inverse modulo BnM.
5197 Please note, all "out" Big number arguments should be properly initialized
5198 by calling to BigNumInit() or BigNumFromBin() functions.
5199
5200 @param[in] BnA Big number.
5201 @param[in] BnM Big number (modulo).
5202 @param[out] BnRes The result, such that (BnA * BnRes) % BnM == 1.
5203
5204 @retval TRUE On success.
5205 @retval FALSE Otherwise.
5206 **/
5207 BOOLEAN
5208 EFIAPI
5209 CryptoServiceBigNumInverseMod (
5210 IN CONST VOID *BnA,
5211 IN CONST VOID *BnM,
5212 OUT VOID *BnRes
5213 )
5214 {
5215 return CALL_BASECRYPTLIB (Bn.Services.InverseMod, BigNumInverseMod, (BnA, BnM, BnRes), FALSE);
5216 }
5217
5218 /**
5219 Divide two Big Numbers.
5220 Please note, all "out" Big number arguments should be properly initialized
5221 by calling to BigNumInit() or BigNumFromBin() functions.
5222
5223 @param[in] BnA Big number.
5224 @param[in] BnB Big number.
5225 @param[out] BnRes The result, such that BnA / BnB.
5226
5227 @retval TRUE On success.
5228 @retval FALSE Otherwise.
5229 **/
5230 BOOLEAN
5231 EFIAPI
5232 CryptoServiceBigNumDiv (
5233 IN CONST VOID *BnA,
5234 IN CONST VOID *BnB,
5235 OUT VOID *BnRes
5236 )
5237 {
5238 return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);
5239 }
5240
5241 /**
5242 Multiply two Big Numbers modulo BnM.
5243 Please note, all "out" Big number arguments should be properly initialized
5244 by calling to BigNumInit() or BigNumFromBin() functions.
5245
5246 @param[in] BnA Big number.
5247 @param[in] BnB Big number.
5248 @param[in] BnM Big number (modulo).
5249 @param[out] BnRes The result, such that (BnA * BnB) % BnM.
5250
5251 @retval TRUE On success.
5252 @retval FALSE Otherwise.
5253 **/
5254 BOOLEAN
5255 EFIAPI
5256 CryptoServiceBigNumMulMod (
5257 IN CONST VOID *BnA,
5258 IN CONST VOID *BnB,
5259 IN CONST VOID *BnM,
5260 OUT VOID *BnRes
5261 )
5262 {
5263 return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);
5264 }
5265
5266 /**
5267 Compare two Big Numbers.
5268
5269 @param[in] BnA Big number.
5270 @param[in] BnB Big number.
5271
5272 @retval 0 BnA == BnB.
5273 @retval 1 BnA > BnB.
5274 @retval -1 BnA < BnB.
5275 **/
5276 INTN
5277 EFIAPI
5278 CryptoServiceBigNumCmp (
5279 IN CONST VOID *BnA,
5280 IN CONST VOID *BnB
5281 )
5282 {
5283 return CALL_BASECRYPTLIB (Bn.Services.Cmp, BigNumCmp, (BnA, BnB), 0);
5284 }
5285
5286 /**
5287 Get number of bits in Bn.
5288
5289 @param[in] Bn Big number.
5290
5291 @retval Number of bits.
5292 **/
5293 UINTN
5294 EFIAPI
5295 CryptoServiceBigNumBits (
5296 IN CONST VOID *Bn
5297 )
5298 {
5299 return CALL_BASECRYPTLIB (Bn.Services.Bits, BigNumBits, (Bn), 0);
5300 }
5301
5302 /**
5303 Get number of bytes in Bn.
5304
5305 @param[in] Bn Big number.
5306
5307 @retval Number of bytes.
5308 **/
5309 UINTN
5310 EFIAPI
5311 CryptoServiceBigNumBytes (
5312 IN CONST VOID *Bn
5313 )
5314 {
5315 return CALL_BASECRYPTLIB (Bn.Services.Bytes, BigNumBytes, (Bn), 0);
5316 }
5317
5318 /**
5319 Checks if Big Number equals to the given Num.
5320
5321 @param[in] Bn Big number.
5322 @param[in] Num Number.
5323
5324 @retval TRUE iff Bn == Num.
5325 @retval FALSE otherwise.
5326 **/
5327 BOOLEAN
5328 EFIAPI
5329 CryptoServiceBigNumIsWord (
5330 IN CONST VOID *Bn,
5331 IN UINTN Num
5332 )
5333 {
5334 return CALL_BASECRYPTLIB (Bn.Services.IsWord, BigNumIsWord, (Bn, Num), FALSE);
5335 }
5336
5337 /**
5338 Checks if Big Number is odd.
5339
5340 @param[in] Bn Big number.
5341
5342 @retval TRUE Bn is odd (Bn % 2 == 1).
5343 @retval FALSE otherwise.
5344 **/
5345 BOOLEAN
5346 EFIAPI
5347 CryptoServiceBigNumIsOdd (
5348 IN CONST VOID *Bn
5349 )
5350 {
5351 return CALL_BASECRYPTLIB (Bn.Services.IsOdd, BigNumIsOdd, (Bn), FALSE);
5352 }
5353
5354 /**
5355 Copy Big number.
5356
5357 @param[out] BnDst Destination.
5358 @param[in] BnSrc Source.
5359
5360 @retval BnDst on success.
5361 @retval NULL otherwise.
5362 **/
5363 VOID *
5364 EFIAPI
5365 CryptoServiceBigNumCopy (
5366 OUT VOID *BnDst,
5367 IN CONST VOID *BnSrc
5368 )
5369 {
5370 return CALL_BASECRYPTLIB (Bn.Services.Copy, BigNumCopy, (BnDst, BnSrc), NULL);
5371 }
5372
5373 /**
5374 Get constant Big number with value of "1".
5375 This may be used to save expensive allocations.
5376
5377 @retval Big Number with value of 1.
5378 **/
5379 CONST VOID *
5380 EFIAPI
5381 CryptoServiceBigNumValueOne (
5382 VOID
5383 )
5384 {
5385 return CALL_BASECRYPTLIB (Bn.Services.ValueOne, BigNumValueOne, (), NULL);
5386 }
5387
5388 /**
5389 Shift right Big Number.
5390 Please note, all "out" Big number arguments should be properly initialized
5391 by calling to BigNumInit() or BigNumFromBin() functions.
5392
5393 @param[in] Bn Big number.
5394 @param[in] N Number of bits to shift.
5395 @param[out] BnRes The result.
5396
5397 @retval TRUE On success.
5398 @retval FALSE Otherwise.
5399 **/
5400 BOOLEAN
5401 EFIAPI
5402 CryptoServiceBigNumRShift (
5403 IN CONST VOID *Bn,
5404 IN UINTN N,
5405 OUT VOID *BnRes
5406 )
5407 {
5408 return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE);
5409 }
5410
5411 /**
5412 Mark Big Number for constant time computations.
5413 This function should be called before any constant time computations are
5414 performed on the given Big number.
5415
5416 @param[in] Bn Big number.
5417 **/
5418 VOID
5419 EFIAPI
5420 CryptoServiceBigNumConstTime (
5421 IN VOID *Bn
5422 )
5423 {
5424 CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));
5425 }
5426
5427 /**
5428 Calculate square modulo.
5429 Please note, all "out" Big number arguments should be properly initialized
5430 by calling to BigNumInit() or BigNumFromBin() functions.
5431
5432 @param[in] BnA Big number.
5433 @param[in] BnM Big number (modulo).
5434 @param[out] BnRes The result, such that (BnA ^ 2) % BnM.
5435
5436 @retval TRUE On success.
5437 @retval FALSE Otherwise.
5438 **/
5439 BOOLEAN
5440 EFIAPI
5441 CryptoServiceBigNumSqrMod (
5442 IN CONST VOID *BnA,
5443 IN CONST VOID *BnM,
5444 OUT VOID *BnRes
5445 )
5446 {
5447 return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE);
5448 }
5449
5450 /**
5451 Create new Big Number computation context. This is an opaque structure
5452 which should be passed to any function that requires it. The BN context is
5453 needed to optimize calculations and expensive allocations.
5454
5455 @retval Big Number context struct or NULL on failure.
5456 **/
5457 VOID *
5458 EFIAPI
5459 CryptoServiceBigNumNewContext (
5460 VOID
5461 )
5462 {
5463 return CALL_BASECRYPTLIB (Bn.Services.NewContext, BigNumNewContext, (), NULL);
5464 }
5465
5466 /**
5467 Free Big Number context that was allocated with BigNumNewContext().
5468
5469 @param[in] BnCtx Big number context to free.
5470 **/
5471 VOID
5472 EFIAPI
5473 CryptoServiceBigNumContextFree (
5474 IN VOID *BnCtx
5475 )
5476 {
5477 CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));
5478 }
5479
5480 /**
5481 Set Big Number to a given value.
5482
5483 @param[in] Bn Big number to set.
5484 @param[in] Val Value to set.
5485
5486 @retval TRUE On success.
5487 @retval FALSE Otherwise.
5488 **/
5489 BOOLEAN
5490 EFIAPI
5491 CryptoServiceBigNumSetUint (
5492 IN VOID *Bn,
5493 IN UINTN Val
5494 )
5495 {
5496 return CALL_BASECRYPTLIB (Bn.Services.SetUint, BigNumSetUint, (Bn, Val), FALSE);
5497 }
5498
5499 /**
5500 Add two Big Numbers modulo BnM.
5501
5502 @param[in] BnA Big number.
5503 @param[in] BnB Big number.
5504 @param[in] BnM Big number (modulo).
5505 @param[out] BnRes The result, such that (BnA + BnB) % BnM.
5506
5507 @retval TRUE On success.
5508 @retval FALSE Otherwise.
5509 **/
5510 BOOLEAN
5511 EFIAPI
5512 CryptoServiceBigNumAddMod (
5513 IN CONST VOID *BnA,
5514 IN CONST VOID *BnB,
5515 IN CONST VOID *BnM,
5516 OUT VOID *BnRes
5517 )
5518 {
5519 return CALL_BASECRYPTLIB (Bn.Services.AddMod, BigNumAddMod, (BnA, BnB, BnM, BnRes), FALSE);
5520 }
5521
5522 const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
5523 /// Version
5524 CryptoServiceGetCryptoVersion,
5525 /// HMAC MD5 - deprecated and unsupported
5526 DeprecatedCryptoServiceHmacMd5New,
5527 DeprecatedCryptoServiceHmacMd5Free,
5528 DeprecatedCryptoServiceHmacMd5SetKey,
5529 DeprecatedCryptoServiceHmacMd5Duplicate,
5530 DeprecatedCryptoServiceHmacMd5Update,
5531 DeprecatedCryptoServiceHmacMd5Final,
5532 /// HMAC SHA1 - deprecated and unsupported
5533 DeprecatedCryptoServiceHmacSha1New,
5534 DeprecatedCryptoServiceHmacSha1Free,
5535 DeprecatedCryptoServiceHmacSha1SetKey,
5536 DeprecatedCryptoServiceHmacSha1Duplicate,
5537 DeprecatedCryptoServiceHmacSha1Update,
5538 DeprecatedCryptoServiceHmacSha1Final,
5539 /// HMAC SHA256
5540 CryptoServiceHmacSha256New,
5541 CryptoServiceHmacSha256Free,
5542 CryptoServiceHmacSha256SetKey,
5543 CryptoServiceHmacSha256Duplicate,
5544 CryptoServiceHmacSha256Update,
5545 CryptoServiceHmacSha256Final,
5546 /// Md4 - deprecated and unsupported
5547 DeprecatedCryptoServiceMd4GetContextSize,
5548 DeprecatedCryptoServiceMd4Init,
5549 DeprecatedCryptoServiceMd4Duplicate,
5550 DeprecatedCryptoServiceMd4Update,
5551 DeprecatedCryptoServiceMd4Final,
5552 DeprecatedCryptoServiceMd4HashAll,
5553 #ifndef ENABLE_MD5_DEPRECATED_INTERFACES
5554 /// Md5 - deprecated and unsupported
5555 DeprecatedCryptoServiceMd5GetContextSize,
5556 DeprecatedCryptoServiceMd5Init,
5557 DeprecatedCryptoServiceMd5Duplicate,
5558 DeprecatedCryptoServiceMd5Update,
5559 DeprecatedCryptoServiceMd5Final,
5560 DeprecatedCryptoServiceMd5HashAll,
5561 #else
5562 /// Md5
5563 CryptoServiceMd5GetContextSize,
5564 CryptoServiceMd5Init,
5565 CryptoServiceMd5Duplicate,
5566 CryptoServiceMd5Update,
5567 CryptoServiceMd5Final,
5568 CryptoServiceMd5HashAll,
5569 #endif
5570 /// Pkcs
5571 CryptoServicePkcs1v2Encrypt,
5572 CryptoServicePkcs5HashPassword,
5573 CryptoServicePkcs7Verify,
5574 CryptoServiceVerifyEKUsInPkcs7Signature,
5575 CryptoServicePkcs7GetSigners,
5576 CryptoServicePkcs7FreeSigners,
5577 CryptoServicePkcs7Sign,
5578 CryptoServicePkcs7GetAttachedContent,
5579 CryptoServicePkcs7GetCertificatesList,
5580 CryptoServiceAuthenticodeVerify,
5581 CryptoServiceImageTimestampVerify,
5582 /// DH
5583 CryptoServiceDhNew,
5584 CryptoServiceDhFree,
5585 CryptoServiceDhGenerateParameter,
5586 CryptoServiceDhSetParameter,
5587 CryptoServiceDhGenerateKey,
5588 CryptoServiceDhComputeKey,
5589 /// Random
5590 CryptoServiceRandomSeed,
5591 CryptoServiceRandomBytes,
5592 /// RSA
5593 CryptoServiceRsaPkcs1Verify,
5594 CryptoServiceRsaNew,
5595 CryptoServiceRsaFree,
5596 CryptoServiceRsaSetKey,
5597 CryptoServiceRsaGetKey,
5598 CryptoServiceRsaGenerateKey,
5599 CryptoServiceRsaCheckKey,
5600 CryptoServiceRsaPkcs1Sign,
5601 CryptoServiceRsaPkcs1Verify,
5602 CryptoServiceRsaGetPrivateKeyFromPem,
5603 CryptoServiceRsaGetPublicKeyFromX509,
5604 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
5605 /// Sha1 - deprecated and unsupported
5606 DeprecatedCryptoServiceSha1GetContextSize,
5607 DeprecatedCryptoServiceSha1Init,
5608 DeprecatedCryptoServiceSha1Duplicate,
5609 DeprecatedCryptoServiceSha1Update,
5610 DeprecatedCryptoServiceSha1Final,
5611 DeprecatedCryptoServiceSha1HashAll,
5612 #else
5613 /// Sha1
5614 CryptoServiceSha1GetContextSize,
5615 CryptoServiceSha1Init,
5616 CryptoServiceSha1Duplicate,
5617 CryptoServiceSha1Update,
5618 CryptoServiceSha1Final,
5619 CryptoServiceSha1HashAll,
5620 #endif
5621 /// Sha256
5622 CryptoServiceSha256GetContextSize,
5623 CryptoServiceSha256Init,
5624 CryptoServiceSha256Duplicate,
5625 CryptoServiceSha256Update,
5626 CryptoServiceSha256Final,
5627 CryptoServiceSha256HashAll,
5628 /// Sha384
5629 CryptoServiceSha384GetContextSize,
5630 CryptoServiceSha384Init,
5631 CryptoServiceSha384Duplicate,
5632 CryptoServiceSha384Update,
5633 CryptoServiceSha384Final,
5634 CryptoServiceSha384HashAll,
5635 /// Sha512
5636 CryptoServiceSha512GetContextSize,
5637 CryptoServiceSha512Init,
5638 CryptoServiceSha512Duplicate,
5639 CryptoServiceSha512Update,
5640 CryptoServiceSha512Final,
5641 CryptoServiceSha512HashAll,
5642 /// X509
5643 CryptoServiceX509GetSubjectName,
5644 CryptoServiceX509GetCommonName,
5645 CryptoServiceX509GetOrganizationName,
5646 CryptoServiceX509VerifyCert,
5647 CryptoServiceX509ConstructCertificate,
5648 CryptoServiceX509ConstructCertificateStack,
5649 CryptoServiceX509Free,
5650 CryptoServiceX509StackFree,
5651 CryptoServiceX509GetTBSCert,
5652 /// TDES - deprecated and unsupported
5653 DeprecatedCryptoServiceTdesGetContextSize,
5654 DeprecatedCryptoServiceTdesInit,
5655 DeprecatedCryptoServiceTdesEcbEncrypt,
5656 DeprecatedCryptoServiceTdesEcbDecrypt,
5657 DeprecatedCryptoServiceTdesCbcEncrypt,
5658 DeprecatedCryptoServiceTdesCbcDecrypt,
5659 /// AES - ECB mode is deprecated and unsupported
5660 CryptoServiceAesGetContextSize,
5661 CryptoServiceAesInit,
5662 DeprecatedCryptoServiceAesEcbEncrypt,
5663 DeprecatedCryptoServiceAesEcbDecrypt,
5664 CryptoServiceAesCbcEncrypt,
5665 CryptoServiceAesCbcDecrypt,
5666 /// Arc4 - deprecated and unsupported
5667 DeprecatedCryptoServiceArc4GetContextSize,
5668 DeprecatedCryptoServiceArc4Init,
5669 DeprecatedCryptoServiceArc4Encrypt,
5670 DeprecatedCryptoServiceArc4Decrypt,
5671 DeprecatedCryptoServiceArc4Reset,
5672 /// SM3
5673 CryptoServiceSm3GetContextSize,
5674 CryptoServiceSm3Init,
5675 CryptoServiceSm3Duplicate,
5676 CryptoServiceSm3Update,
5677 CryptoServiceSm3Final,
5678 CryptoServiceSm3HashAll,
5679 /// HKDF
5680 CryptoServiceHkdfSha256ExtractAndExpand,
5681 /// X509 (Continued)
5682 CryptoServiceX509ConstructCertificateStackV,
5683 /// TLS
5684 CryptoServiceTlsInitialize,
5685 CryptoServiceTlsCtxFree,
5686 CryptoServiceTlsCtxNew,
5687 CryptoServiceTlsFree,
5688 CryptoServiceTlsNew,
5689 CryptoServiceTlsInHandshake,
5690 CryptoServiceTlsDoHandshake,
5691 CryptoServiceTlsHandleAlert,
5692 CryptoServiceTlsCloseNotify,
5693 CryptoServiceTlsCtrlTrafficOut,
5694 CryptoServiceTlsCtrlTrafficIn,
5695 CryptoServiceTlsRead,
5696 CryptoServiceTlsWrite,
5697 /// TLS Set
5698 CryptoServiceTlsSetVersion,
5699 CryptoServiceTlsSetConnectionEnd,
5700 CryptoServiceTlsSetCipherList,
5701 CryptoServiceTlsSetCompressionMethod,
5702 CryptoServiceTlsSetVerify,
5703 CryptoServiceTlsSetVerifyHost,
5704 CryptoServiceTlsSetSessionId,
5705 CryptoServiceTlsSetCaCertificate,
5706 CryptoServiceTlsSetHostPublicCert,
5707 CryptoServiceTlsSetHostPrivateKey,
5708 CryptoServiceTlsSetCertRevocationList,
5709 /// TLS Get
5710 CryptoServiceTlsGetVersion,
5711 CryptoServiceTlsGetConnectionEnd,
5712 CryptoServiceTlsGetCurrentCipher,
5713 CryptoServiceTlsGetCurrentCompressionId,
5714 CryptoServiceTlsGetVerify,
5715 CryptoServiceTlsGetSessionId,
5716 CryptoServiceTlsGetClientRandom,
5717 CryptoServiceTlsGetServerRandom,
5718 CryptoServiceTlsGetKeyMaterial,
5719 CryptoServiceTlsGetCaCertificate,
5720 CryptoServiceTlsGetHostPublicCert,
5721 CryptoServiceTlsGetHostPrivateKey,
5722 CryptoServiceTlsGetCertRevocationList,
5723 /// RSA PSS
5724 CryptoServiceRsaPssSign,
5725 CryptoServiceRsaPssVerify,
5726 /// Parallel hash
5727 CryptoServiceParallelHash256HashAll,
5728 /// HMAC SHA256 (continued)
5729 CryptoServiceHmacSha256All,
5730 /// HMAC SHA384
5731 CryptoServiceHmacSha384New,
5732 CryptoServiceHmacSha384Free,
5733 CryptoServiceHmacSha384SetKey,
5734 CryptoServiceHmacSha384Duplicate,
5735 CryptoServiceHmacSha384Update,
5736 CryptoServiceHmacSha384Final,
5737 CryptoServiceHmacSha384All,
5738 /// HKDF (continued)
5739 CryptoServiceHkdfSha256Extract,
5740 CryptoServiceHkdfSha256Expand,
5741 CryptoServiceHkdfSha384ExtractAndExpand,
5742 CryptoServiceHkdfSha384Extract,
5743 CryptoServiceHkdfSha384Expand,
5744 /// Aead Aes GCM
5745 CryptoServiceAeadAesGcmEncrypt,
5746 CryptoServiceAeadAesGcmDecrypt,
5747 /// Big Numbers
5748 CryptoServiceBigNumInit,
5749 CryptoServiceBigNumFromBin,
5750 CryptoServiceBigNumToBin,
5751 CryptoServiceBigNumFree,
5752 CryptoServiceBigNumAdd,
5753 CryptoServiceBigNumSub,
5754 CryptoServiceBigNumMod,
5755 CryptoServiceBigNumExpMod,
5756 CryptoServiceBigNumInverseMod,
5757 CryptoServiceBigNumDiv,
5758 CryptoServiceBigNumMulMod,
5759 CryptoServiceBigNumCmp,
5760 CryptoServiceBigNumBits,
5761 CryptoServiceBigNumBytes,
5762 CryptoServiceBigNumIsWord,
5763 CryptoServiceBigNumIsOdd,
5764 CryptoServiceBigNumCopy,
5765 CryptoServiceBigNumValueOne,
5766 CryptoServiceBigNumRShift,
5767 CryptoServiceBigNumConstTime,
5768 CryptoServiceBigNumSqrMod,
5769 CryptoServiceBigNumNewContext,
5770 CryptoServiceBigNumContextFree,
5771 CryptoServiceBigNumSetUint,
5772 CryptoServiceBigNumAddMod,
5773 };