]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Driver/Crypto.c
1928adbff778e51c74fdd27f5e685fe325b458e1
[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 Shutdown a TLS connection.
4243
4244 Shutdown the TLS connection without releasing the resources, meaning a new
4245 connection can be started without calling TlsNew() and without setting
4246 certificates etc.
4247
4248 @param[in] Tls Pointer to the TLS object to shutdown.
4249
4250 @retval EFI_SUCCESS The TLS is shutdown successfully.
4251 @retval EFI_INVALID_PARAMETER Tls is NULL.
4252 @retval EFI_PROTOCOL_ERROR Some other error occurred.
4253 **/
4254 EFI_STATUS
4255 EFIAPI
4256 CryptoServiceTlsShutdown (
4257 IN VOID *Tls
4258 )
4259 {
4260 return CALL_BASECRYPTLIB (Tls.Services.Shutdown, TlsShutdown, (Tls), EFI_UNSUPPORTED);
4261 }
4262
4263 /**
4264 Set a new TLS/SSL method for a particular TLS object.
4265
4266 This function sets a new TLS/SSL method for a particular TLS object.
4267
4268 @param[in] Tls Pointer to a TLS object.
4269 @param[in] MajorVer Major Version of TLS/SSL Protocol.
4270 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
4271
4272 @retval EFI_SUCCESS The TLS/SSL method was set successfully.
4273 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4274 @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
4275
4276 **/
4277 EFI_STATUS
4278 EFIAPI
4279 CryptoServiceTlsSetVersion (
4280 IN VOID *Tls,
4281 IN UINT8 MajorVer,
4282 IN UINT8 MinorVer
4283 )
4284 {
4285 return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);
4286 }
4287
4288 /**
4289 Set TLS object to work in client or server mode.
4290
4291 This function prepares a TLS object to work in client or server mode.
4292
4293 @param[in] Tls Pointer to a TLS object.
4294 @param[in] IsServer Work in server mode.
4295
4296 @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
4297 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4298 @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
4299
4300 **/
4301 EFI_STATUS
4302 EFIAPI
4303 CryptoServiceTlsSetConnectionEnd (
4304 IN VOID *Tls,
4305 IN BOOLEAN IsServer
4306 )
4307 {
4308 return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);
4309 }
4310
4311 /**
4312 Set the ciphers list to be used by the TLS object.
4313
4314 This function sets the ciphers for use by a specified TLS object.
4315
4316 @param[in] Tls Pointer to a TLS object.
4317 @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
4318 cipher identifier comes from the TLS Cipher Suite
4319 Registry of the IANA, interpreting Byte1 and Byte2
4320 in network (big endian) byte order.
4321 @param[in] CipherNum The number of cipher in the list.
4322
4323 @retval EFI_SUCCESS The ciphers list was set successfully.
4324 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4325 @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
4326 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4327
4328 **/
4329 EFI_STATUS
4330 EFIAPI
4331 CryptoServiceTlsSetCipherList (
4332 IN VOID *Tls,
4333 IN UINT16 *CipherId,
4334 IN UINTN CipherNum
4335 )
4336 {
4337 return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);
4338 }
4339
4340 /**
4341 Set the compression method for TLS/SSL operations.
4342
4343 This function handles TLS/SSL integrated compression methods.
4344
4345 @param[in] CompMethod The compression method ID.
4346
4347 @retval EFI_SUCCESS The compression method for the communication was
4348 set successfully.
4349 @retval EFI_UNSUPPORTED Unsupported compression method.
4350
4351 **/
4352 EFI_STATUS
4353 EFIAPI
4354 CryptoServiceTlsSetCompressionMethod (
4355 IN UINT8 CompMethod
4356 )
4357 {
4358 return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);
4359 }
4360
4361 /**
4362 Set peer certificate verification mode for the TLS connection.
4363
4364 This function sets the verification mode flags for the TLS connection.
4365
4366 @param[in] Tls Pointer to the TLS object.
4367 @param[in] VerifyMode A set of logically or'ed verification mode flags.
4368
4369 **/
4370 VOID
4371 EFIAPI
4372 CryptoServiceTlsSetVerify (
4373 IN VOID *Tls,
4374 IN UINT32 VerifyMode
4375 )
4376 {
4377 CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));
4378 }
4379
4380 /**
4381 Set the specified host name to be verified.
4382
4383 @param[in] Tls Pointer to the TLS object.
4384 @param[in] Flags The setting flags during the validation.
4385 @param[in] HostName The specified host name to be verified.
4386
4387 @retval EFI_SUCCESS The HostName setting was set successfully.
4388 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4389 @retval EFI_ABORTED Invalid HostName setting.
4390
4391 **/
4392 EFI_STATUS
4393 EFIAPI
4394 CryptoServiceTlsSetVerifyHost (
4395 IN VOID *Tls,
4396 IN UINT32 Flags,
4397 IN CHAR8 *HostName
4398 )
4399 {
4400 return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);
4401 }
4402
4403 /**
4404 Sets a TLS/SSL session ID to be used during TLS/SSL connect.
4405
4406 This function sets a session ID to be used when the TLS/SSL connection is
4407 to be established.
4408
4409 @param[in] Tls Pointer to the TLS object.
4410 @param[in] SessionId Session ID data used for session resumption.
4411 @param[in] SessionIdLen Length of Session ID in bytes.
4412
4413 @retval EFI_SUCCESS Session ID was set successfully.
4414 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4415 @retval EFI_UNSUPPORTED No available session for ID setting.
4416
4417 **/
4418 EFI_STATUS
4419 EFIAPI
4420 CryptoServiceTlsSetSessionId (
4421 IN VOID *Tls,
4422 IN UINT8 *SessionId,
4423 IN UINT16 SessionIdLen
4424 )
4425 {
4426 return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4427 }
4428
4429 /**
4430 Adds the CA to the cert store when requesting Server or Client authentication.
4431
4432 This function adds the CA certificate to the list of CAs when requesting
4433 Server or Client authentication for the chosen TLS connection.
4434
4435 @param[in] Tls Pointer to the TLS object.
4436 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4437 X.509 certificate or PEM-encoded X.509 certificate.
4438 @param[in] DataSize The size of data buffer in bytes.
4439
4440 @retval EFI_SUCCESS The operation succeeded.
4441 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4442 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4443 @retval EFI_ABORTED Invalid X.509 certificate.
4444
4445 **/
4446 EFI_STATUS
4447 EFIAPI
4448 CryptoServiceTlsSetCaCertificate (
4449 IN VOID *Tls,
4450 IN VOID *Data,
4451 IN UINTN DataSize
4452 )
4453 {
4454 return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4455 }
4456
4457 /**
4458 Loads the local public certificate into the specified TLS object.
4459
4460 This function loads the X.509 certificate into the specified TLS object
4461 for TLS negotiation.
4462
4463 @param[in] Tls Pointer to the TLS object.
4464 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4465 X.509 certificate or PEM-encoded X.509 certificate.
4466 @param[in] DataSize The size of data buffer in bytes.
4467
4468 @retval EFI_SUCCESS The operation succeeded.
4469 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4470 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4471 @retval EFI_ABORTED Invalid X.509 certificate.
4472
4473 **/
4474 EFI_STATUS
4475 EFIAPI
4476 CryptoServiceTlsSetHostPublicCert (
4477 IN VOID *Tls,
4478 IN VOID *Data,
4479 IN UINTN DataSize
4480 )
4481 {
4482 return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4483 }
4484
4485 /**
4486 Adds the local private key to the specified TLS object.
4487
4488 This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private
4489 key) into the specified TLS object for TLS negotiation.
4490
4491 @param[in] Tls Pointer to the TLS object.
4492 @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded
4493 or PKCS#8 private key.
4494 @param[in] DataSize The size of data buffer in bytes.
4495 @param[in] Password Pointer to NULL-terminated private key password, set it to NULL
4496 if private key not encrypted.
4497
4498 @retval EFI_SUCCESS The operation succeeded.
4499 @retval EFI_UNSUPPORTED This function is not supported.
4500 @retval EFI_ABORTED Invalid private key data.
4501
4502 **/
4503 EFI_STATUS
4504 EFIAPI
4505 CryptoServiceTlsSetHostPrivateKeyEx (
4506 IN VOID *Tls,
4507 IN VOID *Data,
4508 IN UINTN DataSize,
4509 IN VOID *Password OPTIONAL
4510 )
4511 {
4512 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKeyEx, TlsSetHostPrivateKeyEx, (Tls, Data, DataSize, Password), EFI_UNSUPPORTED);
4513 }
4514
4515 /**
4516 Adds the local private key to the specified TLS object.
4517
4518 This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private
4519 key) into the specified TLS object for TLS negotiation.
4520
4521 @param[in] Tls Pointer to the TLS object.
4522 @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded
4523 or PKCS#8 private key.
4524 @param[in] DataSize The size of data buffer in bytes.
4525
4526 @retval EFI_SUCCESS The operation succeeded.
4527 @retval EFI_UNSUPPORTED This function is not supported.
4528 @retval EFI_ABORTED Invalid private key data.
4529
4530 **/
4531 EFI_STATUS
4532 EFIAPI
4533 CryptoServiceTlsSetHostPrivateKey (
4534 IN VOID *Tls,
4535 IN VOID *Data,
4536 IN UINTN DataSize
4537 )
4538 {
4539 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4540 }
4541
4542 /**
4543 Adds the CA-supplied certificate revocation list for certificate validation.
4544
4545 This function adds the CA-supplied certificate revocation list data for
4546 certificate validity checking.
4547
4548 @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
4549 @param[in] DataSize The size of data buffer in bytes.
4550
4551 @retval EFI_SUCCESS The operation succeeded.
4552 @retval EFI_UNSUPPORTED This function is not supported.
4553 @retval EFI_ABORTED Invalid CRL data.
4554
4555 **/
4556 EFI_STATUS
4557 EFIAPI
4558 CryptoServiceTlsSetCertRevocationList (
4559 IN VOID *Data,
4560 IN UINTN DataSize
4561 )
4562 {
4563 return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4564 }
4565
4566 /**
4567 Set the signature algorithm list to used by the TLS object.
4568
4569 This function sets the signature algorithms for use by a specified TLS object.
4570
4571 @param[in] Tls Pointer to a TLS object.
4572 @param[in] Data Array of UINT8 of signature algorithms. The array consists of
4573 pairs of the hash algorithm and the signature algorithm as defined
4574 in RFC 5246
4575 @param[in] DataSize The length the SignatureAlgoList. Must be divisible by 2.
4576
4577 @retval EFI_SUCCESS The signature algorithm list was set successfully.
4578 @retval EFI_INVALID_PARAMETER The parameters are invalid.
4579 @retval EFI_UNSUPPORTED No supported TLS signature algorithm was found in SignatureAlgoList
4580 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4581
4582 **/
4583 EFI_STATUS
4584 EFIAPI
4585 CryptoServiceTlsSetSignatureAlgoList (
4586 IN VOID *Tls,
4587 IN UINT8 *Data,
4588 IN UINTN DataSize
4589 )
4590 {
4591 return CALL_BASECRYPTLIB (TlsSet.Services.SignatureAlgoList, TlsSetSignatureAlgoList, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4592 }
4593
4594 /**
4595 Set the EC curve to be used for TLS flows
4596
4597 This function sets the EC curve to be used for TLS flows.
4598
4599 @param[in] Tls Pointer to a TLS object.
4600 @param[in] Data An EC named curve as defined in section 5.1.1 of RFC 4492.
4601 @param[in] DataSize Size of Data, it should be sizeof (UINT32)
4602
4603 @retval EFI_SUCCESS The EC curve was set successfully.
4604 @retval EFI_INVALID_PARAMETER The parameters are invalid.
4605 @retval EFI_UNSUPPORTED The requested TLS EC curve is not supported
4606
4607 **/
4608 EFI_STATUS
4609 EFIAPI
4610 CryptoServiceTlsSetEcCurve (
4611 IN VOID *Tls,
4612 IN UINT8 *Data,
4613 IN UINTN DataSize
4614 )
4615 {
4616 return CALL_BASECRYPTLIB (TlsSet.Services.EcCurve, TlsSetEcCurve, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4617 }
4618
4619 /**
4620 Gets the protocol version used by the specified TLS connection.
4621
4622 This function returns the protocol version used by the specified TLS
4623 connection.
4624
4625 If Tls is NULL, then ASSERT().
4626
4627 @param[in] Tls Pointer to the TLS object.
4628
4629 @return The protocol version of the specified TLS connection.
4630
4631 **/
4632 UINT16
4633 EFIAPI
4634 CryptoServiceTlsGetVersion (
4635 IN VOID *Tls
4636 )
4637 {
4638 return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);
4639 }
4640
4641 /**
4642 Gets the connection end of the specified TLS connection.
4643
4644 This function returns the connection end (as client or as server) used by
4645 the specified TLS connection.
4646
4647 If Tls is NULL, then ASSERT().
4648
4649 @param[in] Tls Pointer to the TLS object.
4650
4651 @return The connection end used by the specified TLS connection.
4652
4653 **/
4654 UINT8
4655 EFIAPI
4656 CryptoServiceTlsGetConnectionEnd (
4657 IN VOID *Tls
4658 )
4659 {
4660 return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);
4661 }
4662
4663 /**
4664 Gets the cipher suite used by the specified TLS connection.
4665
4666 This function returns current cipher suite used by the specified
4667 TLS connection.
4668
4669 @param[in] Tls Pointer to the TLS object.
4670 @param[in,out] CipherId The cipher suite used by the TLS object.
4671
4672 @retval EFI_SUCCESS The cipher suite was returned successfully.
4673 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4674 @retval EFI_UNSUPPORTED Unsupported cipher suite.
4675
4676 **/
4677 EFI_STATUS
4678 EFIAPI
4679 CryptoServiceTlsGetCurrentCipher (
4680 IN VOID *Tls,
4681 IN OUT UINT16 *CipherId
4682 )
4683 {
4684 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);
4685 }
4686
4687 /**
4688 Gets the compression methods used by the specified TLS connection.
4689
4690 This function returns current integrated compression methods used by
4691 the specified TLS connection.
4692
4693 @param[in] Tls Pointer to the TLS object.
4694 @param[in,out] CompressionId The current compression method used by
4695 the TLS object.
4696
4697 @retval EFI_SUCCESS The compression method was returned successfully.
4698 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4699 @retval EFI_ABORTED Invalid Compression method.
4700 @retval EFI_UNSUPPORTED This function is not supported.
4701
4702 **/
4703 EFI_STATUS
4704 EFIAPI
4705 CryptoServiceTlsGetCurrentCompressionId (
4706 IN VOID *Tls,
4707 IN OUT UINT8 *CompressionId
4708 )
4709 {
4710 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);
4711 }
4712
4713 /**
4714 Gets the verification mode currently set in the TLS connection.
4715
4716 This function returns the peer verification mode currently set in the
4717 specified TLS connection.
4718
4719 If Tls is NULL, then ASSERT().
4720
4721 @param[in] Tls Pointer to the TLS object.
4722
4723 @return The verification mode set in the specified TLS connection.
4724
4725 **/
4726 UINT32
4727 EFIAPI
4728 CryptoServiceTlsGetVerify (
4729 IN VOID *Tls
4730 )
4731 {
4732 return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);
4733 }
4734
4735 /**
4736 Gets the session ID used by the specified TLS connection.
4737
4738 This function returns the TLS/SSL session ID currently used by the
4739 specified TLS connection.
4740
4741 @param[in] Tls Pointer to the TLS object.
4742 @param[in,out] SessionId Buffer to contain the returned session ID.
4743 @param[in,out] SessionIdLen The length of Session ID in bytes.
4744
4745 @retval EFI_SUCCESS The Session ID was returned successfully.
4746 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4747 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4748
4749 **/
4750 EFI_STATUS
4751 EFIAPI
4752 CryptoServiceTlsGetSessionId (
4753 IN VOID *Tls,
4754 IN OUT UINT8 *SessionId,
4755 IN OUT UINT16 *SessionIdLen
4756 )
4757 {
4758 return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4759 }
4760
4761 /**
4762 Gets the client random data used in the specified TLS connection.
4763
4764 This function returns the TLS/SSL client random data currently used in
4765 the specified TLS connection.
4766
4767 @param[in] Tls Pointer to the TLS object.
4768 @param[in,out] ClientRandom Buffer to contain the returned client
4769 random data (32 bytes).
4770
4771 **/
4772 VOID
4773 EFIAPI
4774 CryptoServiceTlsGetClientRandom (
4775 IN VOID *Tls,
4776 IN OUT UINT8 *ClientRandom
4777 )
4778 {
4779 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));
4780 }
4781
4782 /**
4783 Gets the server random data used in the specified TLS connection.
4784
4785 This function returns the TLS/SSL server random data currently used in
4786 the specified TLS connection.
4787
4788 @param[in] Tls Pointer to the TLS object.
4789 @param[in,out] ServerRandom Buffer to contain the returned server
4790 random data (32 bytes).
4791
4792 **/
4793 VOID
4794 EFIAPI
4795 CryptoServiceTlsGetServerRandom (
4796 IN VOID *Tls,
4797 IN OUT UINT8 *ServerRandom
4798 )
4799 {
4800 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));
4801 }
4802
4803 /**
4804 Gets the master key data used in the specified TLS connection.
4805
4806 This function returns the TLS/SSL master key material currently used in
4807 the specified TLS connection.
4808
4809 @param[in] Tls Pointer to the TLS object.
4810 @param[in,out] KeyMaterial Buffer to contain the returned key material.
4811
4812 @retval EFI_SUCCESS Key material was returned successfully.
4813 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4814 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4815
4816 **/
4817 EFI_STATUS
4818 EFIAPI
4819 CryptoServiceTlsGetKeyMaterial (
4820 IN VOID *Tls,
4821 IN OUT UINT8 *KeyMaterial
4822 )
4823 {
4824 return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);
4825 }
4826
4827 /**
4828 Gets the CA Certificate from the cert store.
4829
4830 This function returns the CA certificate for the chosen
4831 TLS connection.
4832
4833 @param[in] Tls Pointer to the TLS object.
4834 @param[out] Data Pointer to the data buffer to receive the CA
4835 certificate data sent to the client.
4836 @param[in,out] DataSize The size of data buffer in bytes.
4837
4838 @retval EFI_SUCCESS The operation succeeded.
4839 @retval EFI_UNSUPPORTED This function is not supported.
4840 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4841
4842 **/
4843 EFI_STATUS
4844 EFIAPI
4845 CryptoServiceTlsGetCaCertificate (
4846 IN VOID *Tls,
4847 OUT VOID *Data,
4848 IN OUT UINTN *DataSize
4849 )
4850 {
4851 return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4852 }
4853
4854 /**
4855 Gets the local public Certificate set in the specified TLS object.
4856
4857 This function returns the local public certificate which was currently set
4858 in the specified TLS object.
4859
4860 @param[in] Tls Pointer to the TLS object.
4861 @param[out] Data Pointer to the data buffer to receive the local
4862 public certificate.
4863 @param[in,out] DataSize The size of data buffer in bytes.
4864
4865 @retval EFI_SUCCESS The operation succeeded.
4866 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4867 @retval EFI_NOT_FOUND The certificate is not found.
4868 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4869
4870 **/
4871 EFI_STATUS
4872 EFIAPI
4873 CryptoServiceTlsGetHostPublicCert (
4874 IN VOID *Tls,
4875 OUT VOID *Data,
4876 IN OUT UINTN *DataSize
4877 )
4878 {
4879 return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4880 }
4881
4882 /**
4883 Gets the local private key set in the specified TLS object.
4884
4885 This function returns the local private key data which was currently set
4886 in the specified TLS object.
4887
4888 @param[in] Tls Pointer to the TLS object.
4889 @param[out] Data Pointer to the data buffer to receive the local
4890 private key data.
4891 @param[in,out] DataSize The size of data buffer in bytes.
4892
4893 @retval EFI_SUCCESS The operation succeeded.
4894 @retval EFI_UNSUPPORTED This function is not supported.
4895 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4896
4897 **/
4898 EFI_STATUS
4899 EFIAPI
4900 CryptoServiceTlsGetHostPrivateKey (
4901 IN VOID *Tls,
4902 OUT VOID *Data,
4903 IN OUT UINTN *DataSize
4904 )
4905 {
4906 return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4907 }
4908
4909 /**
4910 Gets the CA-supplied certificate revocation list data set in the specified
4911 TLS object.
4912
4913 This function returns the CA-supplied certificate revocation list data which
4914 was currently set in the specified TLS object.
4915
4916 @param[out] Data Pointer to the data buffer to receive the CRL data.
4917 @param[in,out] DataSize The size of data buffer in bytes.
4918
4919 @retval EFI_SUCCESS The operation succeeded.
4920 @retval EFI_UNSUPPORTED This function is not supported.
4921 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4922
4923 **/
4924 EFI_STATUS
4925 EFIAPI
4926 CryptoServiceTlsGetCertRevocationList (
4927 OUT VOID *Data,
4928 IN OUT UINTN *DataSize
4929 )
4930 {
4931 return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4932 }
4933
4934 /**
4935 Derive keying material from a TLS connection.
4936
4937 This function exports keying material using the mechanism described in RFC
4938 5705.
4939
4940 @param[in] Tls Pointer to the TLS object
4941 @param[in] Label Description of the key for the PRF function
4942 @param[in] Context Optional context
4943 @param[in] ContextLen The length of the context value in bytes
4944 @param[out] KeyBuffer Buffer to hold the output of the TLS-PRF
4945 @param[in] KeyBufferLen The length of the KeyBuffer
4946
4947 @retval EFI_SUCCESS The operation succeeded.
4948 @retval EFI_INVALID_PARAMETER The TLS object is invalid.
4949 @retval EFI_PROTOCOL_ERROR Some other error occurred.
4950
4951 **/
4952 EFI_STATUS
4953 EFIAPI
4954 CryptoServiceTlsGetExportKey (
4955 IN VOID *Tls,
4956 IN CONST VOID *Label,
4957 IN CONST VOID *Context,
4958 IN UINTN ContextLen,
4959 OUT VOID *KeyBuffer,
4960 IN UINTN KeyBufferLen
4961 )
4962 {
4963 return CALL_BASECRYPTLIB (
4964 TlsGet.Services.ExportKey,
4965 TlsGetExportKey,
4966 (Tls, Label, Context, ContextLen,
4967 KeyBuffer, KeyBufferLen),
4968 EFI_UNSUPPORTED
4969 );
4970 }
4971
4972 /**
4973 Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.
4974
4975 This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in
4976 RFC 8017.
4977 Mask generation function is the same as the message digest algorithm.
4978 If the Signature buffer is too small to hold the contents of signature, FALSE
4979 is returned and SigSize is set to the required buffer size to obtain the signature.
4980
4981 If RsaContext is NULL, then return FALSE.
4982 If Message is NULL, then return FALSE.
4983 If MsgSize is zero or > INT_MAX, then return FALSE.
4984 If DigestLen is NOT 32, 48 or 64, return FALSE.
4985 If SaltLen is not equal to DigestLen, then return FALSE.
4986 If SigSize is large enough but Signature is NULL, then return FALSE.
4987 If this interface is not supported, then return FALSE.
4988
4989 @param[in] RsaContext Pointer to RSA context for signature generation.
4990 @param[in] Message Pointer to octet message to be signed.
4991 @param[in] MsgSize Size of the message in bytes.
4992 @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.
4993 @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.
4994 @param[out] Signature Pointer to buffer to receive RSA PSS signature.
4995 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
4996 On output, the size of data returned in Signature buffer in bytes.
4997
4998 @retval TRUE Signature successfully generated in RSASSA-PSS.
4999 @retval FALSE Signature generation failed.
5000 @retval FALSE SigSize is too small.
5001 @retval FALSE This interface is not supported.
5002
5003 **/
5004 BOOLEAN
5005 EFIAPI
5006 CryptoServiceRsaPssSign (
5007 IN VOID *RsaContext,
5008 IN CONST UINT8 *Message,
5009 IN UINTN MsgSize,
5010 IN UINT16 DigestLen,
5011 IN UINT16 SaltLen,
5012 OUT UINT8 *Signature,
5013 IN OUT UINTN *SigSize
5014 )
5015 {
5016 return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);
5017 }
5018
5019 /**
5020 Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.
5021 Implementation determines salt length automatically from the signature encoding.
5022 Mask generation function is the same as the message digest algorithm.
5023 Salt length should be equal to digest length.
5024
5025 @param[in] RsaContext Pointer to RSA context for signature verification.
5026 @param[in] Message Pointer to octet message to be verified.
5027 @param[in] MsgSize Size of the message in bytes.
5028 @param[in] Signature Pointer to RSASSA-PSS signature to be verified.
5029 @param[in] SigSize Size of signature in bytes.
5030 @param[in] DigestLen Length of digest for RSA operation.
5031 @param[in] SaltLen Salt length for PSS encoding.
5032
5033 @retval TRUE Valid signature encoded in RSASSA-PSS.
5034 @retval FALSE Invalid signature or invalid RSA context.
5035
5036 **/
5037 BOOLEAN
5038 EFIAPI
5039 CryptoServiceRsaPssVerify (
5040 IN VOID *RsaContext,
5041 IN CONST UINT8 *Message,
5042 IN UINTN MsgSize,
5043 IN CONST UINT8 *Signature,
5044 IN UINTN SigSize,
5045 IN UINT16 DigestLen,
5046 IN UINT16 SaltLen
5047 )
5048 {
5049 return CALL_BASECRYPTLIB (RsaPss.Services.Verify, RsaPssVerify, (RsaContext, Message, MsgSize, Signature, SigSize, DigestLen, SaltLen), FALSE);
5050 }
5051
5052 /**
5053 Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,
5054 published December 2016.
5055
5056 @param[in] Input Pointer to the input message (X).
5057 @param[in] InputByteLen The number(>0) of input bytes provided for the input data.
5058 @param[in] BlockSize The size of each block (B).
5059 @param[out] Output Pointer to the output buffer.
5060 @param[in] OutputByteLen The desired number of output bytes (L).
5061 @param[in] Customization Pointer to the customization string (S).
5062 @param[in] CustomByteLen The length of the customization string in bytes.
5063
5064 @retval TRUE ParallelHash256 digest computation succeeded.
5065 @retval FALSE ParallelHash256 digest computation failed.
5066 @retval FALSE This interface is not supported.
5067
5068 **/
5069 BOOLEAN
5070 EFIAPI
5071 CryptoServiceParallelHash256HashAll (
5072 IN CONST VOID *Input,
5073 IN UINTN InputByteLen,
5074 IN UINTN BlockSize,
5075 OUT VOID *Output,
5076 IN UINTN OutputByteLen,
5077 IN CONST VOID *Customization,
5078 IN UINTN CustomByteLen
5079 )
5080 {
5081 return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);
5082 }
5083
5084 /**
5085 Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).
5086
5087 IvSize must be 12, otherwise FALSE is returned.
5088 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
5089 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
5090
5091 @param[in] Key Pointer to the encryption key.
5092 @param[in] KeySize Size of the encryption key in bytes.
5093 @param[in] Iv Pointer to the IV value.
5094 @param[in] IvSize Size of the IV value in bytes.
5095 @param[in] AData Pointer to the additional authenticated data (AAD).
5096 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
5097 @param[in] DataIn Pointer to the input data buffer to be encrypted.
5098 @param[in] DataInSize Size of the input data buffer in bytes.
5099 @param[out] TagOut Pointer to a buffer that receives the authentication tag output.
5100 @param[in] TagSize Size of the authentication tag in bytes.
5101 @param[out] DataOut Pointer to a buffer that receives the encryption output.
5102 @param[out] DataOutSize Size of the output data buffer in bytes.
5103
5104 @retval TRUE AEAD AES-GCM authenticated encryption succeeded.
5105 @retval FALSE AEAD AES-GCM authenticated encryption failed.
5106
5107 **/
5108 BOOLEAN
5109 EFIAPI
5110 CryptoServiceAeadAesGcmEncrypt (
5111 IN CONST UINT8 *Key,
5112 IN UINTN KeySize,
5113 IN CONST UINT8 *Iv,
5114 IN UINTN IvSize,
5115 IN CONST UINT8 *AData,
5116 IN UINTN ADataSize,
5117 IN CONST UINT8 *DataIn,
5118 IN UINTN DataInSize,
5119 OUT UINT8 *TagOut,
5120 IN UINTN TagSize,
5121 OUT UINT8 *DataOut,
5122 OUT UINTN *DataOutSize
5123 )
5124 {
5125 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Encrypt, AeadAesGcmEncrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, TagOut, TagSize, DataOut, DataOutSize), FALSE);
5126 }
5127
5128 /**
5129 Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).
5130
5131 IvSize must be 12, otherwise FALSE is returned.
5132 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
5133 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
5134 If additional authenticated data verification fails, FALSE is returned.
5135
5136 @param[in] Key Pointer to the encryption key.
5137 @param[in] KeySize Size of the encryption key in bytes.
5138 @param[in] Iv Pointer to the IV value.
5139 @param[in] IvSize Size of the IV value in bytes.
5140 @param[in] AData Pointer to the additional authenticated data (AAD).
5141 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
5142 @param[in] DataIn Pointer to the input data buffer to be decrypted.
5143 @param[in] DataInSize Size of the input data buffer in bytes.
5144 @param[in] Tag Pointer to a buffer that contains the authentication tag.
5145 @param[in] TagSize Size of the authentication tag in bytes.
5146 @param[out] DataOut Pointer to a buffer that receives the decryption output.
5147 @param[out] DataOutSize Size of the output data buffer in bytes.
5148
5149 @retval TRUE AEAD AES-GCM authenticated decryption succeeded.
5150 @retval FALSE AEAD AES-GCM authenticated decryption failed.
5151
5152 **/
5153 BOOLEAN
5154 EFIAPI
5155 CryptoServiceAeadAesGcmDecrypt (
5156 IN CONST UINT8 *Key,
5157 IN UINTN KeySize,
5158 IN CONST UINT8 *Iv,
5159 IN UINTN IvSize,
5160 IN CONST UINT8 *AData,
5161 IN UINTN ADataSize,
5162 IN CONST UINT8 *DataIn,
5163 IN UINTN DataInSize,
5164 IN CONST UINT8 *Tag,
5165 IN UINTN TagSize,
5166 OUT UINT8 *DataOut,
5167 OUT UINTN *DataOutSize
5168 )
5169 {
5170 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);
5171 }
5172
5173 // =====================================================================================
5174 // Big number primitives
5175 // =====================================================================================
5176
5177 /**
5178 Allocate new Big Number.
5179
5180 @retval New BigNum opaque structure or NULL on failure.
5181 **/
5182 VOID *
5183 EFIAPI
5184 CryptoServiceBigNumInit (
5185 VOID
5186 )
5187 {
5188 return CALL_BASECRYPTLIB (Bn.Services.Init, BigNumInit, (), NULL);
5189 }
5190
5191 /**
5192 Allocate new Big Number and assign the provided value to it.
5193
5194 @param[in] Buf Big endian encoded buffer.
5195 @param[in] Len Buffer length.
5196
5197 @retval New BigNum opaque structure or NULL on failure.
5198 **/
5199 VOID *
5200 EFIAPI
5201 CryptoServiceBigNumFromBin (
5202 IN CONST UINT8 *Buf,
5203 IN UINTN Len
5204 )
5205 {
5206 return CALL_BASECRYPTLIB (Bn.Services.FromBin, BigNumFromBin, (Buf, Len), NULL);
5207 }
5208
5209 /**
5210 Convert the absolute value of Bn into big-endian form and store it at Buf.
5211 The Buf array should have at least BigNumBytes() in it.
5212
5213 @param[in] Bn Big number to convert.
5214 @param[out] Buf Output buffer.
5215
5216 @retval The length of the big-endian number placed at Buf or -1 on error.
5217 **/
5218 INTN
5219 EFIAPI
5220 CryptoServiceBigNumToBin (
5221 IN CONST VOID *Bn,
5222 OUT UINT8 *Buf
5223 )
5224 {
5225 return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1);
5226 }
5227
5228 /**
5229 Free the Big Number.
5230
5231 @param[in] Bn Big number to free.
5232 @param[in] Clear TRUE if the buffer should be cleared.
5233 **/
5234 VOID
5235 EFIAPI
5236 CryptoServiceBigNumFree (
5237 IN VOID *Bn,
5238 IN BOOLEAN Clear
5239 )
5240 {
5241 CALL_VOID_BASECRYPTLIB (Bn.Services.Free, BigNumFree, (Bn, Clear));
5242 }
5243
5244 /**
5245 Calculate the sum of two Big Numbers.
5246 Please note, all "out" Big number arguments should be properly initialized
5247 by calling to BigNumInit() or BigNumFromBin() functions.
5248
5249 @param[in] BnA Big number.
5250 @param[in] BnB Big number.
5251 @param[out] BnRes The result of BnA + BnB.
5252
5253 @retval TRUE On success.
5254 @retval FALSE Otherwise.
5255 **/
5256 BOOLEAN
5257 EFIAPI
5258 CryptoServiceBigNumAdd (
5259 IN CONST VOID *BnA,
5260 IN CONST VOID *BnB,
5261 OUT VOID *BnRes
5262 )
5263 {
5264 return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE);
5265 }
5266
5267 /**
5268 Subtract two Big Numbers.
5269 Please note, all "out" Big number arguments should be properly initialized
5270 by calling to BigNumInit() or BigNumFromBin() functions.
5271
5272 @param[in] BnA Big number.
5273 @param[in] BnB Big number.
5274 @param[out] BnRes The result of BnA - BnB.
5275
5276 @retval TRUE On success.
5277 @retval FALSE Otherwise.
5278 **/
5279 BOOLEAN
5280 EFIAPI
5281 CryptoServiceBigNumSub (
5282 IN CONST VOID *BnA,
5283 IN CONST VOID *BnB,
5284 OUT VOID *BnRes
5285 )
5286 {
5287 return CALL_BASECRYPTLIB (Bn.Services.Sub, BigNumSub, (BnA, BnB, BnRes), FALSE);
5288 }
5289
5290 /**
5291 Calculate remainder: BnRes = BnA % BnB.
5292 Please note, all "out" Big number arguments should be properly initialized
5293 by calling to BigNumInit() or BigNumFromBin() functions.
5294
5295 @param[in] BnA Big number.
5296 @param[in] BnB Big number.
5297 @param[out] BnRes The result of BnA % BnB.
5298
5299 @retval TRUE On success.
5300 @retval FALSE Otherwise.
5301 **/
5302 BOOLEAN
5303 EFIAPI
5304 CryptoServiceBigNumMod (
5305 IN CONST VOID *BnA,
5306 IN CONST VOID *BnB,
5307 OUT VOID *BnRes
5308 )
5309 {
5310 return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);
5311 }
5312
5313 /**
5314 Compute BnA to the BnP-th power modulo BnM.
5315 Please note, all "out" Big number arguments should be properly initialized.
5316 by calling to BigNumInit() or BigNumFromBin() functions.
5317
5318 @param[in] BnA Big number.
5319 @param[in] BnP Big number (power).
5320 @param[in] BnM Big number (modulo).
5321 @param[out] BnRes The result of (BnA ^ BnP) % BnM.
5322
5323 @retval TRUE On success.
5324 @retval FALSE Otherwise.
5325 **/
5326 BOOLEAN
5327 EFIAPI
5328 CryptoServiceBigNumExpMod (
5329 IN CONST VOID *BnA,
5330 IN CONST VOID *BnP,
5331 IN CONST VOID *BnM,
5332 OUT VOID *BnRes
5333 )
5334 {
5335 return CALL_BASECRYPTLIB (Bn.Services.ExpMod, BigNumExpMod, (BnA, BnP, BnM, BnRes), FALSE);
5336 }
5337
5338 /**
5339 Compute BnA inverse modulo BnM.
5340 Please note, all "out" Big number arguments should be properly initialized
5341 by calling to BigNumInit() or BigNumFromBin() functions.
5342
5343 @param[in] BnA Big number.
5344 @param[in] BnM Big number (modulo).
5345 @param[out] BnRes The result, such that (BnA * BnRes) % BnM == 1.
5346
5347 @retval TRUE On success.
5348 @retval FALSE Otherwise.
5349 **/
5350 BOOLEAN
5351 EFIAPI
5352 CryptoServiceBigNumInverseMod (
5353 IN CONST VOID *BnA,
5354 IN CONST VOID *BnM,
5355 OUT VOID *BnRes
5356 )
5357 {
5358 return CALL_BASECRYPTLIB (Bn.Services.InverseMod, BigNumInverseMod, (BnA, BnM, BnRes), FALSE);
5359 }
5360
5361 /**
5362 Divide two Big Numbers.
5363 Please note, all "out" Big number arguments should be properly initialized
5364 by calling to BigNumInit() or BigNumFromBin() functions.
5365
5366 @param[in] BnA Big number.
5367 @param[in] BnB Big number.
5368 @param[out] BnRes The result, such that BnA / BnB.
5369
5370 @retval TRUE On success.
5371 @retval FALSE Otherwise.
5372 **/
5373 BOOLEAN
5374 EFIAPI
5375 CryptoServiceBigNumDiv (
5376 IN CONST VOID *BnA,
5377 IN CONST VOID *BnB,
5378 OUT VOID *BnRes
5379 )
5380 {
5381 return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);
5382 }
5383
5384 /**
5385 Multiply two Big Numbers modulo BnM.
5386 Please note, all "out" Big number arguments should be properly initialized
5387 by calling to BigNumInit() or BigNumFromBin() functions.
5388
5389 @param[in] BnA Big number.
5390 @param[in] BnB Big number.
5391 @param[in] BnM Big number (modulo).
5392 @param[out] BnRes The result, such that (BnA * BnB) % BnM.
5393
5394 @retval TRUE On success.
5395 @retval FALSE Otherwise.
5396 **/
5397 BOOLEAN
5398 EFIAPI
5399 CryptoServiceBigNumMulMod (
5400 IN CONST VOID *BnA,
5401 IN CONST VOID *BnB,
5402 IN CONST VOID *BnM,
5403 OUT VOID *BnRes
5404 )
5405 {
5406 return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);
5407 }
5408
5409 /**
5410 Compare two Big Numbers.
5411
5412 @param[in] BnA Big number.
5413 @param[in] BnB Big number.
5414
5415 @retval 0 BnA == BnB.
5416 @retval 1 BnA > BnB.
5417 @retval -1 BnA < BnB.
5418 **/
5419 INTN
5420 EFIAPI
5421 CryptoServiceBigNumCmp (
5422 IN CONST VOID *BnA,
5423 IN CONST VOID *BnB
5424 )
5425 {
5426 return CALL_BASECRYPTLIB (Bn.Services.Cmp, BigNumCmp, (BnA, BnB), 0);
5427 }
5428
5429 /**
5430 Get number of bits in Bn.
5431
5432 @param[in] Bn Big number.
5433
5434 @retval Number of bits.
5435 **/
5436 UINTN
5437 EFIAPI
5438 CryptoServiceBigNumBits (
5439 IN CONST VOID *Bn
5440 )
5441 {
5442 return CALL_BASECRYPTLIB (Bn.Services.Bits, BigNumBits, (Bn), 0);
5443 }
5444
5445 /**
5446 Get number of bytes in Bn.
5447
5448 @param[in] Bn Big number.
5449
5450 @retval Number of bytes.
5451 **/
5452 UINTN
5453 EFIAPI
5454 CryptoServiceBigNumBytes (
5455 IN CONST VOID *Bn
5456 )
5457 {
5458 return CALL_BASECRYPTLIB (Bn.Services.Bytes, BigNumBytes, (Bn), 0);
5459 }
5460
5461 /**
5462 Checks if Big Number equals to the given Num.
5463
5464 @param[in] Bn Big number.
5465 @param[in] Num Number.
5466
5467 @retval TRUE iff Bn == Num.
5468 @retval FALSE otherwise.
5469 **/
5470 BOOLEAN
5471 EFIAPI
5472 CryptoServiceBigNumIsWord (
5473 IN CONST VOID *Bn,
5474 IN UINTN Num
5475 )
5476 {
5477 return CALL_BASECRYPTLIB (Bn.Services.IsWord, BigNumIsWord, (Bn, Num), FALSE);
5478 }
5479
5480 /**
5481 Checks if Big Number is odd.
5482
5483 @param[in] Bn Big number.
5484
5485 @retval TRUE Bn is odd (Bn % 2 == 1).
5486 @retval FALSE otherwise.
5487 **/
5488 BOOLEAN
5489 EFIAPI
5490 CryptoServiceBigNumIsOdd (
5491 IN CONST VOID *Bn
5492 )
5493 {
5494 return CALL_BASECRYPTLIB (Bn.Services.IsOdd, BigNumIsOdd, (Bn), FALSE);
5495 }
5496
5497 /**
5498 Copy Big number.
5499
5500 @param[out] BnDst Destination.
5501 @param[in] BnSrc Source.
5502
5503 @retval BnDst on success.
5504 @retval NULL otherwise.
5505 **/
5506 VOID *
5507 EFIAPI
5508 CryptoServiceBigNumCopy (
5509 OUT VOID *BnDst,
5510 IN CONST VOID *BnSrc
5511 )
5512 {
5513 return CALL_BASECRYPTLIB (Bn.Services.Copy, BigNumCopy, (BnDst, BnSrc), NULL);
5514 }
5515
5516 /**
5517 Get constant Big number with value of "1".
5518 This may be used to save expensive allocations.
5519
5520 @retval Big Number with value of 1.
5521 **/
5522 CONST VOID *
5523 EFIAPI
5524 CryptoServiceBigNumValueOne (
5525 VOID
5526 )
5527 {
5528 return CALL_BASECRYPTLIB (Bn.Services.ValueOne, BigNumValueOne, (), NULL);
5529 }
5530
5531 /**
5532 Shift right Big Number.
5533 Please note, all "out" Big number arguments should be properly initialized
5534 by calling to BigNumInit() or BigNumFromBin() functions.
5535
5536 @param[in] Bn Big number.
5537 @param[in] N Number of bits to shift.
5538 @param[out] BnRes The result.
5539
5540 @retval TRUE On success.
5541 @retval FALSE Otherwise.
5542 **/
5543 BOOLEAN
5544 EFIAPI
5545 CryptoServiceBigNumRShift (
5546 IN CONST VOID *Bn,
5547 IN UINTN N,
5548 OUT VOID *BnRes
5549 )
5550 {
5551 return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE);
5552 }
5553
5554 /**
5555 Mark Big Number for constant time computations.
5556 This function should be called before any constant time computations are
5557 performed on the given Big number.
5558
5559 @param[in] Bn Big number.
5560 **/
5561 VOID
5562 EFIAPI
5563 CryptoServiceBigNumConstTime (
5564 IN VOID *Bn
5565 )
5566 {
5567 CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));
5568 }
5569
5570 /**
5571 Calculate square modulo.
5572 Please note, all "out" Big number arguments should be properly initialized
5573 by calling to BigNumInit() or BigNumFromBin() functions.
5574
5575 @param[in] BnA Big number.
5576 @param[in] BnM Big number (modulo).
5577 @param[out] BnRes The result, such that (BnA ^ 2) % BnM.
5578
5579 @retval TRUE On success.
5580 @retval FALSE Otherwise.
5581 **/
5582 BOOLEAN
5583 EFIAPI
5584 CryptoServiceBigNumSqrMod (
5585 IN CONST VOID *BnA,
5586 IN CONST VOID *BnM,
5587 OUT VOID *BnRes
5588 )
5589 {
5590 return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE);
5591 }
5592
5593 /**
5594 Create new Big Number computation context. This is an opaque structure
5595 which should be passed to any function that requires it. The BN context is
5596 needed to optimize calculations and expensive allocations.
5597
5598 @retval Big Number context struct or NULL on failure.
5599 **/
5600 VOID *
5601 EFIAPI
5602 CryptoServiceBigNumNewContext (
5603 VOID
5604 )
5605 {
5606 return CALL_BASECRYPTLIB (Bn.Services.NewContext, BigNumNewContext, (), NULL);
5607 }
5608
5609 /**
5610 Free Big Number context that was allocated with BigNumNewContext().
5611
5612 @param[in] BnCtx Big number context to free.
5613 **/
5614 VOID
5615 EFIAPI
5616 CryptoServiceBigNumContextFree (
5617 IN VOID *BnCtx
5618 )
5619 {
5620 CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));
5621 }
5622
5623 /**
5624 Set Big Number to a given value.
5625
5626 @param[in] Bn Big number to set.
5627 @param[in] Val Value to set.
5628
5629 @retval TRUE On success.
5630 @retval FALSE Otherwise.
5631 **/
5632 BOOLEAN
5633 EFIAPI
5634 CryptoServiceBigNumSetUint (
5635 IN VOID *Bn,
5636 IN UINTN Val
5637 )
5638 {
5639 return CALL_BASECRYPTLIB (Bn.Services.SetUint, BigNumSetUint, (Bn, Val), FALSE);
5640 }
5641
5642 /**
5643 Add two Big Numbers modulo BnM.
5644
5645 @param[in] BnA Big number.
5646 @param[in] BnB Big number.
5647 @param[in] BnM Big number (modulo).
5648 @param[out] BnRes The result, such that (BnA + BnB) % BnM.
5649
5650 @retval TRUE On success.
5651 @retval FALSE Otherwise.
5652 **/
5653 BOOLEAN
5654 EFIAPI
5655 CryptoServiceBigNumAddMod (
5656 IN CONST VOID *BnA,
5657 IN CONST VOID *BnB,
5658 IN CONST VOID *BnM,
5659 OUT VOID *BnRes
5660 )
5661 {
5662 return CALL_BASECRYPTLIB (Bn.Services.AddMod, BigNumAddMod, (BnA, BnB, BnM, BnRes), FALSE);
5663 }
5664
5665 // =====================================================================================
5666 // Basic Elliptic Curve Primitives
5667 // =====================================================================================
5668
5669 /**
5670 Initialize new opaque EcGroup object. This object represents an EC curve and
5671 and is used for calculation within this group. This object should be freed
5672 using EcGroupFree() function.
5673
5674 @param[in] CryptoNid Identifying number for the ECC curve (Defined in
5675 BaseCryptLib.h).
5676
5677 @retval EcGroup object On success.
5678 @retval NULL On failure.
5679 **/
5680 VOID *
5681 EFIAPI
5682 CryptoServiceEcGroupInit (
5683 IN UINTN CryptoNid
5684 )
5685 {
5686 return CALL_BASECRYPTLIB (Ec.Services.GroupInit, EcGroupInit, (CryptoNid), NULL);
5687 }
5688
5689 /**
5690 Get EC curve parameters. While elliptic curve equation is Y^2 mod P = (X^3 + AX + B) Mod P.
5691 This function will set the provided Big Number objects to the corresponding
5692 values. The caller needs to make sure all the "out" BigNumber parameters
5693 are properly initialized.
5694 @param[in] EcGroup EC group object.
5695 @param[out] BnPrime Group prime number.
5696 @param[out] BnA A coefficient.
5697 @param[out] BnB B coefficient.
5698 @param[in] BnCtx BN context.
5699
5700 @retval TRUE On success.
5701 @retval FALSE Otherwise.
5702 **/
5703 BOOLEAN
5704 EFIAPI
5705 CryptoServiceEcGroupGetCurve (
5706 IN CONST VOID *EcGroup,
5707 OUT VOID *BnPrime,
5708 OUT VOID *BnA,
5709 OUT VOID *BnB,
5710 IN VOID *BnCtx
5711 )
5712 {
5713 return CALL_BASECRYPTLIB (Ec.Services.GroupGetCurve, EcGroupGetCurve, (EcGroup, BnPrime, BnA, BnB, BnCtx), FALSE);
5714 }
5715
5716 /**
5717 Get EC group order.
5718 This function will set the provided Big Number object to the corresponding
5719 value. The caller needs to make sure that the "out" BigNumber parameter
5720 is properly initialized.
5721
5722 @param[in] EcGroup EC group object.
5723 @param[out] BnOrder Group prime number.
5724
5725 @retval TRUE On success.
5726 @retval FALSE Otherwise.
5727 **/
5728 BOOLEAN
5729 EFIAPI
5730 CryptoServiceEcGroupGetOrder (
5731 IN VOID *EcGroup,
5732 OUT VOID *BnOrder
5733 )
5734 {
5735 return CALL_BASECRYPTLIB (Ec.Services.GroupGetOrder, EcGroupGetOrder, (EcGroup, BnOrder), FALSE);
5736 }
5737
5738 /**
5739 Free previously allocated EC group object using EcGroupInit().
5740
5741 @param[in] EcGroup EC group object to free.
5742 **/
5743 VOID
5744 EFIAPI
5745 CryptoServiceEcGroupFree (
5746 IN VOID *EcGroup
5747 )
5748 {
5749 CALL_VOID_BASECRYPTLIB (Ec.Services.GroupFree, EcGroupFree, (EcGroup));
5750 }
5751
5752 /**
5753 Initialize new opaque EC Point object. This object represents an EC point
5754 within the given EC group (curve).
5755
5756 @param[in] EC Group, properly initialized using EcGroupInit().
5757
5758 @retval EC Point object On success.
5759 @retval NULL On failure.
5760 **/
5761 VOID *
5762 EFIAPI
5763 CryptoServiceEcPointInit (
5764 IN CONST VOID *EcGroup
5765 )
5766 {
5767 return CALL_BASECRYPTLIB (Ec.Services.PointInit, EcPointInit, (EcGroup), NULL);
5768 }
5769
5770 /**
5771 Free previously allocated EC Point object using EcPointInit().
5772
5773 @param[in] EcPoint EC Point to free.
5774 @param[in] Clear TRUE iff the memory should be cleared.
5775 **/
5776 VOID
5777 EFIAPI
5778 CryptoServiceEcPointDeInit (
5779 IN VOID *EcPoint,
5780 IN BOOLEAN Clear
5781 )
5782 {
5783 CALL_VOID_BASECRYPTLIB (Ec.Services.PointDeInit, EcPointDeInit, (EcPoint, Clear));
5784 }
5785
5786 /**
5787 Get EC point affine (x,y) coordinates.
5788 This function will set the provided Big Number objects to the corresponding
5789 values. The caller needs to make sure all the "out" BigNumber parameters
5790 are properly initialized.
5791
5792 @param[in] EcGroup EC group object.
5793 @param[in] EcPoint EC point object.
5794 @param[out] BnX X coordinate.
5795 @param[out] BnY Y coordinate.
5796 @param[in] BnCtx BN context, created with BigNumNewContext().
5797
5798 @retval TRUE On success.
5799 @retval FALSE Otherwise.
5800 **/
5801 BOOLEAN
5802 EFIAPI
5803 CryptoServiceEcPointGetAffineCoordinates (
5804 IN CONST VOID *EcGroup,
5805 IN CONST VOID *EcPoint,
5806 OUT VOID *BnX,
5807 OUT VOID *BnY,
5808 IN VOID *BnCtx
5809 )
5810 {
5811 return CALL_BASECRYPTLIB (Ec.Services.PointGetAffineCoordinates, EcPointGetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);
5812 }
5813
5814 /**
5815 Set EC point affine (x,y) coordinates.
5816
5817 @param[in] EcGroup EC group object.
5818 @param[in] EcPoint EC point object.
5819 @param[in] BnX X coordinate.
5820 @param[in] BnY Y coordinate.
5821 @param[in] BnCtx BN context, created with BigNumNewContext().
5822
5823 @retval TRUE On success.
5824 @retval FALSE Otherwise.
5825 **/
5826 BOOLEAN
5827 EFIAPI
5828 CryptoServiceEcPointSetAffineCoordinates (
5829 IN CONST VOID *EcGroup,
5830 IN VOID *EcPoint,
5831 IN CONST VOID *BnX,
5832 IN CONST VOID *BnY,
5833 IN VOID *BnCtx
5834 )
5835 {
5836 return CALL_BASECRYPTLIB (Ec.Services.PointSetAffineCoordinates, EcPointSetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);
5837 }
5838
5839 /**
5840 EC Point addition. EcPointResult = EcPointA + EcPointB.
5841 @param[in] EcGroup EC group object.
5842 @param[out] EcPointResult EC point to hold the result. The point should
5843 be properly initialized.
5844 @param[in] EcPointA EC Point.
5845 @param[in] EcPointB EC Point.
5846 @param[in] BnCtx BN context, created with BigNumNewContext().
5847
5848 @retval TRUE On success.
5849 @retval FALSE Otherwise.
5850 **/
5851 BOOLEAN
5852 EFIAPI
5853 CryptoServiceEcPointAdd (
5854 IN CONST VOID *EcGroup,
5855 OUT VOID *EcPointResult,
5856 IN CONST VOID *EcPointA,
5857 IN CONST VOID *EcPointB,
5858 IN VOID *BnCtx
5859 )
5860 {
5861 return CALL_BASECRYPTLIB (Ec.Services.PointAdd, EcPointAdd, (EcGroup, EcPointResult, EcPointA, EcPointB, BnCtx), FALSE);
5862 }
5863
5864 /**
5865 Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar.
5866
5867 @param[in] EcGroup EC group object.
5868 @param[out] EcPointResult EC point to hold the result. The point should
5869 be properly initialized.
5870 @param[in] EcPoint EC Point.
5871 @param[in] BnPScalar P Scalar.
5872 @param[in] BnCtx BN context, created with BigNumNewContext().
5873
5874 @retval TRUE On success.
5875 @retval FALSE Otherwise.
5876 **/
5877 BOOLEAN
5878 EFIAPI
5879 CryptoServiceEcPointMul (
5880 IN CONST VOID *EcGroup,
5881 OUT VOID *EcPointResult,
5882 IN CONST VOID *EcPoint,
5883 IN CONST VOID *BnPScalar,
5884 IN VOID *BnCtx
5885 )
5886 {
5887 return CALL_BASECRYPTLIB (Ec.Services.PointMul, EcPointMul, (EcGroup, EcPointResult, EcPoint, BnPScalar, BnCtx), FALSE);
5888 }
5889
5890 /**
5891 Calculate the inverse of the supplied EC point.
5892
5893 @param[in] EcGroup EC group object.
5894 @param[in,out] EcPoint EC point to invert.
5895 @param[in] BnCtx BN context, created with BigNumNewContext().
5896
5897 @retval TRUE On success.
5898 @retval FALSE Otherwise.
5899 **/
5900 BOOLEAN
5901 EFIAPI
5902 CryptoServiceEcPointInvert (
5903 IN CONST VOID *EcGroup,
5904 IN OUT VOID *EcPoint,
5905 IN VOID *BnCtx
5906 )
5907 {
5908 return CALL_BASECRYPTLIB (Ec.Services.PointInvert, EcPointInvert, (EcGroup, EcPoint, BnCtx), FALSE);
5909 }
5910
5911 /**
5912 Check if the supplied point is on EC curve.
5913
5914 @param[in] EcGroup EC group object.
5915 @param[in] EcPoint EC point to check.
5916 @param[in] BnCtx BN context, created with BigNumNewContext().
5917
5918 @retval TRUE On curve.
5919 @retval FALSE Otherwise.
5920 **/
5921 BOOLEAN
5922 EFIAPI
5923 CryptoServiceEcPointIsOnCurve (
5924 IN CONST VOID *EcGroup,
5925 IN CONST VOID *EcPoint,
5926 IN VOID *BnCtx
5927 )
5928 {
5929 return CALL_BASECRYPTLIB (Ec.Services.PointIsOnCurve, EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE);
5930 }
5931
5932 /**
5933 Check if the supplied point is at infinity.
5934
5935 @param[in] EcGroup EC group object.
5936 @param[in] EcPoint EC point to check.
5937
5938 @retval TRUE At infinity.
5939 @retval FALSE Otherwise.
5940 **/
5941 BOOLEAN
5942 EFIAPI
5943 CryptoServiceEcPointIsAtInfinity (
5944 IN CONST VOID *EcGroup,
5945 IN CONST VOID *EcPoint
5946 )
5947 {
5948 return CALL_BASECRYPTLIB (Ec.Services.PointIsAtInfinity, EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE);
5949 }
5950
5951 /**
5952 Check if EC points are equal.
5953
5954 @param[in] EcGroup EC group object.
5955 @param[in] EcPointA EC point A.
5956 @param[in] EcPointB EC point B.
5957 @param[in] BnCtx BN context, created with BigNumNewContext().
5958
5959 @retval TRUE A == B.
5960 @retval FALSE Otherwise.
5961 **/
5962 BOOLEAN
5963 EFIAPI
5964 CryptoServiceEcPointEqual (
5965 IN CONST VOID *EcGroup,
5966 IN CONST VOID *EcPointA,
5967 IN CONST VOID *EcPointB,
5968 IN VOID *BnCtx
5969 )
5970 {
5971 return CALL_BASECRYPTLIB (Ec.Services.PointEqual, EcPointEqual, (EcGroup, EcPointA, EcPointB, BnCtx), FALSE);
5972 }
5973
5974 /**
5975 Set EC point compressed coordinates. Points can be described in terms of
5976 their compressed coordinates. For a point (x, y), for any given value for x
5977 such that the point is on the curve there will only ever be two possible
5978 values for y. Therefore, a point can be set using this function where BnX is
5979 the x coordinate and YBit is a value 0 or 1 to identify which of the two
5980 possible values for y should be used.
5981
5982 @param[in] EcGroup EC group object.
5983 @param[in] EcPoint EC Point.
5984 @param[in] BnX X coordinate.
5985 @param[in] YBit 0 or 1 to identify which Y value is used.
5986 @param[in] BnCtx BN context, created with BigNumNewContext().
5987
5988 @retval TRUE On success.
5989 @retval FALSE Otherwise.
5990 **/
5991 BOOLEAN
5992 EFIAPI
5993 CryptoServiceEcPointSetCompressedCoordinates (
5994 IN CONST VOID *EcGroup,
5995 IN VOID *EcPoint,
5996 IN CONST VOID *BnX,
5997 IN UINT8 YBit,
5998 IN VOID *BnCtx
5999 )
6000 {
6001 return CALL_BASECRYPTLIB (Ec.Services.PointSetCompressedCoordinates, EcPointSetCompressedCoordinates, (EcGroup, EcPoint, BnX, YBit, BnCtx), FALSE);
6002 }
6003
6004 // =====================================================================================
6005 // Elliptic Curve Diffie Hellman Primitives
6006 // =====================================================================================
6007
6008 /**
6009 Allocates and Initializes one Elliptic Curve Context for subsequent use
6010 with the NID.
6011
6012 @param[in] Nid cipher NID
6013 @return Pointer to the Elliptic Curve Context that has been initialized.
6014 If the allocations fails, EcNewByNid() returns NULL.
6015 **/
6016 VOID *
6017 EFIAPI
6018 CryptoServiceEcNewByNid (
6019 IN UINTN Nid
6020 )
6021 {
6022 return CALL_BASECRYPTLIB (Ec.Services.NewByNid, EcNewByNid, (Nid), NULL);
6023 }
6024
6025 /**
6026 Release the specified EC context.
6027
6028 @param[in] EcContext Pointer to the EC context to be released.
6029 **/
6030 VOID
6031 EFIAPI
6032 CryptoServiceEcFree (
6033 IN VOID *EcContext
6034 )
6035 {
6036 CALL_VOID_BASECRYPTLIB (Ec.Services.Free, EcFree, (EcContext));
6037 }
6038
6039 /**
6040 Generates EC key and returns EC public key (X, Y), Please note, this function uses
6041 pseudo random number generator. The caller must make sure RandomSeed()
6042 function was properly called before.
6043 The Ec context should be correctly initialized by EcNewByNid.
6044 This function generates random secret, and computes the public key (X, Y), which is
6045 returned via parameter Public, PublicSize.
6046 X is the first half of Public with size being PublicSize / 2,
6047 Y is the second half of Public with size being PublicSize / 2.
6048 EC context is updated accordingly.
6049 If the Public buffer is too small to hold the public X, Y, FALSE is returned and
6050 PublicSize is set to the required buffer size to obtain the public X, Y.
6051 For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6052 For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6053 For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6054 If EcContext is NULL, then return FALSE.
6055 If PublicSize is NULL, then return FALSE.
6056 If PublicSize is large enough but Public is NULL, then return FALSE.
6057 @param[in, out] EcContext Pointer to the EC context.
6058 @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.
6059 @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.
6060 On output, the size of data returned in Public buffer in bytes.
6061 @retval TRUE EC public X,Y generation succeeded.
6062 @retval FALSE EC public X,Y generation failed.
6063 @retval FALSE PublicKeySize is not large enough.
6064 **/
6065 BOOLEAN
6066 EFIAPI
6067 CryptoServiceEcGenerateKey (
6068 IN OUT VOID *EcContext,
6069 OUT UINT8 *PublicKey,
6070 IN OUT UINTN *PublicKeySize
6071 )
6072 {
6073 return CALL_BASECRYPTLIB (Ec.Services.GenerateKey, EcGenerateKey, (EcContext, PublicKey, PublicKeySize), FALSE);
6074 }
6075
6076 /**
6077 Gets the public key component from the established EC context.
6078 The Ec context should be correctly initialized by EcNewByNid, and successfully
6079 generate key pair from EcGenerateKey().
6080 For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6081 For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6082 For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6083 @param[in, out] EcContext Pointer to EC context being set.
6084 @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.
6085 @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.
6086 On output, the size of data returned in Public buffer in bytes.
6087 @retval TRUE EC key component was retrieved successfully.
6088 @retval FALSE Invalid EC key component.
6089 **/
6090 BOOLEAN
6091 EFIAPI
6092 CryptoServiceEcGetPubKey (
6093 IN OUT VOID *EcContext,
6094 OUT UINT8 *PublicKey,
6095 IN OUT UINTN *PublicKeySize
6096 )
6097 {
6098 return CALL_BASECRYPTLIB (Ec.Services.GetPubKey, EcGetPubKey, (EcContext, PublicKey, PublicKeySize), FALSE);
6099 }
6100
6101 /**
6102 Computes exchanged common key.
6103 Given peer's public key (X, Y), this function computes the exchanged common key,
6104 based on its own context including value of curve parameter and random secret.
6105 X is the first half of PeerPublic with size being PeerPublicSize / 2,
6106 Y is the second half of PeerPublic with size being PeerPublicSize / 2.
6107 If EcContext is NULL, then return FALSE.
6108 If PeerPublic is NULL, then return FALSE.
6109 If PeerPublicSize is 0, then return FALSE.
6110 If Key is NULL, then return FALSE.
6111 If KeySize is not large enough, then return FALSE.
6112 For P-256, the PeerPublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6113 For P-384, the PeerPublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6114 For P-521, the PeerPublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6115 @param[in, out] EcContext Pointer to the EC context.
6116 @param[in] PeerPublic Pointer to the peer's public X,Y.
6117 @param[in] PeerPublicSize Size of peer's public X,Y in bytes.
6118 @param[in] CompressFlag Flag of PeerPublic is compressed or not.
6119 @param[out] Key Pointer to the buffer to receive generated key.
6120 @param[in, out] KeySize On input, the size of Key buffer in bytes.
6121 On output, the size of data returned in Key buffer in bytes.
6122 @retval TRUE EC exchanged key generation succeeded.
6123 @retval FALSE EC exchanged key generation failed.
6124 @retval FALSE KeySize is not large enough.
6125 **/
6126 BOOLEAN
6127 EFIAPI
6128 CryptoServiceEcDhComputeKey (
6129 IN OUT VOID *EcContext,
6130 IN CONST UINT8 *PeerPublic,
6131 IN UINTN PeerPublicSize,
6132 IN CONST INT32 *CompressFlag,
6133 OUT UINT8 *Key,
6134 IN OUT UINTN *KeySize
6135 )
6136 {
6137 return CALL_BASECRYPTLIB (Ec.Services.DhComputeKey, EcDhComputeKey, (EcContext, PeerPublic, PeerPublicSize, CompressFlag, Key, KeySize), FALSE);
6138 }
6139
6140 /**
6141 Retrieve the EC Public Key from one DER-encoded X509 certificate.
6142
6143 @param[in] Cert Pointer to the DER-encoded X509 certificate.
6144 @param[in] CertSize Size of the X509 certificate in bytes.
6145 @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved
6146 EC public key component. Use EcFree() function to free the
6147 resource.
6148
6149 If Cert is NULL, then return FALSE.
6150 If EcContext is NULL, then return FALSE.
6151
6152 @retval TRUE EC Public Key was retrieved successfully.
6153 @retval FALSE Fail to retrieve EC public key from X509 certificate.
6154
6155 **/
6156 BOOLEAN
6157 EFIAPI
6158 CryptoServiceEcGetPublicKeyFromX509 (
6159 IN CONST UINT8 *Cert,
6160 IN UINTN CertSize,
6161 OUT VOID **EcContext
6162 )
6163 {
6164 return CALL_BASECRYPTLIB (Ec.Services.GetPublicKeyFromX509, EcGetPublicKeyFromX509, (Cert, CertSize, EcContext), FALSE);
6165 }
6166
6167 /**
6168 Retrieve the EC Private Key from the password-protected PEM key data.
6169
6170 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
6171 @param[in] PemSize Size of the PEM key data in bytes.
6172 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
6173 @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved
6174 EC private key component. Use EcFree() function to free the
6175 resource.
6176
6177 If PemData is NULL, then return FALSE.
6178 If EcContext is NULL, then return FALSE.
6179
6180 @retval TRUE EC Private Key was retrieved successfully.
6181 @retval FALSE Invalid PEM key data or incorrect password.
6182
6183 **/
6184 BOOLEAN
6185 EFIAPI
6186 CryptoServiceEcGetPrivateKeyFromPem (
6187 IN CONST UINT8 *PemData,
6188 IN UINTN PemSize,
6189 IN CONST CHAR8 *Password,
6190 OUT VOID **EcContext
6191 )
6192 {
6193 return CALL_BASECRYPTLIB (Ec.Services.GetPrivateKeyFromPem, EcGetPrivateKeyFromPem, (PemData, PemSize, Password, EcContext), FALSE);
6194 }
6195
6196 /**
6197 Carries out the EC-DSA signature.
6198
6199 This function carries out the EC-DSA signature.
6200 If the Signature buffer is too small to hold the contents of signature, FALSE
6201 is returned and SigSize is set to the required buffer size to obtain the signature.
6202
6203 If EcContext is NULL, then return FALSE.
6204 If MessageHash is NULL, then return FALSE.
6205 If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.
6206 If SigSize is large enough but Signature is NULL, then return FALSE.
6207
6208 For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.
6209 For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.
6210 For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.
6211
6212 @param[in] EcContext Pointer to EC context for signature generation.
6213 @param[in] HashNid hash NID
6214 @param[in] MessageHash Pointer to octet message hash to be signed.
6215 @param[in] HashSize Size of the message hash in bytes.
6216 @param[out] Signature Pointer to buffer to receive EC-DSA signature.
6217 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
6218 On output, the size of data returned in Signature buffer in bytes.
6219
6220 @retval TRUE Signature successfully generated in EC-DSA.
6221 @retval FALSE Signature generation failed.
6222 @retval FALSE SigSize is too small.
6223
6224 **/
6225 BOOLEAN
6226 EFIAPI
6227 CryptoServiceEcDsaSign (
6228 IN VOID *EcContext,
6229 IN UINTN HashNid,
6230 IN CONST UINT8 *MessageHash,
6231 IN UINTN HashSize,
6232 OUT UINT8 *Signature,
6233 IN OUT UINTN *SigSize
6234 )
6235 {
6236 return CALL_BASECRYPTLIB (Ec.Services.DsaSign, EcDsaSign, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);
6237 }
6238
6239 /**
6240 Verifies the EC-DSA signature.
6241
6242 If EcContext is NULL, then return FALSE.
6243 If MessageHash is NULL, then return FALSE.
6244 If Signature is NULL, then return FALSE.
6245 If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.
6246
6247 For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.
6248 For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.
6249 For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.
6250
6251 @param[in] EcContext Pointer to EC context for signature verification.
6252 @param[in] HashNid hash NID
6253 @param[in] MessageHash Pointer to octet message hash to be checked.
6254 @param[in] HashSize Size of the message hash in bytes.
6255 @param[in] Signature Pointer to EC-DSA signature to be verified.
6256 @param[in] SigSize Size of signature in bytes.
6257
6258 @retval TRUE Valid signature encoded in EC-DSA.
6259 @retval FALSE Invalid signature or invalid EC context.
6260
6261 **/
6262 BOOLEAN
6263 EFIAPI
6264 CryptoServiceEcDsaVerify (
6265 IN VOID *EcContext,
6266 IN UINTN HashNid,
6267 IN CONST UINT8 *MessageHash,
6268 IN UINTN HashSize,
6269 IN CONST UINT8 *Signature,
6270 IN UINTN SigSize
6271 )
6272 {
6273 return CALL_BASECRYPTLIB (Ec.Services.DsaVerify, EcDsaVerify, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);
6274 }
6275
6276 const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
6277 /// Version
6278 CryptoServiceGetCryptoVersion,
6279 /// HMAC MD5 - deprecated and unsupported
6280 DeprecatedCryptoServiceHmacMd5New,
6281 DeprecatedCryptoServiceHmacMd5Free,
6282 DeprecatedCryptoServiceHmacMd5SetKey,
6283 DeprecatedCryptoServiceHmacMd5Duplicate,
6284 DeprecatedCryptoServiceHmacMd5Update,
6285 DeprecatedCryptoServiceHmacMd5Final,
6286 /// HMAC SHA1 - deprecated and unsupported
6287 DeprecatedCryptoServiceHmacSha1New,
6288 DeprecatedCryptoServiceHmacSha1Free,
6289 DeprecatedCryptoServiceHmacSha1SetKey,
6290 DeprecatedCryptoServiceHmacSha1Duplicate,
6291 DeprecatedCryptoServiceHmacSha1Update,
6292 DeprecatedCryptoServiceHmacSha1Final,
6293 /// HMAC SHA256
6294 CryptoServiceHmacSha256New,
6295 CryptoServiceHmacSha256Free,
6296 CryptoServiceHmacSha256SetKey,
6297 CryptoServiceHmacSha256Duplicate,
6298 CryptoServiceHmacSha256Update,
6299 CryptoServiceHmacSha256Final,
6300 /// Md4 - deprecated and unsupported
6301 DeprecatedCryptoServiceMd4GetContextSize,
6302 DeprecatedCryptoServiceMd4Init,
6303 DeprecatedCryptoServiceMd4Duplicate,
6304 DeprecatedCryptoServiceMd4Update,
6305 DeprecatedCryptoServiceMd4Final,
6306 DeprecatedCryptoServiceMd4HashAll,
6307 #ifndef ENABLE_MD5_DEPRECATED_INTERFACES
6308 /// Md5 - deprecated and unsupported
6309 DeprecatedCryptoServiceMd5GetContextSize,
6310 DeprecatedCryptoServiceMd5Init,
6311 DeprecatedCryptoServiceMd5Duplicate,
6312 DeprecatedCryptoServiceMd5Update,
6313 DeprecatedCryptoServiceMd5Final,
6314 DeprecatedCryptoServiceMd5HashAll,
6315 #else
6316 /// Md5
6317 CryptoServiceMd5GetContextSize,
6318 CryptoServiceMd5Init,
6319 CryptoServiceMd5Duplicate,
6320 CryptoServiceMd5Update,
6321 CryptoServiceMd5Final,
6322 CryptoServiceMd5HashAll,
6323 #endif
6324 /// Pkcs
6325 CryptoServicePkcs1v2Encrypt,
6326 CryptoServicePkcs5HashPassword,
6327 CryptoServicePkcs7Verify,
6328 CryptoServiceVerifyEKUsInPkcs7Signature,
6329 CryptoServicePkcs7GetSigners,
6330 CryptoServicePkcs7FreeSigners,
6331 CryptoServicePkcs7Sign,
6332 CryptoServicePkcs7GetAttachedContent,
6333 CryptoServicePkcs7GetCertificatesList,
6334 CryptoServiceAuthenticodeVerify,
6335 CryptoServiceImageTimestampVerify,
6336 /// DH
6337 CryptoServiceDhNew,
6338 CryptoServiceDhFree,
6339 CryptoServiceDhGenerateParameter,
6340 CryptoServiceDhSetParameter,
6341 CryptoServiceDhGenerateKey,
6342 CryptoServiceDhComputeKey,
6343 /// Random
6344 CryptoServiceRandomSeed,
6345 CryptoServiceRandomBytes,
6346 /// RSA
6347 CryptoServiceRsaPkcs1Verify,
6348 CryptoServiceRsaNew,
6349 CryptoServiceRsaFree,
6350 CryptoServiceRsaSetKey,
6351 CryptoServiceRsaGetKey,
6352 CryptoServiceRsaGenerateKey,
6353 CryptoServiceRsaCheckKey,
6354 CryptoServiceRsaPkcs1Sign,
6355 CryptoServiceRsaPkcs1Verify,
6356 CryptoServiceRsaGetPrivateKeyFromPem,
6357 CryptoServiceRsaGetPublicKeyFromX509,
6358 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
6359 /// Sha1 - deprecated and unsupported
6360 DeprecatedCryptoServiceSha1GetContextSize,
6361 DeprecatedCryptoServiceSha1Init,
6362 DeprecatedCryptoServiceSha1Duplicate,
6363 DeprecatedCryptoServiceSha1Update,
6364 DeprecatedCryptoServiceSha1Final,
6365 DeprecatedCryptoServiceSha1HashAll,
6366 #else
6367 /// Sha1
6368 CryptoServiceSha1GetContextSize,
6369 CryptoServiceSha1Init,
6370 CryptoServiceSha1Duplicate,
6371 CryptoServiceSha1Update,
6372 CryptoServiceSha1Final,
6373 CryptoServiceSha1HashAll,
6374 #endif
6375 /// Sha256
6376 CryptoServiceSha256GetContextSize,
6377 CryptoServiceSha256Init,
6378 CryptoServiceSha256Duplicate,
6379 CryptoServiceSha256Update,
6380 CryptoServiceSha256Final,
6381 CryptoServiceSha256HashAll,
6382 /// Sha384
6383 CryptoServiceSha384GetContextSize,
6384 CryptoServiceSha384Init,
6385 CryptoServiceSha384Duplicate,
6386 CryptoServiceSha384Update,
6387 CryptoServiceSha384Final,
6388 CryptoServiceSha384HashAll,
6389 /// Sha512
6390 CryptoServiceSha512GetContextSize,
6391 CryptoServiceSha512Init,
6392 CryptoServiceSha512Duplicate,
6393 CryptoServiceSha512Update,
6394 CryptoServiceSha512Final,
6395 CryptoServiceSha512HashAll,
6396 /// X509
6397 CryptoServiceX509GetSubjectName,
6398 CryptoServiceX509GetCommonName,
6399 CryptoServiceX509GetOrganizationName,
6400 CryptoServiceX509VerifyCert,
6401 CryptoServiceX509ConstructCertificate,
6402 CryptoServiceX509ConstructCertificateStack,
6403 CryptoServiceX509Free,
6404 CryptoServiceX509StackFree,
6405 CryptoServiceX509GetTBSCert,
6406 /// TDES - deprecated and unsupported
6407 DeprecatedCryptoServiceTdesGetContextSize,
6408 DeprecatedCryptoServiceTdesInit,
6409 DeprecatedCryptoServiceTdesEcbEncrypt,
6410 DeprecatedCryptoServiceTdesEcbDecrypt,
6411 DeprecatedCryptoServiceTdesCbcEncrypt,
6412 DeprecatedCryptoServiceTdesCbcDecrypt,
6413 /// AES - ECB mode is deprecated and unsupported
6414 CryptoServiceAesGetContextSize,
6415 CryptoServiceAesInit,
6416 DeprecatedCryptoServiceAesEcbEncrypt,
6417 DeprecatedCryptoServiceAesEcbDecrypt,
6418 CryptoServiceAesCbcEncrypt,
6419 CryptoServiceAesCbcDecrypt,
6420 /// Arc4 - deprecated and unsupported
6421 DeprecatedCryptoServiceArc4GetContextSize,
6422 DeprecatedCryptoServiceArc4Init,
6423 DeprecatedCryptoServiceArc4Encrypt,
6424 DeprecatedCryptoServiceArc4Decrypt,
6425 DeprecatedCryptoServiceArc4Reset,
6426 /// SM3
6427 CryptoServiceSm3GetContextSize,
6428 CryptoServiceSm3Init,
6429 CryptoServiceSm3Duplicate,
6430 CryptoServiceSm3Update,
6431 CryptoServiceSm3Final,
6432 CryptoServiceSm3HashAll,
6433 /// HKDF
6434 CryptoServiceHkdfSha256ExtractAndExpand,
6435 /// X509 (Continued)
6436 CryptoServiceX509ConstructCertificateStackV,
6437 /// TLS
6438 CryptoServiceTlsInitialize,
6439 CryptoServiceTlsCtxFree,
6440 CryptoServiceTlsCtxNew,
6441 CryptoServiceTlsFree,
6442 CryptoServiceTlsNew,
6443 CryptoServiceTlsInHandshake,
6444 CryptoServiceTlsDoHandshake,
6445 CryptoServiceTlsHandleAlert,
6446 CryptoServiceTlsCloseNotify,
6447 CryptoServiceTlsCtrlTrafficOut,
6448 CryptoServiceTlsCtrlTrafficIn,
6449 CryptoServiceTlsRead,
6450 CryptoServiceTlsWrite,
6451 /// TLS Set
6452 CryptoServiceTlsSetVersion,
6453 CryptoServiceTlsSetConnectionEnd,
6454 CryptoServiceTlsSetCipherList,
6455 CryptoServiceTlsSetCompressionMethod,
6456 CryptoServiceTlsSetVerify,
6457 CryptoServiceTlsSetVerifyHost,
6458 CryptoServiceTlsSetSessionId,
6459 CryptoServiceTlsSetCaCertificate,
6460 CryptoServiceTlsSetHostPublicCert,
6461 CryptoServiceTlsSetHostPrivateKey,
6462 CryptoServiceTlsSetCertRevocationList,
6463 /// TLS Get
6464 CryptoServiceTlsGetVersion,
6465 CryptoServiceTlsGetConnectionEnd,
6466 CryptoServiceTlsGetCurrentCipher,
6467 CryptoServiceTlsGetCurrentCompressionId,
6468 CryptoServiceTlsGetVerify,
6469 CryptoServiceTlsGetSessionId,
6470 CryptoServiceTlsGetClientRandom,
6471 CryptoServiceTlsGetServerRandom,
6472 CryptoServiceTlsGetKeyMaterial,
6473 CryptoServiceTlsGetCaCertificate,
6474 CryptoServiceTlsGetHostPublicCert,
6475 CryptoServiceTlsGetHostPrivateKey,
6476 CryptoServiceTlsGetCertRevocationList,
6477 /// RSA PSS
6478 CryptoServiceRsaPssSign,
6479 CryptoServiceRsaPssVerify,
6480 /// Parallel hash
6481 CryptoServiceParallelHash256HashAll,
6482 /// HMAC SHA256 (continued)
6483 CryptoServiceHmacSha256All,
6484 /// HMAC SHA384
6485 CryptoServiceHmacSha384New,
6486 CryptoServiceHmacSha384Free,
6487 CryptoServiceHmacSha384SetKey,
6488 CryptoServiceHmacSha384Duplicate,
6489 CryptoServiceHmacSha384Update,
6490 CryptoServiceHmacSha384Final,
6491 CryptoServiceHmacSha384All,
6492 /// HKDF (continued)
6493 CryptoServiceHkdfSha256Extract,
6494 CryptoServiceHkdfSha256Expand,
6495 CryptoServiceHkdfSha384ExtractAndExpand,
6496 CryptoServiceHkdfSha384Extract,
6497 CryptoServiceHkdfSha384Expand,
6498 /// Aead Aes GCM
6499 CryptoServiceAeadAesGcmEncrypt,
6500 CryptoServiceAeadAesGcmDecrypt,
6501 /// Big Numbers
6502 CryptoServiceBigNumInit,
6503 CryptoServiceBigNumFromBin,
6504 CryptoServiceBigNumToBin,
6505 CryptoServiceBigNumFree,
6506 CryptoServiceBigNumAdd,
6507 CryptoServiceBigNumSub,
6508 CryptoServiceBigNumMod,
6509 CryptoServiceBigNumExpMod,
6510 CryptoServiceBigNumInverseMod,
6511 CryptoServiceBigNumDiv,
6512 CryptoServiceBigNumMulMod,
6513 CryptoServiceBigNumCmp,
6514 CryptoServiceBigNumBits,
6515 CryptoServiceBigNumBytes,
6516 CryptoServiceBigNumIsWord,
6517 CryptoServiceBigNumIsOdd,
6518 CryptoServiceBigNumCopy,
6519 CryptoServiceBigNumValueOne,
6520 CryptoServiceBigNumRShift,
6521 CryptoServiceBigNumConstTime,
6522 CryptoServiceBigNumSqrMod,
6523 CryptoServiceBigNumNewContext,
6524 CryptoServiceBigNumContextFree,
6525 CryptoServiceBigNumSetUint,
6526 CryptoServiceBigNumAddMod,
6527 /// EC
6528 CryptoServiceEcGroupInit,
6529 CryptoServiceEcGroupGetCurve,
6530 CryptoServiceEcGroupGetOrder,
6531 CryptoServiceEcGroupFree,
6532 CryptoServiceEcPointInit,
6533 CryptoServiceEcPointDeInit,
6534 CryptoServiceEcPointGetAffineCoordinates,
6535 CryptoServiceEcPointSetAffineCoordinates,
6536 CryptoServiceEcPointAdd,
6537 CryptoServiceEcPointMul,
6538 CryptoServiceEcPointInvert,
6539 CryptoServiceEcPointIsOnCurve,
6540 CryptoServiceEcPointIsAtInfinity,
6541 CryptoServiceEcPointEqual,
6542 CryptoServiceEcPointSetCompressedCoordinates,
6543 CryptoServiceEcNewByNid,
6544 CryptoServiceEcFree,
6545 CryptoServiceEcGenerateKey,
6546 CryptoServiceEcGetPubKey,
6547 CryptoServiceEcDhComputeKey,
6548 /// TLS (continued)
6549 CryptoServiceTlsShutdown,
6550 /// TLS Set (continued)
6551 CryptoServiceTlsSetHostPrivateKeyEx,
6552 CryptoServiceTlsSetSignatureAlgoList,
6553 CryptoServiceTlsSetEcCurve,
6554 /// TLS Get (continued)
6555 CryptoServiceTlsGetExportKey,
6556 /// Ec (Continued)
6557 CryptoServiceEcGetPublicKeyFromX509,
6558 CryptoServiceEcGetPrivateKeyFromPem,
6559 CryptoServiceEcDsaSign,
6560 CryptoServiceEcDsaVerify
6561 };