Skip to content

Commit

Permalink
SecurityPkg/Tcg2Dxe: Add EV_EFI_SPDM_DEVICE_POLICY measure
Browse files Browse the repository at this point in the history
Signed-off-by: Wenxing Hou <wenxing.hou@intel.com>
  • Loading branch information
Wenxing-hou authored and jyao1 committed Feb 5, 2024
1 parent 6b4249f commit 93cb538
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
33 changes: 32 additions & 1 deletion SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Guid/EventExitBootServiceFailed.h>
#include <Guid/ImageAuthentication.h>
#include <Guid/TpmInstance.h>
#include <Guid/DeviceAuthentication.h>

#include <Protocol/DevicePath.h>
#include <Protocol/MpService.h>
Expand Down Expand Up @@ -2077,7 +2078,7 @@ MeasureVariable (
);
}

if (EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) {
if ((EventType == EV_EFI_VARIABLE_DRIVER_CONFIG) || (EventType == EV_EFI_SPDM_DEVICE_POLICY)) {
//
// Digest is the event data (UEFI_VARIABLE_DATA)
//
Expand Down Expand Up @@ -2333,6 +2334,36 @@ MeasureAllSecureVariables (
DEBUG ((DEBUG_INFO, "Skip measuring variable %s since it's deleted\n", EFI_IMAGE_SECURITY_DATABASE2));
}

//
// Meaurement UEFI device signature database
//
if ((PcdGet32 (PcdTcgPfpMeasurementRevision) >= TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_106) &&
(PcdGet8 (PcdEnableSpdmDeviceAuthenticaion) != 0)) {
Status = GetVariable2 (EFI_DEVICE_SECURITY_DATABASE, &gEfiDeviceSignatureDatabaseGuid, &Data, &DataSize);
if (Status == EFI_SUCCESS) {
Status = MeasureVariable (
PCR_INDEX_FOR_SIGNATURE_DB,
EV_EFI_SPDM_DEVICE_POLICY,
EFI_DEVICE_SECURITY_DATABASE,
&gEfiDeviceSignatureDatabaseGuid,
Data,
DataSize
);
FreePool (Data);
} else if (Status == EFI_NOT_FOUND) {
Data = NULL;
DataSize = 0;
Status = MeasureVariable (
PCR_INDEX_FOR_SIGNATURE_DB,
EV_EFI_SPDM_DEVICE_POLICY,
EFI_DEVICE_SECURITY_DATABASE,
&gEfiDeviceSignatureDatabaseGuid,
Data,
DataSize
);
}
}

return EFI_SUCCESS;
}

Expand Down
2 changes: 2 additions & 0 deletions SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
gTcgEvent2EntryHobGuid ## SOMETIMES_CONSUMES ## HOB
gTpm2StartupLocalityHobGuid ## SOMETIMES_CONSUMES ## HOB
gTcg800155PlatformIdEventHobGuid ## SOMETIMES_CONSUMES ## HOB
gEfiDeviceSignatureDatabaseGuid

[Protocols]
gEfiTcg2ProtocolGuid ## PRODUCES
Expand All @@ -106,6 +107,7 @@
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableRev ## CONSUMES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableLaml ## PRODUCES
gEfiSecurityPkgTokenSpaceGuid.PcdTpm2AcpiTableLasa ## PRODUCES
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableSpdmDeviceAuthenticaion ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdTcgPfpMeasurementRevision ## CONSUMES

[Depex]
Expand Down

0 comments on commit 93cb538

Please sign in to comment.