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