Skip to content

Sb db owner guid #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dasharo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions DasharoPayloadPkg/DasharoPayloadPkg.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ INF SecurityPkg/Pkcs7Verify/Pkcs7VerifyDxe/Pkcs7VerifyDxe.inf
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/MicCorUEFCA2011_2011-06-27.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/windows_uefi_ca_2023.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/microsoft_uefi_ca_2023.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/microsoft_option_rom_uefi_ca_2023.crt
SECTION UI = "DefaultDbCert"
}

Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions OvmfPkg/OvmfPkgX64.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ INF OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/MicCorUEFCA2011_2011-06-27.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/windows_uefi_ca_2023.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/microsoft_uefi_ca_2023.crt
SECTION RAW = DasharoPayloadPkg/SecureBootDefaultKeys/microsoft_option_rom_uefi_ca_2023.crt
SECTION UI = "DefaultDbCert"
}

Expand Down
5 changes: 4 additions & 1 deletion SecurityPkg/Include/Library/SecureBootVariableLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ IsSecureBootEnabled (
@param[in] KeyInfoCount The number of certificate pointer and size pairs inside KeyInfo.
@param[in] KeyInfo A pointer to all certificates, in the format of DER-encoded,
to be concatenated into signature lists.
@param[in] OwnerGuid A pointer to OwnerGUID, to be used when creating the signature
list. NULL means gEfiGlobalVariableGuid will be used.

@retval EFI_SUCCESS Created signature list from payload successfully.
@retval EFI_NOT_FOUND Section with key has not been found.
Expand All @@ -94,7 +96,8 @@ SecureBootCreateDataFromInput (
OUT UINTN *SigListsSize,
OUT EFI_SIGNATURE_LIST **SigListOut,
IN UINTN KeyInfoCount,
IN CONST SECURE_BOOT_CERTIFICATE_INFO *KeyInfo
IN CONST SECURE_BOOT_CERTIFICATE_INFO *KeyInfo,
IN EFI_GUID *OwnerGuid OPTIONAL
);

/**
Expand Down
23 changes: 16 additions & 7 deletions SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ EFI_TIME mDefaultPayloadTimestamp = {

/** Creates EFI Signature List structure.

@param[in] Data A pointer to signature data.
@param[in] Size Size of signature data.
@param[out] SigList Created Signature List.
@param[in] Data A pointer to signature data.
@param[in] Size Size of signature data.
@param[out] SigList Created Signature List.
@param[in] OwnerGuid Optional OwnerGuid of the Signature List

@retval EFI_SUCCESS Signature List was created successfully.
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory.
Expand All @@ -70,7 +71,8 @@ EFI_STATUS
CreateSigList (
IN VOID *Data,
IN UINTN Size,
OUT EFI_SIGNATURE_LIST **SigList
OUT EFI_SIGNATURE_LIST **SigList,
IN EFI_GUID *OwnerGuid OPTIONAL
)
{
UINTN SigListSize;
Expand Down Expand Up @@ -98,7 +100,11 @@ CreateSigList (
// Copy key data
//
SigData = (EFI_SIGNATURE_DATA *)(TmpSigList + 1);
CopyGuid (&SigData->SignatureOwner, &gEfiGlobalVariableGuid);
if (OwnerGuid == NULL) {
CopyGuid (&SigData->SignatureOwner, &gEfiGlobalVariableGuid);
} else {
CopyGuid (&SigData->SignatureOwner, OwnerGuid);
}
CopyMem (&SigData->SignatureData[0], Data, Size);

*SigList = TmpSigList;
Expand Down Expand Up @@ -157,6 +163,8 @@ ConcatenateSigList (
@param[in] KeyInfoCount The number of certificate pointer and size pairs inside KeyInfo.
@param[in] KeyInfo A pointer to all certificates, in the format of DER-encoded,
to be concatenated into signature lists.
@param[in] OwnerGuid A pointer to OwnerGUID, to be used when creating the signature
list. NULL means gEfiGlobalVariableGuid will be used.

@retval EFI_SUCCESS Created signature list from payload successfully.
@retval EFI_NOT_FOUND Section with key has not been found.
Expand All @@ -170,7 +178,8 @@ SecureBootCreateDataFromInput (
OUT UINTN *SigListsSize,
OUT EFI_SIGNATURE_LIST **SigListOut,
IN UINTN KeyInfoCount,
IN CONST SECURE_BOOT_CERTIFICATE_INFO *KeyInfo
IN CONST SECURE_BOOT_CERTIFICATE_INFO *KeyInfo,
IN EFI_GUID *OwnerGuid OPTIONAL
)
{
EFI_SIGNATURE_LIST *EfiSig;
Expand Down Expand Up @@ -206,7 +215,7 @@ SecureBootCreateDataFromInput (
return EFI_OUT_OF_RESOURCES;
}

Status = CreateSigList (Buffer, Size, &TmpEfiSig);
Status = CreateSigList (Buffer, Size, &TmpEfiSig, OwnerGuid);

if (EFI_ERROR (Status)) {
FreePool (Buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ SecureBootCreateDataFromInputSimple (
KeyInfo.Data = TestData;
KeyInfo.DataSize = sizeof (TestData);

Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 1, &KeyInfo);
Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 1, &KeyInfo, NULL);

UT_ASSERT_NOT_EFI_ERROR (Status);

Expand Down Expand Up @@ -403,10 +403,10 @@ SecureBootCreateDataFromInputNull (
.DataSize = 0
};

Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 0, NULL);
Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 0, NULL, NULL);
UT_ASSERT_STATUS_EQUAL (Status, EFI_INVALID_PARAMETER);

Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 1, &KeyInfo);
Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 1, &KeyInfo, NULL);
UT_ASSERT_STATUS_EQUAL (Status, EFI_NOT_FOUND);

return UNIT_TEST_PASSED;
Expand Down Expand Up @@ -448,7 +448,7 @@ SecureBootCreateDataFromInputMultiple (
KeyInfo[1].Data = TestData2;
KeyInfo[1].DataSize = sizeof (TestData2);

Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 2, KeyInfo);
Status = SecureBootCreateDataFromInput (&SigListSize, &SigList, 2, KeyInfo, NULL);
UT_ASSERT_NOT_EFI_ERROR (Status);

UT_ASSERT_NOT_NULL (SigList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include <Library/DxeServicesLib.h>
#include <Library/AuthVariableLib.h>

#define EFI_MICROSOFT_OWNER_GUID \
{ 0x77FA9ABD, 0x0359, 0x4D32, {0xBD, 0x60, 0x28, 0xF4, 0xE7, 0x8F, 0x78, 0x4B} }

EFI_GUID gEfiMicrosoftOwnerGuid = EFI_MICROSOFT_OWNER_GUID;

/**
Create a EFI Signature List with data fetched from section specified as a argument.
Found keys are verified using RsaGetPublicKeyFromX509().
Expand Down Expand Up @@ -55,10 +60,12 @@ SecureBootFetchData (
UINTN Index;
SECURE_BOOT_CERTIFICATE_INFO *CertInfo;
SECURE_BOOT_CERTIFICATE_INFO *NewCertInfo;
EFI_GUID *OwnerGuid;

KeyIndex = 0;
*SigListOut = NULL;
*SigListsSize = 0;
OwnerGuid = NULL;
CertInfo = AllocatePool (sizeof (SECURE_BOOT_CERTIFICATE_INFO));
NewCertInfo = CertInfo;
while (1) {
Expand Down Expand Up @@ -118,8 +125,14 @@ SecureBootFetchData (
goto Cleanup;
}

// MS Certificates owner GUID in DB/KEK must be 77fa9abd-0359-4d32-bd60-28f4e78f784b.
if (CompareGuid(KeyFileGuid, &gDefaultdbFileGuid) ||
CompareGuid(KeyFileGuid, &gDefaultKEKFileGuid)) {
OwnerGuid = &gEfiMicrosoftOwnerGuid;
}

// Now that we collected all certs from FV, convert it into sig list
Status = SecureBootCreateDataFromInput (SigListsSize, SigListOut, KeyIndex, CertInfo);
Status = SecureBootCreateDataFromInput (SigListsSize, SigListOut, KeyIndex, CertInfo, OwnerGuid);
if (EFI_ERROR (Status)) {
goto Cleanup;
}
Expand Down