9#include "InternalCryptLib.h"
10#include <mbedtls/x509.h>
11#include <mbedtls/x509_crt.h>
12#include <mbedtls/rsa.h>
13#include <mbedtls/ecp.h>
14#include <mbedtls/ecdh.h>
15#include <mbedtls/ecdsa.h>
35STATIC mbedtls_x509_crt_profile gCompatProfile =
39 MBEDTLS_X509_ID_FLAG (MBEDTLS_MD_SHA256) |
40 MBEDTLS_X509_ID_FLAG (MBEDTLS_MD_SHA384) |
41 MBEDTLS_X509_ID_FLAG (MBEDTLS_MD_SHA512),
46 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_SECP256R1) |
47 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_SECP384R1) |
48 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_SECP521R1) |
49 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_BP256R1) |
50 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_BP384R1) |
51 MBEDTLS_X509_ID_FLAG (MBEDTLS_ECP_DP_BP512R1) |
75 OUT UINT8 **SingleX509Cert
78 mbedtls_x509_crt *MbedTlsCert;
81 if ((Cert ==
NULL) || (SingleX509Cert ==
NULL) || (CertSize == 0)) {
86 if (MbedTlsCert ==
NULL) {
90 mbedtls_x509_crt_init (MbedTlsCert);
92 *SingleX509Cert = (UINT8 *)(VOID *)MbedTlsCert;
93 Ret = mbedtls_x509_crt_parse_der (MbedTlsCert, Cert, CertSize);
97 mbedtls_x509_crt_free (MbedTlsCert);
125 IN OUT UINT8 **X509Stack,
133 mbedtls_x509_crt *Crt;
135 if (X509Stack ==
NULL) {
141 if (*X509Stack ==
NULL) {
147 mbedtls_x509_crt_init (Crt);
148 *X509Stack = (UINT8 *)Crt;
151 for (Index = 0; ; Index++) {
155 Cert =
VA_ARG (Args, UINT8 *);
165 Ret = mbedtls_x509_crt_parse_der ((mbedtls_x509_crt *)*X509Stack, Cert, CertSize);
176 mbedtls_x509_crt_free (Crt);
204 IN OUT UINT8 **X509Stack,
231 if (X509Cert !=
NULL) {
232 mbedtls_x509_crt_free (X509Cert);
251 if (X509Stack ==
NULL) {
255 mbedtls_x509_crt_free (X509Stack);
278 if (mbedtls_asn1_get_tag (Ptr, End, Length, (INT32)Tag) == 0) {
307 OUT UINT8 *CertSubject,
311 mbedtls_x509_crt Crt;
318 mbedtls_x509_crt_init (&Crt);
320 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
323 if (CertSubject !=
NULL) {
324 CopyMem (CertSubject, Crt.subject_raw.p, Crt.subject_raw.len);
327 *SubjectSize = Crt.subject_raw.len;
330 mbedtls_x509_crt_free (&Crt);
365 IN mbedtls_x509_name *Name,
368 IN OUT CHAR8 *CommonName OPTIONAL,
372 CONST mbedtls_asn1_named_data *data;
374 data = mbedtls_asn1_find_named_data (Name, Oid, OidSize);
376 if (*CommonNameSize <= data->val.len) {
377 *CommonNameSize = data->val.len + 1;
381 if (CommonName !=
NULL) {
382 CopyMem (CommonName, data->val.p, data->val.len);
383 CommonName[data->val.len] =
'\0';
386 *CommonNameSize = data->val.len + 1;
428 IN OUT CHAR8 *CommonName OPTIONAL,
432 mbedtls_x509_crt Crt;
434 mbedtls_x509_name *Name;
435 RETURN_STATUS ReturnStatus;
443 mbedtls_x509_crt_init (&Crt);
445 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
448 Name = &(Crt.subject);
452 mbedtls_x509_crt_free (&Crt);
492 OUT CHAR8 *CommonName OPTIONAL,
496 mbedtls_x509_crt Crt;
498 mbedtls_x509_name *Name;
499 RETURN_STATUS ReturnStatus;
507 mbedtls_x509_crt_init (&Crt);
509 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
512 Name = &(Crt.issuer);
516 mbedtls_x509_crt_free (&Crt);
552 OUT CHAR8 *CommonName OPTIONAL,
590 OUT CHAR8 *NameBuffer OPTIONAL,
594 return InternalX509GetSubjectNIDName (Cert, CertSize, (CHAR8 *)OID_organizationName,
sizeof (OID_organizationName), NameBuffer, NameBufferSize);
618 OUT VOID **RsaContext
621 mbedtls_x509_crt Crt;
622 mbedtls_rsa_context *Rsa;
625 mbedtls_x509_crt_init (&Crt);
627 if (mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize) != 0) {
631 if (mbedtls_pk_get_type (&Crt.pk) != MBEDTLS_PK_RSA) {
632 mbedtls_x509_crt_free (&Crt);
638 mbedtls_x509_crt_free (&Crt);
642 Ret = mbedtls_rsa_copy (Rsa, mbedtls_pk_rsa (Crt.pk));
645 mbedtls_x509_crt_free (&Crt);
649 mbedtls_x509_crt_free (&Crt);
710 mbedtls_x509_crt End;
712 mbedtls_x509_crt_profile Profile;
714 if ((Cert ==
NULL) || (CACert ==
NULL)) {
719 CopyMem (&Profile, &gCompatProfile,
sizeof (mbedtls_x509_crt_profile));
721 mbedtls_x509_crt_init (&Ca);
722 mbedtls_x509_crt_init (&End);
724 Ret = mbedtls_x509_crt_parse_der (&Ca, CACert, CACertSize);
727 Ret = mbedtls_x509_crt_parse_der (&End, Cert, CertSize);
731 Ret = mbedtls_x509_crt_verify_with_profile (&End, &Ca,
NULL, &Profile,
NULL, &VFlag,
NULL,
NULL);
734 mbedtls_x509_crt_free (&Ca);
735 mbedtls_x509_crt_free (&End);
766 UINTN PrecedingCertLen;
767 CONST UINT8 *PrecedingCert;
768 UINTN CurrentCertLen;
769 CONST UINT8 *CurrentCert;
775 PrecedingCert = RootCert;
776 PrecedingCertLen = RootCertLength;
778 CurrentCert = CertChain;
784 TmpPtr = CurrentCert;
785 Ret = mbedtls_asn1_get_tag ((UINT8 **)&TmpPtr, CertChain + CertChainLength, &Asn1Len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
790 CurrentCertLen = Asn1Len + (TmpPtr - CurrentCert);
792 if (!
X509VerifyCert (CurrentCert, CurrentCertLen, PrecedingCert, PrecedingCertLen)) {
802 PrecedingCert = CurrentCert;
803 PrecedingCertLen = CurrentCertLen;
808 CurrentCert = CurrentCert + CurrentCertLen;
844 UINTN CurrentCertLen;
845 CONST UINT8 *CurrentCert;
852 if ((CertChain ==
NULL) || (Cert ==
NULL) ||
853 (CertIndex < -1) || (CertLength ==
NULL))
858 CurrentCert = CertChain;
868 TmpPtr = CurrentCert;
869 Ret = mbedtls_asn1_get_tag ((UINT8 **)&TmpPtr, CertChain + CertChainLength, &Asn1Len, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
874 CurrentCertLen = Asn1Len + (TmpPtr - CurrentCert);
877 if (CurrentIndex == CertIndex) {
879 *CertLength = CurrentCertLen;
886 CurrentCert = CurrentCert + CurrentCertLen;
892 if ((CertIndex == -1) && (CurrentIndex >= 0)) {
893 *Cert = CurrentCert - CurrentCertLen;
894 *CertLength = CurrentCertLen;
935 if ((Cert ==
NULL) || (TBSCert ==
NULL) ||
936 (TBSCertSize ==
NULL) || (CertSize > INT_MAX))
962 End = Cert + CertSize;
964 Ret = mbedtls_asn1_get_tag (&Ptr, End, &Length, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
971 Ret = mbedtls_asn1_get_tag (&Ptr, End, &Length, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
976 *TBSCert = (UINT8 *)Temp;
977 *TBSCertSize = Length + (Ptr - Temp);
1006 mbedtls_x509_crt Crt;
1008 BOOLEAN ReturnStatus;
1014 ReturnStatus =
FALSE;
1016 mbedtls_x509_crt_init (&Crt);
1018 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1021 *Version = Crt.version - 1;
1022 ReturnStatus =
TRUE;
1025 mbedtls_x509_crt_free (&Crt);
1027 return ReturnStatus;
1058 OUT UINT8 *SerialNumber OPTIONAL,
1062 mbedtls_x509_crt Crt;
1064 BOOLEAN ReturnStatus;
1070 ReturnStatus =
FALSE;
1072 mbedtls_x509_crt_init (&Crt);
1074 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1077 if (*SerialNumberSize <= Crt.serial.len) {
1078 *SerialNumberSize = Crt.serial.len + 1;
1079 ReturnStatus =
FALSE;
1083 if (SerialNumber !=
NULL) {
1084 CopyMem (SerialNumber, Crt.serial.p, Crt.serial.len);
1085 SerialNumber[Crt.serial.len] =
'\0';
1088 *SerialNumberSize = Crt.serial.len + 1;
1089 ReturnStatus =
TRUE;
1093 mbedtls_x509_crt_free (&Crt);
1095 return ReturnStatus;
1122 OUT UINT8 *CertIssuer,
1126 mbedtls_x509_crt Crt;
1136 mbedtls_x509_crt_init (&Crt);
1138 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1141 if (*CertIssuerSize < Crt.serial.len) {
1142 *CertIssuerSize = Crt.serial.len;
1147 if (CertIssuer !=
NULL) {
1148 CopyMem (CertIssuer, Crt.serial.p, Crt.serial.len);
1151 *CertIssuerSize = Crt.serial.len;
1156 mbedtls_x509_crt_free (&Crt);
1192 OUT CHAR8 *CommonName OPTIONAL,
1230 OUT CHAR8 *NameBuffer OPTIONAL,
1234 return InternalX509GetIssuerNIDName (Cert, CertSize, (CHAR8 *)OID_organizationName,
sizeof (OID_organizationName), NameBuffer, NameBufferSize);
1260 OUT UINT8 *Oid OPTIONAL,
1264 mbedtls_x509_crt Crt;
1266 BOOLEAN ReturnStatus;
1268 if ((Cert ==
NULL) || (CertSize == 0) || (OidSize ==
NULL)) {
1272 ReturnStatus =
FALSE;
1274 mbedtls_x509_crt_init (&Crt);
1276 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1279 if (*OidSize < Crt.sig_oid.len) {
1280 *OidSize = Crt.serial.len;
1281 ReturnStatus =
FALSE;
1286 CopyMem (Oid, Crt.sig_oid.p, Crt.sig_oid.len);
1289 *OidSize = Crt.sig_oid.len;
1290 ReturnStatus =
TRUE;
1294 mbedtls_x509_crt_free (&Crt);
1296 return ReturnStatus;
1317 UINT8 **FindExtensionData,
1318 UINTN *FindExtensionDataLen
1322 UINT8 *ExtensionPtr;
1325 RETURN_STATUS ReturnStatus;
1326 size_t FindExtensionLen;
1342 Ret = mbedtls_asn1_get_tag (&Ptr, End, &ObjLen, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
1344 HeaderLen = (size_t)(Ptr - ExtensionPtr);
1345 FindExtensionLen = ObjLen;
1347 Ret = mbedtls_asn1_get_tag (&Ptr, End, &ObjLen, MBEDTLS_ASN1_OID);
1352 if ((Ret == 0) && (
CompareMem (Ptr, Oid, OidSize) == 0)) {
1355 Ret = mbedtls_asn1_get_tag (&Ptr, End, &ObjLen, MBEDTLS_ASN1_BOOLEAN);
1360 Ret = mbedtls_asn1_get_tag (&Ptr, End, &ObjLen, MBEDTLS_ASN1_OCTET_STRING);
1366 *FindExtensionData = Ptr;
1367 *FindExtensionDataLen = ObjLen;
1373 Ptr = ExtensionPtr + HeaderLen + FindExtensionLen;
1377 return ReturnStatus;
1407 OUT UINT8 *ExtensionData,
1411 mbedtls_x509_crt Crt;
1413 RETURN_STATUS ReturnStatus;
1419 if ((Cert ==
NULL) ||
1423 (ExtensionDataSize ==
NULL))
1431 mbedtls_x509_crt_init (&Crt);
1433 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1437 End = Crt.v3_ext.p + Crt.v3_ext.len;
1438 Ret = mbedtls_asn1_get_tag (&Ptr, End, &ObjLen, MBEDTLS_ASN1_CONSTRUCTED | MBEDTLS_ASN1_SEQUENCE);
1446 if (*ExtensionDataSize < ObjLen) {
1447 *ExtensionDataSize = ObjLen;
1453 CopyMem (ExtensionData, Ptr, ObjLen);
1456 *ExtensionDataSize = ObjLen;
1461 mbedtls_x509_crt_free (&Crt);
1498 mbedtls_x509_crt Crt;
1510 mbedtls_x509_crt_init (&Crt);
1512 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1515 FSize =
sizeof (mbedtls_x509_time);
1516 if (*FromSize < FSize) {
1523 CopyMem (From, &(Crt.valid_from), FSize);
1526 TSize =
sizeof (mbedtls_x509_time);
1527 if (*ToSize < TSize) {
1534 CopyMem (To, &(Crt.valid_to), sizeof (mbedtls_x509_time));
1541 mbedtls_x509_crt_free (&Crt);
1565 mbedtls_x509_crt Crt;
1575 mbedtls_x509_crt_init (&Crt);
1577 Ret = mbedtls_x509_crt_parse_der (&Crt, Cert, CertSize);
1580 *Usage = Crt.key_usage;
1584 mbedtls_x509_crt_free (&Crt);
1615 BOOLEAN ReturnStatus;
1617 if ((Cert ==
NULL) || (CertSize == 0) || (UsageSize ==
NULL)) {
1621 ReturnStatus =
X509GetExtensionData ((UINT8 *)Cert, CertSize, (UINT8 *)OID_extKeyUsage,
sizeof (OID_extKeyUsage), Usage, UsageSize);
1623 return ReturnStatus;
1638 CONST mbedtls_x509_time *Before,
1639 CONST mbedtls_x509_time *After
1642 if (Before->year > After->year) {
1646 if ((Before->year == After->year) &&
1647 (Before->mon > After->mon))
1652 if ((Before->year == After->year) &&
1653 (Before->mon == After->mon) &&
1654 (Before->day > After->day))
1659 if ((Before->year == After->year) &&
1660 (Before->mon == After->mon) &&
1661 (Before->day == After->day) &&
1662 (Before->hour > After->hour))
1667 if ((Before->year == After->year) &&
1668 (Before->mon == After->mon) &&
1669 (Before->day == After->day) &&
1670 (Before->hour == After->hour) &&
1671 (Before->min > After->min))
1676 if ((Before->year == After->year) &&
1677 (Before->mon == After->mon) &&
1678 (Before->day == After->day) &&
1679 (Before->hour == After->hour) &&
1680 (Before->min == After->min) &&
1681 (Before->sec > After->sec))
1710 while (Ptr < PEnd) {
1714 Knum = (Knum << 3) + (Knum << 1) + (*Ptr) -
'0';
1748 IN OUT VOID *DateTime,
1752 mbedtls_x509_time Dt;
1760 RETURN_STATUS ReturnStatus;
1777 Dt.year = (int)Year;
1778 Dt.mon = (int)Month;
1780 Dt.hour = (int)Hour;
1781 Dt.min = (int)Minute;
1782 Dt.sec = (int)Second;
1784 if (*DateTimeSize <
sizeof (mbedtls_x509_time)) {
1785 *DateTimeSize =
sizeof (mbedtls_x509_time);
1790 if (DateTime !=
NULL) {
1791 CopyMem (DateTime, &Dt,
sizeof (mbedtls_x509_time));
1794 *DateTimeSize =
sizeof (mbedtls_x509_time);
1797 return ReturnStatus;
1823 if ((DateTime1 ==
NULL) || (DateTime2 ==
NULL)) {
1827 if (
CompareMem (DateTime2, DateTime1,
sizeof (mbedtls_x509_time)) == 0) {
1861 UINT8 *BasicConstraints,
1862 UINTN *BasicConstraintsSize
1867 if ((Cert ==
NULL) || (CertSize == 0) || (BasicConstraintsSize ==
NULL)) {
1874 OID_BasicConstraints,
1875 sizeof (OID_BasicConstraints),
1877 BasicConstraintsSize
1914 mbedtls_x509_time *Tm;
1916 if (*DateTimeSize <
sizeof (mbedtls_x509_time)) {
1920 if (DateTime ==
NULL) {
1924 Tm = (mbedtls_x509_time *)DateTime;
1926 Tm->year = (DateTimeStr[0] +
'0') * 1000 + (DateTimeStr[1] +
'0') * 100 +
1927 (DateTimeStr[2] +
'0') * 10 + (DateTimeStr[3] +
'0') * 1;
1929 Tm->mon = (DateTimeStr[4] +
'0') * 10 + (DateTimeStr[5] +
'0') * 1;
1931 Tm->day = (DateTimeStr[6] +
'0') * 10 + (DateTimeStr[7] +
'0') * 1;
1933 Tm->hour = (DateTimeStr[8] +
'0') * 10 + (DateTimeStr[9] +
'0') * 1;
1935 Tm->min = (DateTimeStr[10] +
'0') * 10 + (DateTimeStr[11] +
'0') * 1;
1937 Tm->sec = (DateTimeStr[12] +
'0') * 10 + (DateTimeStr[13] +
'0') * 1;
VOID *EFIAPI RsaNew(VOID)
VOID EFIAPI RsaFree(IN VOID *RsaContext)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define RETURN_BUFFER_TOO_SMALL
#define VA_ARG(Marker, TYPE)
#define VA_START(Marker, Parameter)
#define RETURN_INVALID_PARAMETER
BOOLEAN EFIAPI X509GetSerialNumber(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *SerialNumber, OPTIONAL IN OUT UINTN *SerialNumberSize)
INT32 EFIAPI X509CompareDateTime(IN CONST VOID *DateTime1, IN CONST VOID *DateTime2)
BOOLEAN EFIAPI X509GetVersion(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Version)
BOOLEAN EFIAPI X509GetExtensionData(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CONST UINT8 *Oid, IN UINTN OidSize, OUT UINT8 *ExtensionData, IN OUT UINTN *ExtensionDataSize)
BOOLEAN EFIAPI X509ConstructCertificateStack(IN OUT UINT8 **X509Stack,...)
BOOLEAN EFIAPI X509GetIssuerName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertIssuer, IN OUT UINTN *CertIssuerSize)
STATIC RETURN_STATUS InternalX509GetNIDName(IN CONST UINT8 *Cert, IN UINTN CertSize, IN INT32 Request_NID, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
BOOLEAN EFIAPI X509FormatDateTime(IN CONST CHAR8 *DateTimeStr, OUT VOID *DateTime, IN OUT UINTN *DateTimeSize)
BOOLEAN EFIAPI X509VerifyCert(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CONST UINT8 *CACert, IN UINTN CACertSize)
BOOLEAN EFIAPI X509GetSignatureAlgorithm(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Oid, OPTIONAL IN OUT UINTN *OidSize)
BOOLEAN EFIAPI RsaGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **RsaContext)
RETURN_STATUS EFIAPI X509GetOrganizationName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *NameBuffer OPTIONAL, IN OUT UINTN *NameBufferSize)
VOID EFIAPI X509StackFree(IN VOID *X509Stack)
BOOLEAN EFIAPI X509GetExtendedKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *Usage, IN OUT UINTN *UsageSize)
BOOLEAN EFIAPI X509GetValidity(IN CONST UINT8 *Cert, IN UINTN CertSize, IN UINT8 *From, IN OUT UINTN *FromSize, IN UINT8 *To, IN OUT UINTN *ToSize)
BOOLEAN EFIAPI Asn1GetTag(IN OUT UINT8 **Ptr, IN CONST UINT8 *End, OUT UINTN *Length, IN UINT32 Tag)
BOOLEAN EFIAPI EcGetPublicKeyFromX509(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT VOID **EcContext)
VOID EFIAPI X509Free(IN VOID *X509Cert)
BOOLEAN EFIAPI X509ConstructCertificateStackV(IN OUT UINT8 **X509Stack, IN VA_LIST Args)
BOOLEAN EFIAPI X509GetCertFromCertChain(IN CONST UINT8 *CertChain, IN UINTN CertChainLength, IN CONST INT32 CertIndex, OUT CONST UINT8 **Cert, OUT UINTN *CertLength)
BOOLEAN EFIAPI X509GetSubjectName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 *CertSubject, IN OUT UINTN *SubjectSize)
BOOLEAN EFIAPI X509GetKeyUsage(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINTN *Usage)
BOOLEAN EFIAPI X509GetTBSCert(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **TBSCert, OUT UINTN *TBSCertSize)
BOOLEAN EFIAPI X509GetExtendedBasicConstraints(CONST UINT8 *Cert, UINTN CertSize, UINT8 *BasicConstraints, UINTN *BasicConstraintsSize)
RETURN_STATUS EFIAPI X509GetCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
BOOLEAN EFIAPI X509VerifyCertChain(IN CONST UINT8 *RootCert, IN UINTN RootCertLength, IN CONST UINT8 *CertChain, IN UINTN CertChainLength)
BOOLEAN EFIAPI X509ConstructCertificate(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT UINT8 **SingleX509Cert)
RETURN_STATUS EFIAPI X509SetDateTime(CHAR8 *DateTimeStr, IN OUT VOID *DateTime, IN OUT UINTN *DateTimeSize)
RETURN_STATUS EFIAPI InternalX509GetSubjectNIDName(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CHAR8 *Oid, IN UINTN OidSize, IN OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
RETURN_STATUS EFIAPI InternalX509GetIssuerNIDName(IN CONST UINT8 *Cert, IN UINTN CertSize, IN CHAR8 *Oid, IN UINTN OidSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
RETURN_STATUS EFIAPI X509GetIssuerOrganizationName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *NameBuffer OPTIONAL, IN OUT UINTN *NameBufferSize)
STATIC INTN InternalX509CheckTime(CONST mbedtls_x509_time *Before, CONST mbedtls_x509_time *After)
RETURN_STATUS EFIAPI X509GetIssuerCommonName(IN CONST UINT8 *Cert, IN UINTN CertSize, OUT CHAR8 *CommonName OPTIONAL, IN OUT UINTN *CommonNameSize)
STATIC INT32 InternalAtoI(CHAR8 *PStart, CHAR8 *PEnd)
STATIC CONST UINT8 OID_commonName[]
STATIC RETURN_STATUS InternalX509FindExtensionData(UINT8 *Start, UINT8 *End, CONST UINT8 *Oid, UINTN OidSize, UINT8 **FindExtensionData, UINTN *FindExtensionDataLen)