Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5eb00d3
DasharoPayloadPkg/PlatformBootManagerLib/: Skip printing hotkeys in S…
miczyg1 Jun 27, 2025
c91830e
SecurityPkg: Refactor DxeImageVerificationLib
miczyg1 Jul 7, 2025
9436bd5
DMP/SovereignBootWizard: Restore SB defaults when SV Boot is not sele…
miczyg1 Jul 8, 2025
63ed99b
DMP/SovereignBootWizard: Prepare SB variables SV Boot provisioning
miczyg1 Jul 8, 2025
203f773
DMP/Application/SovereignBootWizard; Fix exiting the forms
miczyg1 Jul 8, 2025
0cb92fe
DMP/Application/SovereignBootWizard: Parse image signatures
miczyg1 Jul 21, 2025
d6c56ac
DMP/Application/SovereignBootWizard: Add confirmation pop-up and hand…
miczyg1 Jul 22, 2025
44217c5
DMP/Application/SovereignBootWizard: Add enrolling certs to DB/DBX
miczyg1 Jul 23, 2025
7f55d29
DPP/OVMF: Use MBED TLS crypt library explicitly for SV Boot
miczyg1 Jul 23, 2025
de17948
CryptoPkg/Include/Library/BaseCryptLib.h: Expose X509GetIssuerCommonName
miczyg1 Jul 24, 2025
dc1a4cd
DasharoModulePkg/Application/SovereignBootWizard: Add certificate det…
miczyg1 Jul 24, 2025
4a26e9c
DMP/Application/SovereignBootWizard: Move SB key management to separa…
miczyg1 Jul 25, 2025
f1328b4
DMP/Application/SovereignBootWizard: Add ephemeral PK and finalize pr…
miczyg1 Jul 25, 2025
52b28a6
UefiBootManagerLib: Pass BootCurrent to SV Boot Wizard
miczyg1 Jul 28, 2025
d76d131
DMP/Application/SovereignBootWizard: Fix booting bootloaders and cert…
miczyg1 Jul 28, 2025
c45df59
CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c: Implement X509GetIssue…
miczyg1 Jul 29, 2025
974217b
DMP/Application/SovereignBootWizard: Check cert chain and validity
miczyg1 Jul 29, 2025
a840667
UefiBootManagerLib,SovereignBootWizard: Avoid re-entering wizard if n…
miczyg1 Jul 29, 2025
0490ac7
OvmfPkg/DasharoPayloadPkg: Use OpenSSL CryptoLib for image verification
miczyg1 Jul 29, 2025
685e72a
DMP/Application/SovereignBootWizard: Show pop-ups when cert is invalid
miczyg1 Jul 30, 2025
d98a8af
DMP/Application/SovereignBootWizard: Free all buffers on unload
miczyg1 Jul 30, 2025
e992ecd
DMP/Application/SovereignBootWizard: Refactor bootloader parsing
miczyg1 Jul 30, 2025
20c1e77
DMP/Application/SovereignBootWizard: Warn when trusting an untrusted …
miczyg1 Jul 30, 2025
ca80ce8
DMP/Application/SovereignBootWizard: Check if cert is CA
miczyg1 Jul 30, 2025
164e0af
DasharoPayloadPkg: Use OVMF RNG for QEMU
miczyg1 Jul 31, 2025
1f21f4a
DasharoModulePkg/Application/SovereignBootWizard: Fix pointer reference
miczyg1 Jul 31, 2025
1ea8bcf
MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c: Add missing clear s…
miczyg1 Jul 31, 2025
97270bc
MdeModulePkg/UefiBootManagerLib: Do not signal ReadyToBoot when launc…
miczyg1 Jul 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ArmVirtPkg/ArmVirtCloudHv.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf
DxeImageVerificationLib|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf

!include MdePkg/MdeLibs.dsc.inc

Expand Down Expand Up @@ -255,7 +256,7 @@
!if $(SECURE_BOOT_ENABLE) == TRUE
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
<LibraryClasses>
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationHandler.inf
}
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.inf
Expand Down
3 changes: 2 additions & 1 deletion ArmVirtPkg/ArmVirtQemu.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
!endif

ArmMonitorLib|ArmVirtPkg/Library/ArmVirtMonitorLib/ArmVirtMonitorLib.inf
DxeImageVerificationLib|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf

[LibraryClasses.AARCH64]
ArmPlatformLib|ArmVirtPkg/Library/ArmPlatformLibQemu/ArmPlatformLibQemu.inf
Expand Down Expand Up @@ -389,7 +390,7 @@
!if $(SECURE_BOOT_ENABLE) == TRUE
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
<LibraryClasses>
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationHandler.inf
!if $(TPM2_ENABLE) == TRUE
NULL|SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.inf
!endif
Expand Down
3 changes: 2 additions & 1 deletion ArmVirtPkg/ArmVirtQemuKernel.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
TpmPlatformHierarchyLib|SecurityPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf

ArmMonitorLib|ArmVirtPkg/Library/ArmVirtMonitorLib/ArmVirtMonitorLib.inf
DxeImageVerificationLib|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf

[LibraryClasses.common.DXE_DRIVER]
AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf
Expand Down Expand Up @@ -311,7 +312,7 @@
!if $(SECURE_BOOT_ENABLE) == TRUE
MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
<LibraryClasses>
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationHandler.inf
}
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.inf
Expand Down
36 changes: 36 additions & 0 deletions CryptoPkg/Include/Library/BaseCryptLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,7 @@ X509GetCommonName (
IN OUT UINTN *CommonNameSize
);


/**
Retrieve the organization name (O) string from one X.509 certificate.

Expand Down Expand Up @@ -2675,6 +2676,41 @@ X509GetIssuerName (
IN OUT UINTN *CertIssuerSize
);

/**
Retrieve the issuer common name (CN) string from one X.509 certificate.

@param[in] Cert Pointer to the DER-encoded X509 certificate.
@param[in] CertSize Size of the X509 certificate in bytes.
@param[out] CommonName Buffer to contain the retrieved certificate issuer common
name string. At most CommonNameSize bytes will be
written and the string will be null terminated. May be
NULL in order to determine the size buffer needed.
@param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
and the size of buffer returned CommonName on output.
If CommonName is NULL then the amount of space needed
in buffer (including the final null) is returned.

@retval RETURN_SUCCESS The certificate Issuer CommonName retrieved successfully.
@retval RETURN_INVALID_PARAMETER If Cert is NULL.
If CommonNameSize is NULL.
If CommonName is not NULL and *CommonNameSize is 0.
If Certificate is invalid.
@retval RETURN_NOT_FOUND If no CommonName entry exists.
@retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
(including the final null) is returned in the
CommonNameSize parameter.
@retval RETURN_UNSUPPORTED The operation is not supported.

**/
RETURN_STATUS
EFIAPI
X509GetIssuerCommonName (
IN CONST UINT8 *Cert,
IN UINTN CertSize,
OUT CHAR8 *CommonName OPTIONAL,
IN OUT UINTN *CommonNameSize
);

/**
Retrieve the Signature Algorithm from one X.509 certificate.

Expand Down
186 changes: 186 additions & 0 deletions CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,192 @@ X509GetIssuerName (
return Status;
}


/**
Retrieve a string from one X.509 certificate issuer base on the Request_NID.

@param[in] Cert Pointer to the DER-encoded X509 certificate.
@param[in] CertSize Size of the X509 certificate in bytes.
@param[in] Request_NID NID of string to obtain
@param[out] CommonName Buffer to contain the retrieved certificate issuer common
name string (UTF8). At most CommonNameSize bytes will be
written and the string will be null terminated. May be
NULL in order to determine the size buffer needed.
@param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
and the size of buffer returned CommonName on output.
If CommonName is NULL then the amount of space needed
in buffer (including the final null) is returned.

@retval RETURN_SUCCESS The certificate issuer CommonName retrieved successfully.
@retval RETURN_INVALID_PARAMETER If Cert is NULL.
If CommonNameSize is NULL.
If CommonName is not NULL and *CommonNameSize is 0.
If Certificate is invalid.
@retval RETURN_NOT_FOUND If no NID Name entry exists.
@retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
(including the final null) is returned in the
CommonNameSize parameter.
@retval RETURN_UNSUPPORTED The operation is not supported.

**/
STATIC
RETURN_STATUS
InternalX509GetIssuerNIDName (
IN CONST UINT8 *Cert,
IN UINTN CertSize,
IN INT32 Request_NID,
OUT CHAR8 *CommonName OPTIONAL,
IN OUT UINTN *CommonNameSize
)
{
RETURN_STATUS ReturnStatus;
BOOLEAN Status;
X509 *X509Cert;
X509_NAME *X509Name;
INT32 Index;
INTN Length;
X509_NAME_ENTRY *Entry;
ASN1_STRING *EntryData;
UINT8 *UTF8Name;

ReturnStatus = RETURN_INVALID_PARAMETER;
UTF8Name = NULL;

//
// Check input parameters.
//
if ((Cert == NULL) || (CertSize > INT_MAX) || (CommonNameSize == NULL)) {
return ReturnStatus;
}

if ((CommonName != NULL) && (*CommonNameSize == 0)) {
return ReturnStatus;
}

X509Cert = NULL;
//
// Read DER-encoded X509 Certificate and Construct X509 object.
//
Status = X509ConstructCertificate (Cert, CertSize, (UINT8 **)&X509Cert);
if ((X509Cert == NULL) || (!Status)) {
//
// Invalid X.509 Certificate
//
goto _Exit;
}

Status = FALSE;

//
// Retrieve issuer name from certificate object.
//
X509Name = X509_get_issuer_name (X509Cert);
if (X509Name == NULL) {
//
// Fail to retrieve subject name content
//
goto _Exit;
}

//
// Retrive the string from X.509 Subject base on the Request_NID
//
Index = X509_NAME_get_index_by_NID (X509Name, Request_NID, -1);
if (Index < 0) {
//
// No Request_NID name entry exists in X509_NAME object
//
*CommonNameSize = 0;
ReturnStatus = RETURN_NOT_FOUND;
goto _Exit;
}

Entry = X509_NAME_get_entry (X509Name, Index);
if (Entry == NULL) {
//
// Fail to retrieve name entry data
//
*CommonNameSize = 0;
ReturnStatus = RETURN_NOT_FOUND;
goto _Exit;
}

EntryData = X509_NAME_ENTRY_get_data (Entry);

Length = ASN1_STRING_to_UTF8 (&UTF8Name, EntryData);
if (Length < 0) {
//
// Fail to convert the Name string
//
*CommonNameSize = 0;
ReturnStatus = RETURN_INVALID_PARAMETER;
goto _Exit;
}

if (CommonName == NULL) {
*CommonNameSize = Length + 1;
ReturnStatus = RETURN_BUFFER_TOO_SMALL;
} else {
*CommonNameSize = MIN ((UINTN)Length, *CommonNameSize - 1) + 1;
CopyMem (CommonName, UTF8Name, *CommonNameSize - 1);
CommonName[*CommonNameSize - 1] = '\0';
ReturnStatus = RETURN_SUCCESS;
}

_Exit:
//
// Release Resources.
//
if (X509Cert != NULL) {
X509_free (X509Cert);
}

if (UTF8Name != NULL) {
OPENSSL_free (UTF8Name);
}

return ReturnStatus;
}

/**
Retrieve the issuer common name (CN) string from one X.509 certificate.

@param[in] Cert Pointer to the DER-encoded X509 certificate.
@param[in] CertSize Size of the X509 certificate in bytes.
@param[out] CommonName Buffer to contain the retrieved certificate issuer common
name string. At most CommonNameSize bytes will be
written and the string will be null terminated. May be
NULL in order to determine the size buffer needed.
@param[in,out] CommonNameSize The size in bytes of the CommonName buffer on input,
and the size of buffer returned CommonName on output.
If CommonName is NULL then the amount of space needed
in buffer (including the final null) is returned.

@retval RETURN_SUCCESS The certificate Issuer CommonName retrieved successfully.
@retval RETURN_INVALID_PARAMETER If Cert is NULL.
If CommonNameSize is NULL.
If CommonName is not NULL and *CommonNameSize is 0.
If Certificate is invalid.
@retval RETURN_NOT_FOUND If no CommonName entry exists.
@retval RETURN_BUFFER_TOO_SMALL If the CommonName is NULL. The required buffer size
(including the final null) is returned in the
CommonNameSize parameter.
@retval RETURN_UNSUPPORTED The operation is not supported.

**/
RETURN_STATUS
EFIAPI
X509GetIssuerCommonName (
IN CONST UINT8 *Cert,
IN UINTN CertSize,
OUT CHAR8 *CommonName OPTIONAL,
IN OUT UINTN *CommonNameSize
)
{
return InternalX509GetIssuerNIDName (Cert, CertSize, NID_commonName, CommonName, CommonNameSize);
}


/**
Retrieve the Signature Algorithm from one X.509 certificate.

Expand Down
Loading