26 UINT8 *DeviceAuthBootMode;
28 DeviceAuthBootMode =
NULL;
34 if (EFI_ERROR (Status)) {
35 DEBUG ((DEBUG_ERROR,
"Cannot check DeviceAuthBootMode variable %r \n ", Status));
42 if (*DeviceAuthBootMode == DEVICE_AUTH_BOOT_MODE_DISABLE) {
74 BOOLEAN IsValidCertChain;
75 BOOLEAN RootCertMatch;
77 if ((
PcdGet32 (PcdTcgPfpMeasurementRevision) < TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_106) ||
78 (
PcdGet8 (PcdEnableSpdmDeviceAuthentication) == 0))
80 return EFI_UNSUPPORTED;
84 if (SpdmDeviceContext ==
NULL) {
85 return EFI_UNSUPPORTED;
89 AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_SUCCESS;
91 IsValidCertChain =
FALSE;
92 RootCertMatch =
FALSE;
94 if (((SecurityPolicy->AuthenticationPolicy & EDKII_DEVICE_AUTHENTICATION_REQUIRED) != 0) ||
97 Status =
DoDeviceCertificate (SpdmDeviceContext, &AuthState, &SlotId, SecurityState, &IsValidCertChain, &RootCertMatch);
98 if (EFI_ERROR (Status)) {
99 DEBUG ((DEBUG_ERROR,
"DoDeviceCertificate failed - %r\n", Status));
101 }
else if ((AuthState == TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG) ||
102 (AuthState == TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID))
108 if (((SecurityPolicy->AuthenticationPolicy & EDKII_DEVICE_AUTHENTICATION_REQUIRED) != 0) && (
IsDeviceAuthBootEnabled ())) {
109 Status =
DoDeviceAuthentication (SpdmDeviceContext, &AuthState, SlotId, IsValidCertChain, RootCertMatch, SecurityState);
110 if (EFI_ERROR (Status)) {
111 DEBUG ((DEBUG_ERROR,
"DoDeviceAuthentication failed - %r\n", Status));
113 }
else if ((AuthState == TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG) ||
114 (AuthState == TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID))
122 if (EFI_ERROR (Status)) {
123 DEBUG ((DEBUG_ERROR,
"DoDeviceMeasurement failed - %r\n", Status));
#define EDKII_DEVICE_MEASUREMENT_REQUIRED
VOID EFIAPI FreePool(IN VOID *Buffer)
#define EFI_DEVICE_AUTH_BOOT_MODE_NAME
#define DEBUG(Expression)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
EFI_STATUS EFIAPI DoDeviceCertificate(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, OUT UINT8 *AuthState, OUT UINT8 *ValidSlotId, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState, OUT BOOLEAN *IsValidCertChain, OUT BOOLEAN *RootCertMatch)
EFI_STATUS EFIAPI DoDeviceAuthentication(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, OUT UINT8 *AuthState, IN UINT8 ValidSlotId, IN BOOLEAN IsValidCertChain, IN BOOLEAN RootCertMatch, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
VOID *EFIAPI GetSpdmIoProtocolViaSpdmContext(IN VOID *SpdmContext)
SPDM_DEVICE_CONTEXT *EFIAPI CreateSpdmDeviceContext(IN EDKII_SPDM_DEVICE_INFO *SpdmDeviceInfo, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
VOID EFIAPI DestroySpdmDeviceContext(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext)
EFI_STATUS EFIAPI DoDeviceMeasurement(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, IN UINT8 SlotId, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
VOID *EFIAPI SpdmGetIoProtocolViaSpdmContext(IN VOID *SpdmContext)
EFI_STATUS EFIAPI SpdmDeviceAuthenticationAndMeasurement(IN EDKII_SPDM_DEVICE_INFO *SpdmDeviceInfo, IN EDKII_DEVICE_SECURITY_POLICY *SecurityPolicy, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
BOOLEAN EFIAPI IsDeviceAuthBootEnabled(VOID)
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)