VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/CryptoPkg/Driver/Crypto.c@ 105670

Last change on this file since 105670 was 105670, checked in by vboxsync, 8 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 227.4 KB
Line 
1/** @file
2 Implements the EDK II Crypto Protocol/PPI services using the library services
3 from BaseCryptLib and TlsLib.
4
5 Copyright (C) Microsoft Corporation. All rights reserved.
6 Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
8
9**/
10#include <Base.h>
11#include <Library/DebugLib.h>
12#include <Library/BaseCryptLib.h>
13#include <Library/TlsLib.h>
14#include <Protocol/Crypto.h>
15#include <Pcd/PcdCryptoServiceFamilyEnable.h>
16
17/**
18 A macro used to retrieve the FixedAtBuild PcdCryptoServiceFamilyEnable with a
19 typecast to its associcted structure type PCD_CRYPTO_SERVICE_FAMILY_ENABLE.
20**/
21#define EDKII_CRYPTO_PCD ((const PCD_CRYPTO_SERVICE_FAMILY_ENABLE *)\
22 (FixedPcdGetPtr (PcdCryptoServiceFamilyEnable)))
23
24/**
25 A macro used to call a non-void BaseCryptLib function if it is enabled.
26
27 If a BaseCryptLib function is not enabled, there will be no references to it
28 from this module and will be optimized away reducing the size of this module.
29
30 @param Enable The name of the enable field in PCD
31 PcdCryptoServiceFamilyEnable for the BaseCryptLib
32 function being called. If the value of this field
33 is non-zero, then the BaseCryptLib function is
34 enabled.
35 @param Function The name of the BaseCryptLib function.
36 @param Args The argument list to pass to Function.
37 @param ErrorReturnValue The value to return if the BaseCryptLib function is
38 not enabled.
39
40**/
41#define CALL_BASECRYPTLIB(Enable, Function, Args, ErrorReturnValue) \
42 EDKII_CRYPTO_PCD->Enable \
43 ? Function Args \
44 : (BaseCryptLibServiceNotEnabled (#Function), ErrorReturnValue)
45
46/**
47 A macro used to call a void BaseCryptLib function if it is enabled.
48
49 If a BaseCryptLib function is not enabled, there will be no references to it
50 from this module and will be optimized away reducing the size of this module.
51
52 @param Enable The name of the enable field in PCD
53 PcdCryptoServiceFamilyEnable for the BaseCryptLib
54 function being called. If the value of this field
55 is non-zero, then the BaseCryptLib function is
56 enabled.
57 @param Function The name of the BaseCryptLib function.
58 @param Args The argument list to pass to Function.
59
60**/
61#define CALL_VOID_BASECRYPTLIB(Enable, Function, Args) \
62 EDKII_CRYPTO_PCD->Enable \
63 ? Function Args \
64 : BaseCryptLibServiceNotEnabled (#Function)
65
66/**
67 Internal worker function that prints a debug message and asserts if a call is
68 made to a BaseCryptLib function that is not enabled in the EDK II Crypto
69 Protocol/PPI.
70
71 If this debug message and assert are observed, then a module is using
72 BaseCryptLib function that is not enabled in a Crypto driver. The
73 PcdCryptoServiceFamilyEnable should be updated to enable the missing service.
74
75 @param[in] FunctionName Null-terminated ASCII string that is the name of an
76 EDK II Crypto service.
77
78**/
79static
80VOID
81BaseCryptLibServiceNotEnabled (
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**/
97static
98VOID
99BaseCryptLibServiceDeprecated (
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**/
113UINTN
114EFIAPI
115CryptoServiceGetCryptoVersion (
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**/
133UINTN
134EFIAPI
135DeprecatedCryptoServiceMd4GetContextSize (
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**/
151BOOLEAN
152EFIAPI
153DeprecatedCryptoServiceMd4Init (
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**/
170BOOLEAN
171EFIAPI
172DeprecatedCryptoServiceMd4Duplicate (
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**/
191BOOLEAN
192EFIAPI
193DeprecatedCryptoServiceMd4Update (
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**/
213BOOLEAN
214EFIAPI
215DeprecatedCryptoServiceMd4Final (
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**/
235BOOLEAN
236EFIAPI
237DeprecatedCryptoServiceMd4HashAll (
238 IN CONST VOID *Data,
239 IN UINTN DataSize,
240 OUT UINT8 *HashValue
241 )
242{
243 return BaseCryptLibServiceDeprecated ("Md4HashAll"), FALSE;
244}
245
246#ifndef ENABLE_MD5_DEPRECATED_INTERFACES
247
248/**
249 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
250
251 If this interface is not supported, then return zero.
252
253 @retval 0 This interface is not supported.
254
255**/
256UINTN
257EFIAPI
258DeprecatedCryptoServiceMd5GetContextSize (
259 VOID
260 )
261{
262 return BaseCryptLibServiceDeprecated ("Md5GetContextSize"), 0;
263}
264
265/**
266 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
267 subsequent use.
268
269 If Md5Context is NULL, then return FALSE.
270 If this interface is not supported, then return FALSE.
271
272 @param[out] Md5Context Pointer to MD5 context being initialized.
273
274 @retval FALSE This interface is not supported.
275
276**/
277BOOLEAN
278EFIAPI
279DeprecatedCryptoServiceMd5Init (
280 OUT VOID *Md5Context
281 )
282{
283 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
284}
285
286/**
287 Makes a copy of an existing MD5 context.
288
289 If Md5Context is NULL, then return FALSE.
290 If NewMd5Context is NULL, then return FALSE.
291 If this interface is not supported, then return FALSE.
292
293 @param[in] Md5Context Pointer to MD5 context being copied.
294 @param[out] NewMd5Context Pointer to new MD5 context.
295
296 @retval FALSE This interface is not supported.
297
298**/
299BOOLEAN
300EFIAPI
301DeprecatedCryptoServiceMd5Duplicate (
302 IN CONST VOID *Md5Context,
303 OUT VOID *NewMd5Context
304 )
305{
306 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
307}
308
309/**
310 Digests the input data and updates MD5 context.
311
312 This function performs MD5 digest on a data buffer of the specified size.
313 It can be called multiple times to compute the digest of long or discontinuous data streams.
314 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
315 by Md5Final(). Behavior with invalid context is undefined.
316
317 If Md5Context is NULL, then return FALSE.
318 If this interface is not supported, then return FALSE.
319
320 @param[in, out] Md5Context Pointer to the MD5 context.
321 @param[in] Data Pointer to the buffer containing the data to be hashed.
322 @param[in] DataSize Size of Data buffer in bytes.
323
324 @retval FALSE This interface is not supported.
325
326**/
327BOOLEAN
328EFIAPI
329DeprecatedCryptoServiceMd5Update (
330 IN OUT VOID *Md5Context,
331 IN CONST VOID *Data,
332 IN UINTN DataSize
333 )
334{
335 return BaseCryptLibServiceDeprecated ("Md5Init"), FALSE;
336}
337
338/**
339 Completes computation of the MD5 digest value.
340
341 This function completes MD5 hash computation and retrieves the digest value into
342 the specified memory. After this function has been called, the MD5 context cannot
343 be used again.
344 MD5 context should be already correctly initialized by Md5Init(), and should not be
345 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
346
347 If Md5Context is NULL, then return FALSE.
348 If HashValue is NULL, then return FALSE.
349 If this interface is not supported, then return FALSE.
350
351 @param[in, out] Md5Context Pointer to the MD5 context.
352 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
353 value (16 bytes).
354
355 @retval FALSE This interface is not supported.
356
357**/
358BOOLEAN
359EFIAPI
360DeprecatedCryptoServiceMd5Final (
361 IN OUT VOID *Md5Context,
362 OUT UINT8 *HashValue
363 )
364{
365 return BaseCryptLibServiceDeprecated ("Md5Final"), FALSE;
366}
367
368/**
369 Computes the MD5 message digest of a input data buffer.
370
371 This function performs the MD5 message digest of a given data buffer, and places
372 the digest value into the specified memory.
373
374 If this interface is not supported, then return FALSE.
375
376 @param[in] Data Pointer to the buffer containing the data to be hashed.
377 @param[in] DataSize Size of Data buffer in bytes.
378 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
379 value (16 bytes).
380
381 @retval FALSE This interface is not supported.
382
383**/
384BOOLEAN
385EFIAPI
386DeprecatedCryptoServiceMd5HashAll (
387 IN CONST VOID *Data,
388 IN UINTN DataSize,
389 OUT UINT8 *HashValue
390 )
391{
392 return BaseCryptLibServiceDeprecated ("Md5HashAll"), FALSE;
393}
394
395#else
396
397/**
398 Retrieves the size, in bytes, of the context buffer required for MD5 hash operations.
399
400 If this interface is not supported, then return zero.
401
402 @return The size, in bytes, of the context buffer required for MD5 hash operations.
403 @retval 0 This interface is not supported.
404
405**/
406UINTN
407EFIAPI
408CryptoServiceMd5GetContextSize (
409 VOID
410 )
411{
412 return CALL_BASECRYPTLIB (Md5.Services.GetContextSize, Md5GetContextSize, (), 0);
413}
414
415/**
416 Initializes user-supplied memory pointed by Md5Context as MD5 hash context for
417 subsequent use.
418
419 If Md5Context is NULL, then return FALSE.
420 If this interface is not supported, then return FALSE.
421
422 @param[out] Md5Context Pointer to MD5 context being initialized.
423
424 @retval TRUE MD5 context initialization succeeded.
425 @retval FALSE MD5 context initialization failed.
426 @retval FALSE This interface is not supported.
427
428**/
429BOOLEAN
430EFIAPI
431CryptoServiceMd5Init (
432 OUT VOID *Md5Context
433 )
434{
435 return CALL_BASECRYPTLIB (Md5.Services.Init, Md5Init, (Md5Context), FALSE);
436}
437
438/**
439 Makes a copy of an existing MD5 context.
440
441 If Md5Context is NULL, then return FALSE.
442 If NewMd5Context is NULL, then return FALSE.
443 If this interface is not supported, then return FALSE.
444
445 @param[in] Md5Context Pointer to MD5 context being copied.
446 @param[out] NewMd5Context Pointer to new MD5 context.
447
448 @retval TRUE MD5 context copy succeeded.
449 @retval FALSE MD5 context copy failed.
450 @retval FALSE This interface is not supported.
451
452**/
453BOOLEAN
454EFIAPI
455CryptoServiceMd5Duplicate (
456 IN CONST VOID *Md5Context,
457 OUT VOID *NewMd5Context
458 )
459{
460 return CALL_BASECRYPTLIB (Md5.Services.Duplicate, Md5Duplicate, (Md5Context, NewMd5Context), FALSE);
461}
462
463/**
464 Digests the input data and updates MD5 context.
465
466 This function performs MD5 digest on a data buffer of the specified size.
467 It can be called multiple times to compute the digest of long or discontinuous data streams.
468 MD5 context should be already correctly initialized by Md5Init(), and should not be finalized
469 by Md5Final(). Behavior with invalid context is undefined.
470
471 If Md5Context is NULL, then return FALSE.
472 If this interface is not supported, then return FALSE.
473
474 @param[in, out] Md5Context Pointer to the MD5 context.
475 @param[in] Data Pointer to the buffer containing the data to be hashed.
476 @param[in] DataSize Size of Data buffer in bytes.
477
478 @retval TRUE MD5 data digest succeeded.
479 @retval FALSE MD5 data digest failed.
480 @retval FALSE This interface is not supported.
481
482**/
483BOOLEAN
484EFIAPI
485CryptoServiceMd5Update (
486 IN OUT VOID *Md5Context,
487 IN CONST VOID *Data,
488 IN UINTN DataSize
489 )
490{
491 return CALL_BASECRYPTLIB (Md5.Services.Update, Md5Update, (Md5Context, Data, DataSize), FALSE);
492}
493
494/**
495 Completes computation of the MD5 digest value.
496
497 This function completes MD5 hash computation and retrieves the digest value into
498 the specified memory. After this function has been called, the MD5 context cannot
499 be used again.
500 MD5 context should be already correctly initialized by Md5Init(), and should not be
501 finalized by Md5Final(). Behavior with invalid MD5 context is undefined.
502
503 If Md5Context is NULL, then return FALSE.
504 If HashValue is NULL, then return FALSE.
505 If this interface is not supported, then return FALSE.
506
507 @param[in, out] Md5Context Pointer to the MD5 context.
508 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
509 value (16 bytes).
510
511 @retval TRUE MD5 digest computation succeeded.
512 @retval FALSE MD5 digest computation failed.
513 @retval FALSE This interface is not supported.
514
515**/
516BOOLEAN
517EFIAPI
518CryptoServiceMd5Final (
519 IN OUT VOID *Md5Context,
520 OUT UINT8 *HashValue
521 )
522{
523 return CALL_BASECRYPTLIB (Md5.Services.Final, Md5Final, (Md5Context, HashValue), FALSE);
524}
525
526/**
527 Computes the MD5 message digest of a input data buffer.
528
529 This function performs the MD5 message digest of a given data buffer, and places
530 the digest value into the specified memory.
531
532 If this interface is not supported, then return FALSE.
533
534 @param[in] Data Pointer to the buffer containing the data to be hashed.
535 @param[in] DataSize Size of Data buffer in bytes.
536 @param[out] HashValue Pointer to a buffer that receives the MD5 digest
537 value (16 bytes).
538
539 @retval TRUE MD5 digest computation succeeded.
540 @retval FALSE MD5 digest computation failed.
541 @retval FALSE This interface is not supported.
542
543**/
544BOOLEAN
545EFIAPI
546CryptoServiceMd5HashAll (
547 IN CONST VOID *Data,
548 IN UINTN DataSize,
549 OUT UINT8 *HashValue
550 )
551{
552 return CALL_BASECRYPTLIB (Md5.Services.HashAll, Md5HashAll, (Data, DataSize, HashValue), FALSE);
553}
554
555#endif
556
557#ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
558
559/**
560 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
561
562 If this interface is not supported, then return zero.
563
564 @retval 0 This interface is not supported.
565
566**/
567UINTN
568EFIAPI
569DeprecatedCryptoServiceSha1GetContextSize (
570 VOID
571 )
572{
573 return BaseCryptLibServiceDeprecated ("Sha1GetContextSize"), 0;
574}
575
576/**
577 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
578 subsequent use.
579
580 If Sha1Context is NULL, then return FALSE.
581 If this interface is not supported, then return FALSE.
582
583 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
584
585 @retval TRUE SHA-1 context initialization succeeded.
586 @retval FALSE SHA-1 context initialization failed.
587 @retval FALSE This interface is not supported.
588
589**/
590BOOLEAN
591EFIAPI
592DeprecatedCryptoServiceSha1Init (
593 OUT VOID *Sha1Context
594 )
595{
596 return BaseCryptLibServiceDeprecated ("Sha1Init"), FALSE;
597}
598
599/**
600 Makes a copy of an existing SHA-1 context.
601
602 If Sha1Context is NULL, then return FALSE.
603 If NewSha1Context is NULL, then return FALSE.
604 If this interface is not supported, then return FALSE.
605
606 @param[in] Sha1Context Pointer to SHA-1 context being copied.
607 @param[out] NewSha1Context Pointer to new SHA-1 context.
608
609 @retval FALSE This interface is not supported.
610
611**/
612BOOLEAN
613EFIAPI
614DeprecatedCryptoServiceSha1Duplicate (
615 IN CONST VOID *Sha1Context,
616 OUT VOID *NewSha1Context
617 )
618{
619 return BaseCryptLibServiceDeprecated ("Sha1Duplicate"), FALSE;
620}
621
622/**
623 Digests the input data and updates SHA-1 context.
624
625 This function performs SHA-1 digest on a data buffer of the specified size.
626 It can be called multiple times to compute the digest of long or discontinuous data streams.
627 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
628 by Sha1Final(). Behavior with invalid context is undefined.
629
630 If Sha1Context is NULL, then return FALSE.
631 If this interface is not supported, then return FALSE.
632
633 @param[in, out] Sha1Context Pointer to the SHA-1 context.
634 @param[in] Data Pointer to the buffer containing the data to be hashed.
635 @param[in] DataSize Size of Data buffer in bytes.
636
637 @retval FALSE This interface is not supported.
638
639**/
640BOOLEAN
641EFIAPI
642DeprecatedCryptoServiceSha1Update (
643 IN OUT VOID *Sha1Context,
644 IN CONST VOID *Data,
645 IN UINTN DataSize
646 )
647{
648 return BaseCryptLibServiceDeprecated ("Sha1Update"), FALSE;
649}
650
651/**
652 Completes computation of the SHA-1 digest value.
653
654 This function completes SHA-1 hash computation and retrieves the digest value into
655 the specified memory. After this function has been called, the SHA-1 context cannot
656 be used again.
657 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
658 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
659
660 If Sha1Context is NULL, then return FALSE.
661 If HashValue is NULL, then return FALSE.
662 If this interface is not supported, then return FALSE.
663
664 @param[in, out] Sha1Context Pointer to the SHA-1 context.
665 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
666 value (20 bytes).
667
668 @retval FALSE This interface is not supported.
669
670**/
671BOOLEAN
672EFIAPI
673DeprecatedCryptoServiceSha1Final (
674 IN OUT VOID *Sha1Context,
675 OUT UINT8 *HashValue
676 )
677{
678 return BaseCryptLibServiceDeprecated ("Sha1Final"), FALSE;
679}
680
681/**
682 Computes the SHA-1 message digest of a input data buffer.
683
684 This function performs the SHA-1 message digest of a given data buffer, and places
685 the digest value into the specified memory.
686
687 If this interface is not supported, then return FALSE.
688
689 @param[in] Data Pointer to the buffer containing the data to be hashed.
690 @param[in] DataSize Size of Data buffer in bytes.
691 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
692 value (20 bytes).
693
694 @retval FALSE This interface is not supported.
695
696**/
697BOOLEAN
698EFIAPI
699DeprecatedCryptoServiceSha1HashAll (
700 IN CONST VOID *Data,
701 IN UINTN DataSize,
702 OUT UINT8 *HashValue
703 )
704{
705 return BaseCryptLibServiceDeprecated ("Sha1HashAll"), FALSE;
706}
707
708#else
709
710/**
711 Retrieves the size, in bytes, of the context buffer required for SHA-1 hash operations.
712
713 If this interface is not supported, then return zero.
714
715 @return The size, in bytes, of the context buffer required for SHA-1 hash operations.
716 @retval 0 This interface is not supported.
717
718**/
719UINTN
720EFIAPI
721CryptoServiceSha1GetContextSize (
722 VOID
723 )
724{
725 return CALL_BASECRYPTLIB (Sha1.Services.GetContextSize, Sha1GetContextSize, (), 0);
726}
727
728/**
729 Initializes user-supplied memory pointed by Sha1Context as SHA-1 hash context for
730 subsequent use.
731
732 If Sha1Context is NULL, then return FALSE.
733 If this interface is not supported, then return FALSE.
734
735 @param[out] Sha1Context Pointer to SHA-1 context being initialized.
736
737 @retval TRUE SHA-1 context initialization succeeded.
738 @retval FALSE SHA-1 context initialization failed.
739 @retval FALSE This interface is not supported.
740
741**/
742BOOLEAN
743EFIAPI
744CryptoServiceSha1Init (
745 OUT VOID *Sha1Context
746 )
747{
748 return CALL_BASECRYPTLIB (Sha1.Services.Init, Sha1Init, (Sha1Context), FALSE);
749}
750
751/**
752 Makes a copy of an existing SHA-1 context.
753
754 If Sha1Context is NULL, then return FALSE.
755 If NewSha1Context is NULL, then return FALSE.
756 If this interface is not supported, then return FALSE.
757
758 @param[in] Sha1Context Pointer to SHA-1 context being copied.
759 @param[out] NewSha1Context Pointer to new SHA-1 context.
760
761 @retval TRUE SHA-1 context copy succeeded.
762 @retval FALSE SHA-1 context copy failed.
763 @retval FALSE This interface is not supported.
764
765**/
766BOOLEAN
767EFIAPI
768CryptoServiceSha1Duplicate (
769 IN CONST VOID *Sha1Context,
770 OUT VOID *NewSha1Context
771 )
772{
773 return CALL_BASECRYPTLIB (Sha1.Services.Duplicate, Sha1Duplicate, (Sha1Context, NewSha1Context), FALSE);
774}
775
776/**
777 Digests the input data and updates SHA-1 context.
778
779 This function performs SHA-1 digest on a data buffer of the specified size.
780 It can be called multiple times to compute the digest of long or discontinuous data streams.
781 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be finalized
782 by Sha1Final(). Behavior with invalid context is undefined.
783
784 If Sha1Context is NULL, then return FALSE.
785 If this interface is not supported, then return FALSE.
786
787 @param[in, out] Sha1Context Pointer to the SHA-1 context.
788 @param[in] Data Pointer to the buffer containing the data to be hashed.
789 @param[in] DataSize Size of Data buffer in bytes.
790
791 @retval TRUE SHA-1 data digest succeeded.
792 @retval FALSE SHA-1 data digest failed.
793 @retval FALSE This interface is not supported.
794
795**/
796BOOLEAN
797EFIAPI
798CryptoServiceSha1Update (
799 IN OUT VOID *Sha1Context,
800 IN CONST VOID *Data,
801 IN UINTN DataSize
802 )
803{
804 return CALL_BASECRYPTLIB (Sha1.Services.Update, Sha1Update, (Sha1Context, Data, DataSize), FALSE);
805}
806
807/**
808 Completes computation of the SHA-1 digest value.
809
810 This function completes SHA-1 hash computation and retrieves the digest value into
811 the specified memory. After this function has been called, the SHA-1 context cannot
812 be used again.
813 SHA-1 context should be already correctly initialized by Sha1Init(), and should not be
814 finalized by Sha1Final(). Behavior with invalid SHA-1 context is undefined.
815
816 If Sha1Context is NULL, then return FALSE.
817 If HashValue is NULL, then return FALSE.
818 If this interface is not supported, then return FALSE.
819
820 @param[in, out] Sha1Context Pointer to the SHA-1 context.
821 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
822 value (20 bytes).
823
824 @retval TRUE SHA-1 digest computation succeeded.
825 @retval FALSE SHA-1 digest computation failed.
826 @retval FALSE This interface is not supported.
827
828**/
829BOOLEAN
830EFIAPI
831CryptoServiceSha1Final (
832 IN OUT VOID *Sha1Context,
833 OUT UINT8 *HashValue
834 )
835{
836 return CALL_BASECRYPTLIB (Sha1.Services.Final, Sha1Final, (Sha1Context, HashValue), FALSE);
837}
838
839/**
840 Computes the SHA-1 message digest of a input data buffer.
841
842 This function performs the SHA-1 message digest of a given data buffer, and places
843 the digest value into the specified memory.
844
845 If this interface is not supported, then return FALSE.
846
847 @param[in] Data Pointer to the buffer containing the data to be hashed.
848 @param[in] DataSize Size of Data buffer in bytes.
849 @param[out] HashValue Pointer to a buffer that receives the SHA-1 digest
850 value (20 bytes).
851
852 @retval TRUE SHA-1 digest computation succeeded.
853 @retval FALSE SHA-1 digest computation failed.
854 @retval FALSE This interface is not supported.
855
856**/
857BOOLEAN
858EFIAPI
859CryptoServiceSha1HashAll (
860 IN CONST VOID *Data,
861 IN UINTN DataSize,
862 OUT UINT8 *HashValue
863 )
864{
865 return CALL_BASECRYPTLIB (Sha1.Services.HashAll, Sha1HashAll, (Data, DataSize, HashValue), FALSE);
866}
867
868#endif
869
870/**
871 Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
872
873 @return The size, in bytes, of the context buffer required for SHA-256 hash operations.
874
875**/
876UINTN
877EFIAPI
878CryptoServiceSha256GetContextSize (
879 VOID
880 )
881{
882 return CALL_BASECRYPTLIB (Sha256.Services.GetContextSize, Sha256GetContextSize, (), 0);
883}
884
885/**
886 Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
887 subsequent use.
888
889 If Sha256Context is NULL, then return FALSE.
890
891 @param[out] Sha256Context Pointer to SHA-256 context being initialized.
892
893 @retval TRUE SHA-256 context initialization succeeded.
894 @retval FALSE SHA-256 context initialization failed.
895
896**/
897BOOLEAN
898EFIAPI
899CryptoServiceSha256Init (
900 OUT VOID *Sha256Context
901 )
902{
903 return CALL_BASECRYPTLIB (Sha256.Services.Init, Sha256Init, (Sha256Context), FALSE);
904}
905
906/**
907 Makes a copy of an existing SHA-256 context.
908
909 If Sha256Context is NULL, then return FALSE.
910 If NewSha256Context is NULL, then return FALSE.
911 If this interface is not supported, then return FALSE.
912
913 @param[in] Sha256Context Pointer to SHA-256 context being copied.
914 @param[out] NewSha256Context Pointer to new SHA-256 context.
915
916 @retval TRUE SHA-256 context copy succeeded.
917 @retval FALSE SHA-256 context copy failed.
918 @retval FALSE This interface is not supported.
919
920**/
921BOOLEAN
922EFIAPI
923CryptoServiceSha256Duplicate (
924 IN CONST VOID *Sha256Context,
925 OUT VOID *NewSha256Context
926 )
927{
928 return CALL_BASECRYPTLIB (Sha256.Services.Duplicate, Sha256Duplicate, (Sha256Context, NewSha256Context), FALSE);
929}
930
931/**
932 Digests the input data and updates SHA-256 context.
933
934 This function performs SHA-256 digest on a data buffer of the specified size.
935 It can be called multiple times to compute the digest of long or discontinuous data streams.
936 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized
937 by Sha256Final(). Behavior with invalid context is undefined.
938
939 If Sha256Context is NULL, then return FALSE.
940
941 @param[in, out] Sha256Context Pointer to the SHA-256 context.
942 @param[in] Data Pointer to the buffer containing the data to be hashed.
943 @param[in] DataSize Size of Data buffer in bytes.
944
945 @retval TRUE SHA-256 data digest succeeded.
946 @retval FALSE SHA-256 data digest failed.
947
948**/
949BOOLEAN
950EFIAPI
951CryptoServiceSha256Update (
952 IN OUT VOID *Sha256Context,
953 IN CONST VOID *Data,
954 IN UINTN DataSize
955 )
956{
957 return CALL_BASECRYPTLIB (Sha256.Services.Update, Sha256Update, (Sha256Context, Data, DataSize), FALSE);
958}
959
960/**
961 Completes computation of the SHA-256 digest value.
962
963 This function completes SHA-256 hash computation and retrieves the digest value into
964 the specified memory. After this function has been called, the SHA-256 context cannot
965 be used again.
966 SHA-256 context should be already correctly initialized by Sha256Init(), and should not be
967 finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
968
969 If Sha256Context is NULL, then return FALSE.
970 If HashValue is NULL, then return FALSE.
971
972 @param[in, out] Sha256Context Pointer to the SHA-256 context.
973 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
974 value (32 bytes).
975
976 @retval TRUE SHA-256 digest computation succeeded.
977 @retval FALSE SHA-256 digest computation failed.
978
979**/
980BOOLEAN
981EFIAPI
982CryptoServiceSha256Final (
983 IN OUT VOID *Sha256Context,
984 OUT UINT8 *HashValue
985 )
986{
987 return CALL_BASECRYPTLIB (Sha256.Services.Final, Sha256Final, (Sha256Context, HashValue), FALSE);
988}
989
990/**
991 Computes the SHA-256 message digest of a input data buffer.
992
993 This function performs the SHA-256 message digest of a given data buffer, and places
994 the digest value into the specified memory.
995
996 If this interface is not supported, then return FALSE.
997
998 @param[in] Data Pointer to the buffer containing the data to be hashed.
999 @param[in] DataSize Size of Data buffer in bytes.
1000 @param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
1001 value (32 bytes).
1002
1003 @retval TRUE SHA-256 digest computation succeeded.
1004 @retval FALSE SHA-256 digest computation failed.
1005 @retval FALSE This interface is not supported.
1006
1007**/
1008BOOLEAN
1009EFIAPI
1010CryptoServiceSha256HashAll (
1011 IN CONST VOID *Data,
1012 IN UINTN DataSize,
1013 OUT UINT8 *HashValue
1014 )
1015{
1016 return CALL_BASECRYPTLIB (Sha256.Services.HashAll, Sha256HashAll, (Data, DataSize, HashValue), FALSE);
1017}
1018
1019/**
1020 Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
1021
1022 @return The size, in bytes, of the context buffer required for SHA-384 hash operations.
1023
1024**/
1025UINTN
1026EFIAPI
1027CryptoServiceSha384GetContextSize (
1028 VOID
1029 )
1030{
1031 return CALL_BASECRYPTLIB (Sha384.Services.GetContextSize, Sha384GetContextSize, (), 0);
1032}
1033
1034/**
1035 Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for
1036 subsequent use.
1037
1038 If Sha384Context is NULL, then return FALSE.
1039
1040 @param[out] Sha384Context Pointer to SHA-384 context being initialized.
1041
1042 @retval TRUE SHA-384 context initialization succeeded.
1043 @retval FALSE SHA-384 context initialization failed.
1044
1045**/
1046BOOLEAN
1047EFIAPI
1048CryptoServiceSha384Init (
1049 OUT VOID *Sha384Context
1050 )
1051{
1052 return CALL_BASECRYPTLIB (Sha384.Services.Init, Sha384Init, (Sha384Context), FALSE);
1053}
1054
1055/**
1056 Makes a copy of an existing SHA-384 context.
1057
1058 If Sha384Context is NULL, then return FALSE.
1059 If NewSha384Context is NULL, then return FALSE.
1060 If this interface is not supported, then return FALSE.
1061
1062 @param[in] Sha384Context Pointer to SHA-384 context being copied.
1063 @param[out] NewSha384Context Pointer to new SHA-384 context.
1064
1065 @retval TRUE SHA-384 context copy succeeded.
1066 @retval FALSE SHA-384 context copy failed.
1067 @retval FALSE This interface is not supported.
1068
1069**/
1070BOOLEAN
1071EFIAPI
1072CryptoServiceSha384Duplicate (
1073 IN CONST VOID *Sha384Context,
1074 OUT VOID *NewSha384Context
1075 )
1076{
1077 return CALL_BASECRYPTLIB (Sha384.Services.Duplicate, Sha384Duplicate, (Sha384Context, NewSha384Context), FALSE);
1078}
1079
1080/**
1081 Digests the input data and updates SHA-384 context.
1082
1083 This function performs SHA-384 digest on a data buffer of the specified size.
1084 It can be called multiple times to compute the digest of long or discontinuous data streams.
1085 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized
1086 by Sha384Final(). Behavior with invalid context is undefined.
1087
1088 If Sha384Context is NULL, then return FALSE.
1089
1090 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1091 @param[in] Data Pointer to the buffer containing the data to be hashed.
1092 @param[in] DataSize Size of Data buffer in bytes.
1093
1094 @retval TRUE SHA-384 data digest succeeded.
1095 @retval FALSE SHA-384 data digest failed.
1096
1097**/
1098BOOLEAN
1099EFIAPI
1100CryptoServiceSha384Update (
1101 IN OUT VOID *Sha384Context,
1102 IN CONST VOID *Data,
1103 IN UINTN DataSize
1104 )
1105{
1106 return CALL_BASECRYPTLIB (Sha384.Services.Update, Sha384Update, (Sha384Context, Data, DataSize), FALSE);
1107}
1108
1109/**
1110 Completes computation of the SHA-384 digest value.
1111
1112 This function completes SHA-384 hash computation and retrieves the digest value into
1113 the specified memory. After this function has been called, the SHA-384 context cannot
1114 be used again.
1115 SHA-384 context should be already correctly initialized by Sha384Init(), and should not be
1116 finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.
1117
1118 If Sha384Context is NULL, then return FALSE.
1119 If HashValue is NULL, then return FALSE.
1120
1121 @param[in, out] Sha384Context Pointer to the SHA-384 context.
1122 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1123 value (48 bytes).
1124
1125 @retval TRUE SHA-384 digest computation succeeded.
1126 @retval FALSE SHA-384 digest computation failed.
1127
1128**/
1129BOOLEAN
1130EFIAPI
1131CryptoServiceSha384Final (
1132 IN OUT VOID *Sha384Context,
1133 OUT UINT8 *HashValue
1134 )
1135{
1136 return CALL_BASECRYPTLIB (Sha384.Services.Final, Sha384Final, (Sha384Context, HashValue), FALSE);
1137}
1138
1139/**
1140 Computes the SHA-384 message digest of a input data buffer.
1141
1142 This function performs the SHA-384 message digest of a given data buffer, and places
1143 the digest value into the specified memory.
1144
1145 If this interface is not supported, then return FALSE.
1146
1147 @param[in] Data Pointer to the buffer containing the data to be hashed.
1148 @param[in] DataSize Size of Data buffer in bytes.
1149 @param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
1150 value (48 bytes).
1151
1152 @retval TRUE SHA-384 digest computation succeeded.
1153 @retval FALSE SHA-384 digest computation failed.
1154 @retval FALSE This interface is not supported.
1155
1156**/
1157BOOLEAN
1158EFIAPI
1159CryptoServiceSha384HashAll (
1160 IN CONST VOID *Data,
1161 IN UINTN DataSize,
1162 OUT UINT8 *HashValue
1163 )
1164{
1165 return CALL_BASECRYPTLIB (Sha384.Services.HashAll, Sha384HashAll, (Data, DataSize, HashValue), FALSE);
1166}
1167
1168/**
1169 Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.
1170
1171 @return The size, in bytes, of the context buffer required for SHA-512 hash operations.
1172
1173**/
1174UINTN
1175EFIAPI
1176CryptoServiceSha512GetContextSize (
1177 VOID
1178 )
1179{
1180 return CALL_BASECRYPTLIB (Sha512.Services.GetContextSize, Sha512GetContextSize, (), 0);
1181}
1182
1183/**
1184 Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for
1185 subsequent use.
1186
1187 If Sha512Context is NULL, then return FALSE.
1188
1189 @param[out] Sha512Context Pointer to SHA-512 context being initialized.
1190
1191 @retval TRUE SHA-512 context initialization succeeded.
1192 @retval FALSE SHA-512 context initialization failed.
1193
1194**/
1195BOOLEAN
1196EFIAPI
1197CryptoServiceSha512Init (
1198 OUT VOID *Sha512Context
1199 )
1200{
1201 return CALL_BASECRYPTLIB (Sha512.Services.Init, Sha512Init, (Sha512Context), FALSE);
1202}
1203
1204/**
1205 Makes a copy of an existing SHA-512 context.
1206
1207 If Sha512Context is NULL, then return FALSE.
1208 If NewSha512Context is NULL, then return FALSE.
1209 If this interface is not supported, then return FALSE.
1210
1211 @param[in] Sha512Context Pointer to SHA-512 context being copied.
1212 @param[out] NewSha512Context Pointer to new SHA-512 context.
1213
1214 @retval TRUE SHA-512 context copy succeeded.
1215 @retval FALSE SHA-512 context copy failed.
1216 @retval FALSE This interface is not supported.
1217
1218**/
1219BOOLEAN
1220EFIAPI
1221CryptoServiceSha512Duplicate (
1222 IN CONST VOID *Sha512Context,
1223 OUT VOID *NewSha512Context
1224 )
1225{
1226 return CALL_BASECRYPTLIB (Sha512.Services.Duplicate, Sha512Duplicate, (Sha512Context, NewSha512Context), FALSE);
1227}
1228
1229/**
1230 Digests the input data and updates SHA-512 context.
1231
1232 This function performs SHA-512 digest on a data buffer of the specified size.
1233 It can be called multiple times to compute the digest of long or discontinuous data streams.
1234 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized
1235 by Sha512Final(). Behavior with invalid context is undefined.
1236
1237 If Sha512Context is NULL, then return FALSE.
1238
1239 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1240 @param[in] Data Pointer to the buffer containing the data to be hashed.
1241 @param[in] DataSize Size of Data buffer in bytes.
1242
1243 @retval TRUE SHA-512 data digest succeeded.
1244 @retval FALSE SHA-512 data digest failed.
1245
1246**/
1247BOOLEAN
1248EFIAPI
1249CryptoServiceSha512Update (
1250 IN OUT VOID *Sha512Context,
1251 IN CONST VOID *Data,
1252 IN UINTN DataSize
1253 )
1254{
1255 return CALL_BASECRYPTLIB (Sha512.Services.Update, Sha512Update, (Sha512Context, Data, DataSize), FALSE);
1256}
1257
1258/**
1259 Completes computation of the SHA-512 digest value.
1260
1261 This function completes SHA-512 hash computation and retrieves the digest value into
1262 the specified memory. After this function has been called, the SHA-512 context cannot
1263 be used again.
1264 SHA-512 context should be already correctly initialized by Sha512Init(), and should not be
1265 finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.
1266
1267 If Sha512Context is NULL, then return FALSE.
1268 If HashValue is NULL, then return FALSE.
1269
1270 @param[in, out] Sha512Context Pointer to the SHA-512 context.
1271 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1272 value (64 bytes).
1273
1274 @retval TRUE SHA-512 digest computation succeeded.
1275 @retval FALSE SHA-512 digest computation failed.
1276
1277**/
1278BOOLEAN
1279EFIAPI
1280CryptoServiceSha512Final (
1281 IN OUT VOID *Sha512Context,
1282 OUT UINT8 *HashValue
1283 )
1284{
1285 return CALL_BASECRYPTLIB (Sha512.Services.Final, Sha512Final, (Sha512Context, HashValue), FALSE);
1286}
1287
1288/**
1289 Computes the SHA-512 message digest of a input data buffer.
1290
1291 This function performs the SHA-512 message digest of a given data buffer, and places
1292 the digest value into the specified memory.
1293
1294 If this interface is not supported, then return FALSE.
1295
1296 @param[in] Data Pointer to the buffer containing the data to be hashed.
1297 @param[in] DataSize Size of Data buffer in bytes.
1298 @param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
1299 value (64 bytes).
1300
1301 @retval TRUE SHA-512 digest computation succeeded.
1302 @retval FALSE SHA-512 digest computation failed.
1303 @retval FALSE This interface is not supported.
1304
1305**/
1306BOOLEAN
1307EFIAPI
1308CryptoServiceSha512HashAll (
1309 IN CONST VOID *Data,
1310 IN UINTN DataSize,
1311 OUT UINT8 *HashValue
1312 )
1313{
1314 return CALL_BASECRYPTLIB (Sha512.Services.HashAll, Sha512HashAll, (Data, DataSize, HashValue), FALSE);
1315}
1316
1317/**
1318 Retrieves the size, in bytes, of the context buffer required for SM3 hash operations.
1319
1320 @return The size, in bytes, of the context buffer required for SM3 hash operations.
1321
1322**/
1323UINTN
1324EFIAPI
1325CryptoServiceSm3GetContextSize (
1326 VOID
1327 )
1328{
1329 return CALL_BASECRYPTLIB (Sm3.Services.GetContextSize, Sm3GetContextSize, (), 0);
1330}
1331
1332/**
1333 Initializes user-supplied memory pointed by Sm3Context as SM3 hash context for
1334 subsequent use.
1335
1336 If Sm3Context is NULL, then return FALSE.
1337
1338 @param[out] Sm3Context Pointer to SM3 context being initialized.
1339
1340 @retval TRUE SM3 context initialization succeeded.
1341 @retval FALSE SM3 context initialization failed.
1342
1343**/
1344BOOLEAN
1345EFIAPI
1346CryptoServiceSm3Init (
1347 OUT VOID *Sm3Context
1348 )
1349{
1350 return CALL_BASECRYPTLIB (Sm3.Services.Init, Sm3Init, (Sm3Context), FALSE);
1351}
1352
1353/**
1354 Makes a copy of an existing SM3 context.
1355
1356 If Sm3Context is NULL, then return FALSE.
1357 If NewSm3Context is NULL, then return FALSE.
1358 If this interface is not supported, then return FALSE.
1359
1360 @param[in] Sm3Context Pointer to SM3 context being copied.
1361 @param[out] NewSm3Context Pointer to new SM3 context.
1362
1363 @retval TRUE SM3 context copy succeeded.
1364 @retval FALSE SM3 context copy failed.
1365 @retval FALSE This interface is not supported.
1366
1367**/
1368BOOLEAN
1369EFIAPI
1370CryptoServiceSm3Duplicate (
1371 IN CONST VOID *Sm3Context,
1372 OUT VOID *NewSm3Context
1373 )
1374{
1375 return CALL_BASECRYPTLIB (Sm3.Services.Duplicate, Sm3Duplicate, (Sm3Context, NewSm3Context), FALSE);
1376}
1377
1378/**
1379 Digests the input data and updates SM3 context.
1380
1381 This function performs SM3 digest on a data buffer of the specified size.
1382 It can be called multiple times to compute the digest of long or discontinuous data streams.
1383 SM3 context should be already correctly initialized by Sm3Init(), and should not be finalized
1384 by Sm3Final(). Behavior with invalid context is undefined.
1385
1386 If Sm3Context is NULL, then return FALSE.
1387
1388 @param[in, out] Sm3Context Pointer to the SM3 context.
1389 @param[in] Data Pointer to the buffer containing the data to be hashed.
1390 @param[in] DataSize Size of Data buffer in bytes.
1391
1392 @retval TRUE SM3 data digest succeeded.
1393 @retval FALSE SM3 data digest failed.
1394
1395**/
1396BOOLEAN
1397EFIAPI
1398CryptoServiceSm3Update (
1399 IN OUT VOID *Sm3Context,
1400 IN CONST VOID *Data,
1401 IN UINTN DataSize
1402 )
1403{
1404 return CALL_BASECRYPTLIB (Sm3.Services.Update, Sm3Update, (Sm3Context, Data, DataSize), FALSE);
1405}
1406
1407/**
1408 Completes computation of the SM3 digest value.
1409
1410 This function completes SM3 hash computation and retrieves the digest value into
1411 the specified memory. After this function has been called, the SM3 context cannot
1412 be used again.
1413 SM3 context should be already correctly initialized by Sm3Init(), and should not be
1414 finalized by Sm3Final(). Behavior with invalid SM3 context is undefined.
1415
1416 If Sm3Context is NULL, then return FALSE.
1417 If HashValue is NULL, then return FALSE.
1418
1419 @param[in, out] Sm3Context Pointer to the SM3 context.
1420 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1421 value (32 bytes).
1422
1423 @retval TRUE SM3 digest computation succeeded.
1424 @retval FALSE SM3 digest computation failed.
1425
1426**/
1427BOOLEAN
1428EFIAPI
1429CryptoServiceSm3Final (
1430 IN OUT VOID *Sm3Context,
1431 OUT UINT8 *HashValue
1432 )
1433{
1434 return CALL_BASECRYPTLIB (Sm3.Services.Final, Sm3Final, (Sm3Context, HashValue), FALSE);
1435}
1436
1437/**
1438 Computes the SM3 message digest of a input data buffer.
1439
1440 This function performs the SM3 message digest of a given data buffer, and places
1441 the digest value into the specified memory.
1442
1443 If this interface is not supported, then return FALSE.
1444
1445 @param[in] Data Pointer to the buffer containing the data to be hashed.
1446 @param[in] DataSize Size of Data buffer in bytes.
1447 @param[out] HashValue Pointer to a buffer that receives the SM3 digest
1448 value (32 bytes).
1449
1450 @retval TRUE SM3 digest computation succeeded.
1451 @retval FALSE SM3 digest computation failed.
1452 @retval FALSE This interface is not supported.
1453
1454**/
1455BOOLEAN
1456EFIAPI
1457CryptoServiceSm3HashAll (
1458 IN CONST VOID *Data,
1459 IN UINTN DataSize,
1460 OUT UINT8 *HashValue
1461 )
1462{
1463 return CALL_BASECRYPTLIB (Sm3.Services.HashAll, Sm3HashAll, (Data, DataSize, HashValue), FALSE);
1464}
1465
1466// =====================================================================================
1467// MAC (Message Authentication Code) Primitive
1468// =====================================================================================
1469
1470/**
1471 HMAC MD5 is deprecated and unsupported any longer.
1472 Keep the function field for binary compability.
1473
1474 @retval NULL This interface is not supported.
1475
1476**/
1477VOID *
1478EFIAPI
1479DeprecatedCryptoServiceHmacMd5New (
1480 VOID
1481 )
1482{
1483 return BaseCryptLibServiceDeprecated ("HmacMd5New"), NULL;
1484}
1485
1486/**
1487 HMAC MD5 is deprecated and unsupported any longer.
1488 Keep the function field for binary compability.
1489
1490 @param[in] HmacMd5Ctx Pointer to the HMAC_CTX context to be released.
1491
1492**/
1493VOID
1494EFIAPI
1495DeprecatedCryptoServiceHmacMd5Free (
1496 IN VOID *HmacMd5Ctx
1497 )
1498{
1499 BaseCryptLibServiceDeprecated ("HmacMd5Free");
1500}
1501
1502/**
1503 HMAC MD5 is deprecated and unsupported any longer.
1504 Keep the function field for binary compability.
1505
1506 @param[out] HmacMd5Context Pointer to HMAC-MD5 context.
1507 @param[in] Key Pointer to the user-supplied key.
1508 @param[in] KeySize Key size in bytes.
1509
1510 @retval FALSE This interface is not supported.
1511
1512**/
1513BOOLEAN
1514EFIAPI
1515DeprecatedCryptoServiceHmacMd5SetKey (
1516 OUT VOID *HmacMd5Context,
1517 IN CONST UINT8 *Key,
1518 IN UINTN KeySize
1519 )
1520{
1521 return BaseCryptLibServiceDeprecated ("HmacMd5SetKey"), FALSE;
1522}
1523
1524/**
1525 HMAC MD5 is deprecated and unsupported any longer.
1526 Keep the function field for binary compability.
1527
1528 @param[in] HmacMd5Context Pointer to HMAC-MD5 context being copied.
1529 @param[out] NewHmacMd5Context Pointer to new HMAC-MD5 context.
1530
1531 @retval FALSE This interface is not supported.
1532
1533**/
1534BOOLEAN
1535EFIAPI
1536DeprecatedCryptoServiceHmacMd5Duplicate (
1537 IN CONST VOID *HmacMd5Context,
1538 OUT VOID *NewHmacMd5Context
1539 )
1540{
1541 return BaseCryptLibServiceDeprecated ("HmacMd5Duplicate"), FALSE;
1542}
1543
1544/**
1545 HMAC MD5 is deprecated and unsupported any longer.
1546 Keep the function field for binary compability.
1547
1548 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1549 @param[in] Data Pointer to the buffer containing the data to be digested.
1550 @param[in] DataSize Size of Data buffer in bytes.
1551
1552 @retval FALSE This interface is not supported.
1553
1554**/
1555BOOLEAN
1556EFIAPI
1557DeprecatedCryptoServiceHmacMd5Update (
1558 IN OUT VOID *HmacMd5Context,
1559 IN CONST VOID *Data,
1560 IN UINTN DataSize
1561 )
1562{
1563 return BaseCryptLibServiceDeprecated ("HmacMd5Update"), FALSE;
1564}
1565
1566/**
1567 HMAC MD5 is deprecated and unsupported any longer.
1568 Keep the function field for binary compability.
1569
1570 @param[in, out] HmacMd5Context Pointer to the HMAC-MD5 context.
1571 @param[out] HmacValue Pointer to a buffer that receives the HMAC-MD5 digest
1572 value (16 bytes).
1573
1574 @retval FALSE This interface is not supported.
1575
1576**/
1577BOOLEAN
1578EFIAPI
1579DeprecatedCryptoServiceHmacMd5Final (
1580 IN OUT VOID *HmacMd5Context,
1581 OUT UINT8 *HmacValue
1582 )
1583{
1584 return BaseCryptLibServiceDeprecated ("HmacMd5Final"), FALSE;
1585}
1586
1587/**
1588 HMAC SHA1 is deprecated and unsupported any longer.
1589 Keep the function field for binary compability.
1590
1591 @return NULL This interface is not supported.
1592
1593**/
1594VOID *
1595EFIAPI
1596DeprecatedCryptoServiceHmacSha1New (
1597 VOID
1598 )
1599{
1600 return BaseCryptLibServiceDeprecated ("HmacSha1New"), NULL;
1601}
1602
1603/**
1604 HMAC SHA1 is deprecated and unsupported any longer.
1605 Keep the function field for binary compability.
1606
1607 @param[in] HmacSha1Ctx Pointer to the HMAC_CTX context to be released.
1608
1609**/
1610VOID
1611EFIAPI
1612DeprecatedCryptoServiceHmacSha1Free (
1613 IN VOID *HmacSha1Ctx
1614 )
1615{
1616 BaseCryptLibServiceDeprecated ("HmacSha1Free");
1617}
1618
1619/**
1620 HMAC SHA1 is deprecated and unsupported any longer.
1621 Keep the function field for binary compability.
1622
1623 @param[out] HmacSha1Context Pointer to HMAC-SHA1 context.
1624 @param[in] Key Pointer to the user-supplied key.
1625 @param[in] KeySize Key size in bytes.
1626
1627 @retval FALSE This interface is not supported.
1628
1629**/
1630BOOLEAN
1631EFIAPI
1632DeprecatedCryptoServiceHmacSha1SetKey (
1633 OUT VOID *HmacSha1Context,
1634 IN CONST UINT8 *Key,
1635 IN UINTN KeySize
1636 )
1637{
1638 return BaseCryptLibServiceDeprecated ("HmacSha1SetKey"), FALSE;
1639}
1640
1641/**
1642 HMAC SHA1 is deprecated and unsupported any longer.
1643 Keep the function field for binary compability.
1644
1645 @param[in] HmacSha1Context Pointer to HMAC-SHA1 context being copied.
1646 @param[out] NewHmacSha1Context Pointer to new HMAC-SHA1 context.
1647
1648 @retval FALSE This interface is not supported.
1649
1650**/
1651BOOLEAN
1652EFIAPI
1653DeprecatedCryptoServiceHmacSha1Duplicate (
1654 IN CONST VOID *HmacSha1Context,
1655 OUT VOID *NewHmacSha1Context
1656 )
1657{
1658 return BaseCryptLibServiceDeprecated ("HmacSha1Duplicate"), FALSE;
1659}
1660
1661/**
1662 HMAC SHA1 is deprecated and unsupported any longer.
1663 Keep the function field for binary compability.
1664
1665 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1666 @param[in] Data Pointer to the buffer containing the data to be digested.
1667 @param[in] DataSize Size of Data buffer in bytes.
1668
1669 @retval FALSE This interface is not supported.
1670
1671**/
1672BOOLEAN
1673EFIAPI
1674DeprecatedCryptoServiceHmacSha1Update (
1675 IN OUT VOID *HmacSha1Context,
1676 IN CONST VOID *Data,
1677 IN UINTN DataSize
1678 )
1679{
1680 return BaseCryptLibServiceDeprecated ("HmacSha1Update"), FALSE;
1681}
1682
1683/**
1684 HMAC SHA1 is deprecated and unsupported any longer.
1685 Keep the function field for binary compability.
1686
1687 @param[in, out] HmacSha1Context Pointer to the HMAC-SHA1 context.
1688 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA1 digest
1689 value (20 bytes).
1690
1691 @retval FALSE This interface is not supported.
1692
1693**/
1694BOOLEAN
1695EFIAPI
1696DeprecatedCryptoServiceHmacSha1Final (
1697 IN OUT VOID *HmacSha1Context,
1698 OUT UINT8 *HmacValue
1699 )
1700{
1701 return BaseCryptLibServiceDeprecated ("HmacSha1Final"), FALSE;
1702}
1703
1704/**
1705 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA256 use.
1706
1707 @return Pointer to the HMAC_CTX context that has been initialized.
1708 If the allocations fails, HmacSha256New() returns NULL.
1709
1710**/
1711VOID *
1712EFIAPI
1713CryptoServiceHmacSha256New (
1714 VOID
1715 )
1716{
1717 return CALL_BASECRYPTLIB (HmacSha256.Services.New, HmacSha256New, (), NULL);
1718}
1719
1720/**
1721 Release the specified HMAC_CTX context.
1722
1723 @param[in] HmacSha256Ctx Pointer to the HMAC_CTX context to be released.
1724
1725**/
1726VOID
1727EFIAPI
1728CryptoServiceHmacSha256Free (
1729 IN VOID *HmacSha256Ctx
1730 )
1731{
1732 CALL_VOID_BASECRYPTLIB (HmacSha256.Services.Free, HmacSha256Free, (HmacSha256Ctx));
1733}
1734
1735/**
1736 Set user-supplied key for subsequent use. It must be done before any
1737 calling to HmacSha256Update().
1738
1739 If HmacSha256Context is NULL, then return FALSE.
1740 If this interface is not supported, then return FALSE.
1741
1742 @param[out] HmacSha256Context Pointer to HMAC-SHA256 context.
1743 @param[in] Key Pointer to the user-supplied key.
1744 @param[in] KeySize Key size in bytes.
1745
1746 @retval TRUE The Key is set successfully.
1747 @retval FALSE The Key is set unsuccessfully.
1748 @retval FALSE This interface is not supported.
1749
1750**/
1751BOOLEAN
1752EFIAPI
1753CryptoServiceHmacSha256SetKey (
1754 OUT VOID *HmacSha256Context,
1755 IN CONST UINT8 *Key,
1756 IN UINTN KeySize
1757 )
1758{
1759 return CALL_BASECRYPTLIB (HmacSha256.Services.SetKey, HmacSha256SetKey, (HmacSha256Context, Key, KeySize), FALSE);
1760}
1761
1762/**
1763 Makes a copy of an existing HMAC-SHA256 context.
1764
1765 If HmacSha256Context is NULL, then return FALSE.
1766 If NewHmacSha256Context is NULL, then return FALSE.
1767 If this interface is not supported, then return FALSE.
1768
1769 @param[in] HmacSha256Context Pointer to HMAC-SHA256 context being copied.
1770 @param[out] NewHmacSha256Context Pointer to new HMAC-SHA256 context.
1771
1772 @retval TRUE HMAC-SHA256 context copy succeeded.
1773 @retval FALSE HMAC-SHA256 context copy failed.
1774 @retval FALSE This interface is not supported.
1775
1776**/
1777BOOLEAN
1778EFIAPI
1779CryptoServiceHmacSha256Duplicate (
1780 IN CONST VOID *HmacSha256Context,
1781 OUT VOID *NewHmacSha256Context
1782 )
1783{
1784 return CALL_BASECRYPTLIB (HmacSha256.Services.Duplicate, HmacSha256Duplicate, (HmacSha256Context, NewHmacSha256Context), FALSE);
1785}
1786
1787/**
1788 Digests the input data and updates HMAC-SHA256 context.
1789
1790 This function performs HMAC-SHA256 digest on a data buffer of the specified size.
1791 It can be called multiple times to compute the digest of long or discontinuous data streams.
1792 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1793 by HmacSha256Final(). Behavior with invalid context is undefined.
1794
1795 If HmacSha256Context is NULL, then return FALSE.
1796 If this interface is not supported, then return FALSE.
1797
1798 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1799 @param[in] Data Pointer to the buffer containing the data to be digested.
1800 @param[in] DataSize Size of Data buffer in bytes.
1801
1802 @retval TRUE HMAC-SHA256 data digest succeeded.
1803 @retval FALSE HMAC-SHA256 data digest failed.
1804 @retval FALSE This interface is not supported.
1805
1806**/
1807BOOLEAN
1808EFIAPI
1809CryptoServiceHmacSha256Update (
1810 IN OUT VOID *HmacSha256Context,
1811 IN CONST VOID *Data,
1812 IN UINTN DataSize
1813 )
1814{
1815 return CALL_BASECRYPTLIB (HmacSha256.Services.Update, HmacSha256Update, (HmacSha256Context, Data, DataSize), FALSE);
1816}
1817
1818/**
1819 Completes computation of the HMAC-SHA256 digest value.
1820
1821 This function completes HMAC-SHA256 hash computation and retrieves the digest value into
1822 the specified memory. After this function has been called, the HMAC-SHA256 context cannot
1823 be used again.
1824 HMAC-SHA256 context should be initialized by HmacSha256New(), and should not be finalized
1825 by HmacSha256Final(). Behavior with invalid HMAC-SHA256 context is undefined.
1826
1827 If HmacSha256Context is NULL, then return FALSE.
1828 If HmacValue is NULL, then return FALSE.
1829 If this interface is not supported, then return FALSE.
1830
1831 @param[in, out] HmacSha256Context Pointer to the HMAC-SHA256 context.
1832 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
1833 value (32 bytes).
1834
1835 @retval TRUE HMAC-SHA256 digest computation succeeded.
1836 @retval FALSE HMAC-SHA256 digest computation failed.
1837 @retval FALSE This interface is not supported.
1838
1839**/
1840BOOLEAN
1841EFIAPI
1842CryptoServiceHmacSha256Final (
1843 IN OUT VOID *HmacSha256Context,
1844 OUT UINT8 *HmacValue
1845 )
1846{
1847 return CALL_BASECRYPTLIB (HmacSha256.Services.Final, HmacSha256Final, (HmacSha256Context, HmacValue), FALSE);
1848}
1849
1850/**
1851 Computes the HMAC-SHA256 digest of a input data buffer.
1852
1853 This function performs the HMAC-SHA256 digest of a given data buffer, and places
1854 the digest value into the specified memory.
1855
1856 If this interface is not supported, then return FALSE.
1857
1858 @param[in] Data Pointer to the buffer containing the data to be digested.
1859 @param[in] DataSize Size of Data buffer in bytes.
1860 @param[in] Key Pointer to the user-supplied key.
1861 @param[in] KeySize Key size in bytes.
1862 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA256 digest
1863 value (32 bytes).
1864
1865 @retval TRUE HMAC-SHA256 digest computation succeeded.
1866 @retval FALSE HMAC-SHA256 digest computation failed.
1867 @retval FALSE This interface is not supported.
1868
1869**/
1870BOOLEAN
1871EFIAPI
1872CryptoServiceHmacSha256All (
1873 IN CONST VOID *Data,
1874 IN UINTN DataSize,
1875 IN CONST UINT8 *Key,
1876 IN UINTN KeySize,
1877 OUT UINT8 *HmacValue
1878 )
1879{
1880 return CALL_BASECRYPTLIB (HmacSha256.Services.All, HmacSha256All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);
1881}
1882
1883/**
1884 Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA384 use.
1885
1886 @return Pointer to the HMAC_CTX context that has been initialized.
1887 If the allocations fails, HmacSha384New() returns NULL.
1888
1889**/
1890VOID *
1891EFIAPI
1892CryptoServiceHmacSha384New (
1893 VOID
1894 )
1895{
1896 return CALL_BASECRYPTLIB (HmacSha384.Services.New, HmacSha384New, (), NULL);
1897}
1898
1899/**
1900 Release the specified HMAC_CTX context.
1901
1902 @param[in] HmacSha384Ctx Pointer to the HMAC_CTX context to be released.
1903
1904**/
1905VOID
1906EFIAPI
1907CryptoServiceHmacSha384Free (
1908 IN VOID *HmacSha384Ctx
1909 )
1910{
1911 CALL_VOID_BASECRYPTLIB (HmacSha384.Services.Free, HmacSha384Free, (HmacSha384Ctx));
1912}
1913
1914/**
1915 Set user-supplied key for subsequent use. It must be done before any
1916 calling to HmacSha384Update().
1917
1918 If HmacSha384Context is NULL, then return FALSE.
1919 If this interface is not supported, then return FALSE.
1920
1921 @param[out] HmacSha384Context Pointer to HMAC-SHA384 context.
1922 @param[in] Key Pointer to the user-supplied key.
1923 @param[in] KeySize Key size in bytes.
1924
1925 @retval TRUE The Key is set successfully.
1926 @retval FALSE The Key is set unsuccessfully.
1927 @retval FALSE This interface is not supported.
1928
1929**/
1930BOOLEAN
1931EFIAPI
1932CryptoServiceHmacSha384SetKey (
1933 OUT VOID *HmacSha384Context,
1934 IN CONST UINT8 *Key,
1935 IN UINTN KeySize
1936 )
1937{
1938 return CALL_BASECRYPTLIB (HmacSha384.Services.SetKey, HmacSha384SetKey, (HmacSha384Context, Key, KeySize), FALSE);
1939}
1940
1941/**
1942 Makes a copy of an existing HMAC-SHA384 context.
1943
1944 If HmacSha384Context is NULL, then return FALSE.
1945 If NewHmacSha384Context is NULL, then return FALSE.
1946 If this interface is not supported, then return FALSE.
1947
1948 @param[in] HmacSha384Context Pointer to HMAC-SHA384 context being copied.
1949 @param[out] NewHmacSha384Context Pointer to new HMAC-SHA384 context.
1950
1951 @retval TRUE HMAC-SHA384 context copy succeeded.
1952 @retval FALSE HMAC-SHA384 context copy failed.
1953 @retval FALSE This interface is not supported.
1954
1955**/
1956BOOLEAN
1957EFIAPI
1958CryptoServiceHmacSha384Duplicate (
1959 IN CONST VOID *HmacSha384Context,
1960 OUT VOID *NewHmacSha384Context
1961 )
1962{
1963 return CALL_BASECRYPTLIB (HmacSha384.Services.Duplicate, HmacSha256Duplicate, (HmacSha384Context, NewHmacSha384Context), FALSE);
1964}
1965
1966/**
1967 Digests the input data and updates HMAC-SHA384 context.
1968
1969 This function performs HMAC-SHA384 digest on a data buffer of the specified size.
1970 It can be called multiple times to compute the digest of long or discontinuous data streams.
1971 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
1972 by HmacSha384Final(). Behavior with invalid context is undefined.
1973
1974 If HmacSha384Context is NULL, then return FALSE.
1975 If this interface is not supported, then return FALSE.
1976
1977 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
1978 @param[in] Data Pointer to the buffer containing the data to be digested.
1979 @param[in] DataSize Size of Data buffer in bytes.
1980
1981 @retval TRUE HMAC-SHA384 data digest succeeded.
1982 @retval FALSE HMAC-SHA384 data digest failed.
1983 @retval FALSE This interface is not supported.
1984
1985**/
1986BOOLEAN
1987EFIAPI
1988CryptoServiceHmacSha384Update (
1989 IN OUT VOID *HmacSha384Context,
1990 IN CONST VOID *Data,
1991 IN UINTN DataSize
1992 )
1993{
1994 return CALL_BASECRYPTLIB (HmacSha384.Services.Update, HmacSha384Update, (HmacSha384Context, Data, DataSize), FALSE);
1995}
1996
1997/**
1998 Completes computation of the HMAC-SHA384 digest value.
1999
2000 This function completes HMAC-SHA384 hash computation and retrieves the digest value into
2001 the specified memory. After this function has been called, the HMAC-SHA384 context cannot
2002 be used again.
2003 HMAC-SHA384 context should be initialized by HmacSha384New(), and should not be finalized
2004 by HmacSha384Final(). Behavior with invalid HMAC-SHA384 context is undefined.
2005
2006 If HmacSha384Context is NULL, then return FALSE.
2007 If HmacValue is NULL, then return FALSE.
2008 If this interface is not supported, then return FALSE.
2009
2010 @param[in, out] HmacSha384Context Pointer to the HMAC-SHA384 context.
2011 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
2012 value (48 bytes).
2013
2014 @retval TRUE HMAC-SHA384 digest computation succeeded.
2015 @retval FALSE HMAC-SHA384 digest computation failed.
2016 @retval FALSE This interface is not supported.
2017
2018**/
2019BOOLEAN
2020EFIAPI
2021CryptoServiceHmacSha384Final (
2022 IN OUT VOID *HmacSha384Context,
2023 OUT UINT8 *HmacValue
2024 )
2025{
2026 return CALL_BASECRYPTLIB (HmacSha384.Services.Final, HmacSha384Final, (HmacSha384Context, HmacValue), FALSE);
2027}
2028
2029/**
2030 Computes the HMAC-SHA384 digest of a input data buffer.
2031
2032 This function performs the HMAC-SHA384 digest of a given data buffer, and places
2033 the digest value into the specified memory.
2034
2035 If this interface is not supported, then return FALSE.
2036
2037 @param[in] Data Pointer to the buffer containing the data to be digested.
2038 @param[in] DataSize Size of Data buffer in bytes.
2039 @param[in] Key Pointer to the user-supplied key.
2040 @param[in] KeySize Key size in bytes.
2041 @param[out] HmacValue Pointer to a buffer that receives the HMAC-SHA384 digest
2042 value (48 bytes).
2043
2044 @retval TRUE HMAC-SHA384 digest computation succeeded.
2045 @retval FALSE HMAC-SHA384 digest computation failed.
2046 @retval FALSE This interface is not supported.
2047
2048**/
2049BOOLEAN
2050EFIAPI
2051CryptoServiceHmacSha384All (
2052 IN CONST VOID *Data,
2053 IN UINTN DataSize,
2054 IN CONST UINT8 *Key,
2055 IN UINTN KeySize,
2056 OUT UINT8 *HmacValue
2057 )
2058{
2059 return CALL_BASECRYPTLIB (HmacSha384.Services.All, HmacSha384All, (Data, DataSize, Key, KeySize, HmacValue), FALSE);
2060}
2061
2062// =====================================================================================
2063// Symmetric Cryptography Primitive
2064// =====================================================================================
2065
2066/**
2067 TDES is deprecated and unsupported any longer.
2068 Keep the function field for binary compability.
2069
2070 @retval 0 This interface is not supported.
2071
2072**/
2073UINTN
2074EFIAPI
2075DeprecatedCryptoServiceTdesGetContextSize (
2076 VOID
2077 )
2078{
2079 return BaseCryptLibServiceDeprecated ("TdesGetContextSize"), 0;
2080}
2081
2082/**
2083 TDES is deprecated and unsupported any longer.
2084 Keep the function field for binary compability.
2085
2086 @param[out] TdesContext Pointer to TDES context being initialized.
2087 @param[in] Key Pointer to the user-supplied TDES key.
2088 @param[in] KeyLength Length of TDES key in bits.
2089
2090 @retval FALSE This interface is not supported.
2091
2092**/
2093BOOLEAN
2094EFIAPI
2095DeprecatedCryptoServiceTdesInit (
2096 OUT VOID *TdesContext,
2097 IN CONST UINT8 *Key,
2098 IN UINTN KeyLength
2099 )
2100{
2101 return BaseCryptLibServiceDeprecated ("TdesInit"), FALSE;
2102}
2103
2104/**
2105 TDES is deprecated and unsupported any longer.
2106 Keep the function field for binary compability.
2107
2108 @param[in] TdesContext Pointer to the TDES context.
2109 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2110 @param[in] InputSize Size of the Input buffer in bytes.
2111 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2112
2113 @retval FALSE This interface is not supported.
2114
2115**/
2116BOOLEAN
2117EFIAPI
2118DeprecatedCryptoServiceTdesEcbEncrypt (
2119 IN VOID *TdesContext,
2120 IN CONST UINT8 *Input,
2121 IN UINTN InputSize,
2122 OUT UINT8 *Output
2123 )
2124{
2125 return BaseCryptLibServiceDeprecated ("TdesEcbEncrypt"), FALSE;
2126}
2127
2128/**
2129 TDES is deprecated and unsupported any longer.
2130 Keep the function field for binary compability.
2131
2132 @param[in] TdesContext Pointer to the TDES context.
2133 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2134 @param[in] InputSize Size of the Input buffer in bytes.
2135 @param[out] Output Pointer to a buffer that receives the TDES decryption output.
2136
2137 @retval FALSE This interface is not supported.
2138
2139**/
2140BOOLEAN
2141EFIAPI
2142DeprecatedCryptoServiceTdesEcbDecrypt (
2143 IN VOID *TdesContext,
2144 IN CONST UINT8 *Input,
2145 IN UINTN InputSize,
2146 OUT UINT8 *Output
2147 )
2148{
2149 return BaseCryptLibServiceDeprecated ("TdesEcbDecrypt"), FALSE;
2150}
2151
2152/**
2153 TDES is deprecated and unsupported any longer.
2154 Keep the function field for binary compability.
2155
2156 @param[in] TdesContext Pointer to the TDES context.
2157 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2158 @param[in] InputSize Size of the Input buffer in bytes.
2159 @param[in] Ivec Pointer to initialization vector.
2160 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2161
2162 @retval FALSE This interface is not supported.
2163
2164**/
2165BOOLEAN
2166EFIAPI
2167DeprecatedCryptoServiceTdesCbcEncrypt (
2168 IN VOID *TdesContext,
2169 IN CONST UINT8 *Input,
2170 IN UINTN InputSize,
2171 IN CONST UINT8 *Ivec,
2172 OUT UINT8 *Output
2173 )
2174{
2175 return BaseCryptLibServiceDeprecated ("TdesCbcEncrypt"), FALSE;
2176}
2177
2178/**
2179 TDES is deprecated and unsupported any longer.
2180 Keep the function field for binary compability.
2181
2182 @param[in] TdesContext Pointer to the TDES context.
2183 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2184 @param[in] InputSize Size of the Input buffer in bytes.
2185 @param[in] Ivec Pointer to initialization vector.
2186 @param[out] Output Pointer to a buffer that receives the TDES encryption output.
2187
2188 @retval FALSE This interface is not supported.
2189
2190**/
2191BOOLEAN
2192EFIAPI
2193DeprecatedCryptoServiceTdesCbcDecrypt (
2194 IN VOID *TdesContext,
2195 IN CONST UINT8 *Input,
2196 IN UINTN InputSize,
2197 IN CONST UINT8 *Ivec,
2198 OUT UINT8 *Output
2199 )
2200{
2201 return BaseCryptLibServiceDeprecated ("TdesCbcDecrypt"), FALSE;
2202}
2203
2204/**
2205 Retrieves the size, in bytes, of the context buffer required for AES operations.
2206
2207 If this interface is not supported, then return zero.
2208
2209 @return The size, in bytes, of the context buffer required for AES operations.
2210 @retval 0 This interface is not supported.
2211
2212**/
2213UINTN
2214EFIAPI
2215CryptoServiceAesGetContextSize (
2216 VOID
2217 )
2218{
2219 return CALL_BASECRYPTLIB (Aes.Services.GetContextSize, AesGetContextSize, (), 0);
2220}
2221
2222/**
2223 Initializes user-supplied memory as AES context for subsequent use.
2224
2225 This function initializes user-supplied memory pointed by AesContext as AES context.
2226 In addition, it sets up all AES key materials for subsequent encryption and decryption
2227 operations.
2228 There are 3 options for key length, 128 bits, 192 bits, and 256 bits.
2229
2230 If AesContext is NULL, then return FALSE.
2231 If Key is NULL, then return FALSE.
2232 If KeyLength is not valid, then return FALSE.
2233 If this interface is not supported, then return FALSE.
2234
2235 @param[out] AesContext Pointer to AES context being initialized.
2236 @param[in] Key Pointer to the user-supplied AES key.
2237 @param[in] KeyLength Length of AES key in bits.
2238
2239 @retval TRUE AES context initialization succeeded.
2240 @retval FALSE AES context initialization failed.
2241 @retval FALSE This interface is not supported.
2242
2243**/
2244BOOLEAN
2245EFIAPI
2246CryptoServiceAesInit (
2247 OUT VOID *AesContext,
2248 IN CONST UINT8 *Key,
2249 IN UINTN KeyLength
2250 )
2251{
2252 return CALL_BASECRYPTLIB (Aes.Services.Init, AesInit, (AesContext, Key, KeyLength), FALSE);
2253}
2254
2255/**
2256 AES ECB Mode is deprecated and unsupported any longer.
2257 Keep the function field for binary compability.
2258
2259 @param[in] AesContext Pointer to the AES context.
2260 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2261 @param[in] InputSize Size of the Input buffer in bytes.
2262 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2263
2264 @retval FALSE This interface is not supported.
2265
2266**/
2267BOOLEAN
2268EFIAPI
2269DeprecatedCryptoServiceAesEcbEncrypt (
2270 IN VOID *AesContext,
2271 IN CONST UINT8 *Input,
2272 IN UINTN InputSize,
2273 OUT UINT8 *Output
2274 )
2275{
2276 return BaseCryptLibServiceDeprecated ("AesEcbEncrypt"), FALSE;
2277}
2278
2279/**
2280 AES ECB Mode is deprecated and unsupported any longer.
2281 Keep the function field for binary compability.
2282
2283 @param[in] AesContext Pointer to the AES context.
2284 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2285 @param[in] InputSize Size of the Input buffer in bytes.
2286 @param[out] Output Pointer to a buffer that receives the AES decryption output.
2287
2288 @retval FALSE This interface is not supported.
2289
2290**/
2291BOOLEAN
2292EFIAPI
2293DeprecatedCryptoServiceAesEcbDecrypt (
2294 IN VOID *AesContext,
2295 IN CONST UINT8 *Input,
2296 IN UINTN InputSize,
2297 OUT UINT8 *Output
2298 )
2299{
2300 return BaseCryptLibServiceDeprecated ("AesEcbDecrypt"), FALSE;
2301}
2302
2303/**
2304 Performs AES encryption on a data buffer of the specified size in CBC mode.
2305
2306 This function performs AES encryption on data buffer pointed by Input, of specified
2307 size of InputSize, in CBC mode.
2308 InputSize must be multiple of block size (16 bytes). This function does not perform
2309 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2310 Initialization vector should be one block size (16 bytes).
2311 AesContext should be already correctly initialized by AesInit(). Behavior with
2312 invalid AES context is undefined.
2313
2314 If AesContext is NULL, then return FALSE.
2315 If Input is NULL, then return FALSE.
2316 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2317 If Ivec is NULL, then return FALSE.
2318 If Output is NULL, then return FALSE.
2319 If this interface is not supported, then return FALSE.
2320
2321 @param[in] AesContext Pointer to the AES context.
2322 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2323 @param[in] InputSize Size of the Input buffer in bytes.
2324 @param[in] Ivec Pointer to initialization vector.
2325 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2326
2327 @retval TRUE AES encryption succeeded.
2328 @retval FALSE AES encryption failed.
2329 @retval FALSE This interface is not supported.
2330
2331**/
2332BOOLEAN
2333EFIAPI
2334CryptoServiceAesCbcEncrypt (
2335 IN VOID *AesContext,
2336 IN CONST UINT8 *Input,
2337 IN UINTN InputSize,
2338 IN CONST UINT8 *Ivec,
2339 OUT UINT8 *Output
2340 )
2341{
2342 return CALL_BASECRYPTLIB (Aes.Services.CbcEncrypt, AesCbcEncrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2343}
2344
2345/**
2346 Performs AES decryption on a data buffer of the specified size in CBC mode.
2347
2348 This function performs AES decryption on data buffer pointed by Input, of specified
2349 size of InputSize, in CBC mode.
2350 InputSize must be multiple of block size (16 bytes). This function does not perform
2351 padding. Caller must perform padding, if necessary, to ensure valid input data size.
2352 Initialization vector should be one block size (16 bytes).
2353 AesContext should be already correctly initialized by AesInit(). Behavior with
2354 invalid AES context is undefined.
2355
2356 If AesContext is NULL, then return FALSE.
2357 If Input is NULL, then return FALSE.
2358 If InputSize is not multiple of block size (16 bytes), then return FALSE.
2359 If Ivec is NULL, then return FALSE.
2360 If Output is NULL, then return FALSE.
2361 If this interface is not supported, then return FALSE.
2362
2363 @param[in] AesContext Pointer to the AES context.
2364 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2365 @param[in] InputSize Size of the Input buffer in bytes.
2366 @param[in] Ivec Pointer to initialization vector.
2367 @param[out] Output Pointer to a buffer that receives the AES encryption output.
2368
2369 @retval TRUE AES decryption succeeded.
2370 @retval FALSE AES decryption failed.
2371 @retval FALSE This interface is not supported.
2372
2373**/
2374BOOLEAN
2375EFIAPI
2376CryptoServiceAesCbcDecrypt (
2377 IN VOID *AesContext,
2378 IN CONST UINT8 *Input,
2379 IN UINTN InputSize,
2380 IN CONST UINT8 *Ivec,
2381 OUT UINT8 *Output
2382 )
2383{
2384 return CALL_BASECRYPTLIB (Aes.Services.CbcDecrypt, AesCbcDecrypt, (AesContext, Input, InputSize, Ivec, Output), FALSE);
2385}
2386
2387/**
2388 ARC4 is deprecated and unsupported any longer.
2389 Keep the function field for binary compability.
2390
2391 @retval 0 This interface is not supported.
2392
2393**/
2394UINTN
2395EFIAPI
2396DeprecatedCryptoServiceArc4GetContextSize (
2397 VOID
2398 )
2399{
2400 return BaseCryptLibServiceDeprecated ("Arc4GetContextSize"), 0;
2401}
2402
2403/**
2404 ARC4 is deprecated and unsupported any longer.
2405 Keep the function field for binary compability.
2406
2407 @param[out] Arc4Context Pointer to ARC4 context being initialized.
2408 @param[in] Key Pointer to the user-supplied ARC4 key.
2409 @param[in] KeySize Size of ARC4 key in bytes.
2410
2411 @retval FALSE This interface is not supported.
2412
2413**/
2414BOOLEAN
2415EFIAPI
2416DeprecatedCryptoServiceArc4Init (
2417 OUT VOID *Arc4Context,
2418 IN CONST UINT8 *Key,
2419 IN UINTN KeySize
2420 )
2421{
2422 return BaseCryptLibServiceDeprecated ("Arc4Init"), FALSE;
2423}
2424
2425/**
2426 ARC4 is deprecated and unsupported any longer.
2427 Keep the function field for binary compability.
2428
2429 @param[in, out] Arc4Context Pointer to the ARC4 context.
2430 @param[in] Input Pointer to the buffer containing the data to be encrypted.
2431 @param[in] InputSize Size of the Input buffer in bytes.
2432 @param[out] Output Pointer to a buffer that receives the ARC4 encryption output.
2433
2434 @retval FALSE This interface is not supported.
2435
2436**/
2437BOOLEAN
2438EFIAPI
2439DeprecatedCryptoServiceArc4Encrypt (
2440 IN OUT VOID *Arc4Context,
2441 IN CONST UINT8 *Input,
2442 IN UINTN InputSize,
2443 OUT UINT8 *Output
2444 )
2445{
2446 return BaseCryptLibServiceDeprecated ("Arc4Encrypt"), FALSE;
2447}
2448
2449/**
2450 ARC4 is deprecated and unsupported any longer.
2451 Keep the function field for binary compability.
2452
2453 @param[in, out] Arc4Context Pointer to the ARC4 context.
2454 @param[in] Input Pointer to the buffer containing the data to be decrypted.
2455 @param[in] InputSize Size of the Input buffer in bytes.
2456 @param[out] Output Pointer to a buffer that receives the ARC4 decryption output.
2457
2458 @retval FALSE This interface is not supported.
2459
2460**/
2461BOOLEAN
2462EFIAPI
2463DeprecatedCryptoServiceArc4Decrypt (
2464 IN OUT VOID *Arc4Context,
2465 IN UINT8 *Input,
2466 IN UINTN InputSize,
2467 OUT UINT8 *Output
2468 )
2469{
2470 return BaseCryptLibServiceDeprecated ("Arc4Decrypt"), FALSE;
2471}
2472
2473/**
2474 ARC4 is deprecated and unsupported any longer.
2475 Keep the function field for binary compability.
2476
2477 @param[in, out] Arc4Context Pointer to the ARC4 context.
2478
2479 @retval FALSE This interface is not supported.
2480
2481**/
2482BOOLEAN
2483EFIAPI
2484DeprecatedCryptoServiceArc4Reset (
2485 IN OUT VOID *Arc4Context
2486 )
2487{
2488 return BaseCryptLibServiceDeprecated ("Arc4Reset"), FALSE;
2489}
2490
2491// =====================================================================================
2492// Asymmetric Cryptography Primitive
2493// =====================================================================================
2494
2495/**
2496 Allocates and initializes one RSA context for subsequent use.
2497
2498 @return Pointer to the RSA context that has been initialized.
2499 If the allocations fails, RsaNew() returns NULL.
2500
2501**/
2502VOID *
2503EFIAPI
2504CryptoServiceRsaNew (
2505 VOID
2506 )
2507{
2508 return CALL_BASECRYPTLIB (Rsa.Services.New, RsaNew, (), NULL);
2509}
2510
2511/**
2512 Release the specified RSA context.
2513
2514 If RsaContext is NULL, then return FALSE.
2515
2516 @param[in] RsaContext Pointer to the RSA context to be released.
2517
2518**/
2519VOID
2520EFIAPI
2521CryptoServiceRsaFree (
2522 IN VOID *RsaContext
2523 )
2524{
2525 CALL_VOID_BASECRYPTLIB (Rsa.Services.Free, RsaFree, (RsaContext));
2526}
2527
2528/**
2529 Sets the tag-designated key component into the established RSA context.
2530
2531 This function sets the tag-designated RSA key component into the established
2532 RSA context from the user-specified non-negative integer (octet string format
2533 represented in RSA PKCS#1).
2534 If BigNumber is NULL, then the specified key component in RSA context is cleared.
2535
2536 If RsaContext is NULL, then return FALSE.
2537
2538 @param[in, out] RsaContext Pointer to RSA context being set.
2539 @param[in] KeyTag Tag of RSA key component being set.
2540 @param[in] BigNumber Pointer to octet integer buffer.
2541 If NULL, then the specified key component in RSA
2542 context is cleared.
2543 @param[in] BnSize Size of big number buffer in bytes.
2544 If BigNumber is NULL, then it is ignored.
2545
2546 @retval TRUE RSA key component was set successfully.
2547 @retval FALSE Invalid RSA key component tag.
2548
2549**/
2550BOOLEAN
2551EFIAPI
2552CryptoServiceRsaSetKey (
2553 IN OUT VOID *RsaContext,
2554 IN RSA_KEY_TAG KeyTag,
2555 IN CONST UINT8 *BigNumber,
2556 IN UINTN BnSize
2557 )
2558{
2559 return CALL_BASECRYPTLIB (Rsa.Services.SetKey, RsaSetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2560}
2561
2562/**
2563 Gets the tag-designated RSA key component from the established RSA context.
2564
2565 This function retrieves the tag-designated RSA key component from the
2566 established RSA context as a non-negative integer (octet string format
2567 represented in RSA PKCS#1).
2568 If specified key component has not been set or has been cleared, then returned
2569 BnSize is set to 0.
2570 If the BigNumber buffer is too small to hold the contents of the key, FALSE
2571 is returned and BnSize is set to the required buffer size to obtain the key.
2572
2573 If RsaContext is NULL, then return FALSE.
2574 If BnSize is NULL, then return FALSE.
2575 If BnSize is large enough but BigNumber is NULL, then return FALSE.
2576 If this interface is not supported, then return FALSE.
2577
2578 @param[in, out] RsaContext Pointer to RSA context being set.
2579 @param[in] KeyTag Tag of RSA key component being set.
2580 @param[out] BigNumber Pointer to octet integer buffer.
2581 @param[in, out] BnSize On input, the size of big number buffer in bytes.
2582 On output, the size of data returned in big number buffer in bytes.
2583
2584 @retval TRUE RSA key component was retrieved successfully.
2585 @retval FALSE Invalid RSA key component tag.
2586 @retval FALSE BnSize is too small.
2587 @retval FALSE This interface is not supported.
2588
2589**/
2590BOOLEAN
2591EFIAPI
2592CryptoServiceRsaGetKey (
2593 IN OUT VOID *RsaContext,
2594 IN RSA_KEY_TAG KeyTag,
2595 OUT UINT8 *BigNumber,
2596 IN OUT UINTN *BnSize
2597 )
2598{
2599 return CALL_BASECRYPTLIB (Rsa.Services.GetKey, RsaGetKey, (RsaContext, KeyTag, BigNumber, BnSize), FALSE);
2600}
2601
2602/**
2603 Generates RSA key components.
2604
2605 This function generates RSA key components. It takes RSA public exponent E and
2606 length in bits of RSA modulus N as input, and generates all key components.
2607 If PublicExponent is NULL, the default RSA public exponent (0x10001) will be used.
2608
2609 Before this function can be invoked, pseudorandom number generator must be correctly
2610 initialized by RandomSeed().
2611
2612 If RsaContext is NULL, then return FALSE.
2613 If this interface is not supported, then return FALSE.
2614
2615 @param[in, out] RsaContext Pointer to RSA context being set.
2616 @param[in] ModulusLength Length of RSA modulus N in bits.
2617 @param[in] PublicExponent Pointer to RSA public exponent.
2618 @param[in] PublicExponentSize Size of RSA public exponent buffer in bytes.
2619
2620 @retval TRUE RSA key component was generated successfully.
2621 @retval FALSE Invalid RSA key component tag.
2622 @retval FALSE This interface is not supported.
2623
2624**/
2625BOOLEAN
2626EFIAPI
2627CryptoServiceRsaGenerateKey (
2628 IN OUT VOID *RsaContext,
2629 IN UINTN ModulusLength,
2630 IN CONST UINT8 *PublicExponent,
2631 IN UINTN PublicExponentSize
2632 )
2633{
2634 return CALL_BASECRYPTLIB (Rsa.Services.GenerateKey, RsaGenerateKey, (RsaContext, ModulusLength, PublicExponent, PublicExponentSize), FALSE);
2635}
2636
2637/**
2638 Validates key components of RSA context.
2639 NOTE: This function performs integrity checks on all the RSA key material, so
2640 the RSA key structure must contain all the private key data.
2641
2642 This function validates key components of RSA context in following aspects:
2643 - Whether p is a prime
2644 - Whether q is a prime
2645 - Whether n = p * q
2646 - Whether d*e = 1 mod lcm(p-1,q-1)
2647
2648 If RsaContext is NULL, then return FALSE.
2649 If this interface is not supported, then return FALSE.
2650
2651 @param[in] RsaContext Pointer to RSA context to check.
2652
2653 @retval TRUE RSA key components are valid.
2654 @retval FALSE RSA key components are not valid.
2655 @retval FALSE This interface is not supported.
2656
2657**/
2658BOOLEAN
2659EFIAPI
2660CryptoServiceRsaCheckKey (
2661 IN VOID *RsaContext
2662 )
2663{
2664 return CALL_BASECRYPTLIB (Rsa.Services.CheckKey, RsaCheckKey, (RsaContext), FALSE);
2665}
2666
2667/**
2668 Carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme.
2669
2670 This function carries out the RSA-SSA signature generation with EMSA-PKCS1-v1_5 encoding scheme defined in
2671 RSA PKCS#1.
2672 If the Signature buffer is too small to hold the contents of signature, FALSE
2673 is returned and SigSize is set to the required buffer size to obtain the signature.
2674
2675 If RsaContext is NULL, then return FALSE.
2676 If MessageHash is NULL, then return FALSE.
2677 If HashSize is not equal to the size of MD5, SHA-1 or SHA-256 digest, then return FALSE.
2678 If SigSize is large enough but Signature is NULL, then return FALSE.
2679 If this interface is not supported, then return FALSE.
2680
2681 @param[in] RsaContext Pointer to RSA context for signature generation.
2682 @param[in] MessageHash Pointer to octet message hash to be signed.
2683 @param[in] HashSize Size of the message hash in bytes.
2684 @param[out] Signature Pointer to buffer to receive RSA PKCS1-v1_5 signature.
2685 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
2686 On output, the size of data returned in Signature buffer in bytes.
2687
2688 @retval TRUE Signature successfully generated in PKCS1-v1_5.
2689 @retval FALSE Signature generation failed.
2690 @retval FALSE SigSize is too small.
2691 @retval FALSE This interface is not supported.
2692
2693**/
2694BOOLEAN
2695EFIAPI
2696CryptoServiceRsaPkcs1Sign (
2697 IN VOID *RsaContext,
2698 IN CONST UINT8 *MessageHash,
2699 IN UINTN HashSize,
2700 OUT UINT8 *Signature,
2701 IN OUT UINTN *SigSize
2702 )
2703{
2704 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Sign, RsaPkcs1Sign, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2705}
2706
2707/**
2708 Verifies the RSA-SSA signature with EMSA-PKCS1-v1_5 encoding scheme defined in
2709 RSA PKCS#1.
2710
2711 If RsaContext is NULL, then return FALSE.
2712 If MessageHash is NULL, then return FALSE.
2713 If Signature is NULL, then return FALSE.
2714 If HashSize is not equal to the size of MD5, SHA-1, SHA-256 digest, then return FALSE.
2715
2716 @param[in] RsaContext Pointer to RSA context for signature verification.
2717 @param[in] MessageHash Pointer to octet message hash to be checked.
2718 @param[in] HashSize Size of the message hash in bytes.
2719 @param[in] Signature Pointer to RSA PKCS1-v1_5 signature to be verified.
2720 @param[in] SigSize Size of signature in bytes.
2721
2722 @retval TRUE Valid signature encoded in PKCS1-v1_5.
2723 @retval FALSE Invalid signature or invalid RSA context.
2724
2725**/
2726BOOLEAN
2727EFIAPI
2728CryptoServiceRsaPkcs1Verify (
2729 IN VOID *RsaContext,
2730 IN CONST UINT8 *MessageHash,
2731 IN UINTN HashSize,
2732 IN CONST UINT8 *Signature,
2733 IN UINTN SigSize
2734 )
2735{
2736 return CALL_BASECRYPTLIB (Rsa.Services.Pkcs1Verify, RsaPkcs1Verify, (RsaContext, MessageHash, HashSize, Signature, SigSize), FALSE);
2737}
2738
2739/**
2740 Retrieve the RSA Private Key from the password-protected PEM key data.
2741
2742 If PemData is NULL, then return FALSE.
2743 If RsaContext is NULL, then return FALSE.
2744 If this interface is not supported, then return FALSE.
2745
2746 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
2747 @param[in] PemSize Size of the PEM key data in bytes.
2748 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
2749 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2750 RSA private key component. Use RsaFree() function to free the
2751 resource.
2752
2753 @retval TRUE RSA Private Key was retrieved successfully.
2754 @retval FALSE Invalid PEM key data or incorrect password.
2755 @retval FALSE This interface is not supported.
2756
2757**/
2758BOOLEAN
2759EFIAPI
2760CryptoServiceRsaGetPrivateKeyFromPem (
2761 IN CONST UINT8 *PemData,
2762 IN UINTN PemSize,
2763 IN CONST CHAR8 *Password,
2764 OUT VOID **RsaContext
2765 )
2766{
2767 return CALL_BASECRYPTLIB (Rsa.Services.GetPrivateKeyFromPem, RsaGetPrivateKeyFromPem, (PemData, PemSize, Password, RsaContext), FALSE);
2768}
2769
2770/**
2771 Retrieve the RSA Public Key from one DER-encoded X509 certificate.
2772
2773 If Cert is NULL, then return FALSE.
2774 If RsaContext is NULL, then return FALSE.
2775 If this interface is not supported, then return FALSE.
2776
2777 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2778 @param[in] CertSize Size of the X509 certificate in bytes.
2779 @param[out] RsaContext Pointer to new-generated RSA context which contain the retrieved
2780 RSA public key component. Use RsaFree() function to free the
2781 resource.
2782
2783 @retval TRUE RSA Public Key was retrieved successfully.
2784 @retval FALSE Fail to retrieve RSA public key from X509 certificate.
2785 @retval FALSE This interface is not supported.
2786
2787**/
2788BOOLEAN
2789EFIAPI
2790CryptoServiceRsaGetPublicKeyFromX509 (
2791 IN CONST UINT8 *Cert,
2792 IN UINTN CertSize,
2793 OUT VOID **RsaContext
2794 )
2795{
2796 return CALL_BASECRYPTLIB (Rsa.Services.GetPublicKeyFromX509, RsaGetPublicKeyFromX509, (Cert, CertSize, RsaContext), FALSE);
2797}
2798
2799/**
2800 Retrieve the subject bytes from one X.509 certificate.
2801
2802 If Cert is NULL, then return FALSE.
2803 If SubjectSize is NULL, then return FALSE.
2804 If this interface is not supported, then return FALSE.
2805
2806 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2807 @param[in] CertSize Size of the X509 certificate in bytes.
2808 @param[out] CertSubject Pointer to the retrieved certificate subject bytes.
2809 @param[in, out] SubjectSize The size in bytes of the CertSubject buffer on input,
2810 and the size of buffer returned CertSubject on output.
2811
2812 @retval TRUE The certificate subject retrieved successfully.
2813 @retval FALSE Invalid certificate, or the SubjectSize is too small for the result.
2814 The SubjectSize will be updated with the required size.
2815 @retval FALSE This interface is not supported.
2816
2817**/
2818BOOLEAN
2819EFIAPI
2820CryptoServiceX509GetSubjectName (
2821 IN CONST UINT8 *Cert,
2822 IN UINTN CertSize,
2823 OUT UINT8 *CertSubject,
2824 IN OUT UINTN *SubjectSize
2825 )
2826{
2827 return CALL_BASECRYPTLIB (X509.Services.GetSubjectName, X509GetSubjectName, (Cert, CertSize, CertSubject, SubjectSize), FALSE);
2828}
2829
2830/**
2831 Retrieve the common name (CN) string from one X.509 certificate.
2832
2833 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2834 @param[in] CertSize Size of the X509 certificate in bytes.
2835 @param[out] CommonName Buffer to contain the retrieved certificate common
2836 name string (UTF8). At most CommonNameSize bytes will be
2837 written and the string will be null terminated. May be
2838 NULL in order to determine the size buffer needed.
2839 @param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
2840 and the size of buffer returned CommonName on output.
2841 If CommonName is NULL then the amount of space needed
2842 in buffer (including the final null) is returned.
2843
2844 @retval RETURN_SUCCESS The certificate CommonName retrieved successfully.
2845 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2846 If CommonNameSize is NULL.
2847 If CommonName is not NULL and *CommonNameSize is 0.
2848 If Certificate is invalid.
2849 @retval RETURN_NOT_FOUND If no CommonName entry exists.
2850 @retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
2851 (including the final null) is returned in the
2852 CommonNameSize parameter.
2853 @retval RETURN_UNSUPPORTED The operation is not supported.
2854
2855**/
2856RETURN_STATUS
2857EFIAPI
2858CryptoServiceX509GetCommonName (
2859 IN CONST UINT8 *Cert,
2860 IN UINTN CertSize,
2861 OUT CHAR8 *CommonName OPTIONAL,
2862 IN OUT UINTN *CommonNameSize
2863 )
2864{
2865 return CALL_BASECRYPTLIB (X509.Services.GetCommonName, X509GetCommonName, (Cert, CertSize, CommonName, CommonNameSize), RETURN_UNSUPPORTED);
2866}
2867
2868/**
2869 Retrieve the organization name (O) string from one X.509 certificate.
2870
2871 @param[in] Cert Pointer to the DER-encoded X509 certificate.
2872 @param[in] CertSize Size of the X509 certificate in bytes.
2873 @param[out] NameBuffer Buffer to contain the retrieved certificate organization
2874 name string. At most NameBufferSize bytes will be
2875 written and the string will be null terminated. May be
2876 NULL in order to determine the size buffer needed.
2877 @param[in,out] NameBufferSize The size in bytes of the Name buffer on input,
2878 and the size of buffer returned Name on output.
2879 If NameBuffer is NULL then the amount of space needed
2880 in buffer (including the final null) is returned.
2881
2882 @retval RETURN_SUCCESS The certificate Organization Name retrieved successfully.
2883 @retval RETURN_INVALID_PARAMETER If Cert is NULL.
2884 If NameBufferSize is NULL.
2885 If NameBuffer is not NULL and *CommonNameSize is 0.
2886 If Certificate is invalid.
2887 @retval RETURN_NOT_FOUND If no Organization Name entry exists.
2888 @retval RETURN_BUFFER_TOO_SMALL If the NameBuffer is NULL. The required buffer size
2889 (including the final null) is returned in the
2890 CommonNameSize parameter.
2891 @retval RETURN_UNSUPPORTED The operation is not supported.
2892
2893**/
2894RETURN_STATUS
2895EFIAPI
2896CryptoServiceX509GetOrganizationName (
2897 IN CONST UINT8 *Cert,
2898 IN UINTN CertSize,
2899 OUT CHAR8 *NameBuffer OPTIONAL,
2900 IN OUT UINTN *NameBufferSize
2901 )
2902{
2903 return CALL_BASECRYPTLIB (X509.Services.GetOrganizationName, X509GetOrganizationName, (Cert, CertSize, NameBuffer, NameBufferSize), RETURN_UNSUPPORTED);
2904}
2905
2906/**
2907 Verify one X509 certificate was issued by the trusted CA.
2908
2909 If Cert is NULL, then return FALSE.
2910 If CACert is NULL, then return FALSE.
2911 If this interface is not supported, then return FALSE.
2912
2913 @param[in] Cert Pointer to the DER-encoded X509 certificate to be verified.
2914 @param[in] CertSize Size of the X509 certificate in bytes.
2915 @param[in] CACert Pointer to the DER-encoded trusted CA certificate.
2916 @param[in] CACertSize Size of the CA Certificate in bytes.
2917
2918 @retval TRUE The certificate was issued by the trusted CA.
2919 @retval FALSE Invalid certificate or the certificate was not issued by the given
2920 trusted CA.
2921 @retval FALSE This interface is not supported.
2922
2923**/
2924BOOLEAN
2925EFIAPI
2926CryptoServiceX509VerifyCert (
2927 IN CONST UINT8 *Cert,
2928 IN UINTN CertSize,
2929 IN CONST UINT8 *CACert,
2930 IN UINTN CACertSize
2931 )
2932{
2933 return CALL_BASECRYPTLIB (X509.Services.VerifyCert, X509VerifyCert, (Cert, CertSize, CACert, CACertSize), FALSE);
2934}
2935
2936/**
2937 Construct a X509 object from DER-encoded certificate data.
2938
2939 If Cert is NULL, then return FALSE.
2940 If SingleX509Cert is NULL, then return FALSE.
2941 If this interface is not supported, then return FALSE.
2942
2943 @param[in] Cert Pointer to the DER-encoded certificate data.
2944 @param[in] CertSize The size of certificate data in bytes.
2945 @param[out] SingleX509Cert The generated X509 object.
2946
2947 @retval TRUE The X509 object generation succeeded.
2948 @retval FALSE The operation failed.
2949 @retval FALSE This interface is not supported.
2950
2951**/
2952BOOLEAN
2953EFIAPI
2954CryptoServiceX509ConstructCertificate (
2955 IN CONST UINT8 *Cert,
2956 IN UINTN CertSize,
2957 OUT UINT8 **SingleX509Cert
2958 )
2959{
2960 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificate, X509ConstructCertificate, (Cert, CertSize, SingleX509Cert), FALSE);
2961}
2962
2963/**
2964 Construct a X509 stack object from a list of DER-encoded certificate data.
2965
2966 If X509Stack is NULL, then return FALSE.
2967 If this interface is not supported, then return FALSE.
2968
2969 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2970 On output, pointer to the X509 stack object with new
2971 inserted X509 certificate.
2972 @param[in] Args VA_LIST marker for the variable argument list.
2973 A list of DER-encoded single certificate data followed
2974 by certificate size. A NULL terminates the list. The
2975 pairs are the arguments to X509ConstructCertificate().
2976
2977 @retval TRUE The X509 stack construction succeeded.
2978 @retval FALSE The construction operation failed.
2979 @retval FALSE This interface is not supported.
2980
2981**/
2982BOOLEAN
2983EFIAPI
2984CryptoServiceX509ConstructCertificateStackV (
2985 IN OUT UINT8 **X509Stack,
2986 IN VA_LIST Args
2987 )
2988{
2989 return CALL_BASECRYPTLIB (X509.Services.ConstructCertificateStackV, X509ConstructCertificateStackV, (X509Stack, Args), FALSE);
2990}
2991
2992/**
2993 Construct a X509 stack object from a list of DER-encoded certificate data.
2994
2995 If X509Stack is NULL, then return FALSE.
2996 If this interface is not supported, then return FALSE.
2997
2998 @param[in, out] X509Stack On input, pointer to an existing or NULL X509 stack object.
2999 On output, pointer to the X509 stack object with new
3000 inserted X509 certificate.
3001 @param ... A list of DER-encoded single certificate data followed
3002 by certificate size. A NULL terminates the list. The
3003 pairs are the arguments to X509ConstructCertificate().
3004
3005 @retval TRUE The X509 stack construction succeeded.
3006 @retval FALSE The construction operation failed.
3007 @retval FALSE This interface is not supported.
3008
3009**/
3010BOOLEAN
3011EFIAPI
3012CryptoServiceX509ConstructCertificateStack (
3013 IN OUT UINT8 **X509Stack,
3014 ...
3015 )
3016{
3017 VA_LIST Args;
3018 BOOLEAN Result;
3019
3020 VA_START (Args, X509Stack);
3021 Result = CryptoServiceX509ConstructCertificateStackV (X509Stack, Args);
3022 VA_END (Args);
3023 return Result;
3024}
3025
3026/**
3027 Release the specified X509 object.
3028
3029 If the interface is not supported, then ASSERT().
3030
3031 @param[in] X509Cert Pointer to the X509 object to be released.
3032
3033**/
3034VOID
3035EFIAPI
3036CryptoServiceX509Free (
3037 IN VOID *X509Cert
3038 )
3039{
3040 CALL_VOID_BASECRYPTLIB (X509.Services.Free, X509Free, (X509Cert));
3041}
3042
3043/**
3044 Release the specified X509 stack object.
3045
3046 If the interface is not supported, then ASSERT().
3047
3048 @param[in] X509Stack Pointer to the X509 stack object to be released.
3049
3050**/
3051VOID
3052EFIAPI
3053CryptoServiceX509StackFree (
3054 IN VOID *X509Stack
3055 )
3056{
3057 CALL_VOID_BASECRYPTLIB (X509.Services.StackFree, X509StackFree, (X509Stack));
3058}
3059
3060/**
3061 Retrieve the TBSCertificate from one given X.509 certificate.
3062
3063 @param[in] Cert Pointer to the given DER-encoded X509 certificate.
3064 @param[in] CertSize Size of the X509 certificate in bytes.
3065 @param[out] TBSCert DER-Encoded To-Be-Signed certificate.
3066 @param[out] TBSCertSize Size of the TBS certificate in bytes.
3067
3068 If Cert is NULL, then return FALSE.
3069 If TBSCert is NULL, then return FALSE.
3070 If TBSCertSize is NULL, then return FALSE.
3071 If this interface is not supported, then return FALSE.
3072
3073 @retval TRUE The TBSCertificate was retrieved successfully.
3074 @retval FALSE Invalid X.509 certificate.
3075
3076**/
3077BOOLEAN
3078EFIAPI
3079CryptoServiceX509GetTBSCert (
3080 IN CONST UINT8 *Cert,
3081 IN UINTN CertSize,
3082 OUT UINT8 **TBSCert,
3083 OUT UINTN *TBSCertSize
3084 )
3085{
3086 return CALL_BASECRYPTLIB (X509.Services.GetTBSCert, X509GetTBSCert, (Cert, CertSize, TBSCert, TBSCertSize), FALSE);
3087}
3088
3089/**
3090 Retrieve the version from one X.509 certificate.
3091
3092 If Cert is NULL, then return FALSE.
3093 If CertSize is 0, then return FALSE.
3094 If this interface is not supported, then return FALSE.
3095
3096 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3097 @param[in] CertSize Size of the X509 certificate in bytes.
3098 @param[out] Version Pointer to the retrieved version integer.
3099
3100 @retval TRUE The certificate version retrieved successfully.
3101 @retval FALSE If Cert is NULL or CertSize is Zero.
3102 @retval FALSE The operation is not supported.
3103
3104**/
3105BOOLEAN
3106EFIAPI
3107CryptoServiceX509GetVersion (
3108 IN CONST UINT8 *Cert,
3109 IN UINTN CertSize,
3110 OUT UINTN *Version
3111 )
3112{
3113 return CALL_BASECRYPTLIB (X509.Services.GetVersion, X509GetVersion, (Cert, CertSize, Version), FALSE);
3114}
3115
3116/**
3117 Retrieve the serialNumber from one X.509 certificate.
3118
3119 If Cert is NULL, then return FALSE.
3120 If CertSize is 0, then return FALSE.
3121 If this interface is not supported, then return FALSE.
3122
3123 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3124 @param[in] CertSize Size of the X509 certificate in bytes.
3125 @param[out] SerialNumber Pointer to the retrieved certificate SerialNumber bytes.
3126 @param[in, out] SerialNumberSize The size in bytes of the SerialNumber buffer on input,
3127 and the size of buffer returned SerialNumber on output.
3128
3129 @retval TRUE The certificate serialNumber retrieved successfully.
3130 @retval FALSE If Cert is NULL or CertSize is Zero.
3131 If SerialNumberSize is NULL.
3132 If Certificate is invalid.
3133 @retval FALSE If no SerialNumber exists.
3134 @retval FALSE If the SerialNumber is NULL. The required buffer size
3135 (including the final null) is returned in the
3136 SerialNumberSize parameter.
3137 @retval FALSE The operation is not supported.
3138**/
3139BOOLEAN
3140EFIAPI
3141CryptoServiceX509GetSerialNumber (
3142 IN CONST UINT8 *Cert,
3143 IN UINTN CertSize,
3144 OUT UINT8 *SerialNumber, OPTIONAL
3145 IN OUT UINTN *SerialNumberSize
3146 )
3147{
3148 return CALL_BASECRYPTLIB (X509.Services.GetSerialNumber, X509GetSerialNumber, (Cert, CertSize, SerialNumber, SerialNumberSize), FALSE);
3149}
3150
3151/**
3152 Retrieve the issuer bytes from one X.509 certificate.
3153
3154 If Cert is NULL, then return FALSE.
3155 If CertIssuerSize is NULL, then return FALSE.
3156 If this interface is not supported, then return FALSE.
3157
3158 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3159 @param[in] CertSize Size of the X509 certificate in bytes.
3160 @param[out] CertIssuer Pointer to the retrieved certificate subject bytes.
3161 @param[in, out] CertIssuerSize The size in bytes of the CertIssuer buffer on input,
3162 and the size of buffer returned CertSubject on output.
3163
3164 @retval TRUE The certificate issuer retrieved successfully.
3165 @retval FALSE Invalid certificate, or the CertIssuerSize is too small for the result.
3166 The CertIssuerSize will be updated with the required size.
3167 @retval FALSE This interface is not supported.
3168
3169**/
3170BOOLEAN
3171EFIAPI
3172CryptoServiceX509GetIssuerName (
3173 IN CONST UINT8 *Cert,
3174 IN UINTN CertSize,
3175 OUT UINT8 *CertIssuer,
3176 IN OUT UINTN *CertIssuerSize
3177 )
3178{
3179 return CALL_BASECRYPTLIB (X509.Services.GetIssuerName, X509GetIssuerName, (Cert, CertSize, CertIssuer, CertIssuerSize), FALSE);
3180}
3181
3182/**
3183 Retrieve the Signature Algorithm from one X.509 certificate.
3184
3185 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3186 @param[in] CertSize Size of the X509 certificate in bytes.
3187 @param[out] Oid Signature Algorithm Object identifier buffer.
3188 @param[in,out] OidSize Signature Algorithm Object identifier buffer size
3189
3190 @retval TRUE The certificate Extension data retrieved successfully.
3191 @retval FALSE If Cert is NULL.
3192 If OidSize is NULL.
3193 If Oid is not NULL and *OidSize is 0.
3194 If Certificate is invalid.
3195 @retval FALSE If no SignatureType.
3196 @retval FALSE If the Oid is NULL. The required buffer size
3197 is returned in the OidSize.
3198 @retval FALSE The operation is not supported.
3199**/
3200BOOLEAN
3201EFIAPI
3202CryptoServiceX509GetSignatureAlgorithm (
3203 IN CONST UINT8 *Cert,
3204 IN UINTN CertSize,
3205 OUT UINT8 *Oid, OPTIONAL
3206 IN OUT UINTN *OidSize
3207 )
3208{
3209 return CALL_BASECRYPTLIB (X509.Services.GetSignatureAlgorithm, X509GetSignatureAlgorithm, (Cert, CertSize, Oid, OidSize), FALSE);
3210}
3211
3212/**
3213 Retrieve Extension data from one X.509 certificate.
3214
3215 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3216 @param[in] CertSize Size of the X509 certificate in bytes.
3217 @param[in] Oid Object identifier buffer
3218 @param[in] OidSize Object identifier buffer size
3219 @param[out] ExtensionData Extension bytes.
3220 @param[in, out] ExtensionDataSize Extension bytes size.
3221
3222 @retval TRUE The certificate Extension data retrieved successfully.
3223 @retval FALSE If Cert is NULL.
3224 If ExtensionDataSize is NULL.
3225 If ExtensionData is not NULL and *ExtensionDataSize is 0.
3226 If Certificate is invalid.
3227 @retval FALSE If no Extension entry match Oid.
3228 @retval FALSE If the ExtensionData is NULL. The required buffer size
3229 is returned in the ExtensionDataSize parameter.
3230 @retval FALSE The operation is not supported.
3231**/
3232BOOLEAN
3233EFIAPI
3234CryptoServiceX509GetExtensionData (
3235 IN CONST UINT8 *Cert,
3236 IN UINTN CertSize,
3237 IN CONST UINT8 *Oid,
3238 IN UINTN OidSize,
3239 OUT UINT8 *ExtensionData,
3240 IN OUT UINTN *ExtensionDataSize
3241 )
3242{
3243 return CALL_BASECRYPTLIB (X509.Services.GetExtensionData, X509GetExtensionData, (Cert, CertSize, Oid, OidSize, ExtensionData, ExtensionDataSize), FALSE);
3244}
3245
3246/**
3247 Retrieve the Extended Key Usage from one X.509 certificate.
3248
3249 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3250 @param[in] CertSize Size of the X509 certificate in bytes.
3251 @param[out] Usage Key Usage bytes.
3252 @param[in, out] UsageSize Key Usage buffer sizs in bytes.
3253
3254 @retval TRUE The Usage bytes retrieve successfully.
3255 @retval FALSE If Cert is NULL.
3256 If CertSize is NULL.
3257 If Usage is not NULL and *UsageSize is 0.
3258 If Cert is invalid.
3259 @retval FALSE If the Usage is NULL. The required buffer size
3260 is returned in the UsageSize parameter.
3261 @retval FALSE The operation is not supported.
3262**/
3263BOOLEAN
3264EFIAPI
3265CryptoServiceX509GetExtendedKeyUsage (
3266 IN CONST UINT8 *Cert,
3267 IN UINTN CertSize,
3268 OUT UINT8 *Usage,
3269 IN OUT UINTN *UsageSize
3270 )
3271{
3272 return CALL_BASECRYPTLIB (X509.Services.GetExtendedKeyUsage, X509GetExtendedKeyUsage, (Cert, CertSize, Usage, UsageSize), FALSE);
3273}
3274
3275/**
3276 Retrieve the Validity from one X.509 certificate
3277
3278 If Cert is NULL, then return FALSE.
3279 If CertIssuerSize is NULL, then return FALSE.
3280 If this interface is not supported, then return FALSE.
3281
3282 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3283 @param[in] CertSize Size of the X509 certificate in bytes.
3284 @param[in] From notBefore Pointer to DateTime object.
3285 @param[in,out] FromSize notBefore DateTime object size.
3286 @param[in] To notAfter Pointer to DateTime object.
3287 @param[in,out] ToSize notAfter DateTime object size.
3288
3289 Note: X509CompareDateTime to compare DateTime oject
3290 x509SetDateTime to get a DateTime object from a DateTimeStr
3291
3292 @retval TRUE The certificate Validity retrieved successfully.
3293 @retval FALSE Invalid certificate, or Validity retrieve failed.
3294 @retval FALSE This interface is not supported.
3295**/
3296BOOLEAN
3297EFIAPI
3298CryptoServiceX509GetValidity (
3299 IN CONST UINT8 *Cert,
3300 IN UINTN CertSize,
3301 IN UINT8 *From,
3302 IN OUT UINTN *FromSize,
3303 IN UINT8 *To,
3304 IN OUT UINTN *ToSize
3305 )
3306{
3307 return CALL_BASECRYPTLIB (X509.Services.GetValidity, X509GetValidity, (Cert, CertSize, From, FromSize, To, ToSize), FALSE);
3308}
3309
3310/**
3311 Format a DateTimeStr to DataTime object in DataTime Buffer
3312
3313 If DateTimeStr is NULL, then return FALSE.
3314 If DateTimeSize is NULL, then return FALSE.
3315 If this interface is not supported, then return FALSE.
3316
3317 @param[in] DateTimeStr DateTime string like YYYYMMDDhhmmssZ
3318 Ref: https://www.w3.org/TR/NOTE-datetime
3319 Z stand for UTC time
3320 @param[out] DateTime Pointer to a DateTime object.
3321 @param[in,out] DateTimeSize DateTime object buffer size.
3322
3323 @retval TRUE The DateTime object create successfully.
3324 @retval FALSE If DateTimeStr is NULL.
3325 If DateTimeSize is NULL.
3326 If DateTime is not NULL and *DateTimeSize is 0.
3327 If Year Month Day Hour Minute Second combination is invalid datetime.
3328 @retval FALSE If the DateTime is NULL. The required buffer size
3329 (including the final null) is returned in the
3330 DateTimeSize parameter.
3331 @retval FALSE The operation is not supported.
3332**/
3333BOOLEAN
3334EFIAPI
3335CryptoServiceX509FormatDateTime (
3336 IN CONST CHAR8 *DateTimeStr,
3337 OUT VOID *DateTime,
3338 IN OUT UINTN *DateTimeSize
3339 )
3340{
3341 return CALL_BASECRYPTLIB (X509.Services.FormatDateTime, X509FormatDateTime, (DateTimeStr, DateTime, DateTimeSize), FALSE);
3342}
3343
3344/**
3345 Compare DateTime1 object and DateTime2 object.
3346
3347 If DateTime1 is NULL, then return -2.
3348 If DateTime2 is NULL, then return -2.
3349 If DateTime1 == DateTime2, then return 0
3350 If DateTime1 > DateTime2, then return 1
3351 If DateTime1 < DateTime2, then return -1
3352
3353 @param[in] DateTime1 Pointer to a DateTime Ojbect
3354 @param[in] DateTime2 Pointer to a DateTime Object
3355
3356 @retval 0 If DateTime1 == DateTime2
3357 @retval 1 If DateTime1 > DateTime2
3358 @retval -1 If DateTime1 < DateTime2
3359**/
3360INT32
3361EFIAPI
3362CryptoServiceX509CompareDateTime (
3363 IN CONST VOID *DateTime1,
3364 IN CONST VOID *DateTime2
3365 )
3366{
3367 return CALL_BASECRYPTLIB (X509.Services.CompareDateTime, X509CompareDateTime, (DateTime1, DateTime2), FALSE);
3368}
3369
3370/**
3371 Retrieve the Key Usage from one X.509 certificate.
3372
3373 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3374 @param[in] CertSize Size of the X509 certificate in bytes.
3375 @param[out] Usage Key Usage (CRYPTO_X509_KU_*)
3376
3377 @retval TRUE The certificate Key Usage retrieved successfully.
3378 @retval FALSE Invalid certificate, or Usage is NULL
3379 @retval FALSE This interface is not supported.
3380**/
3381BOOLEAN
3382EFIAPI
3383CryptoServiceX509GetKeyUsage (
3384 IN CONST UINT8 *Cert,
3385 IN UINTN CertSize,
3386 OUT UINTN *Usage
3387 )
3388{
3389 return CALL_BASECRYPTLIB (X509.Services.GetKeyUsage, X509GetKeyUsage, (Cert, CertSize, Usage), FALSE);
3390}
3391
3392/**
3393 Verify one X509 certificate was issued by the trusted CA.
3394 @param[in] RootCert Trusted Root Certificate buffer
3395
3396 @param[in] RootCertLength Trusted Root Certificate buffer length
3397 @param[in] CertChain One or more ASN.1 DER-encoded X.509 certificates
3398 where the first certificate is signed by the Root
3399 Certificate or is the Root Cerificate itself. and
3400 subsequent cerificate is signed by the preceding
3401 cerificate.
3402 @param[in] CertChainLength Total length of the certificate chain, in bytes.
3403
3404 @retval TRUE All cerificates was issued by the first certificate in X509Certchain.
3405 @retval FALSE Invalid certificate or the certificate was not issued by the given
3406 trusted CA.
3407**/
3408BOOLEAN
3409EFIAPI
3410CryptoServiceX509VerifyCertChain (
3411 IN CONST UINT8 *RootCert,
3412 IN UINTN RootCertLength,
3413 IN CONST UINT8 *CertChain,
3414 IN UINTN CertChainLength
3415 )
3416{
3417 return CALL_BASECRYPTLIB (X509.Services.VerifyCertChain, X509VerifyCertChain, (RootCert, RootCertLength, CertChain, CertChainLength), FALSE);
3418}
3419
3420/**
3421 Get one X509 certificate from CertChain.
3422
3423 @param[in] CertChain One or more ASN.1 DER-encoded X.509 certificates
3424 where the first certificate is signed by the Root
3425 Certificate or is the Root Cerificate itself. and
3426 subsequent cerificate is signed by the preceding
3427 cerificate.
3428 @param[in] CertChainLength Total length of the certificate chain, in bytes.
3429
3430 @param[in] CertIndex Index of certificate.
3431
3432 @param[out] Cert The certificate at the index of CertChain.
3433 @param[out] CertLength The length certificate at the index of CertChain.
3434
3435 @retval TRUE Success.
3436 @retval FALSE Failed to get certificate from certificate chain.
3437**/
3438BOOLEAN
3439EFIAPI
3440CryptoServiceX509GetCertFromCertChain (
3441 IN CONST UINT8 *CertChain,
3442 IN UINTN CertChainLength,
3443 IN CONST INT32 CertIndex,
3444 OUT CONST UINT8 **Cert,
3445 OUT UINTN *CertLength
3446 )
3447{
3448 return CALL_BASECRYPTLIB (X509.Services.GetCertFromCertChain, X509GetCertFromCertChain, (CertChain, CertChainLength, CertIndex, Cert, CertLength), FALSE);
3449}
3450
3451/**
3452 Retrieve the tag and length of the tag.
3453
3454 @param Ptr The position in the ASN.1 data
3455 @param End End of data
3456 @param Length The variable that will receive the length
3457 @param Tag The expected tag
3458
3459 @retval TRUE Get tag successful
3460 @retval FALSe Failed to get tag or tag not match
3461**/
3462BOOLEAN
3463EFIAPI
3464CryptoServiceAsn1GetTag (
3465 IN OUT UINT8 **Ptr,
3466 IN CONST UINT8 *End,
3467 OUT UINTN *Length,
3468 IN UINT32 Tag
3469 )
3470{
3471 return CALL_BASECRYPTLIB (X509.Services.Asn1GetTag, Asn1GetTag, (Ptr, End, Length, Tag), FALSE);
3472}
3473
3474/**
3475 Retrieve the basic constraints from one X.509 certificate.
3476
3477 @param[in] Cert Pointer to the DER-encoded X509 certificate.
3478 @param[in] CertSize size of the X509 certificate in bytes.
3479 @param[out] BasicConstraints basic constraints bytes.
3480 @param[in, out] BasicConstraintsSize basic constraints buffer sizs in bytes.
3481
3482 @retval TRUE The basic constraints retrieve successfully.
3483 @retval FALSE If cert is NULL.
3484 If cert_size is NULL.
3485 If basic_constraints is not NULL and *basic_constraints_size is 0.
3486 If cert is invalid.
3487 @retval FALSE The required buffer size is small.
3488 The return buffer size is basic_constraints_size parameter.
3489 @retval FALSE If no Extension entry match oid.
3490 @retval FALSE The operation is not supported.
3491 **/
3492BOOLEAN
3493EFIAPI
3494CryptoServiceX509GetExtendedBasicConstraints (
3495 CONST UINT8 *Cert,
3496 UINTN CertSize,
3497 UINT8 *BasicConstraints,
3498 UINTN *BasicConstraintsSize
3499 )
3500{
3501 return CALL_BASECRYPTLIB (X509.Services.GetExtendedBasicConstraints, X509GetExtendedBasicConstraints, (Cert, CertSize, BasicConstraints, BasicConstraintsSize), FALSE);
3502}
3503
3504/**
3505 Derives a key from a password using a salt and iteration count, based on PKCS#5 v2.0
3506 password based encryption key derivation function PBKDF2, as specified in RFC 2898.
3507
3508 If Password or Salt or OutKey is NULL, then return FALSE.
3509 If the hash algorithm could not be determined, then return FALSE.
3510 If this interface is not supported, then return FALSE.
3511
3512 @param[in] PasswordLength Length of input password in bytes.
3513 @param[in] Password Pointer to the array for the password.
3514 @param[in] SaltLength Size of the Salt in bytes.
3515 @param[in] Salt Pointer to the Salt.
3516 @param[in] IterationCount Number of iterations to perform. Its value should be
3517 greater than or equal to 1.
3518 @param[in] DigestSize Size of the message digest to be used (eg. SHA256_DIGEST_SIZE).
3519 NOTE: DigestSize will be used to determine the hash algorithm.
3520 Only SHA1_DIGEST_SIZE or SHA256_DIGEST_SIZE is supported.
3521 @param[in] KeyLength Size of the derived key buffer in bytes.
3522 @param[out] OutKey Pointer to the output derived key buffer.
3523
3524 @retval TRUE A key was derived successfully.
3525 @retval FALSE One of the pointers was NULL or one of the sizes was too large.
3526 @retval FALSE The hash algorithm could not be determined from the digest size.
3527 @retval FALSE The key derivation operation failed.
3528 @retval FALSE This interface is not supported.
3529
3530**/
3531BOOLEAN
3532EFIAPI
3533CryptoServicePkcs5HashPassword (
3534 IN UINTN PasswordLength,
3535 IN CONST CHAR8 *Password,
3536 IN UINTN SaltLength,
3537 IN CONST UINT8 *Salt,
3538 IN UINTN IterationCount,
3539 IN UINTN DigestSize,
3540 IN UINTN KeyLength,
3541 OUT UINT8 *OutKey
3542 )
3543{
3544 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs5HashPassword, Pkcs5HashPassword, (PasswordLength, Password, SaltLength, Salt, IterationCount, DigestSize, KeyLength, OutKey), FALSE);
3545}
3546
3547/**
3548 Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
3549 encrypted message in a newly allocated buffer.
3550
3551 Things that can cause a failure include:
3552 - X509 key size does not match any known key size.
3553 - Fail to parse X509 certificate.
3554 - Fail to allocate an intermediate buffer.
3555 - Null pointer provided for a non-optional parameter.
3556 - Data size is too large for the provided key size (max size is a function of key size
3557 and hash digest size).
3558
3559 @param[in] PublicKey A pointer to the DER-encoded X509 certificate that
3560 will be used to encrypt the data.
3561 @param[in] PublicKeySize Size of the X509 cert buffer.
3562 @param[in] InData Data to be encrypted.
3563 @param[in] InDataSize Size of the data buffer.
3564 @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer
3565 to be used when initializing the PRNG. NULL otherwise.
3566 @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.
3567 0 otherwise.
3568 @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted
3569 message.
3570 @param[out] EncryptedDataSize Size of the encrypted message buffer.
3571
3572 @retval TRUE Encryption was successful.
3573 @retval FALSE Encryption failed.
3574
3575**/
3576BOOLEAN
3577EFIAPI
3578CryptoServicePkcs1v2Encrypt (
3579 IN CONST UINT8 *PublicKey,
3580 IN UINTN PublicKeySize,
3581 IN UINT8 *InData,
3582 IN UINTN InDataSize,
3583 IN CONST UINT8 *PrngSeed OPTIONAL,
3584 IN UINTN PrngSeedSize OPTIONAL,
3585 OUT UINT8 **EncryptedData,
3586 OUT UINTN *EncryptedDataSize
3587 )
3588{
3589 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Encrypt, Pkcs1v2Encrypt, (PublicKey, PublicKeySize, InData, InDataSize, PrngSeed, PrngSeedSize, EncryptedData, EncryptedDataSize), FALSE);
3590}
3591
3592/**
3593 Encrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
3594 encrypted message in a newly allocated buffer.
3595
3596 Things that can cause a failure include:
3597 - X509 key size does not match any known key size.
3598 - Fail to allocate an intermediate buffer.
3599 - Null pointer provided for a non-optional parameter.
3600 - Data size is too large for the provided key size (max size is a function of key size
3601 and hash digest size).
3602
3603 @param[in] RsaContext A pointer to an RSA context created by RsaNew() and
3604 provisioned with a public key using RsaSetKey().
3605 @param[in] InData Data to be encrypted.
3606 @param[in] InDataSize Size of the data buffer.
3607 @param[in] PrngSeed [Optional] If provided, a pointer to a random seed buffer
3608 to be used when initializing the PRNG. NULL otherwise.
3609 @param[in] PrngSeedSize [Optional] If provided, size of the random seed buffer.
3610 0 otherwise.
3611 @param[in] DigestLen [Optional] If provided, size of the hash used:
3612 SHA1_DIGEST_SIZE
3613 SHA256_DIGEST_SIZE
3614 SHA384_DIGEST_SIZE
3615 SHA512_DIGEST_SIZE
3616 0 to use default (SHA1)
3617 @param[out] EncryptedData Pointer to an allocated buffer containing the encrypted
3618 message.
3619 @param[out] EncryptedDataSize Size of the encrypted message buffer.
3620
3621 @retval TRUE Encryption was successful.
3622 @retval FALSE Encryption failed.
3623
3624**/
3625BOOLEAN
3626EFIAPI
3627CryptoServiceRsaOaepEncrypt (
3628 IN VOID *RsaContext,
3629 IN UINT8 *InData,
3630 IN UINTN InDataSize,
3631 IN CONST UINT8 *PrngSeed OPTIONAL,
3632 IN UINTN PrngSeedSize OPTIONAL,
3633 IN UINT16 DigestLen OPTIONAL,
3634 OUT UINT8 **EncryptedData,
3635 OUT UINTN *EncryptedDataSize
3636 )
3637{
3638 return CALL_BASECRYPTLIB (Rsa.Services.RsaOaepEncrypt, RsaOaepEncrypt, (RsaContext, InData, InDataSize, PrngSeed, PrngSeedSize, DigestLen, EncryptedData, EncryptedDataSize), FALSE);
3639}
3640
3641/**
3642 Decrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
3643 decrypted message in a newly allocated buffer.
3644
3645 Things that can cause a failure include:
3646 - Fail to parse private key.
3647 - Fail to allocate an intermediate buffer.
3648 - Null pointer provided for a non-optional parameter.
3649
3650 @param[in] PrivateKey A pointer to the DER-encoded private key.
3651 @param[in] PrivateKeySize Size of the private key buffer.
3652 @param[in] EncryptedData Data to be decrypted.
3653 @param[in] EncryptedDataSize Size of the encrypted buffer.
3654 @param[out] OutData Pointer to an allocated buffer containing the encrypted
3655 message.
3656 @param[out] OutDataSize Size of the encrypted message buffer.
3657
3658 @retval TRUE Encryption was successful.
3659 @retval FALSE Encryption failed.
3660
3661**/
3662BOOLEAN
3663EFIAPI
3664CryptoServicePkcs1v2Decrypt (
3665 IN CONST UINT8 *PrivateKey,
3666 IN UINTN PrivateKeySize,
3667 IN UINT8 *EncryptedData,
3668 IN UINTN EncryptedDataSize,
3669 OUT UINT8 **OutData,
3670 OUT UINTN *OutDataSize
3671 )
3672{
3673 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs1v2Decrypt, Pkcs1v2Decrypt, (PrivateKey, PrivateKeySize, EncryptedData, EncryptedDataSize, OutData, OutDataSize), FALSE);
3674}
3675
3676/**
3677 Decrypts a blob using PKCS1v2 (RSAES-OAEP) schema. On success, will return the
3678 decrypted message in a newly allocated buffer.
3679
3680 Things that can cause a failure include:
3681 - Fail to parse private key.
3682 - Fail to allocate an intermediate buffer.
3683 - Null pointer provided for a non-optional parameter.
3684
3685 @param[in] RsaContext A pointer to an RSA context created by RsaNew() and
3686 provisioned with a private key using RsaSetKey().
3687 @param[in] EncryptedData Data to be decrypted.
3688 @param[in] EncryptedDataSize Size of the encrypted buffer.
3689 @param[in] DigestLen [Optional] If provided, size of the hash used:
3690 SHA1_DIGEST_SIZE
3691 SHA256_DIGEST_SIZE
3692 SHA384_DIGEST_SIZE
3693 SHA512_DIGEST_SIZE
3694 0 to use default (SHA1)
3695 @param[out] OutData Pointer to an allocated buffer containing the encrypted
3696 message.
3697 @param[out] OutDataSize Size of the encrypted message buffer.
3698
3699 @retval TRUE Encryption was successful.
3700 @retval FALSE Encryption failed.
3701
3702**/
3703BOOLEAN
3704EFIAPI
3705CryptoServiceRsaOaepDecrypt (
3706 IN VOID *RsaContext,
3707 IN UINT8 *EncryptedData,
3708 IN UINTN EncryptedDataSize,
3709 IN UINT16 DigestLen OPTIONAL,
3710 OUT UINT8 **OutData,
3711 OUT UINTN *OutDataSize
3712 )
3713{
3714 return CALL_BASECRYPTLIB (Rsa.Services.RsaOaepDecrypt, RsaOaepDecrypt, (RsaContext, EncryptedData, EncryptedDataSize, DigestLen, OutData, OutDataSize), FALSE);
3715}
3716
3717/**
3718 Get the signer's certificates from PKCS#7 signed data as described in "PKCS #7:
3719 Cryptographic Message Syntax Standard". The input signed data could be wrapped
3720 in a ContentInfo structure.
3721
3722 If P7Data, CertStack, StackLength, TrustedCert or CertLength is NULL, then
3723 return FALSE. If P7Length overflow, then return FALSE.
3724 If this interface is not supported, then return FALSE.
3725
3726 @param[in] P7Data Pointer to the PKCS#7 message to verify.
3727 @param[in] P7Length Length of the PKCS#7 message in bytes.
3728 @param[out] CertStack Pointer to Signer's certificates retrieved from P7Data.
3729 It's caller's responsibility to free the buffer with
3730 Pkcs7FreeSigners().
3731 This data structure is EFI_CERT_STACK type.
3732 @param[out] StackLength Length of signer's certificates in bytes.
3733 @param[out] TrustedCert Pointer to a trusted certificate from Signer's certificates.
3734 It's caller's responsibility to free the buffer with
3735 Pkcs7FreeSigners().
3736 @param[out] CertLength Length of the trusted certificate in bytes.
3737
3738 @retval TRUE The operation is finished successfully.
3739 @retval FALSE Error occurs during the operation.
3740 @retval FALSE This interface is not supported.
3741
3742**/
3743BOOLEAN
3744EFIAPI
3745CryptoServicePkcs7GetSigners (
3746 IN CONST UINT8 *P7Data,
3747 IN UINTN P7Length,
3748 OUT UINT8 **CertStack,
3749 OUT UINTN *StackLength,
3750 OUT UINT8 **TrustedCert,
3751 OUT UINTN *CertLength
3752 )
3753{
3754 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetSigners, Pkcs7GetSigners, (P7Data, P7Length, CertStack, StackLength, TrustedCert, CertLength), FALSE);
3755}
3756
3757/**
3758 Wrap function to use free() to free allocated memory for certificates.
3759
3760 If this interface is not supported, then ASSERT().
3761
3762 @param[in] Certs Pointer to the certificates to be freed.
3763
3764**/
3765VOID
3766EFIAPI
3767CryptoServicePkcs7FreeSigners (
3768 IN UINT8 *Certs
3769 )
3770{
3771 CALL_VOID_BASECRYPTLIB (Pkcs.Services.Pkcs7FreeSigners, Pkcs7FreeSigners, (Certs));
3772}
3773
3774/**
3775 Retrieves all embedded certificates from PKCS#7 signed data as described in "PKCS #7:
3776 Cryptographic Message Syntax Standard", and outputs two certificate lists chained and
3777 unchained to the signer's certificates.
3778 The input signed data could be wrapped in a ContentInfo structure.
3779
3780 @param[in] P7Data Pointer to the PKCS#7 message.
3781 @param[in] P7Length Length of the PKCS#7 message in bytes.
3782 @param[out] SignerChainCerts Pointer to the certificates list chained to signer's
3783 certificate. It's caller's responsibility to free the buffer
3784 with Pkcs7FreeSigners().
3785 This data structure is EFI_CERT_STACK type.
3786 @param[out] ChainLength Length of the chained certificates list buffer in bytes.
3787 @param[out] UnchainCerts Pointer to the unchained certificates lists. It's caller's
3788 responsibility to free the buffer with Pkcs7FreeSigners().
3789 This data structure is EFI_CERT_STACK type.
3790 @param[out] UnchainLength Length of the unchained certificates list buffer in bytes.
3791
3792 @retval TRUE The operation is finished successfully.
3793 @retval FALSE Error occurs during the operation.
3794
3795**/
3796BOOLEAN
3797EFIAPI
3798CryptoServicePkcs7GetCertificatesList (
3799 IN CONST UINT8 *P7Data,
3800 IN UINTN P7Length,
3801 OUT UINT8 **SignerChainCerts,
3802 OUT UINTN *ChainLength,
3803 OUT UINT8 **UnchainCerts,
3804 OUT UINTN *UnchainLength
3805 )
3806{
3807 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetCertificatesList, Pkcs7GetCertificatesList, (P7Data, P7Length, SignerChainCerts, ChainLength, UnchainCerts, UnchainLength), FALSE);
3808}
3809
3810/**
3811 Creates a PKCS#7 signedData as described in "PKCS #7: Cryptographic Message
3812 Syntax Standard, version 1.5". This interface is only intended to be used for
3813 application to perform PKCS#7 functionality validation.
3814
3815 If this interface is not supported, then return FALSE.
3816
3817 @param[in] PrivateKey Pointer to the PEM-formatted private key data for
3818 data signing.
3819 @param[in] PrivateKeySize Size of the PEM private key data in bytes.
3820 @param[in] KeyPassword NULL-terminated passphrase used for encrypted PEM
3821 key data.
3822 @param[in] InData Pointer to the content to be signed.
3823 @param[in] InDataSize Size of InData in bytes.
3824 @param[in] SignCert Pointer to signer's DER-encoded certificate to sign with.
3825 @param[in] OtherCerts Pointer to an optional additional set of certificates to
3826 include in the PKCS#7 signedData (e.g. any intermediate
3827 CAs in the chain).
3828 @param[out] SignedData Pointer to output PKCS#7 signedData. It's caller's
3829 responsibility to free the buffer with FreePool().
3830 @param[out] SignedDataSize Size of SignedData in bytes.
3831
3832 @retval TRUE PKCS#7 data signing succeeded.
3833 @retval FALSE PKCS#7 data signing failed.
3834 @retval FALSE This interface is not supported.
3835
3836**/
3837BOOLEAN
3838EFIAPI
3839CryptoServicePkcs7Sign (
3840 IN CONST UINT8 *PrivateKey,
3841 IN UINTN PrivateKeySize,
3842 IN CONST UINT8 *KeyPassword,
3843 IN UINT8 *InData,
3844 IN UINTN InDataSize,
3845 IN UINT8 *SignCert,
3846 IN UINT8 *OtherCerts OPTIONAL,
3847 OUT UINT8 **SignedData,
3848 OUT UINTN *SignedDataSize
3849 )
3850{
3851 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Sign, Pkcs7Sign, (PrivateKey, PrivateKeySize, KeyPassword, InData, InDataSize, SignCert, OtherCerts, SignedData, SignedDataSize), FALSE);
3852}
3853
3854/**
3855 Verifies the validity of a PKCS#7 signed data as described in "PKCS #7:
3856 Cryptographic Message Syntax Standard". The input signed data could be wrapped
3857 in a ContentInfo structure.
3858
3859 If P7Data, TrustedCert or InData is NULL, then return FALSE.
3860 If P7Length, CertLength or DataLength overflow, then return FALSE.
3861 If this interface is not supported, then return FALSE.
3862
3863 @param[in] P7Data Pointer to the PKCS#7 message to verify.
3864 @param[in] P7Length Length of the PKCS#7 message in bytes.
3865 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3866 is used for certificate chain verification.
3867 @param[in] CertLength Length of the trusted certificate in bytes.
3868 @param[in] InData Pointer to the content to be verified.
3869 @param[in] DataLength Length of InData in bytes.
3870
3871 @retval TRUE The specified PKCS#7 signed data is valid.
3872 @retval FALSE Invalid PKCS#7 signed data.
3873 @retval FALSE This interface is not supported.
3874
3875**/
3876BOOLEAN
3877EFIAPI
3878CryptoServicePkcs7Verify (
3879 IN CONST UINT8 *P7Data,
3880 IN UINTN P7Length,
3881 IN CONST UINT8 *TrustedCert,
3882 IN UINTN CertLength,
3883 IN CONST UINT8 *InData,
3884 IN UINTN DataLength
3885 )
3886{
3887 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7Verify, Pkcs7Verify, (P7Data, P7Length, TrustedCert, CertLength, InData, DataLength), FALSE);
3888}
3889
3890/**
3891 This function receives a PKCS7 formatted signature, and then verifies that
3892 the specified Enhanced or Extended Key Usages (EKU's) are present in the end-entity
3893 leaf signing certificate.
3894 Note that this function does not validate the certificate chain.
3895
3896 Applications for custom EKU's are quite flexible. For example, a policy EKU
3897 may be present in an Issuing Certificate Authority (CA), and any sub-ordinate
3898 certificate issued might also contain this EKU, thus constraining the
3899 sub-ordinate certificate. Other applications might allow a certificate
3900 embedded in a device to specify that other Object Identifiers (OIDs) are
3901 present which contains binary data specifying custom capabilities that
3902 the device is able to do.
3903
3904 @param[in] Pkcs7Signature The PKCS#7 signed information content block. An array
3905 containing the content block with both the signature,
3906 the signer's certificate, and any necessary intermediate
3907 certificates.
3908 @param[in] Pkcs7SignatureSize Number of bytes in Pkcs7Signature.
3909 @param[in] RequiredEKUs Array of null-terminated strings listing OIDs of
3910 required EKUs that must be present in the signature.
3911 @param[in] RequiredEKUsSize Number of elements in the RequiredEKUs string array.
3912 @param[in] RequireAllPresent If this is TRUE, then all of the specified EKU's
3913 must be present in the leaf signer. If it is
3914 FALSE, then we will succeed if we find any
3915 of the specified EKU's.
3916
3917 @retval EFI_SUCCESS The required EKUs were found in the signature.
3918 @retval EFI_INVALID_PARAMETER A parameter was invalid.
3919 @retval EFI_NOT_FOUND One or more EKU's were not found in the signature.
3920
3921**/
3922RETURN_STATUS
3923EFIAPI
3924CryptoServiceVerifyEKUsInPkcs7Signature (
3925 IN CONST UINT8 *Pkcs7Signature,
3926 IN CONST UINT32 SignatureSize,
3927 IN CONST CHAR8 *RequiredEKUs[],
3928 IN CONST UINT32 RequiredEKUsSize,
3929 IN BOOLEAN RequireAllPresent
3930 )
3931{
3932 return CALL_BASECRYPTLIB (Pkcs.Services.VerifyEKUsInPkcs7Signature, VerifyEKUsInPkcs7Signature, (Pkcs7Signature, SignatureSize, RequiredEKUs, RequiredEKUsSize, RequireAllPresent), FALSE);
3933}
3934
3935/**
3936 Extracts the attached content from a PKCS#7 signed data if existed. The input signed
3937 data could be wrapped in a ContentInfo structure.
3938
3939 If P7Data, Content, or ContentSize is NULL, then return FALSE. If P7Length overflow,
3940 then return FALSE. If the P7Data is not correctly formatted, then return FALSE.
3941
3942 Caution: This function may receive untrusted input. So this function will do
3943 basic check for PKCS#7 data structure.
3944
3945 @param[in] P7Data Pointer to the PKCS#7 signed data to process.
3946 @param[in] P7Length Length of the PKCS#7 signed data in bytes.
3947 @param[out] Content Pointer to the extracted content from the PKCS#7 signedData.
3948 It's caller's responsibility to free the buffer with FreePool().
3949 @param[out] ContentSize The size of the extracted content in bytes.
3950
3951 @retval TRUE The P7Data was correctly formatted for processing.
3952 @retval FALSE The P7Data was not correctly formatted for processing.
3953
3954**/
3955BOOLEAN
3956EFIAPI
3957CryptoServicePkcs7GetAttachedContent (
3958 IN CONST UINT8 *P7Data,
3959 IN UINTN P7Length,
3960 OUT VOID **Content,
3961 OUT UINTN *ContentSize
3962 )
3963{
3964 return CALL_BASECRYPTLIB (Pkcs.Services.Pkcs7GetAttachedContent, Pkcs7GetAttachedContent, (P7Data, P7Length, Content, ContentSize), FALSE);
3965}
3966
3967/**
3968 Verifies the validity of a PE/COFF Authenticode Signature as described in "Windows
3969 Authenticode Portable Executable Signature Format".
3970
3971 If AuthData is NULL, then return FALSE.
3972 If ImageHash is NULL, then return FALSE.
3973 If this interface is not supported, then return FALSE.
3974
3975 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
3976 PE/COFF image to be verified.
3977 @param[in] DataSize Size of the Authenticode Signature in bytes.
3978 @param[in] TrustedCert Pointer to a trusted/root certificate encoded in DER, which
3979 is used for certificate chain verification.
3980 @param[in] CertSize Size of the trusted certificate in bytes.
3981 @param[in] ImageHash Pointer to the original image file hash value. The procedure
3982 for calculating the image hash value is described in Authenticode
3983 specification.
3984 @param[in] HashSize Size of Image hash value in bytes.
3985
3986 @retval TRUE The specified Authenticode Signature is valid.
3987 @retval FALSE Invalid Authenticode Signature.
3988 @retval FALSE This interface is not supported.
3989
3990**/
3991BOOLEAN
3992EFIAPI
3993CryptoServiceAuthenticodeVerify (
3994 IN CONST UINT8 *AuthData,
3995 IN UINTN DataSize,
3996 IN CONST UINT8 *TrustedCert,
3997 IN UINTN CertSize,
3998 IN CONST UINT8 *ImageHash,
3999 IN UINTN HashSize
4000 )
4001{
4002 return CALL_BASECRYPTLIB (Pkcs.Services.AuthenticodeVerify, AuthenticodeVerify, (AuthData, DataSize, TrustedCert, CertSize, ImageHash, HashSize), FALSE);
4003}
4004
4005/**
4006 Verifies the validity of a RFC3161 Timestamp CounterSignature embedded in PE/COFF Authenticode
4007 signature.
4008
4009 If AuthData is NULL, then return FALSE.
4010 If this interface is not supported, then return FALSE.
4011
4012 @param[in] AuthData Pointer to the Authenticode Signature retrieved from signed
4013 PE/COFF image to be verified.
4014 @param[in] DataSize Size of the Authenticode Signature in bytes.
4015 @param[in] TsaCert Pointer to a trusted/root TSA certificate encoded in DER, which
4016 is used for TSA certificate chain verification.
4017 @param[in] CertSize Size of the trusted certificate in bytes.
4018 @param[out] SigningTime Return the time of timestamp generation time if the timestamp
4019 signature is valid.
4020
4021 @retval TRUE The specified Authenticode includes a valid RFC3161 Timestamp CounterSignature.
4022 @retval FALSE No valid RFC3161 Timestamp CounterSignature in the specified Authenticode data.
4023
4024**/
4025BOOLEAN
4026EFIAPI
4027CryptoServiceImageTimestampVerify (
4028 IN CONST UINT8 *AuthData,
4029 IN UINTN DataSize,
4030 IN CONST UINT8 *TsaCert,
4031 IN UINTN CertSize,
4032 OUT EFI_TIME *SigningTime
4033 )
4034{
4035 return CALL_BASECRYPTLIB (Pkcs.Services.ImageTimestampVerify, ImageTimestampVerify, (AuthData, DataSize, TsaCert, CertSize, SigningTime), FALSE);
4036}
4037
4038// =====================================================================================
4039// DH Key Exchange Primitive
4040// =====================================================================================
4041
4042/**
4043 Allocates and Initializes one Diffie-Hellman Context for subsequent use.
4044
4045 @return Pointer to the Diffie-Hellman Context that has been initialized.
4046 If the allocations fails, DhNew() returns NULL.
4047 If the interface is not supported, DhNew() returns NULL.
4048
4049**/
4050VOID *
4051EFIAPI
4052CryptoServiceDhNew (
4053 VOID
4054 )
4055{
4056 return CALL_BASECRYPTLIB (Dh.Services.New, DhNew, (), NULL);
4057}
4058
4059/**
4060 Release the specified DH context.
4061
4062 If the interface is not supported, then ASSERT().
4063
4064 @param[in] DhContext Pointer to the DH context to be released.
4065
4066**/
4067VOID
4068EFIAPI
4069CryptoServiceDhFree (
4070 IN VOID *DhContext
4071 )
4072{
4073 CALL_VOID_BASECRYPTLIB (Dh.Services.Free, DhFree, (DhContext));
4074}
4075
4076/**
4077 Generates DH parameter.
4078
4079 Given generator g, and length of prime number p in bits, this function generates p,
4080 and sets DH context according to value of g and p.
4081
4082 Before this function can be invoked, pseudorandom number generator must be correctly
4083 initialized by RandomSeed().
4084
4085 If DhContext is NULL, then return FALSE.
4086 If Prime is NULL, then return FALSE.
4087 If this interface is not supported, then return FALSE.
4088
4089 @param[in, out] DhContext Pointer to the DH context.
4090 @param[in] Generator Value of generator.
4091 @param[in] PrimeLength Length in bits of prime to be generated.
4092 @param[out] Prime Pointer to the buffer to receive the generated prime number.
4093
4094 @retval TRUE DH parameter generation succeeded.
4095 @retval FALSE Value of Generator is not supported.
4096 @retval FALSE PRNG fails to generate random prime number with PrimeLength.
4097 @retval FALSE This interface is not supported.
4098
4099**/
4100BOOLEAN
4101EFIAPI
4102CryptoServiceDhGenerateParameter (
4103 IN OUT VOID *DhContext,
4104 IN UINTN Generator,
4105 IN UINTN PrimeLength,
4106 OUT UINT8 *Prime
4107 )
4108{
4109 return CALL_BASECRYPTLIB (Dh.Services.GenerateParameter, DhGenerateParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
4110}
4111
4112/**
4113 Sets generator and prime parameters for DH.
4114
4115 Given generator g, and prime number p, this function and sets DH
4116 context accordingly.
4117
4118 If DhContext is NULL, then return FALSE.
4119 If Prime is NULL, then return FALSE.
4120 If this interface is not supported, then return FALSE.
4121
4122 @param[in, out] DhContext Pointer to the DH context.
4123 @param[in] Generator Value of generator.
4124 @param[in] PrimeLength Length in bits of prime to be generated.
4125 @param[in] Prime Pointer to the prime number.
4126
4127 @retval TRUE DH parameter setting succeeded.
4128 @retval FALSE Value of Generator is not supported.
4129 @retval FALSE Value of Generator is not suitable for the Prime.
4130 @retval FALSE Value of Prime is not a prime number.
4131 @retval FALSE Value of Prime is not a safe prime number.
4132 @retval FALSE This interface is not supported.
4133
4134**/
4135BOOLEAN
4136EFIAPI
4137CryptoServiceDhSetParameter (
4138 IN OUT VOID *DhContext,
4139 IN UINTN Generator,
4140 IN UINTN PrimeLength,
4141 IN CONST UINT8 *Prime
4142 )
4143{
4144 return CALL_BASECRYPTLIB (Dh.Services.SetParameter, DhSetParameter, (DhContext, Generator, PrimeLength, Prime), FALSE);
4145}
4146
4147/**
4148 Generates DH public key.
4149
4150 This function generates random secret exponent, and computes the public key, which is
4151 returned via parameter PublicKey and PublicKeySize. DH context is updated accordingly.
4152 If the PublicKey buffer is too small to hold the public key, FALSE is returned and
4153 PublicKeySize is set to the required buffer size to obtain the public key.
4154
4155 If DhContext is NULL, then return FALSE.
4156 If PublicKeySize is NULL, then return FALSE.
4157 If PublicKeySize is large enough but PublicKey is NULL, then return FALSE.
4158 If this interface is not supported, then return FALSE.
4159
4160 @param[in, out] DhContext Pointer to the DH context.
4161 @param[out] PublicKey Pointer to the buffer to receive generated public key.
4162 @param[in, out] PublicKeySize On input, the size of PublicKey buffer in bytes.
4163 On output, the size of data returned in PublicKey buffer in bytes.
4164
4165 @retval TRUE DH public key generation succeeded.
4166 @retval FALSE DH public key generation failed.
4167 @retval FALSE PublicKeySize is not large enough.
4168 @retval FALSE This interface is not supported.
4169
4170**/
4171BOOLEAN
4172EFIAPI
4173CryptoServiceDhGenerateKey (
4174 IN OUT VOID *DhContext,
4175 OUT UINT8 *PublicKey,
4176 IN OUT UINTN *PublicKeySize
4177 )
4178{
4179 return CALL_BASECRYPTLIB (Dh.Services.GenerateKey, DhGenerateKey, (DhContext, PublicKey, PublicKeySize), FALSE);
4180}
4181
4182/**
4183 Computes exchanged common key.
4184
4185 Given peer's public key, this function computes the exchanged common key, based on its own
4186 context including value of prime modulus and random secret exponent.
4187
4188 If DhContext is NULL, then return FALSE.
4189 If PeerPublicKey is NULL, then return FALSE.
4190 If KeySize is NULL, then return FALSE.
4191 If Key is NULL, then return FALSE.
4192 If KeySize is not large enough, then return FALSE.
4193 If this interface is not supported, then return FALSE.
4194
4195 @param[in, out] DhContext Pointer to the DH context.
4196 @param[in] PeerPublicKey Pointer to the peer's public key.
4197 @param[in] PeerPublicKeySize Size of peer's public key in bytes.
4198 @param[out] Key Pointer to the buffer to receive generated key.
4199 @param[in, out] KeySize On input, the size of Key buffer in bytes.
4200 On output, the size of data returned in Key buffer in bytes.
4201
4202 @retval TRUE DH exchanged key generation succeeded.
4203 @retval FALSE DH exchanged key generation failed.
4204 @retval FALSE KeySize is not large enough.
4205 @retval FALSE This interface is not supported.
4206
4207**/
4208BOOLEAN
4209EFIAPI
4210CryptoServiceDhComputeKey (
4211 IN OUT VOID *DhContext,
4212 IN CONST UINT8 *PeerPublicKey,
4213 IN UINTN PeerPublicKeySize,
4214 OUT UINT8 *Key,
4215 IN OUT UINTN *KeySize
4216 )
4217{
4218 return CALL_BASECRYPTLIB (Dh.Services.ComputeKey, DhComputeKey, (DhContext, PeerPublicKey, PeerPublicKeySize, Key, KeySize), FALSE);
4219}
4220
4221// =====================================================================================
4222// Pseudo-Random Generation Primitive
4223// =====================================================================================
4224
4225/**
4226 Sets up the seed value for the pseudorandom number generator.
4227
4228 This function sets up the seed value for the pseudorandom number generator.
4229 If Seed is not NULL, then the seed passed in is used.
4230 If Seed is NULL, then default seed is used.
4231 If this interface is not supported, then return FALSE.
4232
4233 @param[in] Seed Pointer to seed value.
4234 If NULL, default seed is used.
4235 @param[in] SeedSize Size of seed value.
4236 If Seed is NULL, this parameter is ignored.
4237
4238 @retval TRUE Pseudorandom number generator has enough entropy for random generation.
4239 @retval FALSE Pseudorandom number generator does not have enough entropy for random generation.
4240 @retval FALSE This interface is not supported.
4241
4242**/
4243BOOLEAN
4244EFIAPI
4245CryptoServiceRandomSeed (
4246 IN CONST UINT8 *Seed OPTIONAL,
4247 IN UINTN SeedSize
4248 )
4249{
4250 return CALL_BASECRYPTLIB (Random.Services.Seed, RandomSeed, (Seed, SeedSize), FALSE);
4251}
4252
4253/**
4254 Generates a pseudorandom byte stream of the specified size.
4255
4256 If Output is NULL, then return FALSE.
4257 If this interface is not supported, then return FALSE.
4258
4259 @param[out] Output Pointer to buffer to receive random value.
4260 @param[in] Size Size of random bytes to generate.
4261
4262 @retval TRUE Pseudorandom byte stream generated successfully.
4263 @retval FALSE Pseudorandom number generator fails to generate due to lack of entropy.
4264 @retval FALSE This interface is not supported.
4265
4266**/
4267BOOLEAN
4268EFIAPI
4269CryptoServiceRandomBytes (
4270 OUT UINT8 *Output,
4271 IN UINTN Size
4272 )
4273{
4274 return CALL_BASECRYPTLIB (Random.Services.Bytes, RandomBytes, (Output, Size), FALSE);
4275}
4276
4277// =====================================================================================
4278// Key Derivation Function Primitive
4279// =====================================================================================
4280
4281/**
4282 Derive key data using HMAC-SHA256 based KDF.
4283
4284 @param[in] Key Pointer to the user-supplied key.
4285 @param[in] KeySize Key size in bytes.
4286 @param[in] Salt Pointer to the salt(non-secret) value.
4287 @param[in] SaltSize Salt size in bytes.
4288 @param[in] Info Pointer to the application specific info.
4289 @param[in] InfoSize Info size in bytes.
4290 @param[out] Out Pointer to buffer to receive hkdf value.
4291 @param[in] OutSize Size of hkdf bytes to generate.
4292
4293 @retval TRUE Hkdf generated successfully.
4294 @retval FALSE Hkdf generation failed.
4295
4296**/
4297BOOLEAN
4298EFIAPI
4299CryptoServiceHkdfSha256ExtractAndExpand (
4300 IN CONST UINT8 *Key,
4301 IN UINTN KeySize,
4302 IN CONST UINT8 *Salt,
4303 IN UINTN SaltSize,
4304 IN CONST UINT8 *Info,
4305 IN UINTN InfoSize,
4306 OUT UINT8 *Out,
4307 IN UINTN OutSize
4308 )
4309{
4310 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256ExtractAndExpand, HkdfSha256ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
4311}
4312
4313/**
4314 Derive SHA256 HMAC-based Extract key Derivation Function (HKDF).
4315
4316 @param[in] Key Pointer to the user-supplied key.
4317 @param[in] KeySize key size in bytes.
4318 @param[in] Salt Pointer to the salt(non-secret) value.
4319 @param[in] SaltSize salt size in bytes.
4320 @param[out] PrkOut Pointer to buffer to receive hkdf value.
4321 @param[in] PrkOutSize size of hkdf bytes to generate.
4322
4323 @retval true Hkdf generated successfully.
4324 @retval false Hkdf generation failed.
4325
4326**/
4327BOOLEAN
4328EFIAPI
4329CryptoServiceHkdfSha256Extract (
4330 IN CONST UINT8 *Key,
4331 IN UINTN KeySize,
4332 IN CONST UINT8 *Salt,
4333 IN UINTN SaltSize,
4334 OUT UINT8 *PrkOut,
4335 UINTN PrkOutSize
4336 )
4337{
4338 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Extract, HkdfSha256Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);
4339}
4340
4341/**
4342 Derive SHA256 HMAC-based Expand Key Derivation Function (HKDF).
4343
4344 @param[in] Prk Pointer to the user-supplied key.
4345 @param[in] PrkSize Key size in bytes.
4346 @param[in] Info Pointer to the application specific info.
4347 @param[in] InfoSize Info size in bytes.
4348 @param[out] Out Pointer to buffer to receive hkdf value.
4349 @param[in] OutSize Size of hkdf bytes to generate.
4350
4351 @retval TRUE Hkdf generated successfully.
4352 @retval FALSE Hkdf generation failed.
4353
4354**/
4355BOOLEAN
4356EFIAPI
4357CryptoServiceHkdfSha256Expand (
4358 IN CONST UINT8 *Prk,
4359 IN UINTN PrkSize,
4360 IN CONST UINT8 *Info,
4361 IN UINTN InfoSize,
4362 OUT UINT8 *Out,
4363 IN UINTN OutSize
4364 )
4365{
4366 return CALL_BASECRYPTLIB (Hkdf.Services.Sha256Expand, HkdfSha256Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);
4367}
4368
4369/**
4370 Derive SHA384 HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
4371
4372 @param[in] Key Pointer to the user-supplied key.
4373 @param[in] KeySize Key size in bytes.
4374 @param[in] Salt Pointer to the salt(non-secret) value.
4375 @param[in] SaltSize Salt size in bytes.
4376 @param[in] Info Pointer to the application specific info.
4377 @param[in] InfoSize Info size in bytes.
4378 @param[out] Out Pointer to buffer to receive hkdf value.
4379 @param[in] OutSize Size of hkdf bytes to generate.
4380
4381 @retval TRUE Hkdf generated successfully.
4382 @retval FALSE Hkdf generation failed.
4383
4384**/
4385BOOLEAN
4386EFIAPI
4387CryptoServiceHkdfSha384ExtractAndExpand (
4388 IN CONST UINT8 *Key,
4389 IN UINTN KeySize,
4390 IN CONST UINT8 *Salt,
4391 IN UINTN SaltSize,
4392 IN CONST UINT8 *Info,
4393 IN UINTN InfoSize,
4394 OUT UINT8 *Out,
4395 IN UINTN OutSize
4396 )
4397{
4398 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384ExtractAndExpand, HkdfSha384ExtractAndExpand, (Key, KeySize, Salt, SaltSize, Info, InfoSize, Out, OutSize), FALSE);
4399}
4400
4401/**
4402 Derive SHA384 HMAC-based Extract key Derivation Function (HKDF).
4403
4404 @param[in] Key Pointer to the user-supplied key.
4405 @param[in] KeySize key size in bytes.
4406 @param[in] Salt Pointer to the salt(non-secret) value.
4407 @param[in] SaltSize salt size in bytes.
4408 @param[out] PrkOut Pointer to buffer to receive hkdf value.
4409 @param[in] PrkOutSize size of hkdf bytes to generate.
4410
4411 @retval true Hkdf generated successfully.
4412 @retval false Hkdf generation failed.
4413
4414**/
4415BOOLEAN
4416EFIAPI
4417CryptoServiceHkdfSha384Extract (
4418 IN CONST UINT8 *Key,
4419 IN UINTN KeySize,
4420 IN CONST UINT8 *Salt,
4421 IN UINTN SaltSize,
4422 OUT UINT8 *PrkOut,
4423 UINTN PrkOutSize
4424 )
4425{
4426 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Extract, HkdfSha384Extract, (Key, KeySize, Salt, SaltSize, PrkOut, PrkOutSize), FALSE);
4427}
4428
4429/**
4430 Derive SHA384 HMAC-based Expand Key Derivation Function (HKDF).
4431
4432 @param[in] Prk Pointer to the user-supplied key.
4433 @param[in] PrkSize Key size in bytes.
4434 @param[in] Info Pointer to the application specific info.
4435 @param[in] InfoSize Info size in bytes.
4436 @param[out] Out Pointer to buffer to receive hkdf value.
4437 @param[in] OutSize Size of hkdf bytes to generate.
4438
4439 @retval TRUE Hkdf generated successfully.
4440 @retval FALSE Hkdf generation failed.
4441
4442**/
4443BOOLEAN
4444EFIAPI
4445CryptoServiceHkdfSha384Expand (
4446 IN CONST UINT8 *Prk,
4447 IN UINTN PrkSize,
4448 IN CONST UINT8 *Info,
4449 IN UINTN InfoSize,
4450 OUT UINT8 *Out,
4451 IN UINTN OutSize
4452 )
4453{
4454 return CALL_BASECRYPTLIB (Hkdf.Services.Sha384Expand, HkdfSha384Expand, (Prk, PrkSize, Info, InfoSize, Out, OutSize), FALSE);
4455}
4456
4457/**
4458 Initializes the OpenSSL library.
4459
4460 This function registers ciphers and digests used directly and indirectly
4461 by SSL/TLS, and initializes the readable error messages.
4462 This function must be called before any other action takes places.
4463
4464 @retval TRUE The OpenSSL library has been initialized.
4465 @retval FALSE Failed to initialize the OpenSSL library.
4466
4467**/
4468BOOLEAN
4469EFIAPI
4470CryptoServiceTlsInitialize (
4471 VOID
4472 )
4473{
4474 return CALL_BASECRYPTLIB (Tls.Services.Initialize, TlsInitialize, (), FALSE);
4475}
4476
4477/**
4478 Free an allocated SSL_CTX object.
4479
4480 @param[in] TlsCtx Pointer to the SSL_CTX object to be released.
4481
4482**/
4483VOID
4484EFIAPI
4485CryptoServiceTlsCtxFree (
4486 IN VOID *TlsCtx
4487 )
4488{
4489 CALL_VOID_BASECRYPTLIB (Tls.Services.CtxFree, TlsCtxFree, (TlsCtx));
4490}
4491
4492/**
4493 Creates a new SSL_CTX object as framework to establish TLS/SSL enabled
4494 connections.
4495
4496 @param[in] MajorVer Major Version of TLS/SSL Protocol.
4497 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
4498
4499 @return Pointer to an allocated SSL_CTX object.
4500 If the creation failed, TlsCtxNew() returns NULL.
4501
4502**/
4503VOID *
4504EFIAPI
4505CryptoServiceTlsCtxNew (
4506 IN UINT8 MajorVer,
4507 IN UINT8 MinorVer
4508 )
4509{
4510 return CALL_BASECRYPTLIB (Tls.Services.CtxNew, TlsCtxNew, (MajorVer, MinorVer), NULL);
4511}
4512
4513/**
4514 Free an allocated TLS object.
4515
4516 This function removes the TLS object pointed to by Tls and frees up the
4517 allocated memory. If Tls is NULL, nothing is done.
4518
4519 @param[in] Tls Pointer to the TLS object to be freed.
4520
4521**/
4522VOID
4523EFIAPI
4524CryptoServiceTlsFree (
4525 IN VOID *Tls
4526 )
4527{
4528 CALL_VOID_BASECRYPTLIB (Tls.Services.Free, TlsFree, (Tls));
4529}
4530
4531/**
4532 Create a new TLS object for a connection.
4533
4534 This function creates a new TLS object for a connection. The new object
4535 inherits the setting of the underlying context TlsCtx: connection method,
4536 options, verification setting.
4537
4538 @param[in] TlsCtx Pointer to the SSL_CTX object.
4539
4540 @return Pointer to an allocated SSL object.
4541 If the creation failed, TlsNew() returns NULL.
4542
4543**/
4544VOID *
4545EFIAPI
4546CryptoServiceTlsNew (
4547 IN VOID *TlsCtx
4548 )
4549{
4550 return CALL_BASECRYPTLIB (Tls.Services.New, TlsNew, (TlsCtx), NULL);
4551}
4552
4553/**
4554 Checks if the TLS handshake was done.
4555
4556 This function will check if the specified TLS handshake was done.
4557
4558 @param[in] Tls Pointer to the TLS object for handshake state checking.
4559
4560 @retval TRUE The TLS handshake was done.
4561 @retval FALSE The TLS handshake was not done.
4562
4563**/
4564BOOLEAN
4565EFIAPI
4566CryptoServiceTlsInHandshake (
4567 IN VOID *Tls
4568 )
4569{
4570 return CALL_BASECRYPTLIB (Tls.Services.InHandshake, TlsInHandshake, (Tls), FALSE);
4571}
4572
4573/**
4574 Perform a TLS/SSL handshake.
4575
4576 This function will perform a TLS/SSL handshake.
4577
4578 @param[in] Tls Pointer to the TLS object for handshake operation.
4579 @param[in] BufferIn Pointer to the most recently received TLS Handshake packet.
4580 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
4581 Handshake packet.
4582 @param[out] BufferOut Pointer to the buffer to hold the built packet.
4583 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
4584 the buffer size provided by the caller. On output, it
4585 is the buffer size in fact needed to contain the
4586 packet.
4587
4588 @retval EFI_SUCCESS The required TLS packet is built successfully.
4589 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4590 Tls is NULL.
4591 BufferIn is NULL but BufferInSize is NOT 0.
4592 BufferInSize is 0 but BufferIn is NOT NULL.
4593 BufferOutSize is NULL.
4594 BufferOut is NULL if *BufferOutSize is not zero.
4595 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
4596 @retval EFI_ABORTED Something wrong during handshake.
4597
4598**/
4599EFI_STATUS
4600EFIAPI
4601CryptoServiceTlsDoHandshake (
4602 IN VOID *Tls,
4603 IN UINT8 *BufferIn OPTIONAL,
4604 IN UINTN BufferInSize OPTIONAL,
4605 OUT UINT8 *BufferOut OPTIONAL,
4606 IN OUT UINTN *BufferOutSize
4607 )
4608{
4609 return CALL_BASECRYPTLIB (Tls.Services.DoHandshake, TlsDoHandshake, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
4610}
4611
4612/**
4613 Handle Alert message recorded in BufferIn. If BufferIn is NULL and BufferInSize is zero,
4614 TLS session has errors and the response packet needs to be Alert message based on error type.
4615
4616 @param[in] Tls Pointer to the TLS object for state checking.
4617 @param[in] BufferIn Pointer to the most recently received TLS Alert packet.
4618 @param[in] BufferInSize Packet size in bytes for the most recently received TLS
4619 Alert packet.
4620 @param[out] BufferOut Pointer to the buffer to hold the built packet.
4621 @param[in, out] BufferOutSize Pointer to the buffer size in bytes. On input, it is
4622 the buffer size provided by the caller. On output, it
4623 is the buffer size in fact needed to contain the
4624 packet.
4625
4626 @retval EFI_SUCCESS The required TLS packet is built successfully.
4627 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4628 Tls is NULL.
4629 BufferIn is NULL but BufferInSize is NOT 0.
4630 BufferInSize is 0 but BufferIn is NOT NULL.
4631 BufferOutSize is NULL.
4632 BufferOut is NULL if *BufferOutSize is not zero.
4633 @retval EFI_ABORTED An error occurred.
4634 @retval EFI_BUFFER_TOO_SMALL BufferOutSize is too small to hold the response packet.
4635
4636**/
4637EFI_STATUS
4638EFIAPI
4639CryptoServiceTlsHandleAlert (
4640 IN VOID *Tls,
4641 IN UINT8 *BufferIn OPTIONAL,
4642 IN UINTN BufferInSize OPTIONAL,
4643 OUT UINT8 *BufferOut OPTIONAL,
4644 IN OUT UINTN *BufferOutSize
4645 )
4646{
4647 return CALL_BASECRYPTLIB (Tls.Services.HandleAlert, TlsHandleAlert, (Tls, BufferIn, BufferInSize, BufferOut, BufferOutSize), EFI_UNSUPPORTED);
4648}
4649
4650/**
4651 Build the CloseNotify packet.
4652
4653 @param[in] Tls Pointer to the TLS object for state checking.
4654 @param[in, out] Buffer Pointer to the buffer to hold the built packet.
4655 @param[in, out] BufferSize Pointer to the buffer size in bytes. On input, it is
4656 the buffer size provided by the caller. On output, it
4657 is the buffer size in fact needed to contain the
4658 packet.
4659
4660 @retval EFI_SUCCESS The required TLS packet is built successfully.
4661 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4662 Tls is NULL.
4663 BufferSize is NULL.
4664 Buffer is NULL if *BufferSize is not zero.
4665 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small to hold the response packet.
4666
4667**/
4668EFI_STATUS
4669EFIAPI
4670CryptoServiceTlsCloseNotify (
4671 IN VOID *Tls,
4672 IN OUT UINT8 *Buffer,
4673 IN OUT UINTN *BufferSize
4674 )
4675{
4676 return CALL_BASECRYPTLIB (Tls.Services.CloseNotify, TlsCloseNotify, (Tls, Buffer, BufferSize), EFI_UNSUPPORTED);
4677}
4678
4679/**
4680 Attempts to read bytes from one TLS object and places the data in Buffer.
4681
4682 This function will attempt to read BufferSize bytes from the TLS object
4683 and places the data in Buffer.
4684
4685 @param[in] Tls Pointer to the TLS object.
4686 @param[in,out] Buffer Pointer to the buffer to store the data.
4687 @param[in] BufferSize The size of Buffer in bytes.
4688
4689 @retval >0 The amount of data successfully read from the TLS object.
4690 @retval <=0 No data was successfully read.
4691
4692**/
4693INTN
4694EFIAPI
4695CryptoServiceTlsCtrlTrafficOut (
4696 IN VOID *Tls,
4697 IN OUT VOID *Buffer,
4698 IN UINTN BufferSize
4699 )
4700{
4701 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficOut, TlsCtrlTrafficOut, (Tls, Buffer, BufferSize), 0);
4702}
4703
4704/**
4705 Attempts to write data from the buffer to TLS object.
4706
4707 This function will attempt to write BufferSize bytes data from the Buffer
4708 to the TLS object.
4709
4710 @param[in] Tls Pointer to the TLS object.
4711 @param[in] Buffer Pointer to the data buffer.
4712 @param[in] BufferSize The size of Buffer in bytes.
4713
4714 @retval >0 The amount of data successfully written to the TLS object.
4715 @retval <=0 No data was successfully written.
4716
4717**/
4718INTN
4719EFIAPI
4720CryptoServiceTlsCtrlTrafficIn (
4721 IN VOID *Tls,
4722 IN VOID *Buffer,
4723 IN UINTN BufferSize
4724 )
4725{
4726 return CALL_BASECRYPTLIB (Tls.Services.CtrlTrafficIn, TlsCtrlTrafficIn, (Tls, Buffer, BufferSize), 0);
4727}
4728
4729/**
4730 Attempts to read bytes from the specified TLS connection into the buffer.
4731
4732 This function tries to read BufferSize bytes data from the specified TLS
4733 connection into the Buffer.
4734
4735 @param[in] Tls Pointer to the TLS connection for data reading.
4736 @param[in,out] Buffer Pointer to the data buffer.
4737 @param[in] BufferSize The size of Buffer in bytes.
4738
4739 @retval >0 The read operation was successful, and return value is the
4740 number of bytes actually read from the TLS connection.
4741 @retval <=0 The read operation was not successful.
4742
4743**/
4744INTN
4745EFIAPI
4746CryptoServiceTlsRead (
4747 IN VOID *Tls,
4748 IN OUT VOID *Buffer,
4749 IN UINTN BufferSize
4750 )
4751{
4752 return CALL_BASECRYPTLIB (Tls.Services.Read, TlsRead, (Tls, Buffer, BufferSize), 0);
4753}
4754
4755/**
4756 Attempts to write data to a TLS connection.
4757
4758 This function tries to write BufferSize bytes data from the Buffer into the
4759 specified TLS connection.
4760
4761 @param[in] Tls Pointer to the TLS connection for data writing.
4762 @param[in] Buffer Pointer to the data buffer.
4763 @param[in] BufferSize The size of Buffer in bytes.
4764
4765 @retval >0 The write operation was successful, and return value is the
4766 number of bytes actually written to the TLS connection.
4767 @retval <=0 The write operation was not successful.
4768
4769**/
4770INTN
4771EFIAPI
4772CryptoServiceTlsWrite (
4773 IN VOID *Tls,
4774 IN VOID *Buffer,
4775 IN UINTN BufferSize
4776 )
4777{
4778 return CALL_BASECRYPTLIB (Tls.Services.Write, TlsWrite, (Tls, Buffer, BufferSize), 0);
4779}
4780
4781/**
4782 Shutdown a TLS connection.
4783
4784 Shutdown the TLS connection without releasing the resources, meaning a new
4785 connection can be started without calling TlsNew() and without setting
4786 certificates etc.
4787
4788 @param[in] Tls Pointer to the TLS object to shutdown.
4789
4790 @retval EFI_SUCCESS The TLS is shutdown successfully.
4791 @retval EFI_INVALID_PARAMETER Tls is NULL.
4792 @retval EFI_PROTOCOL_ERROR Some other error occurred.
4793**/
4794EFI_STATUS
4795EFIAPI
4796CryptoServiceTlsShutdown (
4797 IN VOID *Tls
4798 )
4799{
4800 return CALL_BASECRYPTLIB (Tls.Services.Shutdown, TlsShutdown, (Tls), EFI_UNSUPPORTED);
4801}
4802
4803/**
4804 Set a new TLS/SSL method for a particular TLS object.
4805
4806 This function sets a new TLS/SSL method for a particular TLS object.
4807
4808 @param[in] Tls Pointer to a TLS object.
4809 @param[in] MajorVer Major Version of TLS/SSL Protocol.
4810 @param[in] MinorVer Minor Version of TLS/SSL Protocol.
4811
4812 @retval EFI_SUCCESS The TLS/SSL method was set successfully.
4813 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4814 @retval EFI_UNSUPPORTED Unsupported TLS/SSL method.
4815
4816**/
4817EFI_STATUS
4818EFIAPI
4819CryptoServiceTlsSetVersion (
4820 IN VOID *Tls,
4821 IN UINT8 MajorVer,
4822 IN UINT8 MinorVer
4823 )
4824{
4825 return CALL_BASECRYPTLIB (TlsSet.Services.Version, TlsSetVersion, (Tls, MajorVer, MinorVer), EFI_UNSUPPORTED);
4826}
4827
4828/**
4829 Set TLS object to work in client or server mode.
4830
4831 This function prepares a TLS object to work in client or server mode.
4832
4833 @param[in] Tls Pointer to a TLS object.
4834 @param[in] IsServer Work in server mode.
4835
4836 @retval EFI_SUCCESS The TLS/SSL work mode was set successfully.
4837 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4838 @retval EFI_UNSUPPORTED Unsupported TLS/SSL work mode.
4839
4840**/
4841EFI_STATUS
4842EFIAPI
4843CryptoServiceTlsSetConnectionEnd (
4844 IN VOID *Tls,
4845 IN BOOLEAN IsServer
4846 )
4847{
4848 return CALL_BASECRYPTLIB (TlsSet.Services.ConnectionEnd, TlsSetConnectionEnd, (Tls, IsServer), EFI_UNSUPPORTED);
4849}
4850
4851/**
4852 Set the ciphers list to be used by the TLS object.
4853
4854 This function sets the ciphers for use by a specified TLS object.
4855
4856 @param[in] Tls Pointer to a TLS object.
4857 @param[in] CipherId Array of UINT16 cipher identifiers. Each UINT16
4858 cipher identifier comes from the TLS Cipher Suite
4859 Registry of the IANA, interpreting Byte1 and Byte2
4860 in network (big endian) byte order.
4861 @param[in] CipherNum The number of cipher in the list.
4862
4863 @retval EFI_SUCCESS The ciphers list was set successfully.
4864 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4865 @retval EFI_UNSUPPORTED No supported TLS cipher was found in CipherId.
4866 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4867
4868**/
4869EFI_STATUS
4870EFIAPI
4871CryptoServiceTlsSetCipherList (
4872 IN VOID *Tls,
4873 IN UINT16 *CipherId,
4874 IN UINTN CipherNum
4875 )
4876{
4877 return CALL_BASECRYPTLIB (TlsSet.Services.CipherList, TlsSetCipherList, (Tls, CipherId, CipherNum), EFI_UNSUPPORTED);
4878}
4879
4880/**
4881 Set the compression method for TLS/SSL operations.
4882
4883 This function handles TLS/SSL integrated compression methods.
4884
4885 @param[in] CompMethod The compression method ID.
4886
4887 @retval EFI_SUCCESS The compression method for the communication was
4888 set successfully.
4889 @retval EFI_UNSUPPORTED Unsupported compression method.
4890
4891**/
4892EFI_STATUS
4893EFIAPI
4894CryptoServiceTlsSetCompressionMethod (
4895 IN UINT8 CompMethod
4896 )
4897{
4898 return CALL_BASECRYPTLIB (TlsSet.Services.CompressionMethod, TlsSetCompressionMethod, (CompMethod), EFI_UNSUPPORTED);
4899}
4900
4901/**
4902 Set peer certificate verification mode for the TLS connection.
4903
4904 This function sets the verification mode flags for the TLS connection.
4905
4906 @param[in] Tls Pointer to the TLS object.
4907 @param[in] VerifyMode A set of logically or'ed verification mode flags.
4908
4909**/
4910VOID
4911EFIAPI
4912CryptoServiceTlsSetVerify (
4913 IN VOID *Tls,
4914 IN UINT32 VerifyMode
4915 )
4916{
4917 CALL_VOID_BASECRYPTLIB (TlsSet.Services.Verify, TlsSetVerify, (Tls, VerifyMode));
4918}
4919
4920/**
4921 Set the specified host name to be verified.
4922
4923 @param[in] Tls Pointer to the TLS object.
4924 @param[in] Flags The setting flags during the validation.
4925 @param[in] HostName The specified host name to be verified.
4926
4927 @retval EFI_SUCCESS The HostName setting was set successfully.
4928 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4929 @retval EFI_ABORTED Invalid HostName setting.
4930
4931**/
4932EFI_STATUS
4933EFIAPI
4934CryptoServiceTlsSetVerifyHost (
4935 IN VOID *Tls,
4936 IN UINT32 Flags,
4937 IN CHAR8 *HostName
4938 )
4939{
4940 return CALL_BASECRYPTLIB (TlsSet.Services.VerifyHost, TlsSetVerifyHost, (Tls, Flags, HostName), EFI_UNSUPPORTED);
4941}
4942
4943/**
4944 Sets a TLS/SSL session ID to be used during TLS/SSL connect.
4945
4946 This function sets a session ID to be used when the TLS/SSL connection is
4947 to be established.
4948
4949 @param[in] Tls Pointer to the TLS object.
4950 @param[in] SessionId Session ID data used for session resumption.
4951 @param[in] SessionIdLen Length of Session ID in bytes.
4952
4953 @retval EFI_SUCCESS Session ID was set successfully.
4954 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4955 @retval EFI_UNSUPPORTED No available session for ID setting.
4956
4957**/
4958EFI_STATUS
4959EFIAPI
4960CryptoServiceTlsSetSessionId (
4961 IN VOID *Tls,
4962 IN UINT8 *SessionId,
4963 IN UINT16 SessionIdLen
4964 )
4965{
4966 return CALL_BASECRYPTLIB (TlsSet.Services.SessionId, TlsSetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
4967}
4968
4969/**
4970 Adds the CA to the cert store when requesting Server or Client authentication.
4971
4972 This function adds the CA certificate to the list of CAs when requesting
4973 Server or Client authentication for the chosen TLS connection.
4974
4975 @param[in] Tls Pointer to the TLS object.
4976 @param[in] Data Pointer to the data buffer of a DER-encoded binary
4977 X.509 certificate or PEM-encoded X.509 certificate.
4978 @param[in] DataSize The size of data buffer in bytes.
4979
4980 @retval EFI_SUCCESS The operation succeeded.
4981 @retval EFI_INVALID_PARAMETER The parameter is invalid.
4982 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
4983 @retval EFI_ABORTED Invalid X.509 certificate.
4984
4985**/
4986EFI_STATUS
4987EFIAPI
4988CryptoServiceTlsSetCaCertificate (
4989 IN VOID *Tls,
4990 IN VOID *Data,
4991 IN UINTN DataSize
4992 )
4993{
4994 return CALL_BASECRYPTLIB (TlsSet.Services.CaCertificate, TlsSetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
4995}
4996
4997/**
4998 Loads the local public certificate into the specified TLS object.
4999
5000 This function loads the X.509 certificate into the specified TLS object
5001 for TLS negotiation.
5002
5003 @param[in] Tls Pointer to the TLS object.
5004 @param[in] Data Pointer to the data buffer of a DER-encoded binary
5005 X.509 certificate or PEM-encoded X.509 certificate.
5006 @param[in] DataSize The size of data buffer in bytes.
5007
5008 @retval EFI_SUCCESS The operation succeeded.
5009 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5010 @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
5011 @retval EFI_ABORTED Invalid X.509 certificate.
5012
5013**/
5014EFI_STATUS
5015EFIAPI
5016CryptoServiceTlsSetHostPublicCert (
5017 IN VOID *Tls,
5018 IN VOID *Data,
5019 IN UINTN DataSize
5020 )
5021{
5022 return CALL_BASECRYPTLIB (TlsSet.Services.HostPublicCert, TlsSetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5023}
5024
5025/**
5026 Adds the local private key to the specified TLS object.
5027
5028 This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private
5029 key) into the specified TLS object for TLS negotiation.
5030
5031 @param[in] Tls Pointer to the TLS object.
5032 @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded
5033 or PKCS#8 private key.
5034 @param[in] DataSize The size of data buffer in bytes.
5035 @param[in] Password Pointer to NULL-terminated private key password, set it to NULL
5036 if private key not encrypted.
5037
5038 @retval EFI_SUCCESS The operation succeeded.
5039 @retval EFI_UNSUPPORTED This function is not supported.
5040 @retval EFI_ABORTED Invalid private key data.
5041
5042**/
5043EFI_STATUS
5044EFIAPI
5045CryptoServiceTlsSetHostPrivateKeyEx (
5046 IN VOID *Tls,
5047 IN VOID *Data,
5048 IN UINTN DataSize,
5049 IN VOID *Password OPTIONAL
5050 )
5051{
5052 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKeyEx, TlsSetHostPrivateKeyEx, (Tls, Data, DataSize, Password), EFI_UNSUPPORTED);
5053}
5054
5055/**
5056 Adds the local private key to the specified TLS object.
5057
5058 This function adds the local private key (DER-encoded or PEM-encoded or PKCS#8 private
5059 key) into the specified TLS object for TLS negotiation.
5060
5061 @param[in] Tls Pointer to the TLS object.
5062 @param[in] Data Pointer to the data buffer of a DER-encoded or PEM-encoded
5063 or PKCS#8 private key.
5064 @param[in] DataSize The size of data buffer in bytes.
5065
5066 @retval EFI_SUCCESS The operation succeeded.
5067 @retval EFI_UNSUPPORTED This function is not supported.
5068 @retval EFI_ABORTED Invalid private key data.
5069
5070**/
5071EFI_STATUS
5072EFIAPI
5073CryptoServiceTlsSetHostPrivateKey (
5074 IN VOID *Tls,
5075 IN VOID *Data,
5076 IN UINTN DataSize
5077 )
5078{
5079 return CALL_BASECRYPTLIB (TlsSet.Services.HostPrivateKey, TlsSetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5080}
5081
5082/**
5083 Adds the CA-supplied certificate revocation list for certificate validation.
5084
5085 This function adds the CA-supplied certificate revocation list data for
5086 certificate validity checking.
5087
5088 @param[in] Data Pointer to the data buffer of a DER-encoded CRL data.
5089 @param[in] DataSize The size of data buffer in bytes.
5090
5091 @retval EFI_SUCCESS The operation succeeded.
5092 @retval EFI_UNSUPPORTED This function is not supported.
5093 @retval EFI_ABORTED Invalid CRL data.
5094
5095**/
5096EFI_STATUS
5097EFIAPI
5098CryptoServiceTlsSetCertRevocationList (
5099 IN VOID *Data,
5100 IN UINTN DataSize
5101 )
5102{
5103 return CALL_BASECRYPTLIB (TlsSet.Services.CertRevocationList, TlsSetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
5104}
5105
5106/**
5107 Set the signature algorithm list to used by the TLS object.
5108
5109 This function sets the signature algorithms for use by a specified TLS object.
5110
5111 @param[in] Tls Pointer to a TLS object.
5112 @param[in] Data Array of UINT8 of signature algorithms. The array consists of
5113 pairs of the hash algorithm and the signature algorithm as defined
5114 in RFC 5246
5115 @param[in] DataSize The length the SignatureAlgoList. Must be divisible by 2.
5116
5117 @retval EFI_SUCCESS The signature algorithm list was set successfully.
5118 @retval EFI_INVALID_PARAMETER The parameters are invalid.
5119 @retval EFI_UNSUPPORTED No supported TLS signature algorithm was found in SignatureAlgoList
5120 @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
5121
5122**/
5123EFI_STATUS
5124EFIAPI
5125CryptoServiceTlsSetSignatureAlgoList (
5126 IN VOID *Tls,
5127 IN UINT8 *Data,
5128 IN UINTN DataSize
5129 )
5130{
5131 return CALL_BASECRYPTLIB (TlsSet.Services.SignatureAlgoList, TlsSetSignatureAlgoList, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5132}
5133
5134/**
5135 Set the EC curve to be used for TLS flows
5136
5137 This function sets the EC curve to be used for TLS flows.
5138
5139 @param[in] Tls Pointer to a TLS object.
5140 @param[in] Data An EC named curve as defined in section 5.1.1 of RFC 4492.
5141 @param[in] DataSize Size of Data, it should be sizeof (UINT32)
5142
5143 @retval EFI_SUCCESS The EC curve was set successfully.
5144 @retval EFI_INVALID_PARAMETER The parameters are invalid.
5145 @retval EFI_UNSUPPORTED The requested TLS EC curve is not supported
5146
5147**/
5148EFI_STATUS
5149EFIAPI
5150CryptoServiceTlsSetEcCurve (
5151 IN VOID *Tls,
5152 IN UINT8 *Data,
5153 IN UINTN DataSize
5154 )
5155{
5156 return CALL_BASECRYPTLIB (TlsSet.Services.EcCurve, TlsSetEcCurve, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5157}
5158
5159/**
5160 Gets the protocol version used by the specified TLS connection.
5161
5162 This function returns the protocol version used by the specified TLS
5163 connection.
5164
5165 If Tls is NULL, then ASSERT().
5166
5167 @param[in] Tls Pointer to the TLS object.
5168
5169 @return The protocol version of the specified TLS connection.
5170
5171**/
5172UINT16
5173EFIAPI
5174CryptoServiceTlsGetVersion (
5175 IN VOID *Tls
5176 )
5177{
5178 return CALL_BASECRYPTLIB (TlsGet.Services.Version, TlsGetVersion, (Tls), 0);
5179}
5180
5181/**
5182 Gets the connection end of the specified TLS connection.
5183
5184 This function returns the connection end (as client or as server) used by
5185 the specified TLS connection.
5186
5187 If Tls is NULL, then ASSERT().
5188
5189 @param[in] Tls Pointer to the TLS object.
5190
5191 @return The connection end used by the specified TLS connection.
5192
5193**/
5194UINT8
5195EFIAPI
5196CryptoServiceTlsGetConnectionEnd (
5197 IN VOID *Tls
5198 )
5199{
5200 return CALL_BASECRYPTLIB (TlsGet.Services.ConnectionEnd, TlsGetConnectionEnd, (Tls), 0);
5201}
5202
5203/**
5204 Gets the cipher suite used by the specified TLS connection.
5205
5206 This function returns current cipher suite used by the specified
5207 TLS connection.
5208
5209 @param[in] Tls Pointer to the TLS object.
5210 @param[in,out] CipherId The cipher suite used by the TLS object.
5211
5212 @retval EFI_SUCCESS The cipher suite was returned successfully.
5213 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5214 @retval EFI_UNSUPPORTED Unsupported cipher suite.
5215
5216**/
5217EFI_STATUS
5218EFIAPI
5219CryptoServiceTlsGetCurrentCipher (
5220 IN VOID *Tls,
5221 IN OUT UINT16 *CipherId
5222 )
5223{
5224 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCipher, TlsGetCurrentCipher, (Tls, CipherId), EFI_UNSUPPORTED);
5225}
5226
5227/**
5228 Gets the compression methods used by the specified TLS connection.
5229
5230 This function returns current integrated compression methods used by
5231 the specified TLS connection.
5232
5233 @param[in] Tls Pointer to the TLS object.
5234 @param[in,out] CompressionId The current compression method used by
5235 the TLS object.
5236
5237 @retval EFI_SUCCESS The compression method was returned successfully.
5238 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5239 @retval EFI_ABORTED Invalid Compression method.
5240 @retval EFI_UNSUPPORTED This function is not supported.
5241
5242**/
5243EFI_STATUS
5244EFIAPI
5245CryptoServiceTlsGetCurrentCompressionId (
5246 IN VOID *Tls,
5247 IN OUT UINT8 *CompressionId
5248 )
5249{
5250 return CALL_BASECRYPTLIB (TlsGet.Services.CurrentCompressionId, TlsGetCurrentCompressionId, (Tls, CompressionId), EFI_UNSUPPORTED);
5251}
5252
5253/**
5254 Gets the verification mode currently set in the TLS connection.
5255
5256 This function returns the peer verification mode currently set in the
5257 specified TLS connection.
5258
5259 If Tls is NULL, then ASSERT().
5260
5261 @param[in] Tls Pointer to the TLS object.
5262
5263 @return The verification mode set in the specified TLS connection.
5264
5265**/
5266UINT32
5267EFIAPI
5268CryptoServiceTlsGetVerify (
5269 IN VOID *Tls
5270 )
5271{
5272 return CALL_BASECRYPTLIB (TlsGet.Services.Verify, TlsGetVerify, (Tls), 0);
5273}
5274
5275/**
5276 Gets the session ID used by the specified TLS connection.
5277
5278 This function returns the TLS/SSL session ID currently used by the
5279 specified TLS connection.
5280
5281 @param[in] Tls Pointer to the TLS object.
5282 @param[in,out] SessionId Buffer to contain the returned session ID.
5283 @param[in,out] SessionIdLen The length of Session ID in bytes.
5284
5285 @retval EFI_SUCCESS The Session ID was returned successfully.
5286 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5287 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
5288
5289**/
5290EFI_STATUS
5291EFIAPI
5292CryptoServiceTlsGetSessionId (
5293 IN VOID *Tls,
5294 IN OUT UINT8 *SessionId,
5295 IN OUT UINT16 *SessionIdLen
5296 )
5297{
5298 return CALL_BASECRYPTLIB (TlsGet.Services.SessionId, TlsGetSessionId, (Tls, SessionId, SessionIdLen), EFI_UNSUPPORTED);
5299}
5300
5301/**
5302 Gets the client random data used in the specified TLS connection.
5303
5304 This function returns the TLS/SSL client random data currently used in
5305 the specified TLS connection.
5306
5307 @param[in] Tls Pointer to the TLS object.
5308 @param[in,out] ClientRandom Buffer to contain the returned client
5309 random data (32 bytes).
5310
5311**/
5312VOID
5313EFIAPI
5314CryptoServiceTlsGetClientRandom (
5315 IN VOID *Tls,
5316 IN OUT UINT8 *ClientRandom
5317 )
5318{
5319 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ClientRandom, TlsGetClientRandom, (Tls, ClientRandom));
5320}
5321
5322/**
5323 Gets the server random data used in the specified TLS connection.
5324
5325 This function returns the TLS/SSL server random data currently used in
5326 the specified TLS connection.
5327
5328 @param[in] Tls Pointer to the TLS object.
5329 @param[in,out] ServerRandom Buffer to contain the returned server
5330 random data (32 bytes).
5331
5332**/
5333VOID
5334EFIAPI
5335CryptoServiceTlsGetServerRandom (
5336 IN VOID *Tls,
5337 IN OUT UINT8 *ServerRandom
5338 )
5339{
5340 CALL_VOID_BASECRYPTLIB (TlsGet.Services.ServerRandom, TlsGetServerRandom, (Tls, ServerRandom));
5341}
5342
5343/**
5344 Gets the master key data used in the specified TLS connection.
5345
5346 This function returns the TLS/SSL master key material currently used in
5347 the specified TLS connection.
5348
5349 @param[in] Tls Pointer to the TLS object.
5350 @param[in,out] KeyMaterial Buffer to contain the returned key material.
5351
5352 @retval EFI_SUCCESS Key material was returned successfully.
5353 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5354 @retval EFI_UNSUPPORTED Invalid TLS/SSL session.
5355
5356**/
5357EFI_STATUS
5358EFIAPI
5359CryptoServiceTlsGetKeyMaterial (
5360 IN VOID *Tls,
5361 IN OUT UINT8 *KeyMaterial
5362 )
5363{
5364 return CALL_BASECRYPTLIB (TlsGet.Services.KeyMaterial, TlsGetKeyMaterial, (Tls, KeyMaterial), EFI_UNSUPPORTED);
5365}
5366
5367/**
5368 Gets the CA Certificate from the cert store.
5369
5370 This function returns the CA certificate for the chosen
5371 TLS connection.
5372
5373 @param[in] Tls Pointer to the TLS object.
5374 @param[out] Data Pointer to the data buffer to receive the CA
5375 certificate data sent to the client.
5376 @param[in,out] DataSize The size of data buffer in bytes.
5377
5378 @retval EFI_SUCCESS The operation succeeded.
5379 @retval EFI_UNSUPPORTED This function is not supported.
5380 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
5381
5382**/
5383EFI_STATUS
5384EFIAPI
5385CryptoServiceTlsGetCaCertificate (
5386 IN VOID *Tls,
5387 OUT VOID *Data,
5388 IN OUT UINTN *DataSize
5389 )
5390{
5391 return CALL_BASECRYPTLIB (TlsGet.Services.CaCertificate, TlsGetCaCertificate, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5392}
5393
5394/**
5395 Gets the local public Certificate set in the specified TLS object.
5396
5397 This function returns the local public certificate which was currently set
5398 in the specified TLS object.
5399
5400 @param[in] Tls Pointer to the TLS object.
5401 @param[out] Data Pointer to the data buffer to receive the local
5402 public certificate.
5403 @param[in,out] DataSize The size of data buffer in bytes.
5404
5405 @retval EFI_SUCCESS The operation succeeded.
5406 @retval EFI_INVALID_PARAMETER The parameter is invalid.
5407 @retval EFI_NOT_FOUND The certificate is not found.
5408 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
5409
5410**/
5411EFI_STATUS
5412EFIAPI
5413CryptoServiceTlsGetHostPublicCert (
5414 IN VOID *Tls,
5415 OUT VOID *Data,
5416 IN OUT UINTN *DataSize
5417 )
5418{
5419 return CALL_BASECRYPTLIB (TlsGet.Services.HostPublicCert, TlsGetHostPublicCert, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5420}
5421
5422/**
5423 Gets the local private key set in the specified TLS object.
5424
5425 This function returns the local private key data which was currently set
5426 in the specified TLS object.
5427
5428 @param[in] Tls Pointer to the TLS object.
5429 @param[out] Data Pointer to the data buffer to receive the local
5430 private key data.
5431 @param[in,out] DataSize The size of data buffer in bytes.
5432
5433 @retval EFI_SUCCESS The operation succeeded.
5434 @retval EFI_UNSUPPORTED This function is not supported.
5435 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
5436
5437**/
5438EFI_STATUS
5439EFIAPI
5440CryptoServiceTlsGetHostPrivateKey (
5441 IN VOID *Tls,
5442 OUT VOID *Data,
5443 IN OUT UINTN *DataSize
5444 )
5445{
5446 return CALL_BASECRYPTLIB (TlsGet.Services.HostPrivateKey, TlsGetHostPrivateKey, (Tls, Data, DataSize), EFI_UNSUPPORTED);
5447}
5448
5449/**
5450 Gets the CA-supplied certificate revocation list data set in the specified
5451 TLS object.
5452
5453 This function returns the CA-supplied certificate revocation list data which
5454 was currently set in the specified TLS object.
5455
5456 @param[out] Data Pointer to the data buffer to receive the CRL data.
5457 @param[in,out] DataSize The size of data buffer in bytes.
5458
5459 @retval EFI_SUCCESS The operation succeeded.
5460 @retval EFI_UNSUPPORTED This function is not supported.
5461 @retval EFI_BUFFER_TOO_SMALL The Data is too small to hold the data.
5462
5463**/
5464EFI_STATUS
5465EFIAPI
5466CryptoServiceTlsGetCertRevocationList (
5467 OUT VOID *Data,
5468 IN OUT UINTN *DataSize
5469 )
5470{
5471 return CALL_BASECRYPTLIB (TlsGet.Services.CertRevocationList, TlsGetCertRevocationList, (Data, DataSize), EFI_UNSUPPORTED);
5472}
5473
5474/**
5475 Derive keying material from a TLS connection.
5476
5477 This function exports keying material using the mechanism described in RFC
5478 5705.
5479
5480 @param[in] Tls Pointer to the TLS object
5481 @param[in] Label Description of the key for the PRF function
5482 @param[in] Context Optional context
5483 @param[in] ContextLen The length of the context value in bytes
5484 @param[out] KeyBuffer Buffer to hold the output of the TLS-PRF
5485 @param[in] KeyBufferLen The length of the KeyBuffer
5486
5487 @retval EFI_SUCCESS The operation succeeded.
5488 @retval EFI_INVALID_PARAMETER The TLS object is invalid.
5489 @retval EFI_PROTOCOL_ERROR Some other error occurred.
5490
5491**/
5492EFI_STATUS
5493EFIAPI
5494CryptoServiceTlsGetExportKey (
5495 IN VOID *Tls,
5496 IN CONST VOID *Label,
5497 IN CONST VOID *Context,
5498 IN UINTN ContextLen,
5499 OUT VOID *KeyBuffer,
5500 IN UINTN KeyBufferLen
5501 )
5502{
5503 return CALL_BASECRYPTLIB (
5504 TlsGet.Services.ExportKey,
5505 TlsGetExportKey,
5506 (Tls, Label, Context, ContextLen,
5507 KeyBuffer, KeyBufferLen),
5508 EFI_UNSUPPORTED
5509 );
5510}
5511
5512/**
5513 Carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme.
5514
5515 This function carries out the RSA-SSA signature generation with EMSA-PSS encoding scheme defined in
5516 RFC 8017.
5517 Mask generation function is the same as the message digest algorithm.
5518 If the Signature buffer is too small to hold the contents of signature, FALSE
5519 is returned and SigSize is set to the required buffer size to obtain the signature.
5520
5521 If RsaContext is NULL, then return FALSE.
5522 If Message is NULL, then return FALSE.
5523 If MsgSize is zero or > INT_MAX, then return FALSE.
5524 If DigestLen is NOT 32, 48 or 64, return FALSE.
5525 If SaltLen is not equal to DigestLen, then return FALSE.
5526 If SigSize is large enough but Signature is NULL, then return FALSE.
5527 If this interface is not supported, then return FALSE.
5528
5529 @param[in] RsaContext Pointer to RSA context for signature generation.
5530 @param[in] Message Pointer to octet message to be signed.
5531 @param[in] MsgSize Size of the message in bytes.
5532 @param[in] DigestLen Length of the digest in bytes to be used for RSA signature operation.
5533 @param[in] SaltLen Length of the salt in bytes to be used for PSS encoding.
5534 @param[out] Signature Pointer to buffer to receive RSA PSS signature.
5535 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
5536 On output, the size of data returned in Signature buffer in bytes.
5537
5538 @retval TRUE Signature successfully generated in RSASSA-PSS.
5539 @retval FALSE Signature generation failed.
5540 @retval FALSE SigSize is too small.
5541 @retval FALSE This interface is not supported.
5542
5543**/
5544BOOLEAN
5545EFIAPI
5546CryptoServiceRsaPssSign (
5547 IN VOID *RsaContext,
5548 IN CONST UINT8 *Message,
5549 IN UINTN MsgSize,
5550 IN UINT16 DigestLen,
5551 IN UINT16 SaltLen,
5552 OUT UINT8 *Signature,
5553 IN OUT UINTN *SigSize
5554 )
5555{
5556 return CALL_BASECRYPTLIB (RsaPss.Services.Sign, RsaPssSign, (RsaContext, Message, MsgSize, DigestLen, SaltLen, Signature, SigSize), FALSE);
5557}
5558
5559/**
5560 Verifies the RSA signature with RSASSA-PSS signature scheme defined in RFC 8017.
5561 Implementation determines salt length automatically from the signature encoding.
5562 Mask generation function is the same as the message digest algorithm.
5563 Salt length should be equal to digest length.
5564
5565 @param[in] RsaContext Pointer to RSA context for signature verification.
5566 @param[in] Message Pointer to octet message to be verified.
5567 @param[in] MsgSize Size of the message in bytes.
5568 @param[in] Signature Pointer to RSASSA-PSS signature to be verified.
5569 @param[in] SigSize Size of signature in bytes.
5570 @param[in] DigestLen Length of digest for RSA operation.
5571 @param[in] SaltLen Salt length for PSS encoding.
5572
5573 @retval TRUE Valid signature encoded in RSASSA-PSS.
5574 @retval FALSE Invalid signature or invalid RSA context.
5575
5576**/
5577BOOLEAN
5578EFIAPI
5579CryptoServiceRsaPssVerify (
5580 IN VOID *RsaContext,
5581 IN CONST UINT8 *Message,
5582 IN UINTN MsgSize,
5583 IN CONST UINT8 *Signature,
5584 IN UINTN SigSize,
5585 IN UINT16 DigestLen,
5586 IN UINT16 SaltLen
5587 )
5588{
5589 return CALL_BASECRYPTLIB (RsaPss.Services.Verify, RsaPssVerify, (RsaContext, Message, MsgSize, Signature, SigSize, DigestLen, SaltLen), FALSE);
5590}
5591
5592/**
5593 Parallel hash function ParallelHash256, as defined in NIST's Special Publication 800-185,
5594 published December 2016.
5595
5596 @param[in] Input Pointer to the input message (X).
5597 @param[in] InputByteLen The number(>0) of input bytes provided for the input data.
5598 @param[in] BlockSize The size of each block (B).
5599 @param[out] Output Pointer to the output buffer.
5600 @param[in] OutputByteLen The desired number of output bytes (L).
5601 @param[in] Customization Pointer to the customization string (S).
5602 @param[in] CustomByteLen The length of the customization string in bytes.
5603
5604 @retval TRUE ParallelHash256 digest computation succeeded.
5605 @retval FALSE ParallelHash256 digest computation failed.
5606 @retval FALSE This interface is not supported.
5607
5608**/
5609BOOLEAN
5610EFIAPI
5611CryptoServiceParallelHash256HashAll (
5612 IN CONST VOID *Input,
5613 IN UINTN InputByteLen,
5614 IN UINTN BlockSize,
5615 OUT VOID *Output,
5616 IN UINTN OutputByteLen,
5617 IN CONST VOID *Customization,
5618 IN UINTN CustomByteLen
5619 )
5620{
5621 return CALL_BASECRYPTLIB (ParallelHash.Services.HashAll, ParallelHash256HashAll, (Input, InputByteLen, BlockSize, Output, OutputByteLen, Customization, CustomByteLen), FALSE);
5622}
5623
5624/**
5625 Performs AEAD AES-GCM authenticated encryption on a data buffer and additional authenticated data (AAD).
5626
5627 IvSize must be 12, otherwise FALSE is returned.
5628 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
5629 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
5630
5631 @param[in] Key Pointer to the encryption key.
5632 @param[in] KeySize Size of the encryption key in bytes.
5633 @param[in] Iv Pointer to the IV value.
5634 @param[in] IvSize Size of the IV value in bytes.
5635 @param[in] AData Pointer to the additional authenticated data (AAD).
5636 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
5637 @param[in] DataIn Pointer to the input data buffer to be encrypted.
5638 @param[in] DataInSize Size of the input data buffer in bytes.
5639 @param[out] TagOut Pointer to a buffer that receives the authentication tag output.
5640 @param[in] TagSize Size of the authentication tag in bytes.
5641 @param[out] DataOut Pointer to a buffer that receives the encryption output.
5642 @param[out] DataOutSize Size of the output data buffer in bytes.
5643
5644 @retval TRUE AEAD AES-GCM authenticated encryption succeeded.
5645 @retval FALSE AEAD AES-GCM authenticated encryption failed.
5646
5647**/
5648BOOLEAN
5649EFIAPI
5650CryptoServiceAeadAesGcmEncrypt (
5651 IN CONST UINT8 *Key,
5652 IN UINTN KeySize,
5653 IN CONST UINT8 *Iv,
5654 IN UINTN IvSize,
5655 IN CONST UINT8 *AData,
5656 IN UINTN ADataSize,
5657 IN CONST UINT8 *DataIn,
5658 IN UINTN DataInSize,
5659 OUT UINT8 *TagOut,
5660 IN UINTN TagSize,
5661 OUT UINT8 *DataOut,
5662 OUT UINTN *DataOutSize
5663 )
5664{
5665 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Encrypt, AeadAesGcmEncrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, TagOut, TagSize, DataOut, DataOutSize), FALSE);
5666}
5667
5668/**
5669 Performs AEAD AES-GCM authenticated decryption on a data buffer and additional authenticated data (AAD).
5670
5671 IvSize must be 12, otherwise FALSE is returned.
5672 KeySize must be 16, 24 or 32, otherwise FALSE is returned.
5673 TagSize must be 12, 13, 14, 15, 16, otherwise FALSE is returned.
5674 If additional authenticated data verification fails, FALSE is returned.
5675
5676 @param[in] Key Pointer to the encryption key.
5677 @param[in] KeySize Size of the encryption key in bytes.
5678 @param[in] Iv Pointer to the IV value.
5679 @param[in] IvSize Size of the IV value in bytes.
5680 @param[in] AData Pointer to the additional authenticated data (AAD).
5681 @param[in] ADataSize Size of the additional authenticated data (AAD) in bytes.
5682 @param[in] DataIn Pointer to the input data buffer to be decrypted.
5683 @param[in] DataInSize Size of the input data buffer in bytes.
5684 @param[in] Tag Pointer to a buffer that contains the authentication tag.
5685 @param[in] TagSize Size of the authentication tag in bytes.
5686 @param[out] DataOut Pointer to a buffer that receives the decryption output.
5687 @param[out] DataOutSize Size of the output data buffer in bytes.
5688
5689 @retval TRUE AEAD AES-GCM authenticated decryption succeeded.
5690 @retval FALSE AEAD AES-GCM authenticated decryption failed.
5691
5692**/
5693BOOLEAN
5694EFIAPI
5695CryptoServiceAeadAesGcmDecrypt (
5696 IN CONST UINT8 *Key,
5697 IN UINTN KeySize,
5698 IN CONST UINT8 *Iv,
5699 IN UINTN IvSize,
5700 IN CONST UINT8 *AData,
5701 IN UINTN ADataSize,
5702 IN CONST UINT8 *DataIn,
5703 IN UINTN DataInSize,
5704 IN CONST UINT8 *Tag,
5705 IN UINTN TagSize,
5706 OUT UINT8 *DataOut,
5707 OUT UINTN *DataOutSize
5708 )
5709{
5710 return CALL_BASECRYPTLIB (AeadAesGcm.Services.Decrypt, AeadAesGcmDecrypt, (Key, KeySize, Iv, IvSize, AData, ADataSize, DataIn, DataInSize, Tag, TagSize, DataOut, DataOutSize), FALSE);
5711}
5712
5713// =====================================================================================
5714// Big number primitives
5715// =====================================================================================
5716
5717/**
5718 Allocate new Big Number.
5719
5720 @retval New BigNum opaque structure or NULL on failure.
5721**/
5722VOID *
5723EFIAPI
5724CryptoServiceBigNumInit (
5725 VOID
5726 )
5727{
5728 return CALL_BASECRYPTLIB (Bn.Services.Init, BigNumInit, (), NULL);
5729}
5730
5731/**
5732 Allocate new Big Number and assign the provided value to it.
5733
5734 @param[in] Buf Big endian encoded buffer.
5735 @param[in] Len Buffer length.
5736
5737 @retval New BigNum opaque structure or NULL on failure.
5738**/
5739VOID *
5740EFIAPI
5741CryptoServiceBigNumFromBin (
5742 IN CONST UINT8 *Buf,
5743 IN UINTN Len
5744 )
5745{
5746 return CALL_BASECRYPTLIB (Bn.Services.FromBin, BigNumFromBin, (Buf, Len), NULL);
5747}
5748
5749/**
5750 Convert the absolute value of Bn into big-endian form and store it at Buf.
5751 The Buf array should have at least BigNumBytes() in it.
5752
5753 @param[in] Bn Big number to convert.
5754 @param[out] Buf Output buffer.
5755
5756 @retval The length of the big-endian number placed at Buf or -1 on error.
5757**/
5758INTN
5759EFIAPI
5760CryptoServiceBigNumToBin (
5761 IN CONST VOID *Bn,
5762 OUT UINT8 *Buf
5763 )
5764{
5765 return CALL_BASECRYPTLIB (Bn.Services.ToBin, BigNumToBin, (Bn, Buf), -1);
5766}
5767
5768/**
5769 Free the Big Number.
5770
5771 @param[in] Bn Big number to free.
5772 @param[in] Clear TRUE if the buffer should be cleared.
5773**/
5774VOID
5775EFIAPI
5776CryptoServiceBigNumFree (
5777 IN VOID *Bn,
5778 IN BOOLEAN Clear
5779 )
5780{
5781 CALL_VOID_BASECRYPTLIB (Bn.Services.Free, BigNumFree, (Bn, Clear));
5782}
5783
5784/**
5785 Calculate the sum of two Big Numbers.
5786 Please note, all "out" Big number arguments should be properly initialized
5787 by calling to BigNumInit() or BigNumFromBin() functions.
5788
5789 @param[in] BnA Big number.
5790 @param[in] BnB Big number.
5791 @param[out] BnRes The result of BnA + BnB.
5792
5793 @retval TRUE On success.
5794 @retval FALSE Otherwise.
5795**/
5796BOOLEAN
5797EFIAPI
5798CryptoServiceBigNumAdd (
5799 IN CONST VOID *BnA,
5800 IN CONST VOID *BnB,
5801 OUT VOID *BnRes
5802 )
5803{
5804 return CALL_BASECRYPTLIB (Bn.Services.Add, BigNumAdd, (BnA, BnB, BnRes), FALSE);
5805}
5806
5807/**
5808 Subtract two Big Numbers.
5809 Please note, all "out" Big number arguments should be properly initialized
5810 by calling to BigNumInit() or BigNumFromBin() functions.
5811
5812 @param[in] BnA Big number.
5813 @param[in] BnB Big number.
5814 @param[out] BnRes The result of BnA - BnB.
5815
5816 @retval TRUE On success.
5817 @retval FALSE Otherwise.
5818**/
5819BOOLEAN
5820EFIAPI
5821CryptoServiceBigNumSub (
5822 IN CONST VOID *BnA,
5823 IN CONST VOID *BnB,
5824 OUT VOID *BnRes
5825 )
5826{
5827 return CALL_BASECRYPTLIB (Bn.Services.Sub, BigNumSub, (BnA, BnB, BnRes), FALSE);
5828}
5829
5830/**
5831 Calculate remainder: BnRes = BnA % BnB.
5832 Please note, all "out" Big number arguments should be properly initialized
5833 by calling to BigNumInit() or BigNumFromBin() functions.
5834
5835 @param[in] BnA Big number.
5836 @param[in] BnB Big number.
5837 @param[out] BnRes The result of BnA % BnB.
5838
5839 @retval TRUE On success.
5840 @retval FALSE Otherwise.
5841**/
5842BOOLEAN
5843EFIAPI
5844CryptoServiceBigNumMod (
5845 IN CONST VOID *BnA,
5846 IN CONST VOID *BnB,
5847 OUT VOID *BnRes
5848 )
5849{
5850 return CALL_BASECRYPTLIB (Bn.Services.Mod, BigNumMod, (BnA, BnB, BnRes), FALSE);
5851}
5852
5853/**
5854 Compute BnA to the BnP-th power modulo BnM.
5855 Please note, all "out" Big number arguments should be properly initialized.
5856 by calling to BigNumInit() or BigNumFromBin() functions.
5857
5858 @param[in] BnA Big number.
5859 @param[in] BnP Big number (power).
5860 @param[in] BnM Big number (modulo).
5861 @param[out] BnRes The result of (BnA ^ BnP) % BnM.
5862
5863 @retval TRUE On success.
5864 @retval FALSE Otherwise.
5865**/
5866BOOLEAN
5867EFIAPI
5868CryptoServiceBigNumExpMod (
5869 IN CONST VOID *BnA,
5870 IN CONST VOID *BnP,
5871 IN CONST VOID *BnM,
5872 OUT VOID *BnRes
5873 )
5874{
5875 return CALL_BASECRYPTLIB (Bn.Services.ExpMod, BigNumExpMod, (BnA, BnP, BnM, BnRes), FALSE);
5876}
5877
5878/**
5879 Compute BnA inverse modulo BnM.
5880 Please note, all "out" Big number arguments should be properly initialized
5881 by calling to BigNumInit() or BigNumFromBin() functions.
5882
5883 @param[in] BnA Big number.
5884 @param[in] BnM Big number (modulo).
5885 @param[out] BnRes The result, such that (BnA * BnRes) % BnM == 1.
5886
5887 @retval TRUE On success.
5888 @retval FALSE Otherwise.
5889**/
5890BOOLEAN
5891EFIAPI
5892CryptoServiceBigNumInverseMod (
5893 IN CONST VOID *BnA,
5894 IN CONST VOID *BnM,
5895 OUT VOID *BnRes
5896 )
5897{
5898 return CALL_BASECRYPTLIB (Bn.Services.InverseMod, BigNumInverseMod, (BnA, BnM, BnRes), FALSE);
5899}
5900
5901/**
5902 Divide two Big Numbers.
5903 Please note, all "out" Big number arguments should be properly initialized
5904 by calling to BigNumInit() or BigNumFromBin() functions.
5905
5906 @param[in] BnA Big number.
5907 @param[in] BnB Big number.
5908 @param[out] BnRes The result, such that BnA / BnB.
5909
5910 @retval TRUE On success.
5911 @retval FALSE Otherwise.
5912**/
5913BOOLEAN
5914EFIAPI
5915CryptoServiceBigNumDiv (
5916 IN CONST VOID *BnA,
5917 IN CONST VOID *BnB,
5918 OUT VOID *BnRes
5919 )
5920{
5921 return CALL_BASECRYPTLIB (Bn.Services.Div, BigNumDiv, (BnA, BnB, BnRes), FALSE);
5922}
5923
5924/**
5925 Multiply two Big Numbers modulo BnM.
5926 Please note, all "out" Big number arguments should be properly initialized
5927 by calling to BigNumInit() or BigNumFromBin() functions.
5928
5929 @param[in] BnA Big number.
5930 @param[in] BnB Big number.
5931 @param[in] BnM Big number (modulo).
5932 @param[out] BnRes The result, such that (BnA * BnB) % BnM.
5933
5934 @retval TRUE On success.
5935 @retval FALSE Otherwise.
5936**/
5937BOOLEAN
5938EFIAPI
5939CryptoServiceBigNumMulMod (
5940 IN CONST VOID *BnA,
5941 IN CONST VOID *BnB,
5942 IN CONST VOID *BnM,
5943 OUT VOID *BnRes
5944 )
5945{
5946 return CALL_BASECRYPTLIB (Bn.Services.MulMod, BigNumMulMod, (BnA, BnB, BnM, BnRes), FALSE);
5947}
5948
5949/**
5950 Compare two Big Numbers.
5951
5952 @param[in] BnA Big number.
5953 @param[in] BnB Big number.
5954
5955 @retval 0 BnA == BnB.
5956 @retval 1 BnA > BnB.
5957 @retval -1 BnA < BnB.
5958**/
5959INTN
5960EFIAPI
5961CryptoServiceBigNumCmp (
5962 IN CONST VOID *BnA,
5963 IN CONST VOID *BnB
5964 )
5965{
5966 return CALL_BASECRYPTLIB (Bn.Services.Cmp, BigNumCmp, (BnA, BnB), 0);
5967}
5968
5969/**
5970 Get number of bits in Bn.
5971
5972 @param[in] Bn Big number.
5973
5974 @retval Number of bits.
5975**/
5976UINTN
5977EFIAPI
5978CryptoServiceBigNumBits (
5979 IN CONST VOID *Bn
5980 )
5981{
5982 return CALL_BASECRYPTLIB (Bn.Services.Bits, BigNumBits, (Bn), 0);
5983}
5984
5985/**
5986 Get number of bytes in Bn.
5987
5988 @param[in] Bn Big number.
5989
5990 @retval Number of bytes.
5991**/
5992UINTN
5993EFIAPI
5994CryptoServiceBigNumBytes (
5995 IN CONST VOID *Bn
5996 )
5997{
5998 return CALL_BASECRYPTLIB (Bn.Services.Bytes, BigNumBytes, (Bn), 0);
5999}
6000
6001/**
6002 Checks if Big Number equals to the given Num.
6003
6004 @param[in] Bn Big number.
6005 @param[in] Num Number.
6006
6007 @retval TRUE iff Bn == Num.
6008 @retval FALSE otherwise.
6009**/
6010BOOLEAN
6011EFIAPI
6012CryptoServiceBigNumIsWord (
6013 IN CONST VOID *Bn,
6014 IN UINTN Num
6015 )
6016{
6017 return CALL_BASECRYPTLIB (Bn.Services.IsWord, BigNumIsWord, (Bn, Num), FALSE);
6018}
6019
6020/**
6021 Checks if Big Number is odd.
6022
6023 @param[in] Bn Big number.
6024
6025 @retval TRUE Bn is odd (Bn % 2 == 1).
6026 @retval FALSE otherwise.
6027**/
6028BOOLEAN
6029EFIAPI
6030CryptoServiceBigNumIsOdd (
6031 IN CONST VOID *Bn
6032 )
6033{
6034 return CALL_BASECRYPTLIB (Bn.Services.IsOdd, BigNumIsOdd, (Bn), FALSE);
6035}
6036
6037/**
6038 Copy Big number.
6039
6040 @param[out] BnDst Destination.
6041 @param[in] BnSrc Source.
6042
6043 @retval BnDst on success.
6044 @retval NULL otherwise.
6045**/
6046VOID *
6047EFIAPI
6048CryptoServiceBigNumCopy (
6049 OUT VOID *BnDst,
6050 IN CONST VOID *BnSrc
6051 )
6052{
6053 return CALL_BASECRYPTLIB (Bn.Services.Copy, BigNumCopy, (BnDst, BnSrc), NULL);
6054}
6055
6056/**
6057 Get constant Big number with value of "1".
6058 This may be used to save expensive allocations.
6059
6060 @retval Big Number with value of 1.
6061**/
6062CONST VOID *
6063EFIAPI
6064CryptoServiceBigNumValueOne (
6065 VOID
6066 )
6067{
6068 return CALL_BASECRYPTLIB (Bn.Services.ValueOne, BigNumValueOne, (), NULL);
6069}
6070
6071/**
6072 Shift right Big Number.
6073 Please note, all "out" Big number arguments should be properly initialized
6074 by calling to BigNumInit() or BigNumFromBin() functions.
6075
6076 @param[in] Bn Big number.
6077 @param[in] N Number of bits to shift.
6078 @param[out] BnRes The result.
6079
6080 @retval TRUE On success.
6081 @retval FALSE Otherwise.
6082**/
6083BOOLEAN
6084EFIAPI
6085CryptoServiceBigNumRShift (
6086 IN CONST VOID *Bn,
6087 IN UINTN N,
6088 OUT VOID *BnRes
6089 )
6090{
6091 return CALL_BASECRYPTLIB (Bn.Services.RShift, BigNumRShift, (Bn, N, BnRes), FALSE);
6092}
6093
6094/**
6095 Mark Big Number for constant time computations.
6096 This function should be called before any constant time computations are
6097 performed on the given Big number.
6098
6099 @param[in] Bn Big number.
6100**/
6101VOID
6102EFIAPI
6103CryptoServiceBigNumConstTime (
6104 IN VOID *Bn
6105 )
6106{
6107 CALL_VOID_BASECRYPTLIB (Bn.Services.ConstTime, BigNumConstTime, (Bn));
6108}
6109
6110/**
6111 Calculate square modulo.
6112 Please note, all "out" Big number arguments should be properly initialized
6113 by calling to BigNumInit() or BigNumFromBin() functions.
6114
6115 @param[in] BnA Big number.
6116 @param[in] BnM Big number (modulo).
6117 @param[out] BnRes The result, such that (BnA ^ 2) % BnM.
6118
6119 @retval TRUE On success.
6120 @retval FALSE Otherwise.
6121**/
6122BOOLEAN
6123EFIAPI
6124CryptoServiceBigNumSqrMod (
6125 IN CONST VOID *BnA,
6126 IN CONST VOID *BnM,
6127 OUT VOID *BnRes
6128 )
6129{
6130 return CALL_BASECRYPTLIB (Bn.Services.SqrMod, BigNumSqrMod, (BnA, BnM, BnRes), FALSE);
6131}
6132
6133/**
6134 Create new Big Number computation context. This is an opaque structure
6135 which should be passed to any function that requires it. The BN context is
6136 needed to optimize calculations and expensive allocations.
6137
6138 @retval Big Number context struct or NULL on failure.
6139**/
6140VOID *
6141EFIAPI
6142CryptoServiceBigNumNewContext (
6143 VOID
6144 )
6145{
6146 return CALL_BASECRYPTLIB (Bn.Services.NewContext, BigNumNewContext, (), NULL);
6147}
6148
6149/**
6150 Free Big Number context that was allocated with BigNumNewContext().
6151
6152 @param[in] BnCtx Big number context to free.
6153**/
6154VOID
6155EFIAPI
6156CryptoServiceBigNumContextFree (
6157 IN VOID *BnCtx
6158 )
6159{
6160 CALL_VOID_BASECRYPTLIB (Bn.Services.ContextFree, BigNumContextFree, (BnCtx));
6161}
6162
6163/**
6164 Set Big Number to a given value.
6165
6166 @param[in] Bn Big number to set.
6167 @param[in] Val Value to set.
6168
6169 @retval TRUE On success.
6170 @retval FALSE Otherwise.
6171**/
6172BOOLEAN
6173EFIAPI
6174CryptoServiceBigNumSetUint (
6175 IN VOID *Bn,
6176 IN UINTN Val
6177 )
6178{
6179 return CALL_BASECRYPTLIB (Bn.Services.SetUint, BigNumSetUint, (Bn, Val), FALSE);
6180}
6181
6182/**
6183 Add two Big Numbers modulo BnM.
6184
6185 @param[in] BnA Big number.
6186 @param[in] BnB Big number.
6187 @param[in] BnM Big number (modulo).
6188 @param[out] BnRes The result, such that (BnA + BnB) % BnM.
6189
6190 @retval TRUE On success.
6191 @retval FALSE Otherwise.
6192**/
6193BOOLEAN
6194EFIAPI
6195CryptoServiceBigNumAddMod (
6196 IN CONST VOID *BnA,
6197 IN CONST VOID *BnB,
6198 IN CONST VOID *BnM,
6199 OUT VOID *BnRes
6200 )
6201{
6202 return CALL_BASECRYPTLIB (Bn.Services.AddMod, BigNumAddMod, (BnA, BnB, BnM, BnRes), FALSE);
6203}
6204
6205// =====================================================================================
6206// Basic Elliptic Curve Primitives
6207// =====================================================================================
6208
6209/**
6210 Initialize new opaque EcGroup object. This object represents an EC curve and
6211 and is used for calculation within this group. This object should be freed
6212 using EcGroupFree() function.
6213
6214 @param[in] CryptoNid Identifying number for the ECC curve (Defined in
6215 BaseCryptLib.h).
6216
6217 @retval EcGroup object On success.
6218 @retval NULL On failure.
6219**/
6220VOID *
6221EFIAPI
6222CryptoServiceEcGroupInit (
6223 IN UINTN CryptoNid
6224 )
6225{
6226 return CALL_BASECRYPTLIB (Ec.Services.GroupInit, EcGroupInit, (CryptoNid), NULL);
6227}
6228
6229/**
6230 Get EC curve parameters. While elliptic curve equation is Y^2 mod P = (X^3 + AX + B) Mod P.
6231 This function will set the provided Big Number objects to the corresponding
6232 values. The caller needs to make sure all the "out" BigNumber parameters
6233 are properly initialized.
6234 @param[in] EcGroup EC group object.
6235 @param[out] BnPrime Group prime number.
6236 @param[out] BnA A coefficient.
6237 @param[out] BnB B coefficient.
6238 @param[in] BnCtx BN context.
6239
6240 @retval TRUE On success.
6241 @retval FALSE Otherwise.
6242**/
6243BOOLEAN
6244EFIAPI
6245CryptoServiceEcGroupGetCurve (
6246 IN CONST VOID *EcGroup,
6247 OUT VOID *BnPrime,
6248 OUT VOID *BnA,
6249 OUT VOID *BnB,
6250 IN VOID *BnCtx
6251 )
6252{
6253 return CALL_BASECRYPTLIB (Ec.Services.GroupGetCurve, EcGroupGetCurve, (EcGroup, BnPrime, BnA, BnB, BnCtx), FALSE);
6254}
6255
6256/**
6257 Get EC group order.
6258 This function will set the provided Big Number object to the corresponding
6259 value. The caller needs to make sure that the "out" BigNumber parameter
6260 is properly initialized.
6261
6262 @param[in] EcGroup EC group object.
6263 @param[out] BnOrder Group prime number.
6264
6265 @retval TRUE On success.
6266 @retval FALSE Otherwise.
6267**/
6268BOOLEAN
6269EFIAPI
6270CryptoServiceEcGroupGetOrder (
6271 IN VOID *EcGroup,
6272 OUT VOID *BnOrder
6273 )
6274{
6275 return CALL_BASECRYPTLIB (Ec.Services.GroupGetOrder, EcGroupGetOrder, (EcGroup, BnOrder), FALSE);
6276}
6277
6278/**
6279 Free previously allocated EC group object using EcGroupInit().
6280
6281 @param[in] EcGroup EC group object to free.
6282**/
6283VOID
6284EFIAPI
6285CryptoServiceEcGroupFree (
6286 IN VOID *EcGroup
6287 )
6288{
6289 CALL_VOID_BASECRYPTLIB (Ec.Services.GroupFree, EcGroupFree, (EcGroup));
6290}
6291
6292/**
6293 Initialize new opaque EC Point object. This object represents an EC point
6294 within the given EC group (curve).
6295
6296 @param[in] EC Group, properly initialized using EcGroupInit().
6297
6298 @retval EC Point object On success.
6299 @retval NULL On failure.
6300**/
6301VOID *
6302EFIAPI
6303CryptoServiceEcPointInit (
6304 IN CONST VOID *EcGroup
6305 )
6306{
6307 return CALL_BASECRYPTLIB (Ec.Services.PointInit, EcPointInit, (EcGroup), NULL);
6308}
6309
6310/**
6311 Free previously allocated EC Point object using EcPointInit().
6312
6313 @param[in] EcPoint EC Point to free.
6314 @param[in] Clear TRUE iff the memory should be cleared.
6315**/
6316VOID
6317EFIAPI
6318CryptoServiceEcPointDeInit (
6319 IN VOID *EcPoint,
6320 IN BOOLEAN Clear
6321 )
6322{
6323 CALL_VOID_BASECRYPTLIB (Ec.Services.PointDeInit, EcPointDeInit, (EcPoint, Clear));
6324}
6325
6326/**
6327 Get EC point affine (x,y) coordinates.
6328 This function will set the provided Big Number objects to the corresponding
6329 values. The caller needs to make sure all the "out" BigNumber parameters
6330 are properly initialized.
6331
6332 @param[in] EcGroup EC group object.
6333 @param[in] EcPoint EC point object.
6334 @param[out] BnX X coordinate.
6335 @param[out] BnY Y coordinate.
6336 @param[in] BnCtx BN context, created with BigNumNewContext().
6337
6338 @retval TRUE On success.
6339 @retval FALSE Otherwise.
6340**/
6341BOOLEAN
6342EFIAPI
6343CryptoServiceEcPointGetAffineCoordinates (
6344 IN CONST VOID *EcGroup,
6345 IN CONST VOID *EcPoint,
6346 OUT VOID *BnX,
6347 OUT VOID *BnY,
6348 IN VOID *BnCtx
6349 )
6350{
6351 return CALL_BASECRYPTLIB (Ec.Services.PointGetAffineCoordinates, EcPointGetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);
6352}
6353
6354/**
6355 Set EC point affine (x,y) coordinates.
6356
6357 @param[in] EcGroup EC group object.
6358 @param[in] EcPoint EC point object.
6359 @param[in] BnX X coordinate.
6360 @param[in] BnY Y coordinate.
6361 @param[in] BnCtx BN context, created with BigNumNewContext().
6362
6363 @retval TRUE On success.
6364 @retval FALSE Otherwise.
6365**/
6366BOOLEAN
6367EFIAPI
6368CryptoServiceEcPointSetAffineCoordinates (
6369 IN CONST VOID *EcGroup,
6370 IN VOID *EcPoint,
6371 IN CONST VOID *BnX,
6372 IN CONST VOID *BnY,
6373 IN VOID *BnCtx
6374 )
6375{
6376 return CALL_BASECRYPTLIB (Ec.Services.PointSetAffineCoordinates, EcPointSetAffineCoordinates, (EcGroup, EcPoint, BnX, BnY, BnCtx), FALSE);
6377}
6378
6379/**
6380 EC Point addition. EcPointResult = EcPointA + EcPointB.
6381 @param[in] EcGroup EC group object.
6382 @param[out] EcPointResult EC point to hold the result. The point should
6383 be properly initialized.
6384 @param[in] EcPointA EC Point.
6385 @param[in] EcPointB EC Point.
6386 @param[in] BnCtx BN context, created with BigNumNewContext().
6387
6388 @retval TRUE On success.
6389 @retval FALSE Otherwise.
6390**/
6391BOOLEAN
6392EFIAPI
6393CryptoServiceEcPointAdd (
6394 IN CONST VOID *EcGroup,
6395 OUT VOID *EcPointResult,
6396 IN CONST VOID *EcPointA,
6397 IN CONST VOID *EcPointB,
6398 IN VOID *BnCtx
6399 )
6400{
6401 return CALL_BASECRYPTLIB (Ec.Services.PointAdd, EcPointAdd, (EcGroup, EcPointResult, EcPointA, EcPointB, BnCtx), FALSE);
6402}
6403
6404/**
6405 Variable EC point multiplication. EcPointResult = EcPoint * BnPScalar.
6406
6407 @param[in] EcGroup EC group object.
6408 @param[out] EcPointResult EC point to hold the result. The point should
6409 be properly initialized.
6410 @param[in] EcPoint EC Point.
6411 @param[in] BnPScalar P Scalar.
6412 @param[in] BnCtx BN context, created with BigNumNewContext().
6413
6414 @retval TRUE On success.
6415 @retval FALSE Otherwise.
6416**/
6417BOOLEAN
6418EFIAPI
6419CryptoServiceEcPointMul (
6420 IN CONST VOID *EcGroup,
6421 OUT VOID *EcPointResult,
6422 IN CONST VOID *EcPoint,
6423 IN CONST VOID *BnPScalar,
6424 IN VOID *BnCtx
6425 )
6426{
6427 return CALL_BASECRYPTLIB (Ec.Services.PointMul, EcPointMul, (EcGroup, EcPointResult, EcPoint, BnPScalar, BnCtx), FALSE);
6428}
6429
6430/**
6431 Calculate the inverse of the supplied EC point.
6432
6433 @param[in] EcGroup EC group object.
6434 @param[in,out] EcPoint EC point to invert.
6435 @param[in] BnCtx BN context, created with BigNumNewContext().
6436
6437 @retval TRUE On success.
6438 @retval FALSE Otherwise.
6439**/
6440BOOLEAN
6441EFIAPI
6442CryptoServiceEcPointInvert (
6443 IN CONST VOID *EcGroup,
6444 IN OUT VOID *EcPoint,
6445 IN VOID *BnCtx
6446 )
6447{
6448 return CALL_BASECRYPTLIB (Ec.Services.PointInvert, EcPointInvert, (EcGroup, EcPoint, BnCtx), FALSE);
6449}
6450
6451/**
6452 Check if the supplied point is on EC curve.
6453
6454 @param[in] EcGroup EC group object.
6455 @param[in] EcPoint EC point to check.
6456 @param[in] BnCtx BN context, created with BigNumNewContext().
6457
6458 @retval TRUE On curve.
6459 @retval FALSE Otherwise.
6460**/
6461BOOLEAN
6462EFIAPI
6463CryptoServiceEcPointIsOnCurve (
6464 IN CONST VOID *EcGroup,
6465 IN CONST VOID *EcPoint,
6466 IN VOID *BnCtx
6467 )
6468{
6469 return CALL_BASECRYPTLIB (Ec.Services.PointIsOnCurve, EcPointIsOnCurve, (EcGroup, EcPoint, BnCtx), FALSE);
6470}
6471
6472/**
6473 Check if the supplied point is at infinity.
6474
6475 @param[in] EcGroup EC group object.
6476 @param[in] EcPoint EC point to check.
6477
6478 @retval TRUE At infinity.
6479 @retval FALSE Otherwise.
6480**/
6481BOOLEAN
6482EFIAPI
6483CryptoServiceEcPointIsAtInfinity (
6484 IN CONST VOID *EcGroup,
6485 IN CONST VOID *EcPoint
6486 )
6487{
6488 return CALL_BASECRYPTLIB (Ec.Services.PointIsAtInfinity, EcPointIsAtInfinity, (EcGroup, EcPoint), FALSE);
6489}
6490
6491/**
6492 Check if EC points are equal.
6493
6494 @param[in] EcGroup EC group object.
6495 @param[in] EcPointA EC point A.
6496 @param[in] EcPointB EC point B.
6497 @param[in] BnCtx BN context, created with BigNumNewContext().
6498
6499 @retval TRUE A == B.
6500 @retval FALSE Otherwise.
6501**/
6502BOOLEAN
6503EFIAPI
6504CryptoServiceEcPointEqual (
6505 IN CONST VOID *EcGroup,
6506 IN CONST VOID *EcPointA,
6507 IN CONST VOID *EcPointB,
6508 IN VOID *BnCtx
6509 )
6510{
6511 return CALL_BASECRYPTLIB (Ec.Services.PointEqual, EcPointEqual, (EcGroup, EcPointA, EcPointB, BnCtx), FALSE);
6512}
6513
6514/**
6515 Set EC point compressed coordinates. Points can be described in terms of
6516 their compressed coordinates. For a point (x, y), for any given value for x
6517 such that the point is on the curve there will only ever be two possible
6518 values for y. Therefore, a point can be set using this function where BnX is
6519 the x coordinate and YBit is a value 0 or 1 to identify which of the two
6520 possible values for y should be used.
6521
6522 @param[in] EcGroup EC group object.
6523 @param[in] EcPoint EC Point.
6524 @param[in] BnX X coordinate.
6525 @param[in] YBit 0 or 1 to identify which Y value is used.
6526 @param[in] BnCtx BN context, created with BigNumNewContext().
6527
6528 @retval TRUE On success.
6529 @retval FALSE Otherwise.
6530**/
6531BOOLEAN
6532EFIAPI
6533CryptoServiceEcPointSetCompressedCoordinates (
6534 IN CONST VOID *EcGroup,
6535 IN VOID *EcPoint,
6536 IN CONST VOID *BnX,
6537 IN UINT8 YBit,
6538 IN VOID *BnCtx
6539 )
6540{
6541 return CALL_BASECRYPTLIB (Ec.Services.PointSetCompressedCoordinates, EcPointSetCompressedCoordinates, (EcGroup, EcPoint, BnX, YBit, BnCtx), FALSE);
6542}
6543
6544// =====================================================================================
6545// Elliptic Curve Diffie Hellman Primitives
6546// =====================================================================================
6547
6548/**
6549 Allocates and Initializes one Elliptic Curve Context for subsequent use
6550 with the NID.
6551
6552 @param[in] Nid cipher NID
6553 @return Pointer to the Elliptic Curve Context that has been initialized.
6554 If the allocations fails, EcNewByNid() returns NULL.
6555**/
6556VOID *
6557EFIAPI
6558CryptoServiceEcNewByNid (
6559 IN UINTN Nid
6560 )
6561{
6562 return CALL_BASECRYPTLIB (Ec.Services.NewByNid, EcNewByNid, (Nid), NULL);
6563}
6564
6565/**
6566 Release the specified EC context.
6567
6568 @param[in] EcContext Pointer to the EC context to be released.
6569**/
6570VOID
6571EFIAPI
6572CryptoServiceEcFree (
6573 IN VOID *EcContext
6574 )
6575{
6576 CALL_VOID_BASECRYPTLIB (Ec.Services.Free, EcFree, (EcContext));
6577}
6578
6579/**
6580 Generates EC key and returns EC public key (X, Y), Please note, this function uses
6581 pseudo random number generator. The caller must make sure RandomSeed()
6582 function was properly called before.
6583 The Ec context should be correctly initialized by EcNewByNid.
6584 This function generates random secret, and computes the public key (X, Y), which is
6585 returned via parameter Public, PublicSize.
6586 X is the first half of Public with size being PublicSize / 2,
6587 Y is the second half of Public with size being PublicSize / 2.
6588 EC context is updated accordingly.
6589 If the Public buffer is too small to hold the public X, Y, FALSE is returned and
6590 PublicSize is set to the required buffer size to obtain the public X, Y.
6591 For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6592 For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6593 For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6594 If EcContext is NULL, then return FALSE.
6595 If PublicSize is NULL, then return FALSE.
6596 If PublicSize is large enough but Public is NULL, then return FALSE.
6597 @param[in, out] EcContext Pointer to the EC context.
6598 @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.
6599 @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.
6600 On output, the size of data returned in Public buffer in bytes.
6601 @retval TRUE EC public X,Y generation succeeded.
6602 @retval FALSE EC public X,Y generation failed.
6603 @retval FALSE PublicKeySize is not large enough.
6604**/
6605BOOLEAN
6606EFIAPI
6607CryptoServiceEcGenerateKey (
6608 IN OUT VOID *EcContext,
6609 OUT UINT8 *PublicKey,
6610 IN OUT UINTN *PublicKeySize
6611 )
6612{
6613 return CALL_BASECRYPTLIB (Ec.Services.GenerateKey, EcGenerateKey, (EcContext, PublicKey, PublicKeySize), FALSE);
6614}
6615
6616/**
6617 Gets the public key component from the established EC context.
6618 The Ec context should be correctly initialized by EcNewByNid, and successfully
6619 generate key pair from EcGenerateKey().
6620 For P-256, the PublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6621 For P-384, the PublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6622 For P-521, the PublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6623 @param[in, out] EcContext Pointer to EC context being set.
6624 @param[out] PublicKey Pointer to t buffer to receive generated public X,Y.
6625 @param[in, out] PublicKeySize On input, the size of Public buffer in bytes.
6626 On output, the size of data returned in Public buffer in bytes.
6627 @retval TRUE EC key component was retrieved successfully.
6628 @retval FALSE Invalid EC key component.
6629**/
6630BOOLEAN
6631EFIAPI
6632CryptoServiceEcGetPubKey (
6633 IN OUT VOID *EcContext,
6634 OUT UINT8 *PublicKey,
6635 IN OUT UINTN *PublicKeySize
6636 )
6637{
6638 return CALL_BASECRYPTLIB (Ec.Services.GetPubKey, EcGetPubKey, (EcContext, PublicKey, PublicKeySize), FALSE);
6639}
6640
6641/**
6642 Computes exchanged common key.
6643 Given peer's public key (X, Y), this function computes the exchanged common key,
6644 based on its own context including value of curve parameter and random secret.
6645 X is the first half of PeerPublic with size being PeerPublicSize / 2,
6646 Y is the second half of PeerPublic with size being PeerPublicSize / 2.
6647 If EcContext is NULL, then return FALSE.
6648 If PeerPublic is NULL, then return FALSE.
6649 If PeerPublicSize is 0, then return FALSE.
6650 If Key is NULL, then return FALSE.
6651 If KeySize is not large enough, then return FALSE.
6652 For P-256, the PeerPublicSize is 64. First 32-byte is X, Second 32-byte is Y.
6653 For P-384, the PeerPublicSize is 96. First 48-byte is X, Second 48-byte is Y.
6654 For P-521, the PeerPublicSize is 132. First 66-byte is X, Second 66-byte is Y.
6655 @param[in, out] EcContext Pointer to the EC context.
6656 @param[in] PeerPublic Pointer to the peer's public X,Y.
6657 @param[in] PeerPublicSize Size of peer's public X,Y in bytes.
6658 @param[in] CompressFlag Flag of PeerPublic is compressed or not.
6659 @param[out] Key Pointer to the buffer to receive generated key.
6660 @param[in, out] KeySize On input, the size of Key buffer in bytes.
6661 On output, the size of data returned in Key buffer in bytes.
6662 @retval TRUE EC exchanged key generation succeeded.
6663 @retval FALSE EC exchanged key generation failed.
6664 @retval FALSE KeySize is not large enough.
6665**/
6666BOOLEAN
6667EFIAPI
6668CryptoServiceEcDhComputeKey (
6669 IN OUT VOID *EcContext,
6670 IN CONST UINT8 *PeerPublic,
6671 IN UINTN PeerPublicSize,
6672 IN CONST INT32 *CompressFlag,
6673 OUT UINT8 *Key,
6674 IN OUT UINTN *KeySize
6675 )
6676{
6677 return CALL_BASECRYPTLIB (Ec.Services.DhComputeKey, EcDhComputeKey, (EcContext, PeerPublic, PeerPublicSize, CompressFlag, Key, KeySize), FALSE);
6678}
6679
6680/**
6681 Retrieve the EC Public Key from one DER-encoded X509 certificate.
6682
6683 @param[in] Cert Pointer to the DER-encoded X509 certificate.
6684 @param[in] CertSize Size of the X509 certificate in bytes.
6685 @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved
6686 EC public key component. Use EcFree() function to free the
6687 resource.
6688
6689 If Cert is NULL, then return FALSE.
6690 If EcContext is NULL, then return FALSE.
6691
6692 @retval TRUE EC Public Key was retrieved successfully.
6693 @retval FALSE Fail to retrieve EC public key from X509 certificate.
6694
6695**/
6696BOOLEAN
6697EFIAPI
6698CryptoServiceEcGetPublicKeyFromX509 (
6699 IN CONST UINT8 *Cert,
6700 IN UINTN CertSize,
6701 OUT VOID **EcContext
6702 )
6703{
6704 return CALL_BASECRYPTLIB (Ec.Services.GetPublicKeyFromX509, EcGetPublicKeyFromX509, (Cert, CertSize, EcContext), FALSE);
6705}
6706
6707/**
6708 Retrieve the EC Private Key from the password-protected PEM key data.
6709
6710 @param[in] PemData Pointer to the PEM-encoded key data to be retrieved.
6711 @param[in] PemSize Size of the PEM key data in bytes.
6712 @param[in] Password NULL-terminated passphrase used for encrypted PEM key data.
6713 @param[out] EcContext Pointer to new-generated EC DSA context which contain the retrieved
6714 EC private key component. Use EcFree() function to free the
6715 resource.
6716
6717 If PemData is NULL, then return FALSE.
6718 If EcContext is NULL, then return FALSE.
6719
6720 @retval TRUE EC Private Key was retrieved successfully.
6721 @retval FALSE Invalid PEM key data or incorrect password.
6722
6723**/
6724BOOLEAN
6725EFIAPI
6726CryptoServiceEcGetPrivateKeyFromPem (
6727 IN CONST UINT8 *PemData,
6728 IN UINTN PemSize,
6729 IN CONST CHAR8 *Password,
6730 OUT VOID **EcContext
6731 )
6732{
6733 return CALL_BASECRYPTLIB (Ec.Services.GetPrivateKeyFromPem, EcGetPrivateKeyFromPem, (PemData, PemSize, Password, EcContext), FALSE);
6734}
6735
6736/**
6737 Carries out the EC-DSA signature.
6738
6739 This function carries out the EC-DSA signature.
6740 If the Signature buffer is too small to hold the contents of signature, FALSE
6741 is returned and SigSize is set to the required buffer size to obtain the signature.
6742
6743 If EcContext is NULL, then return FALSE.
6744 If MessageHash is NULL, then return FALSE.
6745 If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.
6746 If SigSize is large enough but Signature is NULL, then return FALSE.
6747
6748 For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.
6749 For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.
6750 For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.
6751
6752 @param[in] EcContext Pointer to EC context for signature generation.
6753 @param[in] HashNid hash NID
6754 @param[in] MessageHash Pointer to octet message hash to be signed.
6755 @param[in] HashSize Size of the message hash in bytes.
6756 @param[out] Signature Pointer to buffer to receive EC-DSA signature.
6757 @param[in, out] SigSize On input, the size of Signature buffer in bytes.
6758 On output, the size of data returned in Signature buffer in bytes.
6759
6760 @retval TRUE Signature successfully generated in EC-DSA.
6761 @retval FALSE Signature generation failed.
6762 @retval FALSE SigSize is too small.
6763
6764**/
6765BOOLEAN
6766EFIAPI
6767CryptoServiceEcDsaSign (
6768 IN VOID *EcContext,
6769 IN UINTN HashNid,
6770 IN CONST UINT8 *MessageHash,
6771 IN UINTN HashSize,
6772 OUT UINT8 *Signature,
6773 IN OUT UINTN *SigSize
6774 )
6775{
6776 return CALL_BASECRYPTLIB (Ec.Services.DsaSign, EcDsaSign, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);
6777}
6778
6779/**
6780 Verifies the EC-DSA signature.
6781
6782 If EcContext is NULL, then return FALSE.
6783 If MessageHash is NULL, then return FALSE.
6784 If Signature is NULL, then return FALSE.
6785 If HashSize need match the HashNid. HashNid could be SHA256, SHA384, SHA512, SHA3_256, SHA3_384, SHA3_512.
6786
6787 For P-256, the SigSize is 64. First 32-byte is R, Second 32-byte is S.
6788 For P-384, the SigSize is 96. First 48-byte is R, Second 48-byte is S.
6789 For P-521, the SigSize is 132. First 66-byte is R, Second 66-byte is S.
6790
6791 @param[in] EcContext Pointer to EC context for signature verification.
6792 @param[in] HashNid hash NID
6793 @param[in] MessageHash Pointer to octet message hash to be checked.
6794 @param[in] HashSize Size of the message hash in bytes.
6795 @param[in] Signature Pointer to EC-DSA signature to be verified.
6796 @param[in] SigSize Size of signature in bytes.
6797
6798 @retval TRUE Valid signature encoded in EC-DSA.
6799 @retval FALSE Invalid signature or invalid EC context.
6800
6801**/
6802BOOLEAN
6803EFIAPI
6804CryptoServiceEcDsaVerify (
6805 IN VOID *EcContext,
6806 IN UINTN HashNid,
6807 IN CONST UINT8 *MessageHash,
6808 IN UINTN HashSize,
6809 IN CONST UINT8 *Signature,
6810 IN UINTN SigSize
6811 )
6812{
6813 return CALL_BASECRYPTLIB (Ec.Services.DsaVerify, EcDsaVerify, (EcContext, HashNid, MessageHash, HashSize, Signature, SigSize), FALSE);
6814}
6815
6816const EDKII_CRYPTO_PROTOCOL mEdkiiCrypto = {
6817 /// Version
6818 CryptoServiceGetCryptoVersion,
6819 /// HMAC MD5 - deprecated and unsupported
6820 DeprecatedCryptoServiceHmacMd5New,
6821 DeprecatedCryptoServiceHmacMd5Free,
6822 DeprecatedCryptoServiceHmacMd5SetKey,
6823 DeprecatedCryptoServiceHmacMd5Duplicate,
6824 DeprecatedCryptoServiceHmacMd5Update,
6825 DeprecatedCryptoServiceHmacMd5Final,
6826 /// HMAC SHA1 - deprecated and unsupported
6827 DeprecatedCryptoServiceHmacSha1New,
6828 DeprecatedCryptoServiceHmacSha1Free,
6829 DeprecatedCryptoServiceHmacSha1SetKey,
6830 DeprecatedCryptoServiceHmacSha1Duplicate,
6831 DeprecatedCryptoServiceHmacSha1Update,
6832 DeprecatedCryptoServiceHmacSha1Final,
6833 /// HMAC SHA256
6834 CryptoServiceHmacSha256New,
6835 CryptoServiceHmacSha256Free,
6836 CryptoServiceHmacSha256SetKey,
6837 CryptoServiceHmacSha256Duplicate,
6838 CryptoServiceHmacSha256Update,
6839 CryptoServiceHmacSha256Final,
6840 /// Md4 - deprecated and unsupported
6841 DeprecatedCryptoServiceMd4GetContextSize,
6842 DeprecatedCryptoServiceMd4Init,
6843 DeprecatedCryptoServiceMd4Duplicate,
6844 DeprecatedCryptoServiceMd4Update,
6845 DeprecatedCryptoServiceMd4Final,
6846 DeprecatedCryptoServiceMd4HashAll,
6847 #ifndef ENABLE_MD5_DEPRECATED_INTERFACES
6848 /// Md5 - deprecated and unsupported
6849 DeprecatedCryptoServiceMd5GetContextSize,
6850 DeprecatedCryptoServiceMd5Init,
6851 DeprecatedCryptoServiceMd5Duplicate,
6852 DeprecatedCryptoServiceMd5Update,
6853 DeprecatedCryptoServiceMd5Final,
6854 DeprecatedCryptoServiceMd5HashAll,
6855 #else
6856 /// Md5
6857 CryptoServiceMd5GetContextSize,
6858 CryptoServiceMd5Init,
6859 CryptoServiceMd5Duplicate,
6860 CryptoServiceMd5Update,
6861 CryptoServiceMd5Final,
6862 CryptoServiceMd5HashAll,
6863 #endif
6864 /// Pkcs
6865 CryptoServicePkcs1v2Encrypt,
6866 CryptoServicePkcs5HashPassword,
6867 CryptoServicePkcs7Verify,
6868 CryptoServiceVerifyEKUsInPkcs7Signature,
6869 CryptoServicePkcs7GetSigners,
6870 CryptoServicePkcs7FreeSigners,
6871 CryptoServicePkcs7Sign,
6872 CryptoServicePkcs7GetAttachedContent,
6873 CryptoServicePkcs7GetCertificatesList,
6874 CryptoServiceAuthenticodeVerify,
6875 CryptoServiceImageTimestampVerify,
6876 /// DH
6877 CryptoServiceDhNew,
6878 CryptoServiceDhFree,
6879 CryptoServiceDhGenerateParameter,
6880 CryptoServiceDhSetParameter,
6881 CryptoServiceDhGenerateKey,
6882 CryptoServiceDhComputeKey,
6883 /// Random
6884 CryptoServiceRandomSeed,
6885 CryptoServiceRandomBytes,
6886 /// RSA
6887 CryptoServiceRsaPkcs1Verify,
6888 CryptoServiceRsaNew,
6889 CryptoServiceRsaFree,
6890 CryptoServiceRsaSetKey,
6891 CryptoServiceRsaGetKey,
6892 CryptoServiceRsaGenerateKey,
6893 CryptoServiceRsaCheckKey,
6894 CryptoServiceRsaPkcs1Sign,
6895 CryptoServiceRsaPkcs1Verify,
6896 CryptoServiceRsaGetPrivateKeyFromPem,
6897 CryptoServiceRsaGetPublicKeyFromX509,
6898 #ifdef DISABLE_SHA1_DEPRECATED_INTERFACES
6899 /// Sha1 - deprecated and unsupported
6900 DeprecatedCryptoServiceSha1GetContextSize,
6901 DeprecatedCryptoServiceSha1Init,
6902 DeprecatedCryptoServiceSha1Duplicate,
6903 DeprecatedCryptoServiceSha1Update,
6904 DeprecatedCryptoServiceSha1Final,
6905 DeprecatedCryptoServiceSha1HashAll,
6906 #else
6907 /// Sha1
6908 CryptoServiceSha1GetContextSize,
6909 CryptoServiceSha1Init,
6910 CryptoServiceSha1Duplicate,
6911 CryptoServiceSha1Update,
6912 CryptoServiceSha1Final,
6913 CryptoServiceSha1HashAll,
6914 #endif
6915 /// Sha256
6916 CryptoServiceSha256GetContextSize,
6917 CryptoServiceSha256Init,
6918 CryptoServiceSha256Duplicate,
6919 CryptoServiceSha256Update,
6920 CryptoServiceSha256Final,
6921 CryptoServiceSha256HashAll,
6922 /// Sha384
6923 CryptoServiceSha384GetContextSize,
6924 CryptoServiceSha384Init,
6925 CryptoServiceSha384Duplicate,
6926 CryptoServiceSha384Update,
6927 CryptoServiceSha384Final,
6928 CryptoServiceSha384HashAll,
6929 /// Sha512
6930 CryptoServiceSha512GetContextSize,
6931 CryptoServiceSha512Init,
6932 CryptoServiceSha512Duplicate,
6933 CryptoServiceSha512Update,
6934 CryptoServiceSha512Final,
6935 CryptoServiceSha512HashAll,
6936 /// X509
6937 CryptoServiceX509GetSubjectName,
6938 CryptoServiceX509GetCommonName,
6939 CryptoServiceX509GetOrganizationName,
6940 CryptoServiceX509VerifyCert,
6941 CryptoServiceX509ConstructCertificate,
6942 CryptoServiceX509ConstructCertificateStack,
6943 CryptoServiceX509Free,
6944 CryptoServiceX509StackFree,
6945 CryptoServiceX509GetTBSCert,
6946 /// TDES - deprecated and unsupported
6947 DeprecatedCryptoServiceTdesGetContextSize,
6948 DeprecatedCryptoServiceTdesInit,
6949 DeprecatedCryptoServiceTdesEcbEncrypt,
6950 DeprecatedCryptoServiceTdesEcbDecrypt,
6951 DeprecatedCryptoServiceTdesCbcEncrypt,
6952 DeprecatedCryptoServiceTdesCbcDecrypt,
6953 /// AES - ECB mode is deprecated and unsupported
6954 CryptoServiceAesGetContextSize,
6955 CryptoServiceAesInit,
6956 DeprecatedCryptoServiceAesEcbEncrypt,
6957 DeprecatedCryptoServiceAesEcbDecrypt,
6958 CryptoServiceAesCbcEncrypt,
6959 CryptoServiceAesCbcDecrypt,
6960 /// Arc4 - deprecated and unsupported
6961 DeprecatedCryptoServiceArc4GetContextSize,
6962 DeprecatedCryptoServiceArc4Init,
6963 DeprecatedCryptoServiceArc4Encrypt,
6964 DeprecatedCryptoServiceArc4Decrypt,
6965 DeprecatedCryptoServiceArc4Reset,
6966 /// SM3
6967 CryptoServiceSm3GetContextSize,
6968 CryptoServiceSm3Init,
6969 CryptoServiceSm3Duplicate,
6970 CryptoServiceSm3Update,
6971 CryptoServiceSm3Final,
6972 CryptoServiceSm3HashAll,
6973 /// HKDF
6974 CryptoServiceHkdfSha256ExtractAndExpand,
6975 /// X509 (Continued)
6976 CryptoServiceX509ConstructCertificateStackV,
6977 /// TLS
6978 CryptoServiceTlsInitialize,
6979 CryptoServiceTlsCtxFree,
6980 CryptoServiceTlsCtxNew,
6981 CryptoServiceTlsFree,
6982 CryptoServiceTlsNew,
6983 CryptoServiceTlsInHandshake,
6984 CryptoServiceTlsDoHandshake,
6985 CryptoServiceTlsHandleAlert,
6986 CryptoServiceTlsCloseNotify,
6987 CryptoServiceTlsCtrlTrafficOut,
6988 CryptoServiceTlsCtrlTrafficIn,
6989 CryptoServiceTlsRead,
6990 CryptoServiceTlsWrite,
6991 /// TLS Set
6992 CryptoServiceTlsSetVersion,
6993 CryptoServiceTlsSetConnectionEnd,
6994 CryptoServiceTlsSetCipherList,
6995 CryptoServiceTlsSetCompressionMethod,
6996 CryptoServiceTlsSetVerify,
6997 CryptoServiceTlsSetVerifyHost,
6998 CryptoServiceTlsSetSessionId,
6999 CryptoServiceTlsSetCaCertificate,
7000 CryptoServiceTlsSetHostPublicCert,
7001 CryptoServiceTlsSetHostPrivateKey,
7002 CryptoServiceTlsSetCertRevocationList,
7003 /// TLS Get
7004 CryptoServiceTlsGetVersion,
7005 CryptoServiceTlsGetConnectionEnd,
7006 CryptoServiceTlsGetCurrentCipher,
7007 CryptoServiceTlsGetCurrentCompressionId,
7008 CryptoServiceTlsGetVerify,
7009 CryptoServiceTlsGetSessionId,
7010 CryptoServiceTlsGetClientRandom,
7011 CryptoServiceTlsGetServerRandom,
7012 CryptoServiceTlsGetKeyMaterial,
7013 CryptoServiceTlsGetCaCertificate,
7014 CryptoServiceTlsGetHostPublicCert,
7015 CryptoServiceTlsGetHostPrivateKey,
7016 CryptoServiceTlsGetCertRevocationList,
7017 /// RSA PSS
7018 CryptoServiceRsaPssSign,
7019 CryptoServiceRsaPssVerify,
7020 /// Parallel hash
7021 CryptoServiceParallelHash256HashAll,
7022 /// HMAC SHA256 (continued)
7023 CryptoServiceHmacSha256All,
7024 /// HMAC SHA384
7025 CryptoServiceHmacSha384New,
7026 CryptoServiceHmacSha384Free,
7027 CryptoServiceHmacSha384SetKey,
7028 CryptoServiceHmacSha384Duplicate,
7029 CryptoServiceHmacSha384Update,
7030 CryptoServiceHmacSha384Final,
7031 CryptoServiceHmacSha384All,
7032 /// HKDF (continued)
7033 CryptoServiceHkdfSha256Extract,
7034 CryptoServiceHkdfSha256Expand,
7035 CryptoServiceHkdfSha384ExtractAndExpand,
7036 CryptoServiceHkdfSha384Extract,
7037 CryptoServiceHkdfSha384Expand,
7038 /// Aead Aes GCM
7039 CryptoServiceAeadAesGcmEncrypt,
7040 CryptoServiceAeadAesGcmDecrypt,
7041 /// Big Numbers
7042 CryptoServiceBigNumInit,
7043 CryptoServiceBigNumFromBin,
7044 CryptoServiceBigNumToBin,
7045 CryptoServiceBigNumFree,
7046 CryptoServiceBigNumAdd,
7047 CryptoServiceBigNumSub,
7048 CryptoServiceBigNumMod,
7049 CryptoServiceBigNumExpMod,
7050 CryptoServiceBigNumInverseMod,
7051 CryptoServiceBigNumDiv,
7052 CryptoServiceBigNumMulMod,
7053 CryptoServiceBigNumCmp,
7054 CryptoServiceBigNumBits,
7055 CryptoServiceBigNumBytes,
7056 CryptoServiceBigNumIsWord,
7057 CryptoServiceBigNumIsOdd,
7058 CryptoServiceBigNumCopy,
7059 CryptoServiceBigNumValueOne,
7060 CryptoServiceBigNumRShift,
7061 CryptoServiceBigNumConstTime,
7062 CryptoServiceBigNumSqrMod,
7063 CryptoServiceBigNumNewContext,
7064 CryptoServiceBigNumContextFree,
7065 CryptoServiceBigNumSetUint,
7066 CryptoServiceBigNumAddMod,
7067 /// EC
7068 CryptoServiceEcGroupInit,
7069 CryptoServiceEcGroupGetCurve,
7070 CryptoServiceEcGroupGetOrder,
7071 CryptoServiceEcGroupFree,
7072 CryptoServiceEcPointInit,
7073 CryptoServiceEcPointDeInit,
7074 CryptoServiceEcPointGetAffineCoordinates,
7075 CryptoServiceEcPointSetAffineCoordinates,
7076 CryptoServiceEcPointAdd,
7077 CryptoServiceEcPointMul,
7078 CryptoServiceEcPointInvert,
7079 CryptoServiceEcPointIsOnCurve,
7080 CryptoServiceEcPointIsAtInfinity,
7081 CryptoServiceEcPointEqual,
7082 CryptoServiceEcPointSetCompressedCoordinates,
7083 CryptoServiceEcNewByNid,
7084 CryptoServiceEcFree,
7085 CryptoServiceEcGenerateKey,
7086 CryptoServiceEcGetPubKey,
7087 CryptoServiceEcDhComputeKey,
7088 /// TLS (continued)
7089 CryptoServiceTlsShutdown,
7090 /// TLS Set (continued)
7091 CryptoServiceTlsSetHostPrivateKeyEx,
7092 CryptoServiceTlsSetSignatureAlgoList,
7093 CryptoServiceTlsSetEcCurve,
7094 /// TLS Get (continued)
7095 CryptoServiceTlsGetExportKey,
7096 /// Ec (Continued)
7097 CryptoServiceEcGetPublicKeyFromX509,
7098 CryptoServiceEcGetPrivateKeyFromPem,
7099 CryptoServiceEcDsaSign,
7100 CryptoServiceEcDsaVerify,
7101 /// X509 (Continued)
7102 CryptoServiceX509GetVersion,
7103 CryptoServiceX509GetSerialNumber,
7104 CryptoServiceX509GetIssuerName,
7105 CryptoServiceX509GetSignatureAlgorithm,
7106 CryptoServiceX509GetExtensionData,
7107 CryptoServiceX509GetExtendedKeyUsage,
7108 CryptoServiceX509GetValidity,
7109 CryptoServiceX509FormatDateTime,
7110 CryptoServiceX509CompareDateTime,
7111 CryptoServiceX509GetKeyUsage,
7112 CryptoServiceX509VerifyCertChain,
7113 CryptoServiceX509GetCertFromCertChain,
7114 CryptoServiceAsn1GetTag,
7115 CryptoServiceX509GetExtendedBasicConstraints,
7116 CryptoServicePkcs1v2Decrypt,
7117 CryptoServiceRsaOaepEncrypt,
7118 CryptoServiceRsaOaepDecrypt,
7119};
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette