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