This repository has been archived by the owner on Jul 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
BaseCryptLib.h
5173 lines (4170 loc) · 177 KB
/
BaseCryptLib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** @file
Defines base cryptographic library APIs.
The Base Cryptographic Library provides implementations of basic cryptography
primitives (Hash Serials, HMAC, AES, RSA, Diffie-Hellman, Elliptic Curve, etc) for UEFI security
functionality enabling.
Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __BASE_CRYPT_LIB_H__
#define __BASE_CRYPT_LIB_H__
#define CRYPTO_NID_NULL 0x0000
// Hash
#define CRYPTO_NID_SHA256 0x0001
#define CRYPTO_NID_SHA384 0x0002
#define CRYPTO_NID_SHA512 0x0003
#define CRYPTO_NID_SHA3_256 0x0004
#define CRYPTO_NID_SHA3_384 0x0005
#define CRYPTO_NID_SHA3_512 0x0006
#define CRYPTO_NID_SM3_256 0x0007
// Signing
#define CRYPTO_NID_RSASSA2048 0x0101
#define CRYPTO_NID_RSASSA3072 0x0102
#define CRYPTO_NID_RSASSA4096 0x0103
#define CRYPTO_NID_RSAPSS2048 0x0104
#define CRYPTO_NID_RSAPSS3072 0x0105
#define CRYPTO_NID_RSAPSS4096 0x0106
#define CRYPTO_NID_ECDSA_NIST_P256 0x0106
#define CRYPTO_NID_ECDSA_NIST_P384 0x0107
#define CRYPTO_NID_ECDSA_NIST_P521 0x0108
#define CRYPTO_NID_ECDSA_SM2_P256 0x0109
#define CRYPTO_NID_EDDSA_ED25519 0x010A
#define CRYPTO_NID_EDDSA_ED448 0x010B
// Key Exchange
#define CRYPTO_NID_FFDHE2048 0x0201
#define CRYPTO_NID_FFDHE3072 0x0202
#define CRYPTO_NID_FFDHE4096 0x0203
#define CRYPTO_NID_SECP256R1 0x0204
#define CRYPTO_NID_SECP384R1 0x0205
#define CRYPTO_NID_SECP521R1 0x0206
#define CRYPTO_NID_SM2_P256 0x0207
// AEAD
#define CRYPTO_NID_AES_128_GCM 0x0301
#define CRYPTO_NID_AES_256_GCM 0x0302
#define CRYPTO_NID_CHACHA20_POLY1305 0x0303
#define CRYPTO_NID_SM4_128_GCM 0x0304
///
/// X.509 v3 Key Usage Extension flags
///
#define CRYPTO_X509_KU_DIGITAL_SIGNATURE (0x80) // bit 0
#define CRYPTO_X509_KU_NON_REPUDIATION (0x40) // bit 1
#define CRYPTO_X509_KU_KEY_ENCIPHERMENT (0x20) // bit 2
#define CRYPTO_X509_KU_DATA_ENCIPHERMENT (0x10) // bit 3
#define CRYPTO_X509_KU_KEY_AGREEMENT (0x08) // bit 4
#define CRYPTO_X509_KU_KEY_CERT_SIGN (0x04) // bit 5
#define CRYPTO_X509_KU_CRL_SIGN (0x02) // bit 6
#define CRYPTO_X509_KU_ENCIPHER_ONLY (0x01) // bit 7
#define CRYPTO_X509_KU_DECIPHER_ONLY (0x8000) // bit 8
///
/// These constants comply with the DER encoded ASN.1 type tags.
///
#define CRYPTO_ASN1_BOOLEAN 0x01
#define CRYPTO_ASN1_INTEGER 0x02
#define CRYPTO_ASN1_BIT_STRING 0x03
#define CRYPTO_ASN1_OCTET_STRING 0x04
#define CRYPTO_ASN1_NULL 0x05
#define CRYPTO_ASN1_OID 0x06
#define CRYPTO_ASN1_UTF8_STRING 0x0C
#define CRYPTO_ASN1_SEQUENCE 0x10
#define CRYPTO_ASN1_SET 0x11
#define CRYPTO_ASN1_PRINTABLE_STRING 0x13
#define CRYPTO_ASN1_T61_STRING 0x14
#define CRYPTO_ASN1_IA5_STRING 0x16
#define CRYPTO_ASN1_UTC_TIME 0x17
#define CRYPTO_ASN1_GENERALIZED_TIME 0x18
#define CRYPTO_ASN1_UNIVERSAL_STRING 0x1C
#define CRYPTO_ASN1_BMP_STRING 0x1E
#define CRYPTO_ASN1_PRIMITIVE 0x00
#define CRYPTO_ASN1_CONSTRUCTED 0x20
#define CRYPTO_ASN1_CONTEXT_SPECIFIC 0x80
#define CRYPTO_ASN1_TAG_CLASS_MASK 0xC0
#define CRYPTO_ASN1_TAG_PC_MASK 0x20
#define CRYPTO_ASN1_TAG_VALUE_MASK 0x1F
///
/// SHA-256 digest size in bytes
///
#define SHA256_DIGEST_SIZE 32
///
/// SHA-384 digest size in bytes
///
#define SHA384_DIGEST_SIZE 48
///
/// SHA-512 digest size in bytes
///
#define SHA512_DIGEST_SIZE 64
///
/// SHA3-256 digest size in bytes
///
#define SHA3_256_DIGEST_SIZE 32
///
/// SHA3-384 digest size in bytes
///
#define SHA3_384_DIGEST_SIZE 48
///
/// SHA3-512 digest size in bytes
///
#define SHA3_512_DIGEST_SIZE 64
///
/// SHAKE256 digest size in bytes
///
#define SHAKE256_DIGEST_SIZE 32
///
/// SM3_256 digest size in bytes
///
#define SM3_256_DIGEST_SIZE 32
///
/// AES block size in bytes
///
#define AES_BLOCK_SIZE 16
///
/// RSA Key Tags Definition used in RsaSetKey() function for key component identification.
///
typedef enum {
RsaKeyN, ///< RSA public Modulus (N)
RsaKeyE, ///< RSA Public exponent (e)
RsaKeyD, ///< RSA Private exponent (d)
RsaKeyP, ///< RSA secret prime factor of Modulus (p)
RsaKeyQ, ///< RSA secret prime factor of Modules (q)
RsaKeyDp, ///< p's CRT exponent (== d mod (p - 1))
RsaKeyDq, ///< q's CRT exponent (== d mod (q - 1))
RsaKeyQInv ///< The CRT coefficient (== 1/q mod p)
} RSA_KEY_TAG;
//=====================================================================================
// One-Way Cryptographic Hash SHA Primitives
//=====================================================================================
/**
Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
@return The size, in bytes, of the context buffer required for SHA-256 hash operations.
**/
UINTN
EFIAPI
Sha256GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha256Context as SHA-256 hash context for
subsequent use.
If Sha256Context is NULL, then return FALSE.
@param[out] Sha256Context Pointer to SHA-256 context being initialized.
@retval TRUE SHA-256 context initialization succeeded.
@retval FALSE SHA-256 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha256Init (
OUT VOID *Sha256Context
);
/**
Makes a copy of an existing SHA-256 context.
If Sha256Context is NULL, then return FALSE.
If NewSha256Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha256Context Pointer to SHA-256 context being copied.
@param[out] NewSha256Context Pointer to new SHA-256 context.
@retval TRUE SHA-256 context copy succeeded.
@retval FALSE SHA-256 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha256Duplicate (
IN CONST VOID *Sha256Context,
OUT VOID *NewSha256Context
);
/**
Digests the input data and updates SHA-256 context.
This function performs SHA-256 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA-256 context should be already correctly initialized by Sha256Init(), and should not be finalized
by Sha256Final(). Behavior with invalid context is undefined.
If Sha256Context is NULL, then return FALSE.
@param[in, out] Sha256Context Pointer to the SHA-256 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA-256 data digest succeeded.
@retval FALSE SHA-256 data digest failed.
**/
BOOLEAN
EFIAPI
Sha256Update (
IN OUT VOID *Sha256Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA-256 digest value.
This function completes SHA-256 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA-256 context cannot
be used again.
SHA-256 context should be already correctly initialized by Sha256Init(), and should not be
finalized by Sha256Final(). Behavior with invalid SHA-256 context is undefined.
If Sha256Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha256Context Pointer to the SHA-256 context.
@param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
value (32 bytes).
@retval TRUE SHA-256 digest computation succeeded.
@retval FALSE SHA-256 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha256Final (
IN OUT VOID *Sha256Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA-256 message digest of a input data buffer.
This function performs the SHA-256 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA-256 digest
value (32 bytes).
@retval TRUE SHA-256 digest computation succeeded.
@retval FALSE SHA-256 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha256HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
/**
Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
@return The size, in bytes, of the context buffer required for SHA-384 hash operations.
**/
UINTN
EFIAPI
Sha384GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha384Context as SHA-384 hash context for
subsequent use.
If Sha384Context is NULL, then return FALSE.
@param[out] Sha384Context Pointer to SHA-384 context being initialized.
@retval TRUE SHA-384 context initialization succeeded.
@retval FALSE SHA-384 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha384Init (
OUT VOID *Sha384Context
);
/**
Makes a copy of an existing SHA-384 context.
If Sha384Context is NULL, then return FALSE.
If NewSha384Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha384Context Pointer to SHA-384 context being copied.
@param[out] NewSha384Context Pointer to new SHA-384 context.
@retval TRUE SHA-384 context copy succeeded.
@retval FALSE SHA-384 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha384Duplicate (
IN CONST VOID *Sha384Context,
OUT VOID *NewSha384Context
);
/**
Digests the input data and updates SHA-384 context.
This function performs SHA-384 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA-384 context should be already correctly initialized by Sha384Init(), and should not be finalized
by Sha384Final(). Behavior with invalid context is undefined.
If Sha384Context is NULL, then return FALSE.
@param[in, out] Sha384Context Pointer to the SHA-384 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA-384 data digest succeeded.
@retval FALSE SHA-384 data digest failed.
**/
BOOLEAN
EFIAPI
Sha384Update (
IN OUT VOID *Sha384Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA-384 digest value.
This function completes SHA-384 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA-384 context cannot
be used again.
SHA-384 context should be already correctly initialized by Sha384Init(), and should not be
finalized by Sha384Final(). Behavior with invalid SHA-384 context is undefined.
If Sha384Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha384Context Pointer to the SHA-384 context.
@param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
value (48 bytes).
@retval TRUE SHA-384 digest computation succeeded.
@retval FALSE SHA-384 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha384Final (
IN OUT VOID *Sha384Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA-384 message digest of a input data buffer.
This function performs the SHA-384 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA-384 digest
value (48 bytes).
@retval TRUE SHA-384 digest computation succeeded.
@retval FALSE SHA-384 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha384HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
/**
Retrieves the size, in bytes, of the context buffer required for SHA-512 hash operations.
@return The size, in bytes, of the context buffer required for SHA-512 hash operations.
**/
UINTN
EFIAPI
Sha512GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha512Context as SHA-512 hash context for
subsequent use.
If Sha512Context is NULL, then return FALSE.
@param[out] Sha512Context Pointer to SHA-512 context being initialized.
@retval TRUE SHA-512 context initialization succeeded.
@retval FALSE SHA-512 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha512Init (
OUT VOID *Sha512Context
);
/**
Makes a copy of an existing SHA-512 context.
If Sha512Context is NULL, then return FALSE.
If NewSha512Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha512Context Pointer to SHA-512 context being copied.
@param[out] NewSha512Context Pointer to new SHA-512 context.
@retval TRUE SHA-512 context copy succeeded.
@retval FALSE SHA-512 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha512Duplicate (
IN CONST VOID *Sha512Context,
OUT VOID *NewSha512Context
);
/**
Digests the input data and updates SHA-512 context.
This function performs SHA-512 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA-512 context should be already correctly initialized by Sha512Init(), and should not be finalized
by Sha512Final(). Behavior with invalid context is undefined.
If Sha512Context is NULL, then return FALSE.
@param[in, out] Sha512Context Pointer to the SHA-512 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA-512 data digest succeeded.
@retval FALSE SHA-512 data digest failed.
**/
BOOLEAN
EFIAPI
Sha512Update (
IN OUT VOID *Sha512Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA-512 digest value.
This function completes SHA-512 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA-512 context cannot
be used again.
SHA-512 context should be already correctly initialized by Sha512Init(), and should not be
finalized by Sha512Final(). Behavior with invalid SHA-512 context is undefined.
If Sha512Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha512Context Pointer to the SHA-512 context.
@param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
value (64 bytes).
@retval TRUE SHA-512 digest computation succeeded.
@retval FALSE SHA-512 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha512Final (
IN OUT VOID *Sha512Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA-512 message digest of a input data buffer.
This function performs the SHA-512 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA-512 digest
value (64 bytes).
@retval TRUE SHA-512 digest computation succeeded.
@retval FALSE SHA-512 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha512HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
//=====================================================================================
// One-Way Cryptographic Hash SHA3 Primitives
//=====================================================================================
/**
Retrieves the size, in bytes, of the context buffer required for SHA-256 hash operations.
@return The size, in bytes, of the context buffer required for SHA-256 hash operations.
**/
UINTN
EFIAPI
Sha3_256GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha3_256Context as SHA3-256 hash context for
subsequent use.
If Sha3_256Context is NULL, then return FALSE.
@param[out] Sha3_256Context Pointer to SHA3-256 context being initialized.
@retval TRUE SHA3-256 context initialization succeeded.
@retval FALSE SHA3-256 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha3_256Init (
OUT VOID *Sha3_256Context
);
/**
Makes a copy of an existing SHA3-256 context.
If Sha3_256Context is NULL, then return FALSE.
If NewSha3_256Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha3_256Context Pointer to SHA3-256 context being copied.
@param[out] NewSha3_256Context Pointer to new SHA3-256 context.
@retval TRUE SHA3-256 context copy succeeded.
@retval FALSE SHA3-256 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_256Duplicate (
IN CONST VOID *Sha3_256Context,
OUT VOID *NewSha3_256Context
);
/**
Digests the input data and updates SHA3-256 context.
This function performs SHA3-256 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA3-256 context should be already correctly initialized by Sha3_256Init(), and should not be finalized
by Sha3_256Final(). Behavior with invalid context is undefined.
If Sha3_256Context is NULL, then return FALSE.
@param[in, out] Sha3_256Context Pointer to the SHA3-256 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA3-256 data digest succeeded.
@retval FALSE SHA3-256 data digest failed.
**/
BOOLEAN
EFIAPI
Sha3_256Update (
IN OUT VOID *Sha3_256Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA3-256 digest value.
This function completes SHA3-256 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA3-256 context cannot
be used again.
SHA3-256 context should be already correctly initialized by Sha3_256Init(), and should not be
finalized by Sha3_256Final(). Behavior with invalid SHA3-256 context is undefined.
If Sha3_256Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha3_256Context Pointer to the SHA3-256 context.
@param[out] HashValue Pointer to a buffer that receives the SHA3-256 digest
value (256 / 8 bytes).
@retval TRUE SHA3-256 digest computation succeeded.
@retval FALSE SHA3-256 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha3_256Final (
IN OUT VOID *Sha3_256Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA3-256 message digest of a input data buffer.
This function performs the SHA3-256 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA3-256 digest
value (256 / 8 bytes).
@retval TRUE SHA3-256 digest computation succeeded.
@retval FALSE SHA3-256 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_256HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
/**
Retrieves the size, in bytes, of the context buffer required for SHA-384 hash operations.
@return The size, in bytes, of the context buffer required for SHA-384 hash operations.
**/
UINTN
EFIAPI
Sha3_384GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha3_384Context as SHA3-384 hash context for
subsequent use.
If Sha3_384Context is NULL, then return FALSE.
@param[out] Sha3_384Context Pointer to SHA3-384 context being initialized.
@retval TRUE SHA3-384 context initialization succeeded.
@retval FALSE SHA3-384 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha3_384Init (
OUT VOID *Sha3_384Context
);
/**
Makes a copy of an existing SHA3-384 context.
If Sha3_384Context is NULL, then return FALSE.
If NewSha3_384Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha3_384Context Pointer to SHA3-384 context being copied.
@param[out] NewSha3_384Context Pointer to new SHA3-384 context.
@retval TRUE SHA3-384 context copy succeeded.
@retval FALSE SHA3-384 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_384Duplicate (
IN CONST VOID *Sha3_384Context,
OUT VOID *NewSha3_384Context
);
/**
Digests the input data and updates SHA3-384 context.
This function performs SHA3-384 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA3-384 context should be already correctly initialized by Sha3_384Init(), and should not be finalized
by Sha3_384Final(). Behavior with invalid context is undefined.
If Sha3_384Context is NULL, then return FALSE.
@param[in, out] Sha3_384Context Pointer to the SHA3-384 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA3-384 data digest succeeded.
@retval FALSE SHA3-384 data digest failed.
**/
BOOLEAN
EFIAPI
Sha3_384Update (
IN OUT VOID *Sha3_384Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA3-384 digest value.
This function completes SHA3-384 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA3-384 context cannot
be used again.
SHA3-384 context should be already correctly initialized by Sha3_384Init(), and should not be
finalized by Sha3_384Final(). Behavior with invalid SHA3-384 context is undefined.
If Sha3_384Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha3_384Context Pointer to the SHA3-384 context.
@param[out] HashValue Pointer to a buffer that receives the SHA3-384 digest
value (384 / 8 bytes).
@retval TRUE SHA3-384 digest computation succeeded.
@retval FALSE SHA3-384 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha3_384Final (
IN OUT VOID *Sha3_384Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA3-384 message digest of a input data buffer.
This function performs the SHA3-384 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA3-384 digest
value (384 / 8 bytes).
@retval TRUE SHA3-384 digest computation succeeded.
@retval FALSE SHA3-384 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_384HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
/**
Retrieves the size, in bytes, of the context buffer required for SHA3-512 hash operations.
@return The size, in bytes, of the context buffer required for SHA3-512 hash operations.
**/
UINTN
EFIAPI
Sha3_512GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Sha3_512Context as SHA3-512 hash context for
subsequent use.
If Sha3_512Context is NULL, then return FALSE.
@param[out] Sha3_512Context Pointer to SHA3-512 context being initialized.
@retval TRUE SHA3-512 context initialization succeeded.
@retval FALSE SHA3-512 context initialization failed.
**/
BOOLEAN
EFIAPI
Sha3_512Init (
OUT VOID *Sha3_512Context
);
/**
Makes a copy of an existing SHA3-512 context.
If Sha3_512Context is NULL, then return FALSE.
If NewSha3_512Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Sha3_512Context Pointer to SHA3-512 context being copied.
@param[out] NewSha3_512Context Pointer to new SHA3-512 context.
@retval TRUE SHA3-512 context copy succeeded.
@retval FALSE SHA3-512 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_512Duplicate (
IN CONST VOID *Sha3_512Context,
OUT VOID *NewSha3_512Context
);
/**
Digests the input data and updates SHA3-512 context.
This function performs SHA3-512 digest on a data buffer of the specified size.
It can be called multiple times to compute the digest of long or discontinuous data streams.
SHA3-512 context should be already correctly initialized by Sha3_512Init(), and should not be finalized
by Sha3_512Final(). Behavior with invalid context is undefined.
If Sha3_512Context is NULL, then return FALSE.
@param[in, out] Sha3_512Context Pointer to the SHA3-512 context.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@retval TRUE SHA3-512 data digest succeeded.
@retval FALSE SHA3-512 data digest failed.
**/
BOOLEAN
EFIAPI
Sha3_512Update (
IN OUT VOID *Sha3_512Context,
IN CONST VOID *Data,
IN UINTN DataSize
);
/**
Completes computation of the SHA3-512 digest value.
This function completes SHA3-512 hash computation and retrieves the digest value into
the specified memory. After this function has been called, the SHA3-512 context cannot
be used again.
SHA3-512 context should be already correctly initialized by Sha3_512Init(), and should not be
finalized by Sha3_512Final(). Behavior with invalid SHA3-512 context is undefined.
If Sha3_512Context is NULL, then return FALSE.
If HashValue is NULL, then return FALSE.
@param[in, out] Sha3_512Context Pointer to the SHA3-512 context.
@param[out] HashValue Pointer to a buffer that receives the SHA3-512 digest
value (512 / 8 bytes).
@retval TRUE SHA3-512 digest computation succeeded.
@retval FALSE SHA3-512 digest computation failed.
**/
BOOLEAN
EFIAPI
Sha3_512Final (
IN OUT VOID *Sha3_512Context,
OUT UINT8 *HashValue
);
/**
Computes the SHA3-512 message digest of a input data buffer.
This function performs the SHA3-512 message digest of a given data buffer, and places
the digest value into the specified memory.
If this interface is not supported, then return FALSE.
@param[in] Data Pointer to the buffer containing the data to be hashed.
@param[in] DataSize Size of Data buffer in bytes.
@param[out] HashValue Pointer to a buffer that receives the SHA3-512 digest
value (512 / 8 bytes).
@retval TRUE SHA3-512 digest computation succeeded.
@retval FALSE SHA3-512 digest computation failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Sha3_512HashAll (
IN CONST VOID *Data,
IN UINTN DataSize,
OUT UINT8 *HashValue
);
/**
Retrieves the size, in bytes, of the context buffer required for SHAKE256 hash operations.
@return The size, in bytes, of the context buffer required for SHAKE256 hash operations.
**/
UINTN
EFIAPI
Shake256GetContextSize (
VOID
);
/**
Initializes user-supplied memory pointed by Shake256Context as SHAKE256 hash context for
subsequent use.
If Shake256Context is NULL, then return FALSE.
@param[out] Shake256Context Pointer to SHAKE256 context being initialized.
@retval TRUE SHAKE256 context initialization succeeded.
@retval FALSE SHAKE256 context initialization failed.
**/
BOOLEAN
EFIAPI
Shake256Init (
OUT VOID *Shake256Context
);
/**
Makes a copy of an existing SHAKE256 context.
If Shake256Context is NULL, then return FALSE.
If NewShake256Context is NULL, then return FALSE.
If this interface is not supported, then return FALSE.
@param[in] Shake256Context Pointer to SHAKE256 context being copied.
@param[out] NewShake256Context Pointer to new SHAKE256 context.
@retval TRUE SHAKE256 context copy succeeded.
@retval FALSE SHAKE256 context copy failed.
@retval FALSE This interface is not supported.
**/
BOOLEAN
EFIAPI
Shake256Duplicate (
IN CONST VOID *Shake256Context,
OUT VOID *NewShake256Context
);
/**