TianoCore EDK2 master
Loading...
Searching...
No Matches
CryptlibWrapper.c
Go to the documentation of this file.
1
9#include <Library/BaseLib.h>
10#include <Library/DebugLib.h>
14#include "hal/base.h"
15#include "hal/library/cryptlib.h"
16
17void *
18libspdm_sha256_new (
19 void
20 )
21{
22 size_t CtxSize;
23 void *HashCtx;
24
25 HashCtx = NULL;
26 CtxSize = Sha256GetContextSize ();
27 HashCtx = AllocatePool (CtxSize);
28
29 return HashCtx;
30}
31
32void
33libspdm_sha256_free (
34 void *Sha256Ctx
35 )
36{
37 if (Sha256Ctx != NULL) {
38 FreePool (Sha256Ctx);
39 Sha256Ctx = NULL;
40 }
41}
42
43bool
44libspdm_sha256_init (
45 void *Sha256Ctx
46 )
47{
48 return Sha256Init (Sha256Ctx);
49}
50
51bool
52libspdm_sha256_duplicate (
53 const void *Sha256Context,
54 void *NewSha256Context
55 )
56{
57 return Sha256Duplicate (Sha256Context, NewSha256Context);
58}
59
60bool
61libspdm_sha256_update (
62 void *Sha256Context,
63 const void *Data,
64 size_t DataSize
65 )
66{
67 return Sha256Update (Sha256Context, Data, DataSize);
68}
69
70bool
71libspdm_sha256_final (
72 void *sha256_context,
73 uint8_t *hash_value
74 )
75{
76 return Sha256Final (sha256_context, hash_value);
77}
78
79bool
80libspdm_sha256_hash_all (
81 const void *data,
82 size_t data_size,
83 uint8_t *hash_value
84 )
85{
86 return Sha256HashAll (data, data_size, hash_value);
87}
88
89void *
90libspdm_sha384_new (
91 void
92 )
93{
94 size_t CtxSize;
95 void *HashCtx;
96
97 HashCtx = NULL;
98 CtxSize = Sha384GetContextSize ();
99 HashCtx = AllocatePool (CtxSize);
100
101 return HashCtx;
102}
103
104void
105libspdm_sha384_free (
106 void *Sha384Ctx
107 )
108{
109 if (Sha384Ctx != NULL) {
110 FreePool (Sha384Ctx);
111 Sha384Ctx = NULL;
112 }
113}
114
115bool
116libspdm_sha384_init (
117 void *sha384_context
118 )
119{
120 return Sha384Init (sha384_context);
121}
122
123bool
124libspdm_sha384_duplicate (
125 const void *sha384_context,
126 void *new_sha384_context
127 )
128{
129 return Sha384Duplicate (sha384_context, new_sha384_context);
130}
131
132bool
133libspdm_sha384_update (
134 void *sha384_context,
135 const void *data,
136 size_t data_size
137 )
138{
139 return Sha384Update (sha384_context, data, data_size);
140}
141
142bool
143libspdm_sha384_final (
144 void *sha384_context,
145 uint8_t *hash_value
146 )
147{
148 return Sha384Final (sha384_context, hash_value);
149}
150
151bool
152libspdm_sha384_hash_all (
153 const void *data,
154 size_t data_size,
155 uint8_t *hash_value
156 )
157{
158 return Sha384HashAll (data, data_size, hash_value);
159}
160
161void *
162libspdm_hmac_sha256_new (
163 void
164 )
165{
166 return HmacSha256New ();
167}
168
169void
170libspdm_hmac_sha256_free (
171 void *hmac_sha256_ctx
172 )
173{
174 HmacSha256Free (hmac_sha256_ctx);
175}
176
177bool
178libspdm_hmac_sha256_set_key (
179 void *hmac_sha256_ctx,
180 const uint8_t *key,
181 size_t key_size
182 )
183{
184 return HmacSha256SetKey (hmac_sha256_ctx, key, key_size);
185}
186
187bool
188libspdm_hmac_sha256_duplicate (
189 const void *hmac_sha256_ctx,
190 void *new_hmac_sha256_ctx
191 )
192{
193 return HmacSha256Duplicate (hmac_sha256_ctx, new_hmac_sha256_ctx);
194}
195
196bool
197libspdm_hmac_sha256_update (
198 void *hmac_sha256_ctx,
199 const void *data,
200 size_t data_size
201 )
202{
203 return HmacSha256Update (hmac_sha256_ctx, data, data_size);
204}
205
206bool
207libspdm_hmac_sha256_final (
208 void *hmac_sha256_ctx,
209 uint8_t *hmac_value
210 )
211{
212 return HmacSha256Final (hmac_sha256_ctx, hmac_value);
213}
214
215bool
216libspdm_hmac_sha256_all (
217 const void *data,
218 size_t data_size,
219 const uint8_t *key,
220 size_t key_size,
221 uint8_t *hmac_value
222 )
223{
224 return HmacSha256All (data, data_size, key, key_size, hmac_value);
225}
226
227void *
228libspdm_hmac_sha384_new (
229 void
230 )
231{
232 return HmacSha384New ();
233}
234
235void
236libspdm_hmac_sha384_free (
237 void *hmac_sha384_ctx
238 )
239{
240 HmacSha384Free (hmac_sha384_ctx);
241}
242
243bool
244libspdm_hmac_sha384_set_key (
245 void *hmac_sha384_ctx,
246 const uint8_t *key,
247 size_t key_size
248 )
249{
250 return HmacSha384SetKey (hmac_sha384_ctx, key, key_size);
251}
252
253bool
254libspdm_hmac_sha384_duplicate (
255 const void *hmac_sha384_ctx,
256 void *new_hmac_sha384_ctx
257 )
258{
259 return HmacSha384Duplicate (hmac_sha384_ctx, new_hmac_sha384_ctx);
260}
261
262bool
263libspdm_hmac_sha384_update (
264 void *hmac_sha384_ctx,
265 const void *data,
266 size_t data_size
267 )
268{
269 return HmacSha384Update (hmac_sha384_ctx, data, data_size);
270}
271
272bool
273libspdm_hmac_sha384_final (
274 void *hmac_sha384_ctx,
275 uint8_t *hmac_value
276 )
277{
278 return HmacSha384Final (hmac_sha384_ctx, hmac_value);
279}
280
281bool
282libspdm_hmac_sha384_all (
283 const void *data,
284 size_t data_size,
285 const uint8_t *key,
286 size_t key_size,
287 uint8_t *hmac_value
288 )
289{
290 return HmacSha384All (data, data_size, key, key_size, hmac_value);
291}
292
293bool
294libspdm_aead_aes_gcm_encrypt (
295 const uint8_t *key,
296 size_t key_size,
297 const uint8_t *iv,
298 size_t iv_size,
299 const uint8_t *a_data,
300 size_t a_data_size,
301 const uint8_t *data_in,
302 size_t data_in_size,
303 uint8_t *tag_out,
304 size_t tag_size,
305 uint8_t *data_out,
306 size_t *data_out_size
307 )
308{
309 return AeadAesGcmEncrypt (
310 key,
311 key_size,
312 iv,
313 iv_size,
314 a_data,
315 a_data_size,
316 data_in,
317 data_in_size,
318 tag_out,
319 tag_size,
320 data_out,
321 data_out_size
322 );
323}
324
325bool
326libspdm_aead_aes_gcm_decrypt (
327 const uint8_t *key,
328 size_t key_size,
329 const uint8_t *iv,
330 size_t iv_size,
331 const uint8_t *a_data,
332 size_t a_data_size,
333 const uint8_t *data_in,
334 size_t data_in_size,
335 const uint8_t *tag,
336 size_t tag_size,
337 uint8_t *data_out,
338 size_t *data_out_size
339 )
340{
341 return AeadAesGcmDecrypt (
342 key,
343 key_size,
344 iv,
345 iv_size,
346 a_data,
347 a_data_size,
348 data_in,
349 data_in_size,
350 tag,
351 tag_size,
352 data_out,
353 data_out_size
354 );
355}
356
357void
358libspdm_rsa_free (
359 void *rsa_context
360 )
361{
362 RsaFree (rsa_context);
363}
364
365bool
366libspdm_rsa_pkcs1_sign_with_nid (
367 void *rsa_context,
368 size_t hash_nid,
369 const uint8_t *message_hash,
370 size_t hash_size,
371 uint8_t *signature,
372 size_t *sig_size
373 )
374{
375 switch (hash_nid) {
376 case CRYPTO_NID_SHA256:
377 if (hash_size != SHA256_DIGEST_SIZE) {
378 return FALSE;
379 }
380
381 break;
382
383 case CRYPTO_NID_SHA384:
384 if (hash_size != SHA384_DIGEST_SIZE) {
385 return FALSE;
386 }
387
388 break;
389
390 case CRYPTO_NID_SHA512:
391 if (hash_size != SHA512_DIGEST_SIZE) {
392 return FALSE;
393 }
394
395 break;
396
397 default:
398 return FALSE;
399 }
400
401 return RsaPkcs1Sign (
402 rsa_context,
403 message_hash,
404 hash_size,
405 signature,
406 sig_size
407 );
408}
409
410bool
411libspdm_rsa_pkcs1_verify_with_nid (
412 void *rsa_context,
413 size_t hash_nid,
414 const uint8_t *message_hash,
415 size_t hash_size,
416 const uint8_t *signature,
417 size_t sig_size
418 )
419{
420 switch (hash_nid) {
421 case CRYPTO_NID_SHA256:
422 if (hash_size != SHA256_DIGEST_SIZE) {
423 return false;
424 }
425
426 break;
427
428 case CRYPTO_NID_SHA384:
429 if (hash_size != SHA384_DIGEST_SIZE) {
430 return false;
431 }
432
433 break;
434
435 case CRYPTO_NID_SHA512:
436 if (hash_size != SHA512_DIGEST_SIZE) {
437 return false;
438 }
439
440 break;
441
442 default:
443 return false;
444 }
445
446 return RsaPkcs1Verify (
447 rsa_context,
448 message_hash,
449 hash_size,
450 signature,
451 sig_size
452 );
453}
454
455bool
456libspdm_rsa_get_private_key_from_pem (
457 const uint8_t *pem_data,
458 size_t pem_size,
459 const char *password,
460 void **rsa_context
461 )
462{
463 return RsaGetPrivateKeyFromPem (pem_data, pem_size, password, rsa_context);
464}
465
466bool
467libspdm_rsa_get_public_key_from_x509 (
468 const uint8_t *cert,
469 size_t cert_size,
470 void **rsa_context
471 )
472{
473 return RsaGetPublicKeyFromX509 (cert, cert_size, rsa_context);
474}
475
476bool
477libspdm_ec_get_public_key_from_der (
478 const uint8_t *der_data,
479 size_t der_size,
480 void **ec_context
481 )
482{
483 return false;
484}
485
486bool
487libspdm_rsa_get_public_key_from_der (
488 const uint8_t *der_data,
489 size_t der_size,
490 void **rsa_context
491 )
492{
493 return false;
494}
495
496bool
497libspdm_ec_get_private_key_from_pem (
498 const uint8_t *pem_data,
499 size_t pem_size,
500 const char *password,
501 void **ec_context
502 )
503{
504 return EcGetPrivateKeyFromPem (pem_data, pem_size, password, ec_context);
505}
506
507bool
508libspdm_ec_get_public_key_from_x509 (
509 const uint8_t *cert,
510 size_t cert_size,
511 void **ec_context
512 )
513{
514 return EcGetPublicKeyFromX509 (cert, cert_size, ec_context);
515}
516
517bool
518libspdm_asn1_get_tag (
519 uint8_t **ptr,
520 const uint8_t *end,
521 size_t *length,
522 uint32_t tag
523 )
524{
525 return Asn1GetTag (ptr, end, length, tag);
526}
527
528bool
529libspdm_x509_get_subject_name (
530 const uint8_t *cert,
531 size_t cert_size,
532 uint8_t *cert_subject,
533 size_t *subject_size
534 )
535{
536 return X509GetSubjectName (cert, cert_size, cert_subject, subject_size);
537}
538
539bool
540libspdm_x509_get_common_name (
541 const uint8_t *cert,
542 size_t cert_size,
543 char *common_name,
544 size_t *common_name_size
545 )
546{
547 EFI_STATUS Status;
548
549 Status = X509GetCommonName (cert, cert_size, common_name, common_name_size);
550 if (EFI_ERROR (Status)) {
551 return false;
552 } else {
553 return true;
554 }
555}
556
557bool
558libspdm_x509_get_organization_name (
559 const uint8_t *cert,
560 size_t cert_size,
561 char *name_buffer,
562 size_t *name_buffer_size
563 )
564{
565 EFI_STATUS Status;
566
567 Status = X509GetOrganizationName (cert, cert_size, name_buffer, name_buffer_size);
568 if (EFI_ERROR (Status)) {
569 return false;
570 } else {
571 return true;
572 }
573}
574
575bool
576libspdm_x509_get_version (
577 const uint8_t *cert,
578 size_t cert_size,
579 size_t *version
580 )
581{
582 return X509GetVersion (cert, cert_size, version);
583}
584
585bool
586libspdm_x509_get_serial_number (
587 const uint8_t *cert,
588 size_t cert_size,
589 uint8_t *serial_number,
590 size_t *serial_number_size
591 )
592{
593 return X509GetSerialNumber (cert, cert_size, serial_number, serial_number_size);
594}
595
596bool
597libspdm_x509_get_issuer_name (
598 const uint8_t *cert,
599 size_t cert_size,
600 uint8_t *cert_issuer,
601 size_t *issuer_size
602 )
603{
604 return X509GetIssuerName (cert, cert_size, cert_issuer, issuer_size);
605}
606
607bool
608libspdm_x509_get_signature_algorithm (
609 const uint8_t *cert,
610 size_t cert_size,
611 uint8_t *oid,
612 size_t *oid_size
613 )
614{
615 return X509GetSignatureAlgorithm (cert, cert_size, oid, oid_size);
616}
617
618bool
619libspdm_x509_get_extension_data (
620 const uint8_t *cert,
621 size_t cert_size,
622 const uint8_t *oid,
623 size_t oid_size,
624 uint8_t *extension_data,
625 size_t *extension_data_size
626 )
627{
628 return X509GetExtensionData (
629 cert,
630 cert_size,
631 oid,
632 oid_size,
633 extension_data,
634 extension_data_size
635 );
636}
637
638bool
639libspdm_x509_get_validity (
640 const uint8_t *cert,
641 size_t cert_size,
642 uint8_t *from,
643 size_t *from_size,
644 uint8_t *to,
645 size_t *to_size
646 )
647{
648 return X509GetValidity (cert, cert_size, from, from_size, to, to_size);
649}
650
651bool
652libspdm_x509_set_date_time (
653 const char *date_time_str,
654 void *date_time,
655 size_t *date_time_size
656 )
657{
658 return X509FormatDateTime (date_time_str, date_time, date_time_size);
659}
660
661int32_t
662libspdm_x509_compare_date_time (
663 const void *date_time1,
664 const void *date_time2
665 )
666{
667 return X509CompareDateTime (date_time1, date_time2);
668}
669
670bool
671libspdm_x509_get_key_usage (
672 const uint8_t *cert,
673 size_t cert_size,
674 size_t *usage
675 )
676{
677 return X509GetKeyUsage (cert, cert_size, usage);
678}
679
680bool
681libspdm_x509_get_extended_key_usage (
682 const uint8_t *cert,
683 size_t cert_size,
684 uint8_t *usage,
685 size_t *usage_size
686 )
687{
688 return X509GetExtendedKeyUsage (cert, cert_size, usage, usage_size);
689}
690
691bool
692libspdm_x509_verify_cert (
693 const uint8_t *cert,
694 size_t cert_size,
695 const uint8_t *ca_cert,
696 size_t ca_cert_size
697 )
698{
699 return X509VerifyCert (cert, cert_size, ca_cert, ca_cert_size);
700}
701
702bool
703libspdm_x509_verify_cert_chain (
704 const uint8_t *root_cert,
705 size_t root_cert_length,
706 const uint8_t *cert_chain,
707 size_t cert_chain_length
708 )
709{
710 return X509VerifyCertChain (root_cert, root_cert_length, cert_chain, cert_chain_length);
711}
712
713bool
714libspdm_x509_get_cert_from_cert_chain (
715 const uint8_t *cert_chain,
716 size_t cert_chain_length,
717 const int32_t cert_index,
718 const uint8_t **cert,
719 size_t *cert_length
720 )
721{
723 cert_chain,
724 cert_chain_length,
725 cert_index,
726 cert,
727 cert_length
728 );
729}
730
731bool
732libspdm_x509_construct_certificate (
733 const uint8_t *cert,
734 size_t cert_size,
735 uint8_t **single_x509_cert
736 )
737{
738 return X509ConstructCertificate (cert, cert_size, single_x509_cert);
739}
740
741bool
742libspdm_x509_get_extended_basic_constraints (
743 const uint8_t *cert,
744 size_t cert_size,
745 uint8_t *basic_constraints,
746 size_t *basic_constraints_size
747 )
748{
750 cert,
751 cert_size,
752 basic_constraints,
753 basic_constraints_size
754 );
755}
756
757void *
758libspdm_ec_new_by_nid (
759 size_t nid
760 )
761{
762 return EcNewByNid (nid);
763}
764
765void
766libspdm_ec_free (
767 void *ec_context
768 )
769{
770 EcFree (ec_context);
771}
772
773bool
774libspdm_ec_generate_key (
775 void *ec_context,
776 uint8_t *public_data,
777 size_t *public_size
778 )
779{
780 return EcGenerateKey (ec_context, public_data, public_size);
781}
782
783bool
784libspdm_ec_compute_key (
785 void *ec_context,
786 const uint8_t *peer_public,
787 size_t peer_public_size,
788 uint8_t *key,
789 size_t *key_size
790 )
791{
792 return EcDhComputeKey (ec_context, peer_public, peer_public_size, NULL, key, key_size);
793}
794
795bool
796libspdm_ecdsa_sign (
797 void *ec_context,
798 size_t hash_nid,
799 const uint8_t *message_hash,
800 size_t hash_size,
801 uint8_t *signature,
802 size_t *sig_size
803 )
804{
805 return EcDsaSign (
806 ec_context,
807 hash_nid,
808 message_hash,
809 hash_size,
810 signature,
811 sig_size
812 );
813}
814
815bool
816libspdm_ecdsa_verify (
817 void *ec_context,
818 size_t hash_nid,
819 const uint8_t *message_hash,
820 size_t hash_size,
821 const uint8_t *signature,
822 size_t sig_size
823 )
824{
825 return EcDsaVerify (
826 ec_context,
827 hash_nid,
828 message_hash,
829 hash_size,
830 signature,
831 sig_size
832 );
833}
834
835bool
836libspdm_random_bytes (
837 uint8_t *output,
838 size_t size
839 )
840{
841 return RandomBytes (output, size);
842}
843
844bool
845libspdm_hkdf_sha256_extract_and_expand (
846 const uint8_t *key,
847 size_t key_size,
848 const uint8_t *salt,
849 size_t salt_size,
850 const uint8_t *info,
851 size_t info_size,
852 uint8_t *out,
853 size_t out_size
854 )
855{
857 key,
858 key_size,
859 salt,
860 salt_size,
861 info,
862 info_size,
863 out,
864 out_size
865 );
866}
867
868bool
869libspdm_hkdf_sha256_extract (
870 const uint8_t *key,
871 size_t key_size,
872 const uint8_t *salt,
873 size_t salt_size,
874 uint8_t *prk_out,
875 size_t prk_out_size
876 )
877{
878 return HkdfSha256Extract (
879 key,
880 key_size,
881 salt,
882 salt_size,
883 prk_out,
884 prk_out_size
885 );
886}
887
888bool
889libspdm_hkdf_sha256_expand (
890 const uint8_t *prk,
891 size_t prk_size,
892 const uint8_t *info,
893 size_t info_size,
894 uint8_t *out,
895 size_t out_size
896 )
897{
898 return HkdfSha256Expand (
899 prk,
900 prk_size,
901 info,
902 info_size,
903 out,
904 out_size
905 );
906}
907
908bool
909libspdm_hkdf_sha384_extract_and_expand (
910 const uint8_t *key,
911 size_t key_size,
912 const uint8_t *salt,
913 size_t salt_size,
914 const uint8_t *info,
915 size_t info_size,
916 uint8_t *out,
917 size_t out_size
918 )
919{
921 key,
922 key_size,
923 salt,
924 salt_size,
925 info,
926 info_size,
927 out,
928 out_size
929 );
930}
931
932bool
933libspdm_hkdf_sha384_extract (
934 const uint8_t *key,
935 size_t key_size,
936 const uint8_t *salt,
937 size_t salt_size,
938 uint8_t *prk_out,
939 size_t prk_out_size
940 )
941{
942 return HkdfSha384Extract (
943 key,
944 key_size,
945 salt,
946 salt_size,
947 prk_out,
948 prk_out_size
949 );
950}
951
952bool
953libspdm_hkdf_sha384_expand (
954 const uint8_t *prk,
955 size_t prk_size,
956 const uint8_t *info,
957 size_t info_size,
958 uint8_t *out,
959 size_t out_size
960 )
961{
962 return HkdfSha384Expand (
963 prk,
964 prk_size,
965 info,
966 info_size,
967 out,
968 out_size
969 );
970}
BOOLEAN EFIAPI X509GetSerialNumber(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *SerialNumber, OPTIONAL IN OUT UINTN *SerialNumberSize)
Definition: CryptX509.c:1011
BOOLEAN EFIAPI HmacSha384Update(IN OUT VOID *HmacSha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptHmac.c:564
INT32 EFIAPI X509CompareDateTime(IN CONST VOID *DateTime1, IN CONST VOID *DateTime2)
Definition: CryptX509.c:1618
UINTN EFIAPI Sha256GetContextSize(VOID)
Definition: CryptSha256.c:20
BOOLEAN EFIAPI HmacSha384SetKey(OUT VOID *HmacSha384Context, IN CONST UINT8 *Key, IN UINTN KeySize)
Definition: CryptHmac.c:508
BOOLEAN EFIAPI HkdfSha256Extract(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, UINTN PrkOutSize)
Definition: CryptHkdf.c:279
BOOLEAN EFIAPI EcGenerateKey(IN OUT VOID *EcContext, OUT UINT8 *PublicKey, IN OUT UINTN *PublicKeySize)
Definition: CryptEc.c:475
VOID *EFIAPI HmacSha256New(VOID)
Definition: CryptHmac.c:297
UINTN EFIAPI Sha384GetContextSize(VOID)
Definition: CryptSha512.c:20
BOOLEAN EFIAPI HmacSha256Duplicate(IN CONST VOID *HmacSha256Context, OUT VOID *NewHmacSha256Context)
Definition: CryptHmac.c:359
VOID *EFIAPI HmacSha384New(VOID)
Definition: CryptHmac.c:468
BOOLEAN EFIAPI X509GetVersion(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Version)
Definition: CryptX509.c:957
BOOLEAN EFIAPI X509GetExtensionData(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CONST UINT8 *Oid, IN UINTN OidSize, OUT UINT8 *ExtensionData, IN OUT UINTN *ExtensionDataSize)
Definition: CryptX509.c:1274
BOOLEAN EFIAPI Sha384Duplicate(IN CONST VOID *Sha384Context, OUT VOID *NewSha384Context)
Definition: CryptSha512.c:78
BOOLEAN EFIAPI HmacSha384All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
Definition: CryptHmac.c:627
BOOLEAN EFIAPI X509GetIssuerName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertIssuer, IN OUT UINTN *CertIssuerSize)
Definition: CryptX509.c:1097
BOOLEAN EFIAPI AeadAesGcmDecrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, IN CONST UINT8 *Tag, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)
BOOLEAN EFIAPI RsaGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **RsaContext)
Definition: CryptPem.c:66
BOOLEAN EFIAPI EcDsaSign(IN VOID *EcContext, IN UINTN HashNid, IN CONST UINT8 *MessageHash, IN UINTN HashSize, OUT UINT8 *Signature, IN OUT UINTN *SigSize)
Definition: CryptEc.c:801
VOID EFIAPI HmacSha384Free(IN VOID *HmacSha384Ctx)
Definition: CryptHmac.c:483
BOOLEAN EFIAPI X509FormatDateTime(IN CONST CHAR8 *DateTimeStr, OUT VOID *DateTime, IN OUT UINTN *DateTimeSize)
Definition: CryptX509.c:1550
BOOLEAN EFIAPI X509VerifyCert(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CONST UINT8 *CACert, IN UINTN CACertSize)
Definition: CryptX509.c:659
VOID EFIAPI HmacSha256Free(IN VOID *HmacSha256Ctx)
Definition: CryptHmac.c:312
BOOLEAN EFIAPI HmacSha384Duplicate(IN CONST VOID *HmacSha384Context, OUT VOID *NewHmacSha384Context)
Definition: CryptHmac.c:534
BOOLEAN EFIAPI RandomBytes(OUT UINT8 *Output, IN UINTN Size)
Definition: CryptRand.c:76
#define SHA512_DIGEST_SIZE
Definition: BaseCryptLib.h:54
BOOLEAN EFIAPI Sha256Init(OUT VOID *Sha256Context)
Definition: CryptSha256.c:44
BOOLEAN EFIAPI X509GetSignatureAlgorithm(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Oid, OPTIONAL IN OUT UINTN *OidSize)
Definition: CryptX509.c:1180
BOOLEAN EFIAPI RsaGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **RsaContext)
Definition: CryptX509.c:580
RETURN_STATUS EFIAPI X509GetOrganizationName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *NameBuffer OPTIONAL, IN OUT UINTN *NameBufferSize)
Definition: CryptX509.c:552
BOOLEAN EFIAPI X509GetExtendedKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Usage, IN OUT UINTN *UsageSize)
Definition: CryptX509.c:1406
BOOLEAN EFIAPI Sha384HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha512.c:201
VOID *EFIAPI EcNewByNid(IN UINTN Nid)
Definition: CryptEc.c:419
BOOLEAN EFIAPI Sha256Final(IN OUT VOID *Sha256Context, OUT UINT8 *HashValue)
Definition: CryptSha256.c:161
#define SHA256_DIGEST_SIZE
Definition: BaseCryptLib.h:44
BOOLEAN EFIAPI HkdfSha384ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
Definition: CryptHkdf.c:345
BOOLEAN EFIAPI X509GetValidity(IN CONST UINT8 *Cert, IN UINTN CertSize, IN UINT8 *From, IN OUT UINTN *FromSize, IN UINT8 *To, IN OUT UINTN *ToSize)
Definition: CryptX509.c:1442
BOOLEAN EFIAPI HmacSha384Final(IN OUT VOID *HmacSha384Context, OUT UINT8 *HmacValue)
Definition: CryptHmac.c:597
BOOLEAN EFIAPI Sha384Update(IN OUT VOID *Sha384Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha512.c:115
BOOLEAN EFIAPI Sha256Duplicate(IN CONST VOID *Sha256Context, OUT VOID *NewSha256Context)
Definition: CryptSha256.c:76
BOOLEAN EFIAPI HmacSha256SetKey(OUT VOID *HmacSha256Context, IN CONST UINT8 *Key, IN UINTN KeySize)
Definition: CryptHmac.c:335
BOOLEAN EFIAPI EcGetPrivateKeyFromPem(IN CONST UINT8 *PemData, IN UINTN PemSize, IN CONST CHAR8 *Password, OUT VOID **EcContext)
Definition: CryptPem.c:149
BOOLEAN EFIAPI HmacSha256Update(IN OUT VOID *HmacSha256Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptHmac.c:387
BOOLEAN EFIAPI HkdfSha384Extract(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, OUT UINT8 *PrkOut, UINTN PrkOutSize)
Definition: CryptHkdf.c:375
BOOLEAN EFIAPI Sha256HashAll(IN CONST VOID *Data, IN UINTN DataSize, OUT UINT8 *HashValue)
Definition: CryptSha256.c:199
BOOLEAN EFIAPI Asn1GetTag(IN OUT UINT8 **Ptr, IN CONST UINT8 *End, OUT UINTN *Length, IN UINT32 Tag)
Definition: CryptX509.c:1884
BOOLEAN EFIAPI Sha256Update(IN OUT VOID *Sha256Context, IN CONST VOID *Data, IN UINTN DataSize)
Definition: CryptSha256.c:113
BOOLEAN EFIAPI HmacSha256All(IN CONST VOID *Data, IN UINTN DataSize, IN CONST UINT8 *Key, IN UINTN KeySize, OUT UINT8 *HmacValue)
Definition: CryptHmac.c:448
BOOLEAN EFIAPI EcGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **EcContext)
Definition: CryptX509.c:878
BOOLEAN EFIAPI HkdfSha256Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
Definition: CryptHkdf.c:315
VOID EFIAPI RsaFree(IN VOID *RsaContext)
Definition: CryptRsaBasic.c:48
BOOLEAN EFIAPI HkdfSha256ExtractAndExpand(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Salt, IN UINTN SaltSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
Definition: CryptHkdf.c:249
BOOLEAN EFIAPI EcDsaVerify(IN VOID *EcContext, IN UINTN HashNid, IN CONST UINT8 *MessageHash, IN UINTN HashSize, IN CONST UINT8 *Signature, IN UINTN SigSize)
Definition: CryptEc.c:933
BOOLEAN EFIAPI Sha384Final(IN OUT VOID *Sha384Context, OUT UINT8 *HashValue)
Definition: CryptSha512.c:163
BOOLEAN EFIAPI X509GetCertFromCertChain(IN CONST UINT8 *CertChain, IN UINTN CertChainLength, IN CONST INT32 CertIndex, OUT CONST UINT8 **Cert, OUT UINTN *CertLength)
Definition: CryptX509.c:1792
BOOLEAN EFIAPI X509GetSubjectName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertSubject, IN OUT UINTN *SubjectSize)
Definition: CryptX509.c:277
BOOLEAN EFIAPI AeadAesGcmEncrypt(IN CONST UINT8 *Key, IN UINTN KeySize, IN CONST UINT8 *Iv, IN UINTN IvSize, IN CONST UINT8 *AData, IN UINTN ADataSize, IN CONST UINT8 *DataIn, IN UINTN DataInSize, OUT UINT8 *TagOut, IN UINTN TagSize, OUT UINT8 *DataOut, OUT UINTN *DataOutSize)
BOOLEAN EFIAPI EcDhComputeKey(IN OUT VOID *EcContext, IN CONST UINT8 *PeerPublic, IN UINTN PeerPublicSize, IN CONST INT32 *CompressFlag, OUT UINT8 *Key, IN OUT UINTN *KeySize)
Definition: CryptEc.c:667
BOOLEAN EFIAPI Sha384Init(OUT VOID *Sha384Context)
Definition: CryptSha512.c:44
BOOLEAN EFIAPI X509GetKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Usage)
Definition: CryptX509.c:1639
BOOLEAN EFIAPI RsaPkcs1Verify(IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, IN CONST UINT8 *Signature, IN UINTN SigSize)
BOOLEAN EFIAPI X509GetExtendedBasicConstraints(CONST UINT8 *Cert, UINTN CertSize, UINT8 *BasicConstraints, UINTN *BasicConstraintsSize)
Definition: CryptX509.c:1938
RETURN_STATUS EFIAPI X509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
Definition: CryptX509.c:514
BOOLEAN EFIAPI HmacSha256Final(IN OUT VOID *HmacSha256Context, OUT UINT8 *HmacValue)
Definition: CryptHmac.c:418
BOOLEAN EFIAPI HkdfSha384Expand(IN CONST UINT8 *Prk, IN UINTN PrkSize, IN CONST UINT8 *Info, IN UINTN InfoSize, OUT UINT8 *Out, IN UINTN OutSize)
Definition: CryptHkdf.c:411
#define SHA384_DIGEST_SIZE
Definition: BaseCryptLib.h:49
BOOLEAN EFIAPI X509VerifyCertChain(IN CONST UINT8 *RootCert, IN UINTN RootCertLength, IN CONST UINT8 *CertChain, IN UINTN CertChainLength)
Definition: CryptX509.c:1705
BOOLEAN EFIAPI X509ConstructCertificate(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **SingleX509Cert)
Definition: CryptX509.c:43
BOOLEAN EFIAPI RsaPkcs1Sign(IN VOID *RsaContext, IN CONST UINT8 *MessageHash, IN UINTN HashSize, OUT UINT8 *Signature, IN OUT UINTN *SigSize)
Definition: CryptRsaExt.c:297
VOID EFIAPI EcFree(IN VOID *EcContext)
Definition: CryptEc.c:440
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29