]> git.proxmox.com Git - mirror_edk2.git/blob - CryptoPkg/Driver/Crypto.c
26f280cd5dbe2b69ea95ae3e9dac879d206803ff
[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 - 2020, 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 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
249
250 If this interface is not supported, then return zero.
251
252 @retval 0 This interface is not supported.
253
254 **/
255 UINTN
256 EFIAPI
257 DeprecatedCryptoServiceMd5GetContextSize (
258 VOID
259 )
260 {
261 return BaseCryptLibServiceDeprecated ("Md5GetContextSize"), 0;
262 }
263
264 /**
265 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
266 subsequent use.
267
268 If Md5Context is NULL, then return FALSE.
269 If this interface is not supported, then return FALSE.
270
271 @param[out] Md5Context Pointer to MD5 context being initialized.
272
273 @retval FALSE This interface is not supported.
274
275 **/
276 BOOLEAN
277 EFIAPI
278 DeprecatedCryptoServiceMd5Init (
279 OUT VOID *Md5Context
280 )
281 {
282 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
283 }
284
285 /**
286 Makes a copy of an existing MD5 context.
287
288 If Md5Context is NULL, then return FALSE.
289 If NewMd5Context is NULL, then return FALSE.
290 If this interface is not supported, then return FALSE.
291
292 @param[in] Md5Context Pointer to MD5 context being copied.
293 @param[out] NewMd5Context Pointer to new MD5 context.
294
295 @retval FALSE This interface is not supported.
296
297 **/
298 BOOLEAN
299 EFIAPI
300 DeprecatedCryptoServiceMd5Duplicate (
301 IN CONST VOID *Md5Context,
302 OUT VOID *NewMd5Context
303 )
304 {
305 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
306 }
307
308 /**
309 Digests the input data and updates MD5 context.
310
311 This function performs MD5 digest on a data buffer of the specified size.
312 It can be called multiple times to compute the digest of long or discontinuous data streams.
313 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
314 by Md5Final(). Behavior with invalid context is undefined.
315
316 If Md5Context is NULL, then return FALSE.
317 If this interface is not supported, then return FALSE.
318
319 @param[in, out] Md5Context Pointer to the MD5 context.
320 @param[in] Data Pointer to the buffer containing the data to be hashed.
321 @param[in] DataSize Size of Data buffer in bytes.
322
323 @retval FALSE This interface is not supported.
324
325 **/
326 BOOLEAN
327 EFIAPI
328 DeprecatedCryptoServiceMd5Update (
329 IN OUT VOID *Md5Context,
330 IN CONST VOID *Data,
331 IN UINTN DataSize
332 )
333 {
334 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
335 }
336
337 /**
338 Completes computation of the MD5 digest value.
339
340 This function completes MD5 hash computation and retrieves the digest value into
341 the specified memory. After this function has been called, the MD5 context cannot
342 be used again.
343 MD5 context should be already correctly initialized by Md5Init(), and should not be
344 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
345
346 If Md5Context is NULL, then return FALSE.
347 If HashValue is NULL, then return FALSE.
348 If this interface is not supported, then return FALSE.
349
350 @param[in, out] Md5Context Pointer to the MD5 context.
351 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
352 value (16 bytes).
353
354 @retval FALSE This interface is not supported.
355
356 **/
357 BOOLEAN
358 EFIAPI
359 DeprecatedCryptoServiceMd5Final (
360 IN OUT VOID *Md5Context,
361 OUT UINT8 *HashValue
362 )
363 {
364 return BaseCryptLibServiceDeprecated ("Md5Final"), FALSE;
365 }
366
367 /**
368 Computes the MD5 message digest of a input data buffer.
369
370 This function performs the MD5 message digest of a given data buffer, and places
371 the digest value into the specified memory.
372
373 If this interface is not supported, then return FALSE.
374
375 @param[in] Data Pointer to the buffer containing the data to be hashed.
376 @param[in] DataSize Size of Data buffer in bytes.
377 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
378 value (16 bytes).
379
380 @retval FALSE This interface is not supported.
381
382 **/
383 BOOLEAN
384 EFIAPI
385 DeprecatedCryptoServiceMd5HashAll (
386 IN CONST VOID *Data,
387 IN UINTN DataSize,
388 OUT UINT8 *HashValue
389 )
390 {
391 return BaseCryptLibServiceDeprecated ("Md5HashAll"), FALSE;
392 }
393 #else
394 /**
395 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
396
397 If this interface is not supported, then return zero.
398
399 @return The size, in bytes, of the context buffer required for MD5 hash operations.
400 @retval 0 This interface is not supported.
401
402 **/
403 UINTN
404 EFIAPI
405 CryptoServiceMd5GetContextSize (
406 VOID
407 )
408 {
409 return CALL_BASECRYPTLIB (Md5.Services.GetContextSize, Md5GetContextSize, (), 0);
410 }
411
412 /**
413 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
414 subsequent use.
415
416 If Md5Context is NULL, then return FALSE.
417 If this interface is not supported, then return FALSE.
418
419 @param[out] Md5Context Pointer to MD5 context being initialized.
420
421 @retval TRUE MD5 context initialization succeeded.
422 @retval FALSE MD5 context initialization failed.
423 @retval FALSE This interface is not supported.
424
425 **/
426 BOOLEAN
427 EFIAPI
428 CryptoServiceMd5Init (
429 OUT VOID *Md5Context
430 )
431 {
432 return CALL_BASECRYPTLIB (Md5.Services.Init, Md5Init, (Md5Context), FALSE);
433 }
434
435 /**
436 Makes a copy of an existing MD5 context.
437
438 If Md5Context is NULL, then return FALSE.
439 If NewMd5Context is NULL, then return FALSE.
440 If this interface is not supported, then return FALSE.
441
442 @param[in] Md5Context Pointer to MD5 context being copied.
443 @param[out] NewMd5Context Pointer to new MD5 context.
444
445 @retval TRUE MD5 context copy succeeded.
446 @retval FALSE MD5 context copy failed.
447 @retval FALSE This interface is not supported.
448
449 **/
450 BOOLEAN
451 EFIAPI
452 CryptoServiceMd5Duplicate (
453 IN CONST VOID *Md5Context,
454 OUT VOID *NewMd5Context
455 )
456 {
457 return CALL_BASECRYPTLIB (Md5.Services.Duplicate, Md5Duplicate, (Md5Context, NewMd5Context), FALSE);
458 }
459
460 /**
461 Digests the input data and updates MD5 context.
462
463 This function performs MD5 digest on a data buffer of the specified size.
464 It can be called multiple times to compute the digest of long or discontinuous data streams.
465 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
466 by Md5Final(). Behavior with invalid context is undefined.
467
468 If Md5Context is NULL, then return FALSE.
469 If this interface is not supported, then return FALSE.
470
471 @param[in, out] Md5Context Pointer to the MD5 context.
472 @param[in] Data Pointer to the buffer containing the data to be hashed.
473 @param[in] DataSize Size of Data buffer in bytes.
474
475 @retval TRUE MD5 data digest succeeded.
476 @retval FALSE MD5 data digest failed.
477 @retval FALSE This interface is not supported.
478
479 **/
480 BOOLEAN
481 EFIAPI
482 CryptoServiceMd5Update (
483 IN OUT VOID *Md5Context,
484 IN CONST VOID *Data,
485 IN UINTN DataSize
486 )
487 {
488 return CALL_BASECRYPTLIB (Md5.Services.Update, Md5Update, (Md5Context, Data, DataSize), FALSE);
489 }
490
491 /**
492 Completes computation of the MD5 digest value.
493
494 This function completes MD5 hash computation and retrieves the digest value into
495 the specified memory. After this function has been called, the MD5 context cannot
496 be used again.
497 MD5 context should be already correctly initialized by Md5Init(), and should not be
498 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
499
500 If Md5Context is NULL, then return FALSE.
501 If HashValue is NULL, then return FALSE.
502 If this interface is not supported, then return FALSE.
503
504 @param[in, out] Md5Context Pointer to the MD5 context.
505 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
506 value (16 bytes).
507
508 @retval TRUE MD5 digest computation succeeded.
509 @retval FALSE MD5 digest computation failed.
510 @retval FALSE This interface is not supported.
511
512 **/
513 BOOLEAN
514 EFIAPI
515 CryptoServiceMd5Final (
516 IN OUT VOID *Md5Context,
517 OUT UINT8 *HashValue
518 )
519 {
520 return CALL_BASECRYPTLIB (Md5.Services.Final, Md5Final, (Md5Context, HashValue), FALSE);
521 }
522
523 /**
524 Computes the MD5 message digest of a input data buffer.
525
526 This function performs the MD5 message digest of a given data buffer, and places
527 the digest value into the specified memory.
528
529 If this interface is not supported, then return FALSE.
530
531 @param[in] Data Pointer to the buffer containing the data to be hashed.
532 @param[in] DataSize Size of Data buffer in bytes.
533 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
534 value (16 bytes).
535
536 @retval TRUE MD5 digest computation succeeded.
537 @retval FALSE MD5 digest computation failed.
538 @retval FALSE This interface is not supported.
539
540 **/
541 BOOLEAN
542 EFIAPI
543 CryptoServiceMd5HashAll (
544 IN CONST VOID *Data,
545 IN UINTN DataSize,
546 OUT UINT8 *HashValue
547 )
548 {
549 return CALL_BASECRYPTLIB (Md5.Services.HashAll, Md5HashAll, (Data, DataSize, HashValue), FALSE);
550 }
551 #endif
552
553 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
554 /**
555 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
556
557 If this interface is not supported, then return zero.
558
559 @retval 0 This interface is not supported.
560
561 **/
562 UINTN
563 EFIAPI
564 DeprecatedCryptoServiceSha1GetContextSize (
565 VOID
566 )
567 {
568 return BaseCryptLibServiceDeprecated ("Sha1GetContextSize"), 0;
569 }
570
571 /**
572 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
573 subsequent use.
574
575 If Sha1Context is NULL, then return FALSE.
576 If this interface is not supported, then return FALSE.
577
578 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
579
580 @retval TRUE SHA-1 context initialization succeeded.
581 @retval FALSE SHA-1 context initialization failed.
582 @retval FALSE This interface is not supported.
583
584 **/
585 BOOLEAN
586 EFIAPI
587 DeprecatedCryptoServiceSha1Init (
588 OUT VOID *Sha1Context
589 )
590 {
591 return BaseCryptLibServiceDeprecated ("Sha1Init"), FALSE;
592 }
593
594 /**
595 Makes a copy of an existing SHA-1 context.
596
597 If Sha1Context is NULL, then return FALSE.
598 If NewSha1Context is NULL, then return FALSE.
599 If this interface is not supported, then return FALSE.
600
601 @param[in] Sha1Context Pointer to SHA-1 context being copied.
602 @param[out] NewSha1Context Pointer to new SHA-1 context.
603
604 @retval FALSE This interface is not supported.
605
606 **/
607 BOOLEAN
608 EFIAPI
609 DeprecatedCryptoServiceSha1Duplicate (
610 IN CONST VOID *Sha1Context,
611 OUT VOID *NewSha1Context
612 )
613 {
614 return BaseCryptLibServiceDeprecated ("Sha1Duplicate"), FALSE;
615 }
616
617 /**
618 Digests the input data and updates SHA-1 context.
619
620 This function performs SHA-1 digest on a data buffer of the specified size.
621 It can be called multiple times to compute the digest of long or discontinuous data streams.
622 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
623 by Sha1Final(). Behavior with invalid context is undefined.
624
625 If Sha1Context is NULL, then return FALSE.
626 If this interface is not supported, then return FALSE.
627
628 @param[in, out] Sha1Context Pointer to the SHA-1 context.
629 @param[in] Data Pointer to the buffer containing the data to be hashed.
630 @param[in] DataSize Size of Data buffer in bytes.
631
632 @retval FALSE This interface is not supported.
633
634 **/
635 BOOLEAN
636 EFIAPI
637 DeprecatedCryptoServiceSha1Update (
638 IN OUT VOID *Sha1Context,
639 IN CONST VOID *Data,
640 IN UINTN DataSize
641 )
642 {
643 return BaseCryptLibServiceDeprecated ("Sha1Update"), FALSE;
644 }
645
646 /**
647 Completes computation of the SHA-1 digest value.
648
649 This function completes SHA-1 hash computation and retrieves the digest value into
650 the specified memory. After this function has been called, the SHA-1 context cannot
651 be used again.
652 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
653 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
654
655 If Sha1Context is NULL, then return FALSE.
656 If HashValue is NULL, then return FALSE.
657 If this interface is not supported, then return FALSE.
658
659 @param[in, out] Sha1Context Pointer to the SHA-1 context.
660 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
661 value (20 bytes).
662
663 @retval FALSE This interface is not supported.
664
665 **/
666 BOOLEAN
667 EFIAPI
668 DeprecatedCryptoServiceSha1Final (
669 IN OUT VOID *Sha1Context,
670 OUT UINT8 *HashValue
671 )
672 {
673 return BaseCryptLibServiceDeprecated ("Sha1Final"), FALSE;
674 }
675
676 /**
677 Computes the SHA-1 message digest of a input data buffer.
678
679 This function performs the SHA-1 message digest of a given data buffer, and places
680 the digest value into the specified memory.
681
682 If this interface is not supported, then return FALSE.
683
684 @param[in] Data Pointer to the buffer containing the data to be hashed.
685 @param[in] DataSize Size of Data buffer in bytes.
686 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
687 value (20 bytes).
688
689 @retval FALSE This interface is not supported.
690
691 **/
692 BOOLEAN
693 EFIAPI
694 DeprecatedCryptoServiceSha1HashAll (
695 IN CONST VOID *Data,
696 IN UINTN DataSize,
697 OUT UINT8 *HashValue
698 )
699 {
700 return BaseCryptLibServiceDeprecated ("Sha1HashAll"), FALSE;
701 }
702 #else
703 /**
704 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
705
706 If this interface is not supported, then return zero.
707
708 @return The size, in bytes, of the context buffer required for SHA-1 hash operations.
709 @retval 0 This interface is not supported.
710
711 **/
712 UINTN
713 EFIAPI
714 CryptoServiceSha1GetContextSize (
715 VOID
716 )
717 {
718 return CALL_BASECRYPTLIB (Sha1.Services.GetContextSize, Sha1GetContextSize, (), 0);
719 }
720
721 /**
722 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
723 subsequent use.
724
725 If Sha1Context is NULL, then return FALSE.
726 If this interface is not supported, then return FALSE.
727
728 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
729
730 @retval TRUE SHA-1 context initialization succeeded.
731 @retval FALSE SHA-1 context initialization failed.
732 @retval FALSE This interface is not supported.
733
734 **/
735 BOOLEAN
736 EFIAPI
737 CryptoServiceSha1Init (
738 OUT VOID *Sha1Context
739 )
740 {
741 return CALL_BASECRYPTLIB (Sha1.Services.Init, Sha1Init, (Sha1Context), FALSE);
742 }
743
744 /**
745 Makes a copy of an existing SHA-1 context.
746
747 If Sha1Context is NULL, then return FALSE.
748 If NewSha1Context is NULL, then return FALSE.
749 If this interface is not supported, then return FALSE.
750
751 @param[in] Sha1Context Pointer to SHA-1 context being copied.
752 @param[out] NewSha1Context Pointer to new SHA-1 context.
753
754 @retval TRUE SHA-1 context copy succeeded.
755 @retval FALSE SHA-1 context copy failed.
756 @retval FALSE This interface is not supported.
757
758 **/
759 BOOLEAN
760 EFIAPI
761 CryptoServiceSha1Duplicate (
762 IN CONST VOID *Sha1Context,
763 OUT VOID *NewSha1Context
764 )
765 {
766 return CALL_BASECRYPTLIB (Sha1.Services.Duplicate, Sha1Duplicate, (Sha1Context, NewSha1Context), FALSE);
767 }
768
769 /**
770 Digests the input data and updates SHA-1 context.
771
772 This function performs SHA-1 digest on a data buffer of the specified size.
773 It can be called multiple times to compute the digest of long or discontinuous data streams.
774 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
775 by Sha1Final(). Behavior with invalid context is undefined.
776
777 If Sha1Context is NULL, then return FALSE.
778 If this interface is not supported, then return FALSE.
779
780 @param[in, out] Sha1Context Pointer to the SHA-1 context.
781 @param[in] Data Pointer to the buffer containing the data to be hashed.
782 @param[in] DataSize Size of Data buffer in bytes.
783
784 @retval TRUE SHA-1 data digest succeeded.
785 @retval FALSE SHA-1 data digest failed.
786 @retval FALSE This interface is not supported.
787
788 **/
789 BOOLEAN
790 EFIAPI
791 CryptoServiceSha1Update (
792 IN OUT VOID *Sha1Context,
793 IN CONST VOID *Data,
794 IN UINTN DataSize
795 )
796 {
797 return CALL_BASECRYPTLIB (Sha1.Services.Update, Sha1Update, (Sha1Context, Data, DataSize), FALSE);
798 }
799
800 /**
801 Completes computation of the SHA-1 digest value.
802
803 This function completes SHA-1 hash computation and retrieves the digest value into
804 the specified memory. After this function has been called, the SHA-1 context cannot
805 be used again.
806 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
807 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
808
809 If Sha1Context is NULL, then return FALSE.
810 If HashValue is NULL, then return FALSE.
811 If this interface is not supported, then return FALSE.
812
813 @param[in, out] Sha1Context Pointer to the SHA-1 context.
814 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
815 value (20 bytes).
816
817 @retval TRUE SHA-1 digest computation succeeded.
818 @retval FALSE SHA-1 digest computation failed.
819 @retval FALSE This interface is not supported.
820
821 **/
822 BOOLEAN
823 EFIAPI
824 CryptoServiceSha1Final (
825 IN OUT VOID *Sha1Context,
826 OUT UINT8 *HashValue
827 )
828 {
829 return CALL_BASECRYPTLIB (Sha1.Services.Final, Sha1Final, (Sha1Context, HashValue), FALSE);
830 }
831
832 /**
833 Computes the SHA-1 message digest of a input data buffer.
834
835 This function performs the SHA-1 message digest of a given data buffer, and places
836 the digest value into the specified memory.
837
838 If this interface is not supported, then return FALSE.
839
840 @param[in] Data Pointer to the buffer containing the data to be hashed.
841 @param[in] DataSize Size of Data buffer in bytes.
842 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
843 value (20 bytes).
844
845 @retval TRUE SHA-1 digest computation succeeded.
846 @retval FALSE SHA-1 digest computation failed.
847 @retval FALSE This interface is not supported.
848
849 **/
850 BOOLEAN
851 EFIAPI
852 CryptoServiceSha1HashAll (
853 IN CONST VOID *Data,
854 IN UINTN DataSize,
855 OUT UINT8 *HashValue
856 )
857 {
858 return CALL_BASECRYPTLIB (Sha1.Services.HashAll, Sha1HashAll, (Data, DataSize, HashValue), FALSE);
859 }
860 #endif
861
862 /**
863 Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
864
865 @return The size, in bytes, of the context buffer required for SHA-256 hash operations.
866
867 **/
868 UINTN
869 EFIAPI
870 CryptoServiceSha256GetContextSize (
871 VOID
872 )
873 {
874 return CALL_BASECRYPTLIB (Sha256.Services.GetContextSize, Sha256GetContextSize, (), 0);
875 }
876
877 /**
878 Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
879 subsequent use.
880
881 If Sha256Context is NULL, then return FALSE.
882
883 @param[out] Sha256Context Pointer to SHA-256 context being initialized.
884
885 @retval TRUE SHA-256 context initialization succeeded.
886 @retval FALSE SHA-256 context initialization failed.
887
888 **/
889 BOOLEAN
890 EFIAPI
891 CryptoServiceSha256Init (
892 OUT VOID *Sha256Context
893 )
894 {
895 return CALL_BASECRYPTLIB (Sha256.Services.Init, Sha256Init, (Sha256Context), FALSE);
896 }
897
898 /**
899 Makes a copy of an existing SHA-256 context.
900
901 If Sha256Context is NULL, then return FALSE.
902 If NewSha256Context is NULL, then return FALSE.
903 If this interface is not supported, then return FALSE.
904
905 @param[in] Sha256Context Pointer to SHA-256 context being copied.
906 @param[out] NewSha256Context Pointer to new SHA-256 context.
907
908 @retval TRUE SHA-256 context copy succeeded.
909 @retval FALSE SHA-256 context copy failed.
910 @retval FALSE This interface is not supported.
911
912 **/
913 BOOLEAN
914 EFIAPI
915 CryptoServiceSha256Duplicate (
916 IN CONST VOID *Sha256Context,
917 OUT VOID *NewSha256Context
918 )
919 {
920 return CALL_BASECRYPTLIB (Sha256.Services.Duplicate, Sha256Duplicate, (Sha256Context, NewSha256Context), FALSE);
921 }
922
923 /**
924 Digests the input data and updates SHA-256 context.
925
926 This function performs SHA-256 digest on a data buffer of the specified size.
927 It can be called multiple times to compute the digest of long or discontinuous data streams.
928 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized
929 by Sha256Final(). Behavior with invalid context is undefined.
930
931 If Sha256Context is NULL, then return FALSE.
932
933 @param[in, out] Sha256Context Pointer to the SHA-256 context.
934 @param[in] Data Pointer to the buffer containing the data to be hashed.
935 @param[in] DataSize Size of Data buffer in bytes.
936
937 @retval TRUE SHA-256 data digest succeeded.
938 @retval FALSE SHA-256 data digest failed.
939
940 **/
941 BOOLEAN
942 EFIAPI
943 CryptoServiceSha256Update (
944 IN OUT VOID *Sha256Context,
945 IN CONST VOID *Data,
946 IN UINTN DataSize
947 )
948 {
949 return CALL_BASECRYPTLIB (Sha256.Services.Update, Sha256Update, (Sha256Context, Data, DataSize), FALSE);
950 }
951
952 /**
953 Completes computation of the SHA-256 digest value.
954
955 This function completes SHA-256 hash computation and retrieves the digest value into
956 the specified memory. After this function has been called, the SHA-256 context cannot
957 be used again.
958 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be
959 finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
960
961 If Sha256Context is NULL, then return FALSE.
962 If HashValue is NULL, then return FALSE.
963
964 @param[in, out] Sha256Context Pointer to the SHA-256 context.
965 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
966 value (32 bytes).
967
968 @retval TRUE SHA-256 digest computation succeeded.
969 @retval FALSE SHA-256 digest computation failed.
970
971 **/
972 BOOLEAN
973 EFIAPI
974 CryptoServiceSha256Final (
975 IN OUT VOID *Sha256Context,
976 OUT UINT8 *HashValue
977 )
978 {
979 return CALL_BASECRYPTLIB (Sha256.Services.Final, Sha256Final, (Sha256Context, HashValue), FALSE);
980 }
981
982 /**
983 Computes the SHA-256 message digest of a input data buffer.
984
985 This function performs the SHA-256 message digest of a given data buffer, and places
986 the digest value into the specified memory.
987
988 If this interface is not supported, then return FALSE.
989
990 @param[in] Data Pointer to the buffer containing the data to be hashed.
991 @param[in] DataSize Size of Data buffer in bytes.
992 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
993 value (32 bytes).
994
995 @retval TRUE SHA-256 digest computation succeeded.
996 @retval FALSE SHA-256 digest computation failed.
997 @retval FALSE This interface is not supported.
998
999 **/
1000 BOOLEAN
1001 EFIAPI
1002 CryptoServiceSha256HashAll (
1003 IN CONST VOID *Data,
1004 IN UINTN DataSize,
1005 OUT UINT8 *HashValue
1006 )
1007 {
1008 return CALL_BASECRYPTLIB (Sha256.Services.HashAll, Sha256HashAll, (Data, DataSize, HashValue), FALSE);
1009 }
1010
1011 /**
1012 Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
1013
1014 @return The size, in bytes, of the context buffer required for SHA-384 hash operations.
1015
1016 **/
1017 UINTN
1018 EFIAPI
1019 CryptoServiceSha384GetContextSize (
1020 VOID
1021 )
1022 {
1023 return CALL_BASECRYPTLIB (Sha384.Services.GetContextSize, Sha384GetContextSize, (), 0);
1024 }
1025
1026 /**
1027 Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for
1028 subsequent use.
1029
1030 If Sha384Context is NULL, then return FALSE.
1031
1032 @param[out] Sha384Context Pointer to SHA-384 context being initialized.
1033
1034 @retval TRUE SHA-384 context initialization succeeded.
1035 @retval FALSE SHA-384 context initialization failed.
1036
1037 **/
1038 BOOLEAN
1039 EFIAPI
1040 CryptoServiceSha384Init (
1041 OUT VOID *Sha384Context
1042 )
1043 {
1044 return CALL_BASECRYPTLIB (Sha384.Services.Init, Sha384Init, (Sha384Context), FALSE);
1045 }
1046
1047 /**
1048 Makes a copy of an existing SHA-384 context.
1049
1050 If Sha384Context is NULL, then return FALSE.
1051 If NewSha384Context is NULL, then return FALSE.
1052 If this interface is not supported, then return FALSE.
1053
1054 @param[in] Sha384Context Pointer to SHA-384 context being copied.
1055 @param[out] NewSha384Context Pointer to new SHA-384 context.
1056
1057 @retval TRUE SHA-384 context copy succeeded.
1058 @retval FALSE SHA-384 context copy failed.
1059 @retval FALSE This interface is not supported.
1060
1061 **/
1062 BOOLEAN
1063 EFIAPI
1064 CryptoServiceSha384Duplicate (
1065 IN CONST VOID *Sha384Context,
1066 OUT VOID *NewSha384Context
1067 )
1068 {
1069 return CALL_BASECRYPTLIB (Sha384.Services.Duplicate, Sha384Duplicate, (Sha384Context, NewSha384Context), FALSE);
1070 }
1071
1072 /**
1073 Digests the input data and updates SHA-384 context.
1074
1075 This function performs SHA-384 digest on a data buffer of the specified size.
1076 It can be called multiple times to compute the digest of long or discontinuous data streams.
1077 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized
1078 by Sha384Final(). Behavior with invalid context is undefined.
1079
1080 If Sha384Context is NULL, then return FALSE.
1081
1082 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1083 @param[in] Data Pointer to the buffer containing the data to be hashed.
1084 @param[in] DataSize Size of Data buffer in bytes.
1085
1086 @retval TRUE SHA-384 data digest succeeded.
1087 @retval FALSE SHA-384 data digest failed.
1088
1089 **/
1090 BOOLEAN
1091 EFIAPI
1092 CryptoServiceSha384Update (
1093 IN OUT VOID *Sha384Context,
1094 IN CONST VOID *Data,
1095 IN UINTN DataSize
1096 )
1097 {
1098 return CALL_BASECRYPTLIB (Sha384.Services.Update, Sha384Update, (Sha384Context, Data, DataSize), FALSE);
1099 }
1100
1101 /**
1102 Completes computation of the SHA-384 digest value.
1103
1104 This function completes SHA-384 hash computation and retrieves the digest value into
1105 the specified memory. After this function has been called, the SHA-384 context cannot
1106 be used again.
1107 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be
1108 finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.
1109
1110 If Sha384Context is NULL, then return FALSE.
1111 If HashValue is NULL, then return FALSE.
1112
1113 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1114 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1115 value (48 bytes).
1116
1117 @retval TRUE SHA-384 digest computation succeeded.
1118 @retval FALSE SHA-384 digest computation failed.
1119
1120 **/
1121 BOOLEAN
1122 EFIAPI
1123 CryptoServiceSha384Final (
1124 IN OUT VOID *Sha384Context,
1125 OUT UINT8 *HashValue
1126 )
1127 {
1128 return CALL_BASECRYPTLIB (Sha384.Services.Final, Sha384Final, (Sha384Context, HashValue), FALSE);
1129 }
1130
1131 /**
1132 Computes the SHA-384 message digest of a input data buffer.
1133
1134 This function performs the SHA-384 message digest of a given data buffer, and places
1135 the digest value into the specified memory.
1136
1137 If this interface is not supported, then return FALSE.
1138
1139 @param[in] Data Pointer to the buffer containing the data to be hashed.
1140 @param[in] DataSize Size of Data buffer in bytes.
1141 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1142 value (48 bytes).
1143
1144 @retval TRUE SHA-384 digest computation succeeded.
1145 @retval FALSE SHA-384 digest computation failed.
1146 @retval FALSE This interface is not supported.
1147
1148 **/
1149 BOOLEAN
1150 EFIAPI
1151 CryptoServiceSha384HashAll (
1152 IN CONST VOID *Data,
1153 IN UINTN DataSize,
1154 OUT UINT8 *HashValue
1155 )
1156 {
1157 return CALL_BASECRYPTLIB (Sha384.Services.HashAll, Sha384HashAll, (Data, DataSize, HashValue), FALSE);
1158 }
1159
1160 /**
1161 Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.
1162
1163 @return The size, in bytes, of the context buffer required for SHA-512 hash operations.
1164
1165 **/
1166 UINTN
1167 EFIAPI
1168 CryptoServiceSha512GetContextSize (
1169 VOID
1170 )
1171 {
1172 return CALL_BASECRYPTLIB (Sha512.Services.GetContextSize, Sha512GetContextSize, (), 0);
1173 }
1174
1175 /**
1176 Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for
1177 subsequent use.
1178
1179 If Sha512Context is NULL, then return FALSE.
1180
1181 @param[out] Sha512Context Pointer to SHA-512 context being initialized.
1182
1183 @retval TRUE SHA-512 context initialization succeeded.
1184 @retval FALSE SHA-512 context initialization failed.
1185
1186 **/
1187 BOOLEAN
1188 EFIAPI
1189 CryptoServiceSha512Init (
1190 OUT VOID *Sha512Context
1191 )
1192 {
1193 return CALL_BASECRYPTLIB (Sha512.Services.Init, Sha512Init, (Sha512Context), FALSE);
1194 }
1195
1196 /**
1197 Makes a copy of an existing SHA-512 context.
1198
1199 If Sha512Context is NULL, then return FALSE.
1200 If NewSha512Context is NULL, then return FALSE.
1201 If this interface is not supported, then return FALSE.
1202
1203 @param[in] Sha512Context Pointer to SHA-512 context being copied.
1204 @param[out] NewSha512Context Pointer to new SHA-512 context.
1205
1206 @retval TRUE SHA-512 context copy succeeded.
1207 @retval FALSE SHA-512 context copy failed.
1208 @retval FALSE This interface is not supported.
1209
1210 **/
1211 BOOLEAN
1212 EFIAPI
1213 CryptoServiceSha512Duplicate (
1214 IN CONST VOID *Sha512Context,
1215 OUT VOID *NewSha512Context
1216 )
1217 {
1218 return CALL_BASECRYPTLIB (Sha512.Services.Duplicate, Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);
1219 }
1220
1221 /**
1222 Digests the input data and updates SHA-512 context.
1223
1224 This function performs SHA-512 digest on a data buffer of the specified size.
1225 It can be called multiple times to compute the digest of long or discontinuous data streams.
1226 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized
1227 by Sha512Final(). Behavior with invalid context is undefined.
1228
1229 If Sha512Context is NULL, then return FALSE.
1230
1231 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1232 @param[in] Data Pointer to the buffer containing the data to be hashed.
1233 @param[in] DataSize Size of Data buffer in bytes.
1234
1235 @retval TRUE SHA-512 data digest succeeded.
1236 @retval FALSE SHA-512 data digest failed.
1237
1238 **/
1239 BOOLEAN
1240 EFIAPI
1241 CryptoServiceSha512Update (
1242 IN OUT VOID *Sha512Context,
1243 IN CONST VOID *Data,
1244 IN UINTN DataSize
1245 )
1246 {
1247 return CALL_BASECRYPTLIB (Sha512.Services.Update, Sha512Update, (Sha512Context, Data, DataSize), FALSE);
1248 }
1249
1250 /**
1251 Completes computation of the SHA-512 digest value.
1252
1253 This function completes SHA-512 hash computation and retrieves the digest value into
1254 the specified memory. After this function has been called, the SHA-512 context cannot
1255 be used again.
1256 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be
1257 finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.
1258
1259 If Sha512Context is NULL, then return FALSE.
1260 If HashValue is NULL, then return FALSE.
1261
1262 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1263 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1264 value (64 bytes).
1265
1266 @retval TRUE SHA-512 digest computation succeeded.
1267 @retval FALSE SHA-512 digest computation failed.
1268
1269 **/
1270 BOOLEAN
1271 EFIAPI
1272 CryptoServiceSha512Final (
1273 IN OUT VOID *Sha512Context,
1274 OUT UINT8 *HashValue
1275 )
1276 {
1277 return CALL_BASECRYPTLIB (Sha512.Services.Final, Sha512Final, (Sha512Context, HashValue), FALSE);
1278 }
1279
1280 /**
1281 Computes the SHA-512 message digest of a input data buffer.
1282
1283 This function performs the SHA-512 message digest of a given data buffer, and places
1284 the digest value into the specified memory.
1285
1286 If this interface is not supported, then return FALSE.
1287
1288 @param[in] Data Pointer to the buffer containing the data to be hashed.
1289 @param[in] DataSize Size of Data buffer in bytes.
1290 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1291 value (64 bytes).
1292
1293 @retval TRUE SHA-512 digest computation succeeded.
1294 @retval FALSE SHA-512 digest computation failed.
1295 @retval FALSE This interface is not supported.
1296
1297 **/
1298 BOOLEAN
1299 EFIAPI
1300 CryptoServiceSha512HashAll (
1301 IN CONST VOID *Data,
1302 IN UINTN DataSize,
1303 OUT UINT8 *HashValue
1304 )
1305 {
1306 return CALL_BASECRYPTLIB (Sha512.Services.HashAll, Sha512HashAll, (Data, DataSize, HashValue), FALSE);
1307 }
1308
1309 /**
1310 Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.
1311
1312 @return The size, in bytes, of the context buffer required for SM3 hash operations.
1313
1314 **/
1315 UINTN
1316 EFIAPI
1317 CryptoServiceSm3GetContextSize (
1318 VOID
1319 )
1320 {
1321 return CALL_BASECRYPTLIB (Sm3.Services.GetContextSize, Sm3GetContextSize, (), 0);
1322 }
1323
1324 /**
1325 Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for
1326 subsequent use.
1327
1328 If Sm3Context is NULL, then return FALSE.
1329
1330 @param[out] Sm3Context Pointer to SM3 context being initialized.
1331
1332 @retval TRUE SM3 context initialization succeeded.
1333 @retval FALSE SM3 context initialization failed.
1334
1335 **/
1336 BOOLEAN
1337 EFIAPI
1338 CryptoServiceSm3Init (
1339 OUT VOID *Sm3Context
1340 )
1341 {
1342 return CALL_BASECRYPTLIB (Sm3.Services.Init, Sm3Init, (Sm3Context), FALSE);
1343 }
1344
1345 /**
1346 Makes a copy of an existing SM3 context.
1347
1348 If Sm3Context is NULL, then return FALSE.
1349 If NewSm3Context is NULL, then return FALSE.
1350 If this interface is not supported, then return FALSE.
1351
1352 @param[in] Sm3Context Pointer to SM3 context being copied.
1353 @param[out] NewSm3Context Pointer to new SM3 context.
1354
1355 @retval TRUE SM3 context copy succeeded.
1356 @retval FALSE SM3 context copy failed.
1357 @retval FALSE This interface is not supported.
1358
1359 **/
1360 BOOLEAN
1361 EFIAPI
1362 CryptoServiceSm3Duplicate (
1363 IN CONST VOID *Sm3Context,
1364 OUT VOID *NewSm3Context
1365 )
1366 {
1367 return CALL_BASECRYPTLIB (Sm3.Services.Duplicate, Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE);
1368 }
1369
1370 /**
1371 Digests the input data and updates SM3 context.
1372
1373 This function performs SM3 digest on a data buffer of the specified size.
1374 It can be called multiple times to compute the digest of long or discontinuous data streams.
1375 SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized
1376 by Sm3Final(). Behavior with invalid context is undefined.
1377
1378 If Sm3Context is NULL, then return FALSE.
1379
1380 @param[in, out] Sm3Context Pointer to the SM3 context.
1381 @param[in] Data Pointer to the buffer containing the data to be hashed.
1382 @param[in] DataSize Size of Data buffer in bytes.
1383
1384 @retval TRUE SM3 data digest succeeded.
1385 @retval FALSE SM3 data digest failed.
1386
1387 **/
1388 BOOLEAN
1389 EFIAPI
1390 CryptoServiceSm3Update (
1391 IN OUT VOID *Sm3Context,
1392 IN CONST VOID *Data,
1393 IN UINTN DataSize
1394 )
1395 {
1396 return CALL_BASECRYPTLIB (Sm3.Services.Update, Sm3Update, (Sm3Context, Data, DataSize), FALSE);
1397 }
1398
1399 /**
1400 Completes computation of the SM3 digest value.
1401
1402 This function completes SM3 hash computation and retrieves the digest value into
1403 the specified memory. After this function has been called, the SM3 context cannot
1404 be used again.
1405 SM3 context should be already correctly initialized by Sm3Init(), and should not be
1406 finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.
1407
1408 If Sm3Context is NULL, then return FALSE.
1409 If HashValue is NULL, then return FALSE.
1410
1411 @param[in, out] Sm3Context Pointer to the SM3 context.
1412 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1413 value (32 bytes).
1414
1415 @retval TRUE SM3 digest computation succeeded.
1416 @retval FALSE SM3 digest computation failed.
1417
1418 **/
1419 BOOLEAN
1420 EFIAPI
1421 CryptoServiceSm3Final (
1422 IN OUT VOID *Sm3Context,
1423 OUT UINT8 *HashValue
1424 )
1425 {
1426 return CALL_BASECRYPTLIB (Sm3.Services.Final, Sm3Final, (Sm3Context, HashValue), FALSE);
1427 }
1428
1429 /**
1430 Computes the SM3 message digest of a input data buffer.
1431
1432 This function performs the SM3 message digest of a given data buffer, and places
1433 the digest value into the specified memory.
1434
1435 If this interface is not supported, then return FALSE.
1436
1437 @param[in] Data Pointer to the buffer containing the data to be hashed.
1438 @param[in] DataSize Size of Data buffer in bytes.
1439 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1440 value (32 bytes).
1441
1442 @retval TRUE SM3 digest computation succeeded.
1443 @retval FALSE SM3 digest computation failed.
1444 @retval FALSE This interface is not supported.
1445
1446 **/
1447 BOOLEAN
1448 EFIAPI
1449 CryptoServiceSm3HashAll (
1450 IN CONST VOID *Data,
1451 IN UINTN DataSize,
1452 OUT UINT8 *HashValue
1453 )
1454 {
1455 return CALL_BASECRYPTLIB (Sm3.Services.HashAll, Sm3HashAll, (Data, DataSize, HashValue), FALSE);
1456 }
1457
1458 //=====================================================================================
1459 // MAC (Message Authentication Code) Primitive
1460 //=====================================================================================
1461
1462 /**
1463 HMAC MD5 is deprecated and unsupported any longer.
1464 Keep the function field for binary compability.
1465
1466 @retval NULL This interface is not supported.
1467
1468 **/
1469 VOID *
1470 EFIAPI
1471 DeprecatedCryptoServiceHmacMd5New (
1472 VOID
1473 )
1474 {
1475 return BaseCryptLibServiceDeprecated ("HmacMd5New"), NULL;
1476 }
1477
1478 /**
1479 HMAC MD5 is deprecated and unsupported any longer.
1480 Keep the function field for binary compability.
1481
1482 @param[in] HmacMd5Ctx Pointer to the HMAC_CTX context to be released.
1483
1484 **/
1485 VOID
1486 EFIAPI
1487 DeprecatedCryptoServiceHmacMd5Free (
1488 IN VOID *HmacMd5Ctx
1489 )
1490 {
1491 BaseCryptLibServiceDeprecated ("HmacMd5Free");
1492 }
1493
1494 /**
1495 HMAC MD5 is deprecated and unsupported any longer.
1496 Keep the function field for binary compability.
1497
1498 @param[out] HmacMd5Context Pointer to HMAC-MD5 context.
1499 @param[in] Key Pointer to the user-supplied key.
1500 @param[in] KeySize Key size in bytes.
1501
1502 @retval FALSE This interface is not supported.
1503
1504 **/
1505 BOOLEAN
1506 EFIAPI
1507 DeprecatedCryptoServiceHmacMd5SetKey (
1508 OUT VOID *HmacMd5Context,
1509 IN CONST UINT8 *Key,
1510 IN UINTN KeySize
1511 )
1512 {
1513 return BaseCryptLibServiceDeprecated ("HmacMd5SetKey"), FALSE;
1514 }
1515
1516 /**
1517 HMAC MD5 is deprecated and unsupported any longer.
1518 Keep the function field for binary compability.
1519
1520 @param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied.
1521 @param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context.
1522
1523 @retval FALSE This interface is not supported.
1524
1525 **/
1526 BOOLEAN
1527 EFIAPI
1528 DeprecatedCryptoServiceHmacMd5Duplicate (
1529 IN CONST VOID *HmacMd5Context,
1530 OUT VOID *NewHmacMd5Context
1531 )
1532 {
1533 return BaseCryptLibServiceDeprecated ("HmacMd5Duplicate"), FALSE;
1534 }
1535
1536 /**
1537 HMAC MD5 is deprecated and unsupported any longer.
1538 Keep the function field for binary compability.
1539
1540 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1541 @param[in] Data Pointer to the buffer containing the data to be digested.
1542 @param[in] DataSize Size of Data buffer in bytes.
1543
1544 @retval FALSE This interface is not supported.
1545
1546 **/
1547 BOOLEAN
1548 EFIAPI
1549 DeprecatedCryptoServiceHmacMd5Update (
1550 IN OUT VOID *HmacMd5Context,
1551 IN CONST VOID *Data,
1552 IN UINTN DataSize
1553 )
1554 {
1555 return BaseCryptLibServiceDeprecated ("HmacMd5Update"), FALSE;
1556 }
1557
1558 /**
1559 HMAC MD5 is deprecated and unsupported any longer.
1560 Keep the function field for binary compability.
1561
1562 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1563 @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest
1564 value (16 bytes).
1565
1566 @retval FALSE This interface is not supported.
1567
1568 **/
1569 BOOLEAN
1570 EFIAPI
1571 DeprecatedCryptoServiceHmacMd5Final (
1572 IN OUT VOID *HmacMd5Context,
1573 OUT UINT8 *HmacValue
1574 )
1575 {
1576 return BaseCryptLibServiceDeprecated ("HmacMd5Final"), FALSE;
1577 }
1578
1579 /**
1580 HMAC SHA1 is deprecated and unsupported any longer.
1581 Keep the function field for binary compability.
1582
1583 @return NULL This interface is not supported.
1584
1585 **/
1586 VOID *
1587 EFIAPI
1588 DeprecatedCryptoServiceHmacSha1New (
1589 VOID
1590 )
1591 {
1592 return BaseCryptLibServiceDeprecated ("HmacSha1New"), NULL;
1593 }
1594
1595 /**
1596 HMAC SHA1 is deprecated and unsupported any longer.
1597 Keep the function field for binary compability.
1598
1599 @param[in] HmacSha1Ctx Pointer to the HMAC_CTX context to be released.
1600
1601 **/
1602 VOID
1603 EFIAPI
1604 DeprecatedCryptoServiceHmacSha1Free (
1605 IN VOID *HmacSha1Ctx
1606 )
1607 {
1608 BaseCryptLibServiceDeprecated ("HmacSha1Free");
1609 }
1610
1611 /**
1612 HMAC SHA1 is deprecated and unsupported any longer.
1613 Keep the function field for binary compability.
1614
1615 @param[out] HmacSha1Context Pointer to HMAC-SHA1 context.
1616 @param[in] Key Pointer to the user-supplied key.
1617 @param[in] KeySize Key size in bytes.
1618
1619 @retval FALSE This interface is not supported.
1620
1621 **/
1622 BOOLEAN
1623 EFIAPI
1624 DeprecatedCryptoServiceHmacSha1SetKey (
1625 OUT VOID *HmacSha1Context,
1626 IN CONST UINT8 *Key,
1627 IN UINTN KeySize
1628 )
1629 {
1630 return BaseCryptLibServiceDeprecated ("HmacSha1SetKey"), FALSE;
1631 }
1632
1633 /**
1634 HMAC SHA1 is deprecated and unsupported any longer.
1635 Keep the function field for binary compability.
1636
1637 @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied.
1638 @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context.
1639
1640 @retval FALSE This interface is not supported.
1641
1642 **/
1643 BOOLEAN
1644 EFIAPI
1645 DeprecatedCryptoServiceHmacSha1Duplicate (
1646 IN CONST VOID *HmacSha1Context,
1647 OUT VOID *NewHmacSha1Context
1648 )
1649 {
1650 return BaseCryptLibServiceDeprecated ("HmacSha1Duplicate"), FALSE;
1651 }
1652
1653 /**
1654 HMAC SHA1 is deprecated and unsupported any longer.
1655 Keep the function field for binary compability.
1656
1657 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1658 @param[in] Data Pointer to the buffer containing the data to be digested.
1659 @param[in] DataSize Size of Data buffer in bytes.
1660
1661 @retval FALSE This interface is not supported.
1662
1663 **/
1664 BOOLEAN
1665 EFIAPI
1666 DeprecatedCryptoServiceHmacSha1Update (
1667 IN OUT VOID *HmacSha1Context,
1668 IN CONST VOID *Data,
1669 IN UINTN DataSize
1670 )
1671 {
1672 return BaseCryptLibServiceDeprecated ("HmacSha1Update"), FALSE;
1673 }
1674
1675 /**
1676 HMAC SHA1 is deprecated and unsupported any longer.
1677 Keep the function field for binary compability.
1678
1679 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1680 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest
1681 value (20 bytes).
1682
1683 @retval FALSE This interface is not supported.
1684
1685 **/
1686 BOOLEAN
1687 EFIAPI
1688 DeprecatedCryptoServiceHmacSha1Final (
1689 IN OUT VOID *HmacSha1Context,
1690 OUT UINT8 *HmacValue
1691 )
1692 {
1693 return BaseCryptLibServiceDeprecated ("HmacSha1Final"), FALSE;
1694 }
1695
1696 /**
1697 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.
1698
1699 @return Pointer to the HMAC_CTX context that has been initialized.
1700 If the allocations fails, HmacSha256New() returns NULL.
1701
1702 **/
1703 VOID *
1704 EFIAPI
1705 CryptoServiceHmacSha256New (
1706 VOID
1707 )
1708 {
1709 return CALL_BASECRYPTLIB (HmacSha256.Services.New, HmacSha256New, (), NULL);
1710 }
1711
1712 /**
1713 Release the specified HMAC_CTX context.
1714
1715 @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.
1716
1717 **/
1718 VOID
1719 EFIAPI
1720 CryptoServiceHmacSha256Free (
1721 IN VOID *HmacSha256Ctx
1722 )
1723 {
1724 CALL_VOID_BASECRYPTLIB (HmacSha256.Services.Free, HmacSha256Free, (HmacSha256Ctx));
1725 }
1726
1727 /**
1728 Set user-supplied key for subsequent use. It must be done before any
1729 calling to HmacSha256Update().
1730
1731 If HmacSha256Context is NULL, then return FALSE.
1732 If this interface is not supported, then return FALSE.
1733
1734 @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.
1735 @param[in] Key Pointer to the user-supplied key.
1736 @param[in] KeySize Key size in bytes.
1737
1738 @retval TRUE The Key is set successfully.
1739 @retval FALSE The Key is set unsuccessfully.
1740 @retval FALSE This interface is not supported.
1741
1742 **/
1743 BOOLEAN
1744 EFIAPI
1745 CryptoServiceHmacSha256SetKey (
1746 OUT VOID *HmacSha256Context,
1747 IN CONST UINT8 *Key,
1748 IN UINTN KeySize
1749 )
1750 {
1751 return CALL_BASECRYPTLIB (HmacSha256.Services.SetKey, HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE);
1752 }
1753
1754 /**
1755 Makes a copy of an existing HMAC-SHA256 context.
1756
1757 If HmacSha256Context is NULL, then return FALSE.
1758 If NewHmacSha256Context is NULL, then return FALSE.
1759 If this interface is not supported, then return FALSE.
1760
1761 @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.
1762 @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.
1763
1764 @retval TRUE HMAC-SHA256 context copy succeeded.
1765 @retval FALSE HMAC-SHA256 context copy failed.
1766 @retval FALSE This interface is not supported.
1767
1768 **/
1769 BOOLEAN
1770 EFIAPI
1771 CryptoServiceHmacSha256Duplicate (
1772 IN CONST VOID *HmacSha256Context,
1773 OUT VOID *NewHmacSha256Context
1774 )
1775 {
1776 return CALL_BASECRYPTLIB (HmacSha256.Services.Duplicate, HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);
1777 }
1778
1779 /**
1780 Digests the input data and updates HMAC-SHA256 context.
1781
1782 This function performs HMAC-SHA256 digest on a data buffer of the specified size.
1783 It can be called multiple times to compute the digest of long or discontinuous data streams.
1784 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1785 by HmacSha256Final(). Behavior with invalid context is undefined.
1786
1787 If HmacSha256Context is NULL, then return FALSE.
1788 If this interface is not supported, then return FALSE.
1789
1790 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1791 @param[in] Data Pointer to the buffer containing the data to be digested.
1792 @param[in] DataSize Size of Data buffer in bytes.
1793
1794 @retval TRUE HMAC-SHA256 data digest succeeded.
1795 @retval FALSE HMAC-SHA256 data digest failed.
1796 @retval FALSE This interface is not supported.
1797
1798 **/
1799 BOOLEAN
1800 EFIAPI
1801 CryptoServiceHmacSha256Update (
1802 IN OUT VOID *HmacSha256Context,
1803 IN CONST VOID *Data,
1804 IN UINTN DataSize
1805 )
1806 {
1807 return CALL_BASECRYPTLIB (HmacSha256.Services.Update, HmacSha256Update, (HmacSha256Context, Data, DataSize), FALSE);
1808 }
1809
1810 /**
1811 Completes computation of the HMAC-SHA256 digest value.
1812
1813 This function completes HMAC-SHA256 hash computation and retrieves the digest value into
1814 the specified memory. After this function has been called, the HMAC-SHA256 context cannot
1815 be used again.
1816 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1817 by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
1818
1819 If HmacSha256Context is NULL, then return FALSE.
1820 If HmacValue is NULL, then return FALSE.
1821 If this interface is not supported, then return FALSE.
1822
1823 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1824 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
1825 value (32 bytes).
1826
1827 @retval TRUE HMAC-SHA256 digest computation succeeded.
1828 @retval FALSE HMAC-SHA256 digest computation failed.
1829 @retval FALSE This interface is not supported.
1830
1831 **/
1832 BOOLEAN
1833 EFIAPI
1834 CryptoServiceHmacSha256Final (
1835 IN OUT VOID *HmacSha256Context,
1836 OUT UINT8 *HmacValue
1837 )
1838 {
1839 return CALL_BASECRYPTLIB (HmacSha256.Services.Final, HmacSha256Final, (HmacSha256Context, HmacValue), FALSE);
1840 }
1841
1842 //=====================================================================================
1843 // Symmetric Cryptography Primitive
1844 //=====================================================================================
1845
1846 /**
1847 TDES is deprecated and unsupported any longer.
1848 Keep the function field for binary compability.
1849
1850 @retval 0 This interface is not supported.
1851
1852 **/
1853 UINTN
1854 EFIAPI
1855 DeprecatedCryptoServiceTdesGetContextSize (
1856 VOID
1857 )
1858 {
1859 return BaseCryptLibServiceDeprecated ("TdesGetContextSize"), 0;
1860 }
1861
1862 /**
1863 TDES is deprecated and unsupported any longer.
1864 Keep the function field for binary compability.
1865
1866 @param[out] TdesContext Pointer to TDES context being initialized.
1867 @param[in] Key Pointer to the user-supplied TDES key.
1868 @param[in] KeyLength Length of TDES key in bits.
1869
1870 @retval FALSE This interface is not supported.
1871
1872 **/
1873 BOOLEAN
1874 EFIAPI
1875 DeprecatedCryptoServiceTdesInit (
1876 OUT VOID *TdesContext,
1877 IN CONST UINT8 *Key,
1878 IN UINTN KeyLength
1879 )
1880 {
1881 return BaseCryptLibServiceDeprecated ("TdesInit"), FALSE;
1882 }
1883
1884 /**
1885 TDES is deprecated and unsupported any longer.
1886 Keep the function field for binary compability.
1887
1888 @param[in] TdesContext Pointer to the TDES context.
1889 @param[in] Input Pointer to the buffer containing the data to be encrypted.
1890 @param[in] InputSize Size of the Input buffer in bytes.
1891 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
1892
1893 @retval FALSE This interface is not supported.
1894
1895 **/
1896 BOOLEAN
1897 EFIAPI
1898 DeprecatedCryptoServiceTdesEcbEncrypt (
1899 IN VOID *TdesContext,
1900 IN CONST UINT8 *Input,
1901 IN UINTN InputSize,
1902 OUT UINT8 *Output
1903 )
1904 {
1905 return BaseCryptLibServiceDeprecated ("TdesEcbEncrypt"), FALSE;
1906 }
1907
1908 /**
1909 TDES is deprecated and unsupported any longer.
1910 Keep the function field for binary compability.
1911
1912 @param[in] TdesContext Pointer to the TDES context.
1913 @param[in] Input Pointer to the buffer containing the data to be decrypted.
1914 @param[in] InputSize Size of the Input buffer in bytes.
1915 @param[out] Output Pointer to a buffer that receives the TDES decryption output.
1916
1917 @retval FALSE This interface is not supported.
1918
1919 **/
1920 BOOLEAN
1921 EFIAPI
1922 DeprecatedCryptoServiceTdesEcbDecrypt (
1923 IN VOID *TdesContext,
1924 IN CONST UINT8 *Input,
1925 IN UINTN InputSize,
1926 OUT UINT8 *Output
1927 )
1928 {
1929 return BaseCryptLibServiceDeprecated ("TdesEcbDecrypt"), FALSE;
1930 }
1931
1932 /**
1933 TDES is deprecated and unsupported any longer.
1934 Keep the function field for binary compability.
1935
1936 @param[in] TdesContext Pointer to the TDES context.
1937 @param[in] Input Pointer to the buffer containing the data to be encrypted.
1938 @param[in] InputSize Size of the Input buffer in bytes.
1939 @param[in] Ivec Pointer to initialization vector.
1940 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
1941
1942 @retval FALSE This interface is not supported.
1943
1944 **/
1945 BOOLEAN
1946 EFIAPI
1947 DeprecatedCryptoServiceTdesCbcEncrypt (
1948 IN VOID *TdesContext,
1949 IN CONST UINT8 *Input,
1950 IN UINTN InputSize,
1951 IN CONST UINT8 *Ivec,
1952 OUT UINT8 *Output
1953 )
1954 {
1955 return BaseCryptLibServiceDeprecated ("TdesCbcEncrypt"), FALSE;
1956 }
1957
1958 /**
1959 TDES is deprecated and unsupported any longer.
1960 Keep the function field for binary compability.
1961
1962 @param[in] TdesContext Pointer to the TDES context.
1963 @param[in] Input Pointer to the buffer containing the data to be encrypted.
1964 @param[in] InputSize Size of the Input buffer in bytes.
1965 @param[in] Ivec Pointer to initialization vector.
1966 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
1967
1968 @retval FALSE This interface is not supported.
1969
1970 **/
1971 BOOLEAN
1972 EFIAPI
1973 DeprecatedCryptoServiceTdesCbcDecrypt (
1974 IN VOID *TdesContext,
1975 IN CONST UINT8 *Input,
1976 IN UINTN InputSize,
1977 IN CONST UINT8 *Ivec,
1978 OUT UINT8 *Output
1979 )
1980 {
1981 return BaseCryptLibServiceDeprecated ("TdesCbcDecrypt"), FALSE;
1982 }
1983
1984 /**
1985 Retrieves the size, in bytes, of the context buffer required for AES operations.
1986
1987 If this interface is not supported, then return zero.
1988
1989 @return The size, in bytes, of the context buffer required for AES operations.
1990 @retval 0 This interface is not supported.
1991
1992 **/
1993 UINTN
1994 EFIAPI
1995 CryptoServiceAesGetContextSize (
1996 VOID
1997 )
1998 {
1999 return CALL_BASECRYPTLIB (Aes.Services.GetContextSize, AesGetContextSize, (), 0);
2000 }
2001
2002 /**
2003 Initializes user-supplied memory as AES context for subsequent use.
2004
2005 This function initializes user-supplied memory pointed by AesContext as AES context.
2006 In addition, it sets up all AES key materials for subsequent encryption and decryption
2007 operations.
2008 There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
2009
2010 If AesContext is NULL, then return FALSE.
2011 If Key is NULL, then return FALSE.
2012 If KeyLength is not valid, then return FALSE.
2013 If this interface is not supported, then return FALSE.
2014
2015 @param[out] AesContext Pointer to AES context being initialized.
2016 @param[in] Key Pointer to the user-supplied AES key.
2017 @param[in] KeyLength Length of AES key in bits.
2018
2019 @retval TRUE AES context initialization succeeded.
2020 @retval FALSE AES context initialization failed.
2021 @retval FALSE This interface is not supported.
2022
2023 **/
2024 BOOLEAN
2025 EFIAPI
2026 CryptoServiceAesInit (
2027 OUT VOID *AesContext,
2028 IN CONST UINT8 *Key,
2029 IN UINTN KeyLength
2030 )
2031 {
2032 return CALL_BASECRYPTLIB (Aes.Services.Init, AesInit, (AesContext, Key, KeyLength), FALSE);
2033 }
2034
2035 /**
2036 AES ECB Mode is deprecated and unsupported any longer.
2037 Keep the function field for binary compability.
2038
2039 @param[in] AesContext Pointer to the AES context.
2040 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2041 @param[in] InputSize Size of the Input buffer in bytes.
2042 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2043
2044 @retval FALSE This interface is not supported.
2045
2046 **/
2047 BOOLEAN
2048 EFIAPI
2049 DeprecatedCryptoServiceAesEcbEncrypt (
2050 IN VOID *AesContext,
2051 IN CONST UINT8 *Input,
2052 IN UINTN InputSize,
2053 OUT UINT8 *Output
2054 )
2055 {
2056 return BaseCryptLibServiceDeprecated ("AesEcbEncrypt"), FALSE;
2057 }
2058
2059 /**
2060 AES ECB Mode is deprecated and unsupported any longer.
2061 Keep the function field for binary compability.
2062
2063 @param[in] AesContext Pointer to the AES context.
2064 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2065 @param[in] InputSize Size of the Input buffer in bytes.
2066 @param[out] Output Pointer to a buffer that receives the AES decryption output.
2067
2068 @retval FALSE This interface is not supported.
2069
2070 **/
2071 BOOLEAN
2072 EFIAPI
2073 DeprecatedCryptoServiceAesEcbDecrypt (
2074 IN VOID *AesContext,
2075 IN CONST UINT8 *Input,
2076 IN UINTN InputSize,
2077 OUT UINT8 *Output
2078 )
2079 {
2080 return BaseCryptLibServiceDeprecated ("AesEcbDecrypt"), FALSE;
2081 }
2082
2083 /**
2084 Performs AES encryption on a data buffer of the specified size in CBC mode.
2085
2086 This function performs AES encryption on data buffer pointed by Input, of specified
2087 size of InputSize, in CBC mode.
2088 InputSize must be multiple of block size (16 bytes). This function does not perform
2089 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2090 Initialization vector should be one block size (16 bytes).
2091 AesContext should be already correctly initialized by AesInit(). Behavior with
2092 invalid AES context is undefined.
2093
2094 If AesContext is NULL, then return FALSE.
2095 If Input is NULL, then return FALSE.
2096 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2097 If Ivec is NULL, then return FALSE.
2098 If Output is NULL, then return FALSE.
2099 If this interface is not supported, then return FALSE.
2100
2101 @param[in] AesContext Pointer to the AES context.
2102 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2103 @param[in] InputSize Size of the Input buffer in bytes.
2104 @param[in] Ivec Pointer to initialization vector.
2105 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2106
2107 @retval TRUE AES encryption succeeded.
2108 @retval FALSE AES encryption failed.
2109 @retval FALSE This interface is not supported.
2110
2111 **/
2112 BOOLEAN
2113 EFIAPI
2114 CryptoServiceAesCbcEncrypt (
2115 IN VOID *AesContext,
2116 IN CONST UINT8 *Input,
2117 IN UINTN InputSize,
2118 IN CONST UINT8 *Ivec,
2119 OUT UINT8 *Output
2120 )
2121 {
2122 return CALL_BASECRYPTLIB (Aes.Services.CbcEncrypt, AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2123 }
2124
2125 /**
2126 Performs AES decryption on a data buffer of the specified size in CBC mode.
2127
2128 This function performs AES decryption on data buffer pointed by Input, of specified
2129 size of InputSize, in CBC mode.
2130 InputSize must be multiple of block size (16 bytes). This function does not perform
2131 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2132 Initialization vector should be one block size (16 bytes).
2133 AesContext should be already correctly initialized by AesInit(). Behavior with
2134 invalid AES context is undefined.
2135
2136 If AesContext is NULL, then return FALSE.
2137 If Input is NULL, then return FALSE.
2138 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2139 If Ivec is NULL, then return FALSE.
2140 If Output is NULL, then return FALSE.
2141 If this interface is not supported, then return FALSE.
2142
2143 @param[in] AesContext Pointer to the AES context.
2144 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2145 @param[in] InputSize Size of the Input buffer in bytes.
2146 @param[in] Ivec Pointer to initialization vector.
2147 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2148
2149 @retval TRUE AES decryption succeeded.
2150 @retval FALSE AES decryption failed.
2151 @retval FALSE This interface is not supported.
2152
2153 **/
2154 BOOLEAN
2155 EFIAPI
2156 CryptoServiceAesCbcDecrypt (
2157 IN VOID *AesContext,
2158 IN CONST UINT8 *Input,
2159 IN UINTN InputSize,
2160 IN CONST UINT8 *Ivec,
2161 OUT UINT8 *Output
2162 )
2163 {
2164 return CALL_BASECRYPTLIB (Aes.Services.CbcDecrypt, AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2165 }
2166
2167 /**
2168 ARC4 is deprecated and unsupported any longer.
2169 Keep the function field for binary compability.
2170
2171 @retval 0 This interface is not supported.
2172
2173 **/
2174 UINTN
2175 EFIAPI
2176 DeprecatedCryptoServiceArc4GetContextSize (
2177 VOID
2178 )
2179 {
2180 return BaseCryptLibServiceDeprecated ("Arc4GetContextSize"), 0;
2181 }
2182
2183 /**
2184 ARC4 is deprecated and unsupported any longer.
2185 Keep the function field for binary compability.
2186
2187 @param[out] Arc4Context Pointer to ARC4 context being initialized.
2188 @param[in] Key Pointer to the user-supplied ARC4 key.
2189 @param[in] KeySize Size of ARC4 key in bytes.
2190
2191 @retval FALSE This interface is not supported.
2192
2193 **/
2194 BOOLEAN
2195 EFIAPI
2196 DeprecatedCryptoServiceArc4Init (
2197 OUT VOID *Arc4Context,
2198 IN CONST UINT8 *Key,
2199 IN UINTN KeySize
2200 )
2201 {
2202 return BaseCryptLibServiceDeprecated ("Arc4Init"), FALSE;
2203 }
2204
2205 /**
2206 ARC4 is deprecated and unsupported any longer.
2207 Keep the function field for binary compability.
2208
2209 @param[in, out] Arc4Context Pointer to the ARC4 context.
2210 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2211 @param[in] InputSize Size of the Input buffer in bytes.
2212 @param[out] Output Pointer to a buffer that receives the ARC4 encryption output.
2213
2214 @retval FALSE This interface is not supported.
2215
2216 **/
2217 BOOLEAN
2218 EFIAPI
2219 DeprecatedCryptoServiceArc4Encrypt (
2220 IN OUT VOID *Arc4Context,
2221 IN CONST UINT8 *Input,
2222 IN UINTN InputSize,
2223 OUT UINT8 *Output
2224 )
2225 {
2226 return BaseCryptLibServiceDeprecated ("Arc4Encrypt"), FALSE;
2227 }
2228
2229 /**
2230 ARC4 is deprecated and unsupported any longer.
2231 Keep the function field for binary compability.
2232
2233 @param[in, out] Arc4Context Pointer to the ARC4 context.
2234 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2235 @param[in] InputSize Size of the Input buffer in bytes.
2236 @param[out] Output Pointer to a buffer that receives the ARC4 decryption output.
2237
2238 @retval FALSE This interface is not supported.
2239
2240 **/
2241 BOOLEAN
2242 EFIAPI
2243 DeprecatedCryptoServiceArc4Decrypt (
2244 IN OUT VOID *Arc4Context,
2245 IN UINT8 *Input,
2246 IN UINTN InputSize,
2247 OUT UINT8 *Output
2248 )
2249 {
2250 return BaseCryptLibServiceDeprecated ("Arc4Decrypt"), FALSE;
2251 }
2252
2253 /**
2254 ARC4 is deprecated and unsupported any longer.
2255 Keep the function field for binary compability.
2256
2257 @param[in, out] Arc4Context Pointer to the ARC4 context.
2258
2259 @retval FALSE This interface is not supported.
2260
2261 **/
2262 BOOLEAN
2263 EFIAPI
2264 DeprecatedCryptoServiceArc4Reset (
2265 IN OUT VOID *Arc4Context
2266 )
2267 {
2268 return BaseCryptLibServiceDeprecated ("Arc4Reset"), FALSE;
2269 }
2270
2271 //=====================================================================================
2272 // Asymmetric Cryptography Primitive
2273 //=====================================================================================
2274
2275 /**
2276 Allocates and initializes one RSA context for subsequent use.
2277
2278 @return Pointer to the RSA context that has been initialized.
2279 If the allocations fails, RsaNew() returns NULL.
2280
2281 **/
2282 VOID *
2283 EFIAPI
2284 CryptoServiceRsaNew (
2285 VOID
2286 )
2287 {
2288 return CALL_BASECRYPTLIB (Rsa.Services.New, RsaNew, (), NULL);
2289 }
2290
2291 /**
2292 Release the specified RSA context.
2293
2294 If RsaContext is NULL, then return FALSE.
2295
2296 @param[in] RsaContext Pointer to the RSA context to be released.
2297
2298 **/
2299 VOID
2300 EFIAPI
2301 CryptoServiceRsaFree (
2302 IN VOID *RsaContext
2303 )
2304 {
2305 CALL_VOID_BASECRYPTLIB (Rsa.Services.Free, RsaFree, (RsaContext));
2306 }
2307
2308 /**
2309 Sets the tag-designated key component into the established RSA context.
2310
2311 This function sets the tag-designated RSA key component into the established
2312 RSA context from the user-specified non-negative integer (octet string format
2313 represented in RSA PKCS#1).
2314 If BigNumber is NULL, then the specified key component in RSA context is cleared.
2315
2316 If RsaContext is NULL, then return FALSE.
2317
2318 @param[in, out] RsaContext Pointer to RSA context being set.
2319 @param[in] KeyTag Tag of RSA key component being set.
2320 @param[in] BigNumber Pointer to octet integer buffer.
2321 If NULL, then the specified key component in RSA
2322 context is cleared.
2323 @param[in] BnSize Size of big number buffer in bytes.
2324 If BigNumber is NULL, then it is ignored.
2325
2326 @retval TRUE RSA key component was set successfully.
2327 @retval FALSE Invalid RSA key component tag.
2328
2329 **/
2330 BOOLEAN
2331 EFIAPI
2332 CryptoServiceRsaSetKey (
2333 IN OUT VOID *RsaContext,
2334 IN RSA_KEY_TAG KeyTag,
2335 IN CONST UINT8 *BigNumber,
2336 IN UINTN BnSize
2337 )
2338 {
2339 return CALL_BASECRYPTLIB (Rsa.Services.SetKey, RsaSetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2340 }
2341
2342 /**
2343 Gets the tag-designated RSA key component from the established RSA context.
2344
2345 This function retrieves the tag-designated RSA key component from the
2346 established RSA context as a non-negative integer (octet string format
2347 represented in RSA PKCS#1).
2348 If specified key component has not been set or has been cleared, then returned
2349 BnSize is set to 0.
2350 If the BigNumber buffer is too small to hold the contents of the key, FALSE
2351 is returned and BnSize is set to the required buffer size to obtain the key.
2352
2353 If RsaContext is NULL, then return FALSE.
2354 If BnSize is NULL, then return FALSE.
2355 If BnSize is large enough but BigNumber is NULL, then return FALSE.
2356 If this interface is not supported, then return FALSE.
2357
2358 @param[in, out] RsaContext Pointer to RSA context being set.
2359 @param[in] KeyTag Tag of RSA key component being set.
2360 @param[out] BigNumber Pointer to octet integer buffer.
2361 @param[in, out] BnSize On input, the size of big number buffer in bytes.
2362 On output, the size of data returned in big number buffer in bytes.
2363
2364 @retval TRUE RSA key component was retrieved successfully.
2365 @retval FALSE Invalid RSA key component tag.
2366 @retval FALSE BnSize is too small.
2367 @retval FALSE This interface is not supported.
2368
2369 **/
2370 BOOLEAN
2371 EFIAPI
2372 CryptoServiceRsaGetKey (
2373 IN OUT VOID *RsaContext,
2374 IN RSA_KEY_TAG KeyTag,
2375 OUT UINT8 *BigNumber,
2376 IN OUT UINTN *BnSize
2377 )
2378 {
2379 return CALL_BASECRYPTLIB (Rsa.Services.GetKey, RsaGetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2380 }
2381
2382 /**
2383 Generates RSA key components.
2384
2385 This function generates RSA key components. It takes RSA public exponent E and
2386 length in bits of RSA modulus N as input, and generates all key components.
2387 If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.
2388
2389 Before this function can be invoked, pseudorandom number generator must be correctly
2390 initialized by RandomSeed().
2391
2392 If RsaContext is NULL, then return FALSE.
2393 If this interface is not supported, then return FALSE.
2394
2395 @param[in, out] RsaContext Pointer to RSA context being set.
2396 @param[in] ModulusLength Length of RSA modulus N in bits.
2397 @param[in] PublicExponent Pointer to RSA public exponent.
2398 @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.
2399
2400 @retval TRUE RSA key component was generated successfully.
2401 @retval FALSE Invalid RSA key component tag.
2402 @retval FALSE This interface is not supported.
2403
2404 **/
2405 BOOLEAN
2406 EFIAPI
2407 CryptoServiceRsaGenerateKey (
2408 IN OUT VOID *RsaContext,
2409 IN UINTN ModulusLength,
2410 IN CONST UINT8 *PublicExponent,
2411 IN UINTN PublicExponentSize
2412 )
2413 {
2414 return CALL_BASECRYPTLIB (Rsa.Services.GenerateKey, RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE);
2415 }
2416
2417 /**
2418 Validates key components of RSA context.
2419 NOTE: This function performs integrity checks on all the RSA key material, so
2420 the RSA key structure must contain all the private key data.
2421
2422 This function validates key components of RSA context in following aspects:
2423 - Whether p is a prime
2424 - Whether q is a prime
2425 - Whether n = p * q
2426 - Whether d*e = 1 mod lcm(p-1,q-1)
2427
2428 If RsaContext is NULL, then return FALSE.
2429 If this interface is not supported, then return FALSE.
2430
2431 @param[in] RsaContext Pointer to RSA context to check.
2432
2433 @retval TRUE RSA key components are valid.
2434 @retval FALSE RSA key components are not valid.
2435 @retval FALSE This interface is not supported.
2436
2437 **/
2438 BOOLEAN
2439 EFIAPI
2440 CryptoServiceRsaCheckKey (
2441 IN VOID *RsaContext
2442 )
2443 {
2444 return CALL_BASECRYPTLIB (Rsa.Services.CheckKey, RsaCheckKey, (RsaContext), FALSE);
2445 }
2446
2447 /**
2448 Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
2449
2450 This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in
2451 RSA PKCS#1.
2452 If the Signature buffer is too small to hold the contents of signature, FALSE
2453 is returned and SigSize is set to the required buffer size to obtain the signature.
2454
2455 If RsaContext is NULL, then return FALSE.
2456 If MessageHash is NULL, then return FALSE.
2457 If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
2458 If SigSize is large enough but Signature is NULL, then return FALSE.
2459 If this interface is not supported, then return FALSE.
2460
2461 @param[in] RsaContext Pointer to RSA context for signature generation.
2462 @param[in] MessageHash Pointer to octet message hash to be signed.
2463 @param[in] HashSize Size of the message hash in bytes.
2464 @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.
2465 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
2466 On output, the size of data returned in Signature buffer in bytes.
2467
2468 @retval TRUE Signature successfully generated in PKCS1-v1_5.
2469 @retval FALSE Signature generation failed.
2470 @retval FALSE SigSize is too small.
2471 @retval FALSE This interface is not supported.
2472
2473 **/
2474 BOOLEAN
2475 EFIAPI
2476 CryptoServiceRsaPkcs1Sign (
2477 IN VOID *RsaContext,
2478 IN CONST UINT8 *MessageHash,
2479 IN UINTN HashSize,
2480 OUT UINT8 *Signature,
2481 IN OUT UINTN *SigSize
2482 )
2483 {
2484 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Sign, RsaPkcs1Sign, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2485 }
2486
2487 /**
2488 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
2489 RSA PKCS#1.
2490
2491 If RsaContext is NULL, then return FALSE.
2492 If MessageHash is NULL, then return FALSE.
2493 If Signature is NULL, then return FALSE.
2494 If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.
2495
2496 @param[in] RsaContext Pointer to RSA context for signature verification.
2497 @param[in] MessageHash Pointer to octet message hash to be checked.
2498 @param[in] HashSize Size of the message hash in bytes.
2499 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
2500 @param[in] SigSize Size of signature in bytes.
2501
2502 @retval TRUE Valid signature encoded in PKCS1-v1_5.
2503 @retval FALSE Invalid signature or invalid RSA context.
2504
2505 **/
2506 BOOLEAN
2507 EFIAPI
2508 CryptoServiceRsaPkcs1Verify (
2509 IN VOID *RsaContext,
2510 IN CONST UINT8 *MessageHash,
2511 IN UINTN HashSize,
2512 IN CONST UINT8 *Signature,
2513 IN UINTN SigSize
2514 )
2515 {
2516 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Verify, RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2517 }
2518
2519 /**
2520 Retrieve the RSA Private Key from the password-protected PEM key data.
2521
2522 If PemData is NULL, then return FALSE.
2523 If RsaContext is NULL, then return FALSE.
2524 If this interface is not supported, then return FALSE.
2525
2526 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
2527 @param[in] PemSize Size of the PEM key data in bytes.
2528 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
2529 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2530 RSA private key component. Use RsaFree() function to free the
2531 resource.
2532
2533 @retval TRUE RSA Private Key was retrieved successfully.
2534 @retval FALSE Invalid PEM key data or incorrect password.
2535 @retval FALSE This interface is not supported.
2536
2537 **/
2538 BOOLEAN
2539 EFIAPI
2540 CryptoServiceRsaGetPrivateKeyFromPem (
2541 IN CONST UINT8 *PemData,
2542 IN UINTN PemSize,
2543 IN CONST CHAR8 *Password,
2544 OUT VOID **RsaContext
2545 )
2546 {
2547 return CALL_BASECRYPTLIB (Rsa.Services.GetPrivateKeyFromPem, RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE);
2548 }
2549
2550 /**
2551 Retrieve the RSA Public Key from one DER-encoded X509 certificate.
2552
2553 If Cert is NULL, then return FALSE.
2554 If RsaContext is NULL, then return FALSE.
2555 If this interface is not supported, then return FALSE.
2556
2557 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2558 @param[in] CertSize Size of the X509 certificate in bytes.
2559 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2560 RSA public key component. Use RsaFree() function to free the
2561 resource.
2562
2563 @retval TRUE RSA Public Key was retrieved successfully.
2564 @retval FALSE Fail to retrieve RSA public key from X509 certificate.
2565 @retval FALSE This interface is not supported.
2566
2567 **/
2568 BOOLEAN
2569 EFIAPI
2570 CryptoServiceRsaGetPublicKeyFromX509 (
2571 IN CONST UINT8 *Cert,
2572 IN UINTN CertSize,
2573 OUT VOID **RsaContext
2574 )
2575 {
2576 return CALL_BASECRYPTLIB (Rsa.Services.GetPublicKeyFromX509, RsaGetPublicKeyFromX509, (Cert, CertSize, RsaContext), FALSE);
2577 }
2578
2579 /**
2580 Retrieve the subject bytes from one X.509 certificate.
2581
2582 If Cert is NULL, then return FALSE.
2583 If SubjectSize is NULL, then return FALSE.
2584 If this interface is not supported, then return FALSE.
2585
2586 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2587 @param[in] CertSize Size of the X509 certificate in bytes.
2588 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.
2589 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,
2590 and the size of buffer returned CertSubject on output.
2591
2592 @retval TRUE The certificate subject retrieved successfully.
2593 @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.
2594 The SubjectSize will be updated with the required size.
2595 @retval FALSE This interface is not supported.
2596
2597 **/
2598 BOOLEAN
2599 EFIAPI
2600 CryptoServiceX509GetSubjectName (
2601 IN CONST UINT8 *Cert,
2602 IN UINTN CertSize,
2603 OUT UINT8 *CertSubject,
2604 IN OUT UINTN *SubjectSize
2605 )
2606 {
2607 return CALL_BASECRYPTLIB (X509.Services.GetSubjectName, X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);
2608 }
2609
2610 /**
2611 Retrieve the common name (CN) string from one X.509 certificate.
2612
2613 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2614 @param[in] CertSize Size of the X509 certificate in bytes.
2615 @param[out] CommonName Buffer to contain the retrieved certificate common
2616 name string (UTF8). At most CommonNameSize bytes will be
2617 written and the string will be null terminated. May be
2618 NULL in order to determine the size buffer needed.
2619 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
2620 and the size of buffer returned CommonName on output.
2621 If CommonName is NULL then the amount of space needed
2622 in buffer (including the final null) is returned.
2623
2624 @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.
2625 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2626 If CommonNameSize is NULL.
2627 If CommonName is not NULL and *CommonNameSize is 0.
2628 If Certificate is invalid.
2629 @retval RETURN_NOT_FOUND If no CommonName entry exists.
2630 @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
2631 (including the final null) is returned in the
2632 CommonNameSize parameter.
2633 @retval RETURN_UNSUPPORTED The operation is not supported.
2634
2635 **/
2636 RETURN_STATUS
2637 EFIAPI
2638 CryptoServiceX509GetCommonName (
2639 IN CONST UINT8 *Cert,
2640 IN UINTN CertSize,
2641 OUT CHAR8 *CommonName, OPTIONAL
2642 IN OUT UINTN *CommonNameSize
2643 )
2644 {
2645 return CALL_BASECRYPTLIB (X509.Services.GetCommonName, X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED);
2646 }
2647
2648 /**
2649 Retrieve the organization name (O) string from one X.509 certificate.
2650
2651 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2652 @param[in] CertSize Size of the X509 certificate in bytes.
2653 @param[out] NameBuffer Buffer to contain the retrieved certificate organization
2654 name string. At most NameBufferSize bytes will be
2655 written and the string will be null terminated. May be
2656 NULL in order to determine the size buffer needed.
2657 @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,
2658 and the size of buffer returned Name on output.
2659 If NameBuffer is NULL then the amount of space needed
2660 in buffer (including the final null) is returned.
2661
2662 @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.
2663 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2664 If NameBufferSize is NULL.
2665 If NameBuffer is not NULL and *CommonNameSize is 0.
2666 If Certificate is invalid.
2667 @retval RETURN_NOT_FOUND If no Organization Name entry exists.
2668 @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size
2669 (including the final null) is returned in the
2670 CommonNameSize parameter.
2671 @retval RETURN_UNSUPPORTED The operation is not supported.
2672
2673 **/
2674 RETURN_STATUS
2675 EFIAPI
2676 CryptoServiceX509GetOrganizationName (
2677 IN CONST UINT8 *Cert,
2678 IN UINTN CertSize,
2679 OUT CHAR8 *NameBuffer, OPTIONAL
2680 IN OUT UINTN *NameBufferSize
2681 )
2682 {
2683 return CALL_BASECRYPTLIB (X509.Services.GetOrganizationName, X509GetOrganizationName, (Cert, CertSize, NameBuffer, NameBufferSize), RETURN_UNSUPPORTED);
2684 }
2685
2686 /**
2687 Verify one X509 certificate was issued by the trusted CA.
2688
2689 If Cert is NULL, then return FALSE.
2690 If CACert is NULL, then return FALSE.
2691 If this interface is not supported, then return FALSE.
2692
2693 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.
2694 @param[in] CertSize Size of the X509 certificate in bytes.
2695 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.
2696 @param[in] CACertSize Size of the CA Certificate in bytes.
2697
2698 @retval TRUE The certificate was issued by the trusted CA.
2699 @retval FALSE Invalid certificate or the certificate was not issued by the given
2700 trusted CA.
2701 @retval FALSE This interface is not supported.
2702
2703 **/
2704 BOOLEAN
2705 EFIAPI
2706 CryptoServiceX509VerifyCert (
2707 IN CONST UINT8 *Cert,
2708 IN UINTN CertSize,
2709 IN CONST UINT8 *CACert,
2710 IN UINTN CACertSize
2711 )
2712 {
2713 return CALL_BASECRYPTLIB (X509.Services.VerifyCert, X509VerifyCert, (Cert, CertSize, CACert, CACertSize), FALSE);
2714 }
2715
2716 /**
2717 Construct a X509 object from DER-encoded certificate data.
2718
2719 If Cert is NULL, then return FALSE.
2720 If SingleX509Cert is NULL, then return FALSE.
2721 If this interface is not supported, then return FALSE.
2722
2723 @param[in] Cert Pointer to the DER-encoded certificate data.
2724 @param[in] CertSize The size of certificate data in bytes.
2725 @param[out] SingleX509Cert The generated X509 object.
2726
2727 @retval TRUE The X509 object generation succeeded.
2728 @retval FALSE The operation failed.
2729 @retval FALSE This interface is not supported.
2730
2731 **/
2732 BOOLEAN
2733 EFIAPI
2734 CryptoServiceX509ConstructCertificate (
2735 IN CONST UINT8 *Cert,
2736 IN UINTN CertSize,
2737 OUT UINT8 **SingleX509Cert
2738 )
2739 {
2740 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificate, X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE);
2741 }
2742
2743 /**
2744 Construct a X509 stack object from a list of DER-encoded certificate data.
2745
2746 If X509Stack is NULL, then return FALSE.
2747 If this interface is not supported, then return FALSE.
2748
2749 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2750 On output, pointer to the X509 stack object with new
2751 inserted X509 certificate.
2752 @param[in] Args VA_LIST marker for the variable argument list.
2753 A list of DER-encoded single certificate data followed
2754 by certificate size. A NULL terminates the list. The
2755 pairs are the arguments to X509ConstructCertificate().
2756
2757 @retval TRUE The X509 stack construction succeeded.
2758 @retval FALSE The construction operation failed.
2759 @retval FALSE This interface is not supported.
2760
2761 **/
2762 BOOLEAN
2763 EFIAPI
2764 CryptoServiceX509ConstructCertificateStackV (
2765 IN OUT UINT8 **X509Stack,
2766 IN VA_LIST Args
2767 )
2768 {
2769 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificateStackV, X509ConstructCertificateStackV, (X509Stack, Args), FALSE);
2770 }
2771
2772 /**
2773 Construct a X509 stack object from a list of DER-encoded certificate data.
2774
2775 If X509Stack is NULL, then return FALSE.
2776 If this interface is not supported, then return FALSE.
2777
2778 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2779 On output, pointer to the X509 stack object with new
2780 inserted X509 certificate.
2781 @param ... A list of DER-encoded single certificate data followed
2782 by certificate size. A NULL terminates the list. The
2783 pairs are the arguments to X509ConstructCertificate().
2784
2785 @retval TRUE The X509 stack construction succeeded.
2786 @retval FALSE The construction operation failed.
2787 @retval FALSE This interface is not supported.
2788
2789 **/
2790 BOOLEAN
2791 EFIAPI
2792 CryptoServiceX509ConstructCertificateStack (
2793 IN OUT UINT8 **X509Stack,
2794 ...
2795 )
2796 {
2797 VA_LIST Args;
2798 BOOLEAN Result;
2799
2800 VA_START (Args, X509Stack);
2801 Result = CryptoServiceX509ConstructCertificateStackV (X509Stack, Args);
2802 VA_END (Args);
2803 return Result;
2804 }
2805
2806 /**
2807 Release the specified X509 object.
2808
2809 If the interface is not supported, then ASSERT().
2810
2811 @param[in] X509Cert Pointer to the X509 object to be released.
2812
2813 **/
2814 VOID
2815 EFIAPI
2816 CryptoServiceX509Free (
2817 IN VOID *X509Cert
2818 )
2819 {
2820 CALL_VOID_BASECRYPTLIB (X509.Services.Free, X509Free, (X509Cert));
2821 }
2822
2823 /**
2824 Release the specified X509 stack object.
2825
2826 If the interface is not supported, then ASSERT().
2827
2828 @param[in] X509Stack Pointer to the X509 stack object to be released.
2829
2830 **/
2831 VOID
2832 EFIAPI
2833 CryptoServiceX509StackFree (
2834 IN VOID *X509Stack
2835 )
2836 {
2837 CALL_VOID_BASECRYPTLIB (X509.Services.StackFree, X509StackFree, (X509Stack));
2838 }
2839
2840 /**
2841 Retrieve the TBSCertificate from one given X.509 certificate.
2842
2843 @param[in] Cert Pointer to the given DER-encoded X509 certificate.
2844 @param[in] CertSize Size of the X509 certificate in bytes.
2845 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.
2846 @param[out] TBSCertSize Size of the TBS certificate in bytes.
2847
2848 If Cert is NULL, then return FALSE.
2849 If TBSCert is NULL, then return FALSE.
2850 If TBSCertSize is NULL, then return FALSE.
2851 If this interface is not supported, then return FALSE.
2852
2853 @retval TRUE The TBSCertificate was retrieved successfully.
2854 @retval FALSE Invalid X.509 certificate.
2855
2856 **/
2857 BOOLEAN
2858 EFIAPI
2859 CryptoServiceX509GetTBSCert (
2860 IN CONST UINT8 *Cert,
2861 IN UINTN CertSize,
2862 OUT UINT8 **TBSCert,
2863 OUT UINTN *TBSCertSize
2864 )
2865 {
2866 return CALL_BASECRYPTLIB (X509.Services.GetTBSCert, X509GetTBSCert, (Cert, CertSize, TBSCert, TBSCertSize), FALSE);
2867 }
2868
2869 /**
2870 Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0
2871 password based encryption key derivation function PBKDF2, as specified in RFC 2898.
2872
2873 If Password or Salt or OutKey is NULL, then return FALSE.
2874 If the hash algorithm could not be determined, then return FALSE.
2875 If this interface is not supported, then return FALSE.
2876
2877 @param[in] PasswordLength Length of input password in bytes.
2878 @param[in] Password Pointer to the array for the password.
2879 @param[in] SaltLength Size of the Salt in bytes.
2880 @param[in] Salt Pointer to the Salt.
2881 @param[in] IterationCount Number of iterations to perform. Its value should be
2882 greater than or equal to 1.
2883 @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).
2884 NOTE: DigestSize will be used to determine the hash algorithm.
2885 Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.
2886 @param[in] KeyLength Size of the derived key buffer in bytes.
2887 @param[out] OutKey Pointer to the output derived key buffer.
2888
2889 @retval TRUE A key was derived successfully.
2890 @retval FALSE One of the pointers was NULL or one of the sizes was too large.
2891 @retval FALSE The hash algorithm could not be determined from the digest size.
2892 @retval FALSE The key derivation operation failed.
2893 @retval FALSE This interface is not supported.
2894
2895 **/
2896 BOOLEAN
2897 EFIAPI
2898 CryptoServicePkcs5HashPassword (
2899 IN UINTN PasswordLength,
2900 IN CONST CHAR8 *Password,
2901 IN UINTN SaltLength,
2902 IN CONST UINT8 *Salt,
2903 IN UINTN IterationCount,
2904 IN UINTN DigestSize,
2905 IN UINTN KeyLength,
2906 OUT UINT8 *OutKey
2907 )
2908 {
2909 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);
2910 }
2911
2912 /**
2913 Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
2914 encrypted message in a newly allocated buffer.
2915
2916 Things that can cause a failure include:
2917 - X509 key size does not match any known key size.
2918 - Fail to parse X509 certificate.
2919 - Fail to allocate an intermediate buffer.
2920 - Null pointer provided for a non-optional parameter.
2921 - Data size is too large for the provided key size (max size is a function of key size
2922 and hash digest size).
2923
2924 @param[in] PublicKey A pointer to the DER-encoded X509 certificate that
2925 will be used to encrypt the data.
2926 @param[in] PublicKeySize Size of the X509 cert buffer.
2927 @param[in] InData Data to be encrypted.
2928 @param[in] InDataSize Size of the data buffer.
2929 @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer
2930 to be used when initializing the PRNG. NULL otherwise.
2931 @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.
2932 0 otherwise.
2933 @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted
2934 message.
2935 @param[out] EncryptedDataSize Size of the encrypted message buffer.
2936
2937 @retval TRUE Encryption was successful.
2938 @retval FALSE Encryption failed.
2939
2940 **/
2941 BOOLEAN
2942 EFIAPI
2943 CryptoServicePkcs1v2Encrypt (
2944 IN CONST UINT8 *PublicKey,
2945 IN UINTN PublicKeySize,
2946 IN UINT8 *InData,
2947 IN UINTN InDataSize,
2948 IN CONST UINT8 *PrngSeed, OPTIONAL
2949 IN UINTN PrngSeedSize, OPTIONAL
2950 OUT UINT8 **EncryptedData,
2951 OUT UINTN *EncryptedDataSize
2952 )
2953 {
2954 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Encrypt, Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);
2955 }
2956
2957 /**
2958 Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:
2959 Cryptographic Message Syntax Standard". The input signed data could be wrapped
2960 in a ContentInfo structure.
2961
2962 If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then
2963 return FALSE. If P7Length overflow, then return FALSE.
2964 If this interface is not supported, then return FALSE.
2965
2966 @param[in] P7Data Pointer to the PKCS#7 message to verify.
2967 @param[in] P7Length Length of the PKCS#7 message in bytes.
2968 @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.
2969 It's caller's responsibility to free the buffer with
2970 Pkcs7FreeSigners().
2971 This data structure is EFI_CERT_STACK type.
2972 @param[out] StackLength Length of signer's certificates in bytes.
2973 @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.
2974 It's caller's responsibility to free the buffer with
2975 Pkcs7FreeSigners().
2976 @param[out] CertLength Length of the trusted certificate in bytes.
2977
2978 @retval TRUE The operation is finished successfully.
2979 @retval FALSE Error occurs during the operation.
2980 @retval FALSE This interface is not supported.
2981
2982 **/
2983 BOOLEAN
2984 EFIAPI
2985 CryptoServicePkcs7GetSigners (
2986 IN CONST UINT8 *P7Data,
2987 IN UINTN P7Length,
2988 OUT UINT8 **CertStack,
2989 OUT UINTN *StackLength,
2990 OUT UINT8 **TrustedCert,
2991 OUT UINTN *CertLength
2992 )
2993 {
2994 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetSigners, Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);
2995 }
2996
2997 /**
2998 Wrap function to use free() to free allocated memory for certificates.
2999
3000 If this interface is not supported, then ASSERT().
3001
3002 @param[in] Certs Pointer to the certificates to be freed.
3003
3004 **/
3005 VOID
3006 EFIAPI
3007 CryptoServicePkcs7FreeSigners (
3008 IN UINT8 *Certs
3009 )
3010 {
3011 CALL_VOID_BASECRYPTLIB (Pkcs.Services.Pkcs7FreeSigners, Pkcs7FreeSigners, (Certs));
3012 }
3013
3014 /**
3015 Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:
3016 Cryptographic Message Syntax Standard", and outputs two certificate lists chained and
3017 unchained to the signer's certificates.
3018 The input signed data could be wrapped in a ContentInfo structure.
3019
3020 @param[in] P7Data Pointer to the PKCS#7 message.
3021 @param[in] P7Length Length of the PKCS#7 message in bytes.
3022 @param[out] SignerChainCerts Pointer to the certificates list chained to signer's
3023 certificate. It's caller's responsibility to free the buffer
3024 with Pkcs7FreeSigners().
3025 This data structure is EFI_CERT_STACK type.
3026 @param[out] ChainLength Length of the chained certificates list buffer in bytes.
3027 @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's
3028 responsibility to free the buffer with Pkcs7FreeSigners().
3029 This data structure is EFI_CERT_STACK type.
3030 @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.
3031
3032 @retval TRUE The operation is finished successfully.
3033 @retval FALSE Error occurs during the operation.
3034
3035 **/
3036 BOOLEAN
3037 EFIAPI
3038 CryptoServicePkcs7GetCertificatesList (
3039 IN CONST UINT8 *P7Data,
3040 IN UINTN P7Length,
3041 OUT UINT8 **SignerChainCerts,
3042 OUT UINTN *ChainLength,
3043 OUT UINT8 **UnchainCerts,
3044 OUT UINTN *UnchainLength
3045 )
3046 {
3047 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetCertificatesList, Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);
3048 }
3049
3050 /**
3051 Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message
3052 Syntax Standard, version 1.5". This interface is only intended to be used for
3053 application to perform PKCS#7 functionality validation.
3054
3055 If this interface is not supported, then return FALSE.
3056
3057 @param[in] PrivateKey Pointer to the PEM-formatted private key data for
3058 data signing.
3059 @param[in] PrivateKeySize Size of the PEM private key data in bytes.
3060 @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM
3061 key data.
3062 @param[in] InData Pointer to the content to be signed.
3063 @param[in] InDataSize Size of InData in bytes.
3064 @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.
3065 @param[in] OtherCerts Pointer to an optional additional set of certificates to
3066 include in the PKCS#7 signedData (e.g. any intermediate
3067 CAs in the chain).
3068 @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's
3069 responsibility to free the buffer with FreePool().
3070 @param[out] SignedDataSize Size of SignedData in bytes.
3071
3072 @retval TRUE PKCS#7 data signing succeeded.
3073 @retval FALSE PKCS#7 data signing failed.
3074 @retval FALSE This interface is not supported.
3075
3076 **/
3077 BOOLEAN
3078 EFIAPI
3079 CryptoServicePkcs7Sign (
3080 IN CONST UINT8 *PrivateKey,
3081 IN UINTN PrivateKeySize,
3082 IN CONST UINT8 *KeyPassword,
3083 IN UINT8 *InData,
3084 IN UINTN InDataSize,
3085 IN UINT8 *SignCert,
3086 IN UINT8 *OtherCerts OPTIONAL,
3087 OUT UINT8 **SignedData,
3088 OUT UINTN *SignedDataSize
3089 )
3090 {
3091 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Sign, Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);
3092 }
3093
3094 /**
3095 Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:
3096 Cryptographic Message Syntax Standard". The input signed data could be wrapped
3097 in a ContentInfo structure.
3098
3099 If P7Data, TrustedCert or InData is NULL, then return FALSE.
3100 If P7Length, CertLength or DataLength overflow, then return FALSE.
3101 If this interface is not supported, then return FALSE.
3102
3103 @param[in] P7Data Pointer to the PKCS#7 message to verify.
3104 @param[in] P7Length Length of the PKCS#7 message in bytes.
3105 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3106 is used for certificate chain verification.
3107 @param[in] CertLength Length of the trusted certificate in bytes.
3108 @param[in] InData Pointer to the content to be verified.
3109 @param[in] DataLength Length of InData in bytes.
3110
3111 @retval TRUE The specified PKCS#7 signed data is valid.
3112 @retval FALSE Invalid PKCS#7 signed data.
3113 @retval FALSE This interface is not supported.
3114
3115 **/
3116 BOOLEAN
3117 EFIAPI
3118 CryptoServicePkcs7Verify (
3119 IN CONST UINT8 *P7Data,
3120 IN UINTN P7Length,
3121 IN CONST UINT8 *TrustedCert,
3122 IN UINTN CertLength,
3123 IN CONST UINT8 *InData,
3124 IN UINTN DataLength
3125 )
3126 {
3127 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Verify, Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);
3128 }
3129
3130 /**
3131 This function receives a PKCS7 formatted signature, and then verifies that
3132 the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity
3133 leaf signing certificate.
3134 Note that this function does not validate the certificate chain.
3135
3136 Applications for custom EKU's are quite flexible. For example, a policy EKU
3137 may be present in an Issuing Certificate Authority (CA), and any sub-ordinate
3138 certificate issued might also contain this EKU, thus constraining the
3139 sub-ordinate certificate. Other applications might allow a certificate
3140 embedded in a device to specify that other Object Identifiers (OIDs) are
3141 present which contains binary data specifying custom capabilities that
3142 the device is able to do.
3143
3144 @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array
3145 containing the content block with both the signature,
3146 the signer's certificate, and any necessary intermediate
3147 certificates.
3148 @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.
3149 @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of
3150 required EKUs that must be present in the signature.
3151 @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.
3152 @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's
3153 must be present in the leaf signer. If it is
3154 FALSE, then we will succeed if we find any
3155 of the specified EKU's.
3156
3157 @retval EFI_SUCCESS The required EKUs were found in the signature.
3158 @retval EFI_INVALID_PARAMETER A parameter was invalid.
3159 @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.
3160
3161 **/
3162 RETURN_STATUS
3163 EFIAPI
3164 CryptoServiceVerifyEKUsInPkcs7Signature (
3165 IN CONST UINT8 *Pkcs7Signature,
3166 IN CONST UINT32 SignatureSize,
3167 IN CONST CHAR8 *RequiredEKUs[],
3168 IN CONST UINT32 RequiredEKUsSize,
3169 IN BOOLEAN RequireAllPresent
3170 )
3171 {
3172 return CALL_BASECRYPTLIB (Pkcs.Services.VerifyEKUsInPkcs7Signature, VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);
3173 }
3174
3175
3176 /**
3177 Extracts the attached content from a PKCS#7 signed data if existed. The input signed
3178 data could be wrapped in a ContentInfo structure.
3179
3180 If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,
3181 then return FALSE. If the P7Data is not correctly formatted, then return FALSE.
3182
3183 Caution: This function may receive untrusted input. So this function will do
3184 basic check for PKCS#7 data structure.
3185
3186 @param[in] P7Data Pointer to the PKCS#7 signed data to process.
3187 @param[in] P7Length Length of the PKCS#7 signed data in bytes.
3188 @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.
3189 It's caller's responsibility to free the buffer with FreePool().
3190 @param[out] ContentSize The size of the extracted content in bytes.
3191
3192 @retval TRUE The P7Data was correctly formatted for processing.
3193 @retval FALSE The P7Data was not correctly formatted for processing.
3194
3195 **/
3196 BOOLEAN
3197 EFIAPI
3198 CryptoServicePkcs7GetAttachedContent (
3199 IN CONST UINT8 *P7Data,
3200 IN UINTN P7Length,
3201 OUT VOID **Content,
3202 OUT UINTN *ContentSize
3203 )
3204 {
3205 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);
3206 }
3207
3208 /**
3209 Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows
3210 Authenticode Portable Executable Signature Format".
3211
3212 If AuthData is NULL, then return FALSE.
3213 If ImageHash is NULL, then return FALSE.
3214 If this interface is not supported, then return FALSE.
3215
3216 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
3217 PE/COFF image to be verified.
3218 @param[in] DataSize Size of the Authenticode Signature in bytes.
3219 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3220 is used for certificate chain verification.
3221 @param[in] CertSize Size of the trusted certificate in bytes.
3222 @param[in] ImageHash Pointer to the original image file hash value. The procedure
3223 for calculating the image hash value is described in Authenticode
3224 specification.
3225 @param[in] HashSize Size of Image hash value in bytes.
3226
3227 @retval TRUE The specified Authenticode Signature is valid.
3228 @retval FALSE Invalid Authenticode Signature.
3229 @retval FALSE This interface is not supported.
3230
3231 **/
3232 BOOLEAN
3233 EFIAPI
3234 CryptoServiceAuthenticodeVerify (
3235 IN CONST UINT8 *AuthData,
3236 IN UINTN DataSize,
3237 IN CONST UINT8 *TrustedCert,
3238 IN UINTN CertSize,
3239 IN CONST UINT8 *ImageHash,
3240 IN UINTN HashSize
3241 )
3242 {
3243 return CALL_BASECRYPTLIB (Pkcs.Services.AuthenticodeVerify, AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);
3244 }
3245
3246 /**
3247 Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode
3248 signature.
3249
3250 If AuthData is NULL, then return FALSE.
3251 If this interface is not supported, then return FALSE.
3252
3253 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
3254 PE/COFF image to be verified.
3255 @param[in] DataSize Size of the Authenticode Signature in bytes.
3256 @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which
3257 is used for TSA certificate chain verification.
3258 @param[in] CertSize Size of the trusted certificate in bytes.
3259 @param[out] SigningTime Return the time of timestamp generation time if the timestamp
3260 signature is valid.
3261
3262 @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.
3263 @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.
3264
3265 **/
3266 BOOLEAN
3267 EFIAPI
3268 CryptoServiceImageTimestampVerify (
3269 IN CONST UINT8 *AuthData,
3270 IN UINTN DataSize,
3271 IN CONST UINT8 *TsaCert,
3272 IN UINTN CertSize,
3273 OUT EFI_TIME *SigningTime
3274 )
3275 {
3276 return CALL_BASECRYPTLIB (Pkcs.Services.ImageTimestampVerify, ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);
3277 }
3278
3279 //=====================================================================================
3280 // DH Key Exchange Primitive
3281 //=====================================================================================
3282
3283 /**
3284 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
3285
3286 @return Pointer to the Diffie-Hellman Context that has been initialized.
3287 If the allocations fails, DhNew() returns NULL.
3288 If the interface is not supported, DhNew() returns NULL.
3289
3290 **/
3291 VOID *
3292 EFIAPI
3293 CryptoServiceDhNew (
3294 VOID
3295 )
3296 {
3297 return CALL_BASECRYPTLIB (Dh.Services.New, DhNew, (), NULL);
3298 }
3299
3300 /**
3301 Release the specified DH context.
3302
3303 If the interface is not supported, then ASSERT().
3304
3305 @param[in] DhContext Pointer to the DH context to be released.
3306
3307 **/
3308 VOID
3309 EFIAPI
3310 CryptoServiceDhFree (
3311 IN VOID *DhContext
3312 )
3313 {
3314 CALL_VOID_BASECRYPTLIB (Dh.Services.Free, DhFree, (DhContext));
3315 }
3316
3317 /**
3318 Generates DH parameter.
3319
3320 Given generator g, and length of prime number p in bits, this function generates p,
3321 and sets DH context according to value of g and p.
3322
3323 Before this function can be invoked, pseudorandom number generator must be correctly
3324 initialized by RandomSeed().
3325
3326 If DhContext is NULL, then return FALSE.
3327 If Prime is NULL, then return FALSE.
3328 If this interface is not supported, then return FALSE.
3329
3330 @param[in, out] DhContext Pointer to the DH context.
3331 @param[in] Generator Value of generator.
3332 @param[in] PrimeLength Length in bits of prime to be generated.
3333 @param[out] Prime Pointer to the buffer to receive the generated prime number.
3334
3335 @retval TRUE DH parameter generation succeeded.
3336 @retval FALSE Value of Generator is not supported.
3337 @retval FALSE PRNG fails to generate random prime number with PrimeLength.
3338 @retval FALSE This interface is not supported.
3339
3340 **/
3341 BOOLEAN
3342 EFIAPI
3343 CryptoServiceDhGenerateParameter (
3344 IN OUT VOID *DhContext,
3345 IN UINTN Generator,
3346 IN UINTN PrimeLength,
3347 OUT UINT8 *Prime
3348 )
3349 {
3350 return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
3351 }
3352
3353 /**
3354 Sets generator and prime parameters for DH.
3355
3356 Given generator g, and prime number p, this function and sets DH
3357 context accordingly.
3358
3359 If DhContext is NULL, then return FALSE.
3360 If Prime is NULL, then return FALSE.
3361 If this interface is not supported, then return FALSE.
3362
3363 @param[in, out] DhContext Pointer to the DH context.
3364 @param[in] Generator Value of generator.
3365 @param[in] PrimeLength Length in bits of prime to be generated.
3366 @param[in] Prime Pointer to the prime number.
3367
3368 @retval TRUE DH parameter setting succeeded.
3369 @retval FALSE Value of Generator is not supported.
3370 @retval FALSE Value of Generator is not suitable for the Prime.
3371 @retval FALSE Value of Prime is not a prime number.
3372 @retval FALSE Value of Prime is not a safe prime number.
3373 @retval FALSE This interface is not supported.
3374
3375 **/
3376 BOOLEAN
3377 EFIAPI
3378 CryptoServiceDhSetParameter (
3379 IN OUT VOID *DhContext,
3380 IN UINTN Generator,
3381 IN UINTN PrimeLength,
3382 IN CONST UINT8 *Prime
3383 )
3384 {
3385 return CALL_BASECRYPTLIB (Dh.Services.SetParameter, DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
3386 }
3387
3388 /**
3389 Generates DH public key.
3390
3391 This function generates random secret exponent, and computes the public key, which is
3392 returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.
3393 If the PublicKey buffer is too small to hold the public key, FALSE is returned and
3394 PublicKeySize is set to the required buffer size to obtain the public key.
3395
3396 If DhContext is NULL, then return FALSE.
3397 If PublicKeySize is NULL, then return FALSE.
3398 If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.
3399 If this interface is not supported, then return FALSE.
3400
3401 @param[in, out] DhContext Pointer to the DH context.
3402 @param[out] PublicKey Pointer to the buffer to receive generated public key.
3403 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
3404 On output, the size of data returned in PublicKey buffer in bytes.
3405
3406 @retval TRUE DH public key generation succeeded.
3407 @retval FALSE DH public key generation failed.
3408 @retval FALSE PublicKeySize is not large enough.
3409 @retval FALSE This interface is not supported.
3410
3411 **/
3412 BOOLEAN
3413 EFIAPI
3414 CryptoServiceDhGenerateKey (
3415 IN OUT VOID *DhContext,
3416 OUT UINT8 *PublicKey,
3417 IN OUT UINTN *PublicKeySize
3418 )
3419 {
3420 return CALL_BASECRYPTLIB (Dh.Services.GenerateKey, DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);
3421 }
3422
3423 /**
3424 Computes exchanged common key.
3425
3426 Given peer's public key, this function computes the exchanged common key, based on its own
3427 context including value of prime modulus and random secret exponent.
3428
3429 If DhContext is NULL, then return FALSE.
3430 If PeerPublicKey is NULL, then return FALSE.
3431 If KeySize is NULL, then return FALSE.
3432 If Key is NULL, then return FALSE.
3433 If KeySize is not large enough, then return FALSE.
3434 If this interface is not supported, then return FALSE.
3435
3436 @param[in, out] DhContext Pointer to the DH context.
3437 @param[in] PeerPublicKey Pointer to the peer's public key.
3438 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
3439 @param[out] Key Pointer to the buffer to receive generated key.
3440 @param[in, out] KeySize On input, the size of Key buffer in bytes.
3441 On output, the size of data returned in Key buffer in bytes.
3442
3443 @retval TRUE DH exchanged key generation succeeded.
3444 @retval FALSE DH exchanged key generation failed.
3445 @retval FALSE KeySize is not large enough.
3446 @retval FALSE This interface is not supported.
3447
3448 **/
3449 BOOLEAN
3450 EFIAPI
3451 CryptoServiceDhComputeKey (
3452 IN OUT VOID *DhContext,
3453 IN CONST UINT8 *PeerPublicKey,
3454 IN UINTN PeerPublicKeySize,
3455 OUT UINT8 *Key,
3456 IN OUT UINTN *KeySize
3457 )
3458 {
3459 return CALL_BASECRYPTLIB (Dh.Services.ComputeKey, DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);
3460 }
3461
3462 //=====================================================================================
3463 // Pseudo-Random Generation Primitive
3464 //=====================================================================================
3465
3466 /**
3467 Sets up the seed value for the pseudorandom number generator.
3468
3469 This function sets up the seed value for the pseudorandom number generator.
3470 If Seed is not NULL, then the seed passed in is used.
3471 If Seed is NULL, then default seed is used.
3472 If this interface is not supported, then return FALSE.
3473
3474 @param[in] Seed Pointer to seed value.
3475 If NULL, default seed is used.
3476 @param[in] SeedSize Size of seed value.
3477 If Seed is NULL, this parameter is ignored.
3478
3479 @retval TRUE Pseudorandom number generator has enough entropy for random generation.
3480 @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.
3481 @retval FALSE This interface is not supported.
3482
3483 **/
3484 BOOLEAN
3485 EFIAPI
3486 CryptoServiceRandomSeed (
3487 IN CONST UINT8 *Seed OPTIONAL,
3488 IN UINTN SeedSize
3489 )
3490 {
3491 return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);
3492 }
3493
3494 /**
3495 Generates a pseudorandom byte stream of the specified size.
3496
3497 If Output is NULL, then return FALSE.
3498 If this interface is not supported, then return FALSE.
3499
3500 @param[out] Output Pointer to buffer to receive random value.
3501 @param[in] Size Size of random bytes to generate.
3502
3503 @retval TRUE Pseudorandom byte stream generated successfully.
3504 @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.
3505 @retval FALSE This interface is not supported.
3506
3507 **/
3508 BOOLEAN
3509 EFIAPI
3510 CryptoServiceRandomBytes (
3511 OUT UINT8 *Output,
3512 IN UINTN Size
3513 )
3514 {
3515 return CALL_BASECRYPTLIB (Random.Services.Bytes, RandomBytes, (Output, Size), FALSE);
3516 }
3517
3518 //=====================================================================================
3519 // Key Derivation Function Primitive
3520 //=====================================================================================
3521
3522 /**
3523 Derive key data using HMAC-SHA256 based KDF.
3524
3525 @param[in] Key Pointer to the user-supplied key.
3526 @param[in] KeySize Key size in bytes.
3527 @param[in] Salt Pointer to the salt(non-secret) value.
3528 @param[in] SaltSize Salt size in bytes.
3529 @param[in] Info Pointer to the application specific info.
3530 @param[in] InfoSize Info size in bytes.
3531 @param[out] Out Pointer to buffer to receive hkdf value.
3532 @param[in] OutSize Size of hkdf bytes to generate.
3533
3534 @retval TRUE Hkdf generated successfully.
3535 @retval FALSE Hkdf generation failed.
3536
3537 **/
3538 BOOLEAN
3539 EFIAPI
3540 CryptoServiceHkdfSha256ExtractAndExpand (
3541 IN CONST UINT8 *Key,
3542 IN UINTN KeySize,
3543 IN CONST UINT8 *Salt,
3544 IN UINTN SaltSize,
3545 IN CONST UINT8 *Info,
3546 IN UINTN InfoSize,
3547 OUT UINT8 *Out,
3548 IN UINTN OutSize
3549 )
3550 {
3551 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256ExtractAndExpand, HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
3552 }
3553
3554 /**
3555 Initializes the OpenSSL library.
3556
3557 This function registers ciphers and digests used directly and indirectly
3558 by SSL/TLS, and initializes the readable error messages.
3559 This function must be called before any other action takes places.
3560
3561 @retval TRUE The OpenSSL library has been initialized.
3562 @retval FALSE Failed to initialize the OpenSSL library.
3563
3564 **/
3565 BOOLEAN
3566 EFIAPI
3567 CryptoServiceTlsInitialize (
3568 VOID
3569 )
3570 {
3571 return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE);
3572 }
3573
3574 /**
3575 Free an allocated SSL_CTX object.
3576
3577 @param[in] TlsCtx Pointer to the SSL_CTX object to be released.
3578
3579 **/
3580 VOID
3581 EFIAPI
3582 CryptoServiceTlsCtxFree (
3583 IN VOID *TlsCtx
3584 )
3585 {
3586 CALL_VOID_BASECRYPTLIB (Tls.Services.CtxFree, TlsCtxFree, (TlsCtx));
3587 }
3588
3589 /**
3590 Creates a new SSL_CTX object as framework to establish TLS/SSL enabled
3591 connections.
3592
3593 @param[in] MajorVer Major Version of TLS/SSL Protocol.
3594 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
3595
3596 @return Pointer to an allocated SSL_CTX object.
3597 If the creation failed, TlsCtxNew() returns NULL.
3598
3599 **/
3600 VOID *
3601 EFIAPI
3602 CryptoServiceTlsCtxNew (
3603 IN UINT8 MajorVer,
3604 IN UINT8 MinorVer
3605 )
3606 {
3607 return CALL_BASECRYPTLIB (Tls.Services.CtxNew, TlsCtxNew, (MajorVer, MinorVer), NULL);
3608 }
3609
3610 /**
3611 Free an allocated TLS object.
3612
3613 This function removes the TLS object pointed to by Tls and frees up the
3614 allocated memory. If Tls is NULL, nothing is done.
3615
3616 @param[in] Tls Pointer to the TLS object to be freed.
3617
3618 **/
3619 VOID
3620 EFIAPI
3621 CryptoServiceTlsFree (
3622 IN VOID *Tls
3623 )
3624 {
3625 CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls));
3626 }
3627
3628 /**
3629 Create a new TLS object for a connection.
3630
3631 This function creates a new TLS object for a connection. The new object
3632 inherits the setting of the underlying context TlsCtx: connection method,
3633 options, verification setting.
3634
3635 @param[in] TlsCtx Pointer to the SSL_CTX object.
3636
3637 @return Pointer to an allocated SSL object.
3638 If the creation failed, TlsNew() returns NULL.
3639
3640 **/
3641 VOID *
3642 EFIAPI
3643 CryptoServiceTlsNew (
3644 IN VOID *TlsCtx
3645 )
3646 {
3647 return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);
3648 }
3649
3650 /**
3651 Checks if the TLS handshake was done.
3652
3653 This function will check if the specified TLS handshake was done.
3654
3655 @param[in] Tls Pointer to the TLS object for handshake state checking.
3656
3657 @retval TRUE The TLS handshake was done.
3658 @retval FALSE The TLS handshake was not done.
3659
3660 **/
3661 BOOLEAN
3662 EFIAPI
3663 CryptoServiceTlsInHandshake (
3664 IN VOID *Tls
3665 )
3666 {
3667 return CALL_BASECRYPTLIB (Tls.Services.InHandshake, TlsInHandshake, (Tls), FALSE);
3668 }
3669
3670 /**
3671 Perform a TLS/SSL handshake.
3672
3673 This function will perform a TLS/SSL handshake.
3674
3675 @param[in] Tls Pointer to the TLS object for handshake operation.
3676 @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
3677 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
3678 Handshake packet.
3679 @param[out] BufferOut Pointer to the buffer to hold the built packet.
3680 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
3681 the buffer size provided by the caller. On output, it
3682 is the buffer size in fact needed to contain the
3683 packet.
3684
3685 @retval EFI_SUCCESS The required TLS packet is built successfully.
3686 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
3687 Tls is NULL.
3688 BufferIn is NULL but BufferInSize is NOT 0.
3689 BufferInSize is 0 but BufferIn is NOT NULL.
3690 BufferOutSize is NULL.
3691 BufferOut is NULL if *BufferOutSize is not zero.
3692 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
3693 @retval EFI_ABORTED Something wrong during handshake.
3694
3695 **/
3696 EFI_STATUS
3697 EFIAPI
3698 CryptoServiceTlsDoHandshake (
3699 IN VOID *Tls,
3700 IN UINT8 *BufferIn, OPTIONAL
3701 IN UINTN BufferInSize, OPTIONAL
3702 OUT UINT8 *BufferOut, OPTIONAL
3703 IN OUT UINTN *BufferOutSize
3704 )
3705 {
3706 return CALL_BASECRYPTLIB (Tls.Services.DoHandshake, TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
3707 }
3708
3709 /**
3710 Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
3711 TLS session has errors and the response packet needs to be Alert message based on error type.
3712
3713 @param[in] Tls Pointer to the TLS object for state checking.
3714 @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
3715 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
3716 Alert packet.
3717 @param[out] BufferOut Pointer to the buffer to hold the built packet.
3718 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
3719 the buffer size provided by the caller. On output, it
3720 is the buffer size in fact needed to contain the
3721 packet.
3722
3723 @retval EFI_SUCCESS The required TLS packet is built successfully.
3724 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
3725 Tls is NULL.
3726 BufferIn is NULL but BufferInSize is NOT 0.
3727 BufferInSize is 0 but BufferIn is NOT NULL.
3728 BufferOutSize is NULL.
3729 BufferOut is NULL if *BufferOutSize is not zero.
3730 @retval EFI_ABORTED An error occurred.
3731 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
3732
3733 **/
3734 EFI_STATUS
3735 EFIAPI
3736 CryptoServiceTlsHandleAlert (
3737 IN VOID *Tls,
3738 IN UINT8 *BufferIn, OPTIONAL
3739 IN UINTN BufferInSize, OPTIONAL
3740 OUT UINT8 *BufferOut, OPTIONAL
3741 IN OUT UINTN *BufferOutSize
3742 )
3743 {
3744 return CALL_BASECRYPTLIB (Tls.Services.HandleAlert, TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
3745 }
3746
3747 /**
3748 Build the CloseNotify packet.
3749
3750 @param[in] Tls Pointer to the TLS object for state checking.
3751 @param[in, out] Buffer Pointer to the buffer to hold the built packet.
3752 @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
3753 the buffer size provided by the caller. On output, it
3754 is the buffer size in fact needed to contain the
3755 packet.
3756
3757 @retval EFI_SUCCESS The required TLS packet is built successfully.
3758 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
3759 Tls is NULL.
3760 BufferSize is NULL.
3761 Buffer is NULL if *BufferSize is not zero.
3762 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
3763
3764 **/
3765 EFI_STATUS
3766 EFIAPI
3767 CryptoServiceTlsCloseNotify (
3768 IN VOID *Tls,
3769 IN OUT UINT8 *Buffer,
3770 IN OUT UINTN *BufferSize
3771 )
3772 {
3773 return CALL_BASECRYPTLIB (Tls.Services.CloseNotify, TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);
3774 }
3775
3776 /**
3777 Attempts to read bytes from one TLS object and places the data in Buffer.
3778
3779 This function will attempt to read BufferSize bytes from the TLS object
3780 and places the data in Buffer.
3781
3782 @param[in] Tls Pointer to the TLS object.
3783 @param[in,out] Buffer Pointer to the buffer to store the data.
3784 @param[in] BufferSize The size of Buffer in bytes.
3785
3786 @retval >0 The amount of data successfully read from the TLS object.
3787 @retval <=0 No data was successfully read.
3788
3789 **/
3790 INTN
3791 EFIAPI
3792 CryptoServiceTlsCtrlTrafficOut (
3793 IN VOID *Tls,
3794 IN OUT VOID *Buffer,
3795 IN UINTN BufferSize
3796 )
3797 {
3798 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);
3799 }
3800
3801 /**
3802 Attempts to write data from the buffer to TLS object.
3803
3804 This function will attempt to write BufferSize bytes data from the Buffer
3805 to the TLS object.
3806
3807 @param[in] Tls Pointer to the TLS object.
3808 @param[in] Buffer Pointer to the data buffer.
3809 @param[in] BufferSize The size of Buffer in bytes.
3810
3811 @retval >0 The amount of data successfully written to the TLS object.
3812 @retval <=0 No data was successfully written.
3813
3814 **/
3815 INTN
3816 EFIAPI
3817 CryptoServiceTlsCtrlTrafficIn (
3818 IN VOID *Tls,
3819 IN VOID *Buffer,
3820 IN UINTN BufferSize
3821 )
3822 {
3823 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficIn, TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);
3824 }
3825
3826 /**
3827 Attempts to read bytes from the specified TLS connection into the buffer.
3828
3829 This function tries to read BufferSize bytes data from the specified TLS
3830 connection into the Buffer.
3831
3832 @param[in] Tls Pointer to the TLS connection for data reading.
3833 @param[in,out] Buffer Pointer to the data buffer.
3834 @param[in] BufferSize The size of Buffer in bytes.
3835
3836 @retval >0 The read operation was successful, and return value is the
3837 number of bytes actually read from the TLS connection.
3838 @retval <=0 The read operation was not successful.
3839
3840 **/
3841 INTN
3842 EFIAPI
3843 CryptoServiceTlsRead (
3844 IN VOID *Tls,
3845 IN OUT VOID *Buffer,
3846 IN UINTN BufferSize
3847 )
3848 {
3849 return CALL_BASECRYPTLIB (Tls.Services.Read, TlsRead, (Tls, Buffer, BufferSize), 0);
3850 }
3851
3852 /**
3853 Attempts to write data to a TLS connection.
3854
3855 This function tries to write BufferSize bytes data from the Buffer into the
3856 specified TLS connection.
3857
3858 @param[in] Tls Pointer to the TLS connection for data writing.
3859 @param[in] Buffer Pointer to the data buffer.
3860 @param[in] BufferSize The size of Buffer in bytes.
3861
3862 @retval >0 The write operation was successful, and return value is the
3863 number of bytes actually written to the TLS connection.
3864 @retval <=0 The write operation was not successful.
3865
3866 **/
3867 INTN
3868 EFIAPI
3869 CryptoServiceTlsWrite (
3870 IN VOID *Tls,
3871 IN VOID *Buffer,
3872 IN UINTN BufferSize
3873 )
3874 {
3875 return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0);
3876 }
3877
3878 /**
3879 Set a new TLS/SSL method for a particular TLS object.
3880
3881 This function sets a new TLS/SSL method for a particular TLS object.
3882
3883 @param[in] Tls Pointer to a TLS object.
3884 @param[in] MajorVer Major Version of TLS/SSL Protocol.
3885 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
3886
3887 @retval EFI_SUCCESS The TLS/SSL method was set successfully.
3888 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3889 @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
3890
3891 **/
3892 EFI_STATUS
3893 EFIAPI
3894 CryptoServiceTlsSetVersion (
3895 IN VOID *Tls,
3896 IN UINT8 MajorVer,
3897 IN UINT8 MinorVer
3898 )
3899 {
3900 return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);
3901 }
3902
3903 /**
3904 Set TLS object to work in client or server mode.
3905
3906 This function prepares a TLS object to work in client or server mode.
3907
3908 @param[in] Tls Pointer to a TLS object.
3909 @param[in] IsServer Work in server mode.
3910
3911 @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
3912 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3913 @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
3914
3915 **/
3916 EFI_STATUS
3917 EFIAPI
3918 CryptoServiceTlsSetConnectionEnd (
3919 IN VOID *Tls,
3920 IN BOOLEAN IsServer
3921 )
3922 {
3923 return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);
3924 }
3925
3926 /**
3927 Set the ciphers list to be used by the TLS object.
3928
3929 This function sets the ciphers for use by a specified TLS object.
3930
3931 @param[in] Tls Pointer to a TLS object.
3932 @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
3933 cipher identifier comes from the TLS Cipher Suite
3934 Registry of the IANA, interpreting Byte1 and Byte2
3935 in network (big endian) byte order.
3936 @param[in] CipherNum The number of cipher in the list.
3937
3938 @retval EFI_SUCCESS The ciphers list was set successfully.
3939 @retval EFI_INVALID_PARAMETER The parameter is invalid.
3940 @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
3941 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
3942
3943 **/
3944 EFI_STATUS
3945 EFIAPI
3946 CryptoServiceTlsSetCipherList (
3947 IN VOID *Tls,
3948 IN UINT16 *CipherId,
3949 IN UINTN CipherNum
3950 )
3951 {
3952 return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);
3953 }
3954
3955 /**
3956 Set the compression method for TLS/SSL operations.
3957
3958 This function handles TLS/SSL integrated compression methods.
3959
3960 @param[in] CompMethod The compression method ID.
3961
3962 @retval EFI_SUCCESS The compression method for the communication was
3963 set successfully.
3964 @retval EFI_UNSUPPORTED Unsupported compression method.
3965
3966 **/
3967 EFI_STATUS
3968 EFIAPI
3969 CryptoServiceTlsSetCompressionMethod (
3970 IN UINT8 CompMethod
3971 )
3972 {
3973 return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);
3974 }
3975
3976 /**
3977 Set peer certificate verification mode for the TLS connection.
3978
3979 This function sets the verification mode flags for the TLS connection.
3980
3981 @param[in] Tls Pointer to the TLS object.
3982 @param[in] VerifyMode A set of logically or'ed verification mode flags.
3983
3984 **/
3985 VOID
3986 EFIAPI
3987 CryptoServiceTlsSetVerify (
3988 IN VOID *Tls,
3989 IN UINT32 VerifyMode
3990 )
3991 {
3992 CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));
3993 }
3994
3995 /**
3996 Set the specified host name to be verified.
3997
3998 @param[in] Tls Pointer to the TLS object.
3999 @param[in] Flags The setting flags during the validation.
4000 @param[in] HostName The specified host name to be verified.
4001
4002 @retval EFI_SUCCESS The HostName setting was set successfully.
4003 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4004 @retval EFI_ABORTED Invalid HostName setting.
4005
4006 **/
4007 EFI_STATUS
4008 EFIAPI
4009 CryptoServiceTlsSetVerifyHost (
4010 IN VOID *Tls,
4011 IN UINT32 Flags,
4012 IN CHAR8 *HostName
4013 )
4014 {
4015 return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);
4016 }
4017
4018 /**
4019 Sets a TLS/SSL session ID to be used during TLS/SSL connect.
4020
4021 This function sets a session ID to be used when the TLS/SSL connection is
4022 to be established.
4023
4024 @param[in] Tls Pointer to the TLS object.
4025 @param[in] SessionId Session ID data used for session resumption.
4026 @param[in] SessionIdLen Length of Session ID in bytes.
4027
4028 @retval EFI_SUCCESS Session ID was set successfully.
4029 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4030 @retval EFI_UNSUPPORTED No available session for ID setting.
4031
4032 **/
4033 EFI_STATUS
4034 EFIAPI
4035 CryptoServiceTlsSetSessionId (
4036 IN VOID *Tls,
4037 IN UINT8 *SessionId,
4038 IN UINT16 SessionIdLen
4039 )
4040 {
4041 return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4042 }
4043
4044 /**
4045 Adds the CA to the cert store when requesting Server or Client authentication.
4046
4047 This function adds the CA certificate to the list of CAs when requesting
4048 Server or Client authentication for the chosen TLS connection.
4049
4050 @param[in] Tls Pointer to the TLS object.
4051 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4052 X.509 certificate or PEM-encoded X.509 certificate.
4053 @param[in] DataSize The size of data buffer in bytes.
4054
4055 @retval EFI_SUCCESS The operation succeeded.
4056 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4057 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4058 @retval EFI_ABORTED Invalid X.509 certificate.
4059
4060 **/
4061 EFI_STATUS
4062 EFIAPI
4063 CryptoServiceTlsSetCaCertificate (
4064 IN VOID *Tls,
4065 IN VOID *Data,
4066 IN UINTN DataSize
4067 )
4068 {
4069 return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4070 }
4071
4072 /**
4073 Loads the local public certificate into the specified TLS object.
4074
4075 This function loads the X.509 certificate into the specified TLS object
4076 for TLS negotiation.
4077
4078 @param[in] Tls Pointer to the TLS object.
4079 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4080 X.509 certificate or PEM-encoded X.509 certificate.
4081 @param[in] DataSize The size of data buffer in bytes.
4082
4083 @retval EFI_SUCCESS The operation succeeded.
4084 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4085 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4086 @retval EFI_ABORTED Invalid X.509 certificate.
4087
4088 **/
4089 EFI_STATUS
4090 EFIAPI
4091 CryptoServiceTlsSetHostPublicCert (
4092 IN VOID *Tls,
4093 IN VOID *Data,
4094 IN UINTN DataSize
4095 )
4096 {
4097 return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4098 }
4099
4100 /**
4101 Adds the local private key to the specified TLS object.
4102
4103 This function adds the local private key (PEM-encoded RSA or PKCS#8 private
4104 key) into the specified TLS object for TLS negotiation.
4105
4106 @param[in] Tls Pointer to the TLS object.
4107 @param[in] Data Pointer to the data buffer of a PEM-encoded RSA
4108 or PKCS#8 private key.
4109 @param[in] DataSize The size of data buffer in bytes.
4110
4111 @retval EFI_SUCCESS The operation succeeded.
4112 @retval EFI_UNSUPPORTED This function is not supported.
4113 @retval EFI_ABORTED Invalid private key data.
4114
4115 **/
4116 EFI_STATUS
4117 EFIAPI
4118 CryptoServiceTlsSetHostPrivateKey (
4119 IN VOID *Tls,
4120 IN VOID *Data,
4121 IN UINTN DataSize
4122 )
4123 {
4124 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4125 }
4126
4127 /**
4128 Adds the CA-supplied certificate revocation list for certificate validation.
4129
4130 This function adds the CA-supplied certificate revocation list data for
4131 certificate validity checking.
4132
4133 @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
4134 @param[in] DataSize The size of data buffer in bytes.
4135
4136 @retval EFI_SUCCESS The operation succeeded.
4137 @retval EFI_UNSUPPORTED This function is not supported.
4138 @retval EFI_ABORTED Invalid CRL data.
4139
4140 **/
4141 EFI_STATUS
4142 EFIAPI
4143 CryptoServiceTlsSetCertRevocationList (
4144 IN VOID *Data,
4145 IN UINTN DataSize
4146 )
4147 {
4148 return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4149 }
4150
4151 /**
4152 Gets the protocol version used by the specified TLS connection.
4153
4154 This function returns the protocol version used by the specified TLS
4155 connection.
4156
4157 If Tls is NULL, then ASSERT().
4158
4159 @param[in] Tls Pointer to the TLS object.
4160
4161 @return The protocol version of the specified TLS connection.
4162
4163 **/
4164 UINT16
4165 EFIAPI
4166 CryptoServiceTlsGetVersion (
4167 IN VOID *Tls
4168 )
4169 {
4170 return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);
4171 }
4172
4173 /**
4174 Gets the connection end of the specified TLS connection.
4175
4176 This function returns the connection end (as client or as server) used by
4177 the specified TLS connection.
4178
4179 If Tls is NULL, then ASSERT().
4180
4181 @param[in] Tls Pointer to the TLS object.
4182
4183 @return The connection end used by the specified TLS connection.
4184
4185 **/
4186 UINT8
4187 EFIAPI
4188 CryptoServiceTlsGetConnectionEnd (
4189 IN VOID *Tls
4190 )
4191 {
4192 return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);
4193 }
4194
4195 /**
4196 Gets the cipher suite used by the specified TLS connection.
4197
4198 This function returns current cipher suite used by the specified
4199 TLS connection.
4200
4201 @param[in] Tls Pointer to the TLS object.
4202 @param[in,out] CipherId The cipher suite used by the TLS object.
4203
4204 @retval EFI_SUCCESS The cipher suite was returned successfully.
4205 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4206 @retval EFI_UNSUPPORTED Unsupported cipher suite.
4207
4208 **/
4209 EFI_STATUS
4210 EFIAPI
4211 CryptoServiceTlsGetCurrentCipher (
4212 IN VOID *Tls,
4213 IN OUT UINT16 *CipherId
4214 )
4215 {
4216 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);
4217 }
4218
4219 /**
4220 Gets the compression methods used by the specified TLS connection.
4221
4222 This function returns current integrated compression methods used by
4223 the specified TLS connection.
4224
4225 @param[in] Tls Pointer to the TLS object.
4226 @param[in,out] CompressionId The current compression method used by
4227 the TLS object.
4228
4229 @retval EFI_SUCCESS The compression method was returned successfully.
4230 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4231 @retval EFI_ABORTED Invalid Compression method.
4232 @retval EFI_UNSUPPORTED This function is not supported.
4233
4234 **/
4235 EFI_STATUS
4236 EFIAPI
4237 CryptoServiceTlsGetCurrentCompressionId (
4238 IN VOID *Tls,
4239 IN OUT UINT8 *CompressionId
4240 )
4241 {
4242 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);
4243 }
4244
4245 /**
4246 Gets the verification mode currently set in the TLS connection.
4247
4248 This function returns the peer verification mode currently set in the
4249 specified TLS connection.
4250
4251 If Tls is NULL, then ASSERT().
4252
4253 @param[in] Tls Pointer to the TLS object.
4254
4255 @return The verification mode set in the specified TLS connection.
4256
4257 **/
4258 UINT32
4259 EFIAPI
4260 CryptoServiceTlsGetVerify (
4261 IN VOID *Tls
4262 )
4263 {
4264 return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);
4265 }
4266
4267 /**
4268 Gets the session ID used by the specified TLS connection.
4269
4270 This function returns the TLS/SSL session ID currently used by the
4271 specified TLS connection.
4272
4273 @param[in] Tls Pointer to the TLS object.
4274 @param[in,out] SessionId Buffer to contain the returned session ID.
4275 @param[in,out] SessionIdLen The length of Session ID in bytes.
4276
4277 @retval EFI_SUCCESS The Session ID was returned successfully.
4278 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4279 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4280
4281 **/
4282 EFI_STATUS
4283 EFIAPI
4284 CryptoServiceTlsGetSessionId (
4285 IN VOID *Tls,
4286 IN OUT UINT8 *SessionId,
4287 IN OUT UINT16 *SessionIdLen
4288 )
4289 {
4290 return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4291 }
4292
4293 /**
4294 Gets the client random data used in the specified TLS connection.
4295
4296 This function returns the TLS/SSL client random data currently used in
4297 the specified TLS connection.
4298
4299 @param[in] Tls Pointer to the TLS object.
4300 @param[in,out] ClientRandom Buffer to contain the returned client
4301 random data (32 bytes).
4302
4303 **/
4304 VOID
4305 EFIAPI
4306 CryptoServiceTlsGetClientRandom (
4307 IN VOID *Tls,
4308 IN OUT UINT8 *ClientRandom
4309 )
4310 {
4311 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));
4312 }
4313
4314 /**
4315 Gets the server random data used in the specified TLS connection.
4316
4317 This function returns the TLS/SSL server random data currently used in
4318 the specified TLS connection.
4319
4320 @param[in] Tls Pointer to the TLS object.
4321 @param[in,out] ServerRandom Buffer to contain the returned server
4322 random data (32 bytes).
4323
4324 **/
4325 VOID
4326 EFIAPI
4327 CryptoServiceTlsGetServerRandom (
4328 IN VOID *Tls,
4329 IN OUT UINT8 *ServerRandom
4330 )
4331 {
4332 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));
4333 }
4334
4335 /**
4336 Gets the master key data used in the specified TLS connection.
4337
4338 This function returns the TLS/SSL master key material currently used in
4339 the specified TLS connection.
4340
4341 @param[in] Tls Pointer to the TLS object.
4342 @param[in,out] KeyMaterial Buffer to contain the returned key material.
4343
4344 @retval EFI_SUCCESS Key material was returned successfully.
4345 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4346 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
4347
4348 **/
4349 EFI_STATUS
4350 EFIAPI
4351 CryptoServiceTlsGetKeyMaterial (
4352 IN VOID *Tls,
4353 IN OUT UINT8 *KeyMaterial
4354 )
4355 {
4356 return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);
4357 }
4358
4359 /**
4360 Gets the CA Certificate from the cert store.
4361
4362 This function returns the CA certificate for the chosen
4363 TLS connection.
4364
4365 @param[in] Tls Pointer to the TLS object.
4366 @param[out] Data Pointer to the data buffer to receive the CA
4367 certificate data sent to the client.
4368 @param[in,out] DataSize The size of data buffer in bytes.
4369
4370 @retval EFI_SUCCESS The operation succeeded.
4371 @retval EFI_UNSUPPORTED This function is not supported.
4372 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4373
4374 **/
4375 EFI_STATUS
4376 EFIAPI
4377 CryptoServiceTlsGetCaCertificate (
4378 IN VOID *Tls,
4379 OUT VOID *Data,
4380 IN OUT UINTN *DataSize
4381 )
4382 {
4383 return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4384 }
4385
4386 /**
4387 Gets the local public Certificate set in the specified TLS object.
4388
4389 This function returns the local public certificate which was currently set
4390 in the specified TLS object.
4391
4392 @param[in] Tls Pointer to the TLS object.
4393 @param[out] Data Pointer to the data buffer to receive the local
4394 public certificate.
4395 @param[in,out] DataSize The size of data buffer in bytes.
4396
4397 @retval EFI_SUCCESS The operation succeeded.
4398 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4399 @retval EFI_NOT_FOUND The certificate is not found.
4400 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4401
4402 **/
4403 EFI_STATUS
4404 EFIAPI
4405 CryptoServiceTlsGetHostPublicCert (
4406 IN VOID *Tls,
4407 OUT VOID *Data,
4408 IN OUT UINTN *DataSize
4409 )
4410 {
4411 return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4412 }
4413
4414 /**
4415 Gets the local private key set in the specified TLS object.
4416
4417 This function returns the local private key data which was currently set
4418 in the specified TLS object.
4419
4420 @param[in] Tls Pointer to the TLS object.
4421 @param[out] Data Pointer to the data buffer to receive the local
4422 private key data.
4423 @param[in,out] DataSize The size of data buffer in bytes.
4424
4425 @retval EFI_SUCCESS The operation succeeded.
4426 @retval EFI_UNSUPPORTED This function is not supported.
4427 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4428
4429 **/
4430 EFI_STATUS
4431 EFIAPI
4432 CryptoServiceTlsGetHostPrivateKey (
4433 IN VOID *Tls,
4434 OUT VOID *Data,
4435 IN OUT UINTN *DataSize
4436 )
4437 {
4438 return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4439 }
4440
4441 /**
4442 Gets the CA-supplied certificate revocation list data set in the specified
4443 TLS object.
4444
4445 This function returns the CA-supplied certificate revocation list data which
4446 was currently set in the specified TLS object.
4447
4448 @param[out] Data Pointer to the data buffer to receive the CRL data.
4449 @param[in,out] DataSize The size of data buffer in bytes.
4450
4451 @retval EFI_SUCCESS The operation succeeded.
4452 @retval EFI_UNSUPPORTED This function is not supported.
4453 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
4454
4455 **/
4456 EFI_STATUS
4457 EFIAPI
4458 CryptoServiceTlsGetCertRevocationList (
4459 OUT VOID *Data,
4460 IN OUT UINTN *DataSize
4461 )
4462 {
4463 return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
4464 }
4465
4466 const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
4467 /// Version
4468 CryptoServiceGetCryptoVersion,
4469 /// HMAC MD5 - deprecated and unsupported
4470 DeprecatedCryptoServiceHmacMd5New,
4471 DeprecatedCryptoServiceHmacMd5Free,
4472 DeprecatedCryptoServiceHmacMd5SetKey,
4473 DeprecatedCryptoServiceHmacMd5Duplicate,
4474 DeprecatedCryptoServiceHmacMd5Update,
4475 DeprecatedCryptoServiceHmacMd5Final,
4476 /// HMAC SHA1 - deprecated and unsupported
4477 DeprecatedCryptoServiceHmacSha1New,
4478 DeprecatedCryptoServiceHmacSha1Free,
4479 DeprecatedCryptoServiceHmacSha1SetKey,
4480 DeprecatedCryptoServiceHmacSha1Duplicate,
4481 DeprecatedCryptoServiceHmacSha1Update,
4482 DeprecatedCryptoServiceHmacSha1Final,
4483 /// HMAC SHA256
4484 CryptoServiceHmacSha256New,
4485 CryptoServiceHmacSha256Free,
4486 CryptoServiceHmacSha256SetKey,
4487 CryptoServiceHmacSha256Duplicate,
4488 CryptoServiceHmacSha256Update,
4489 CryptoServiceHmacSha256Final,
4490 /// Md4 - deprecated and unsupported
4491 DeprecatedCryptoServiceMd4GetContextSize,
4492 DeprecatedCryptoServiceMd4Init,
4493 DeprecatedCryptoServiceMd4Duplicate,
4494 DeprecatedCryptoServiceMd4Update,
4495 DeprecatedCryptoServiceMd4Final,
4496 DeprecatedCryptoServiceMd4HashAll,
4497 #ifndef ENABLE_MD5_DEPRECATED_INTERFACES
4498 /// Md5 - deprecated and unsupported
4499 DeprecatedCryptoServiceMd5GetContextSize,
4500 DeprecatedCryptoServiceMd5Init,
4501 DeprecatedCryptoServiceMd5Duplicate,
4502 DeprecatedCryptoServiceMd5Update,
4503 DeprecatedCryptoServiceMd5Final,
4504 DeprecatedCryptoServiceMd5HashAll,
4505 #else
4506 /// Md5
4507 CryptoServiceMd5GetContextSize,
4508 CryptoServiceMd5Init,
4509 CryptoServiceMd5Duplicate,
4510 CryptoServiceMd5Update,
4511 CryptoServiceMd5Final,
4512 CryptoServiceMd5HashAll,
4513 #endif
4514 /// Pkcs
4515 CryptoServicePkcs1v2Encrypt,
4516 CryptoServicePkcs5HashPassword,
4517 CryptoServicePkcs7Verify,
4518 CryptoServiceVerifyEKUsInPkcs7Signature,
4519 CryptoServicePkcs7GetSigners,
4520 CryptoServicePkcs7FreeSigners,
4521 CryptoServicePkcs7Sign,
4522 CryptoServicePkcs7GetAttachedContent,
4523 CryptoServicePkcs7GetCertificatesList,
4524 CryptoServiceAuthenticodeVerify,
4525 CryptoServiceImageTimestampVerify,
4526 /// DH
4527 CryptoServiceDhNew,
4528 CryptoServiceDhFree,
4529 CryptoServiceDhGenerateParameter,
4530 CryptoServiceDhSetParameter,
4531 CryptoServiceDhGenerateKey,
4532 CryptoServiceDhComputeKey,
4533 /// Random
4534 CryptoServiceRandomSeed,
4535 CryptoServiceRandomBytes,
4536 /// RSA
4537 CryptoServiceRsaPkcs1Verify,
4538 CryptoServiceRsaNew,
4539 CryptoServiceRsaFree,
4540 CryptoServiceRsaSetKey,
4541 CryptoServiceRsaGetKey,
4542 CryptoServiceRsaGenerateKey,
4543 CryptoServiceRsaCheckKey,
4544 CryptoServiceRsaPkcs1Sign,
4545 CryptoServiceRsaPkcs1Verify,
4546 CryptoServiceRsaGetPrivateKeyFromPem,
4547 CryptoServiceRsaGetPublicKeyFromX509,
4548 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
4549 /// Sha1 - deprecated and unsupported
4550 DeprecatedCryptoServiceSha1GetContextSize,
4551 DeprecatedCryptoServiceSha1Init,
4552 DeprecatedCryptoServiceSha1Duplicate,
4553 DeprecatedCryptoServiceSha1Update,
4554 DeprecatedCryptoServiceSha1Final,
4555 DeprecatedCryptoServiceSha1HashAll,
4556 #else
4557 /// Sha1
4558 CryptoServiceSha1GetContextSize,
4559 CryptoServiceSha1Init,
4560 CryptoServiceSha1Duplicate,
4561 CryptoServiceSha1Update,
4562 CryptoServiceSha1Final,
4563 CryptoServiceSha1HashAll,
4564 #endif
4565 /// Sha256
4566 CryptoServiceSha256GetContextSize,
4567 CryptoServiceSha256Init,
4568 CryptoServiceSha256Duplicate,
4569 CryptoServiceSha256Update,
4570 CryptoServiceSha256Final,
4571 CryptoServiceSha256HashAll,
4572 /// Sha384
4573 CryptoServiceSha384GetContextSize,
4574 CryptoServiceSha384Init,
4575 CryptoServiceSha384Duplicate,
4576 CryptoServiceSha384Update,
4577 CryptoServiceSha384Final,
4578 CryptoServiceSha384HashAll,
4579 /// Sha512
4580 CryptoServiceSha512GetContextSize,
4581 CryptoServiceSha512Init,
4582 CryptoServiceSha512Duplicate,
4583 CryptoServiceSha512Update,
4584 CryptoServiceSha512Final,
4585 CryptoServiceSha512HashAll,
4586 /// X509
4587 CryptoServiceX509GetSubjectName,
4588 CryptoServiceX509GetCommonName,
4589 CryptoServiceX509GetOrganizationName,
4590 CryptoServiceX509VerifyCert,
4591 CryptoServiceX509ConstructCertificate,
4592 CryptoServiceX509ConstructCertificateStack,
4593 CryptoServiceX509Free,
4594 CryptoServiceX509StackFree,
4595 CryptoServiceX509GetTBSCert,
4596 /// TDES - deprecated and unsupported
4597 DeprecatedCryptoServiceTdesGetContextSize,
4598 DeprecatedCryptoServiceTdesInit,
4599 DeprecatedCryptoServiceTdesEcbEncrypt,
4600 DeprecatedCryptoServiceTdesEcbDecrypt,
4601 DeprecatedCryptoServiceTdesCbcEncrypt,
4602 DeprecatedCryptoServiceTdesCbcDecrypt,
4603 /// AES - ECB mode is deprecated and unsupported
4604 CryptoServiceAesGetContextSize,
4605 CryptoServiceAesInit,
4606 DeprecatedCryptoServiceAesEcbEncrypt,
4607 DeprecatedCryptoServiceAesEcbDecrypt,
4608 CryptoServiceAesCbcEncrypt,
4609 CryptoServiceAesCbcDecrypt,
4610 /// Arc4 - deprecated and unsupported
4611 DeprecatedCryptoServiceArc4GetContextSize,
4612 DeprecatedCryptoServiceArc4Init,
4613 DeprecatedCryptoServiceArc4Encrypt,
4614 DeprecatedCryptoServiceArc4Decrypt,
4615 DeprecatedCryptoServiceArc4Reset,
4616 /// SM3
4617 CryptoServiceSm3GetContextSize,
4618 CryptoServiceSm3Init,
4619 CryptoServiceSm3Duplicate,
4620 CryptoServiceSm3Update,
4621 CryptoServiceSm3Final,
4622 CryptoServiceSm3HashAll,
4623 /// HKDF
4624 CryptoServiceHkdfSha256ExtractAndExpand,
4625 /// X509 (Continued)
4626 CryptoServiceX509ConstructCertificateStackV,
4627 /// TLS
4628 CryptoServiceTlsInitialize,
4629 CryptoServiceTlsCtxFree,
4630 CryptoServiceTlsCtxNew,
4631 CryptoServiceTlsFree,
4632 CryptoServiceTlsNew,
4633 CryptoServiceTlsInHandshake,
4634 CryptoServiceTlsDoHandshake,
4635 CryptoServiceTlsHandleAlert,
4636 CryptoServiceTlsCloseNotify,
4637 CryptoServiceTlsCtrlTrafficOut,
4638 CryptoServiceTlsCtrlTrafficIn,
4639 CryptoServiceTlsRead,
4640 CryptoServiceTlsWrite,
4641 /// TLS Set
4642 CryptoServiceTlsSetVersion,
4643 CryptoServiceTlsSetConnectionEnd,
4644 CryptoServiceTlsSetCipherList,
4645 CryptoServiceTlsSetCompressionMethod,
4646 CryptoServiceTlsSetVerify,
4647 CryptoServiceTlsSetVerifyHost,
4648 CryptoServiceTlsSetSessionId,
4649 CryptoServiceTlsSetCaCertificate,
4650 CryptoServiceTlsSetHostPublicCert,
4651 CryptoServiceTlsSetHostPrivateKey,
4652 CryptoServiceTlsSetCertRevocationList,
4653 /// TLS Get
4654 CryptoServiceTlsGetVersion,
4655 CryptoServiceTlsGetConnectionEnd,
4656 CryptoServiceTlsGetCurrentCipher,
4657 CryptoServiceTlsGetCurrentCompressionId,
4658 CryptoServiceTlsGetVerify,
4659 CryptoServiceTlsGetSessionId,
4660 CryptoServiceTlsGetClientRandom,
4661 CryptoServiceTlsGetServerRandom,
4662 CryptoServiceTlsGetKeyMaterial,
4663 CryptoServiceTlsGetCaCertificate,
4664 CryptoServiceTlsGetHostPublicCert,
4665 CryptoServiceTlsGetHostPrivateKey,
4666 CryptoServiceTlsGetCertRevocationList
4667 };