43 if (!(((VarSize == 0) && (VarData ==
NULL)) || ((VarSize != 0) && (VarData !=
NULL)))) {
45 return EFI_INVALID_PARAMETER;
48 VarNameLength =
StrLen (VarName);
49 VarLogSize = (UINT32)(
sizeof (*VarLog) + VarNameLength *
sizeof (*VarName) + VarSize
50 -
sizeof (VarLog->UnicodeName) -
sizeof (VarLog->
VariableData));
54 return EFI_OUT_OF_RESOURCES;
57 CopyMem (&VarLog->VariableName, VendorGuid, sizeof (VarLog->VariableName));
58 VarLog->UnicodeNameLength = VarNameLength;
59 VarLog->VariableDataLength = VarSize;
63 VarNameLength * sizeof (*VarName)
67 (CHAR16 *)VarLog->UnicodeName + VarNameLength,
73 DEBUG ((DEBUG_INFO,
"VariableDxe: MeasureVariable (Pcr - %x, EventType - %x, ", (
UINTN)PcrIndex, (
UINTN)EventType));
74 DEBUG ((DEBUG_INFO,
"VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));
112 IN VOID *TrustAnchor,
125 UINTN DeviceContextSize;
127 UINTN DevicePathSize;
131 SPDM_DATA_PARAMETER Parameter;
133 UINTN SignatureDataSize;
135 SpdmContext = SpdmDeviceContext->SpdmContext;
138 ZeroMem (&Parameter,
sizeof (Parameter));
139 Parameter.location = SpdmDataLocationConnection;
140 DataSize =
sizeof (BaseHashAlgo);
141 Status = SpdmGetData (SpdmContext, SpdmDataBaseHashAlgo, &Parameter, &BaseHashAlgo, &DataSize);
148 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_SUCCESS:
149 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_AUTH:
150 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_BINDING:
153 sizeof (UINT64) + DevicePathSize +
158 if (EventLog ==
NULL) {
159 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_UEFI_OUT_OF_RESOURCE;
160 return EFI_OUT_OF_RESOURCES;
163 EventLogPtr = EventLog;
165 NvIndexInstance = (VOID *)EventLogPtr;
166 CopyMem (NvIndexInstance->Signature, TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE, sizeof (TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE));
167 NvIndexInstance->Version = TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT_VERSION;
168 ZeroMem (NvIndexInstance->Reserved, sizeof (NvIndexInstance->Reserved));
171 EventData2 = (VOID *)EventLogPtr;
172 CopyMem (EventData2->Signature, TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE_2, sizeof (EventData2->Signature));
173 EventData2->Version = TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_2;
174 EventData2->AuthState = AuthState;
175 EventData2->Reserved = 0;
176 EventData2->Length = (UINT32)EventLogSize;
179 EventData2->SubHeaderType = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_CERT_CHAIN;
181 EventData2->SubHeaderUID = SpdmDeviceContext->DeviceUID;
183 EventLogPtr = (VOID *)(EventData2 + 1);
185 *(UINT64 *)EventLogPtr = (UINT64)DevicePathSize;
186 EventLogPtr +=
sizeof (UINT64);
187 CopyMem (EventLogPtr, SpdmDeviceContext->DevicePath, DevicePathSize);
188 EventLogPtr += DevicePathSize;
190 TcgSpdmCertChain = (VOID *)EventLogPtr;
191 TcgSpdmCertChain->SpdmVersion = SpdmDeviceContext->SpdmVersion;
192 TcgSpdmCertChain->SpdmSlotId = SlotId;
193 TcgSpdmCertChain->Reserved = 0;
194 TcgSpdmCertChain->SpdmHashAlgo = BaseHashAlgo;
197 CopyMem (EventLogPtr, CertChain, CertChainSize);
198 EventLogPtr += CertChainSize;
200 if (DeviceContextSize != 0) {
201 DeviceContext = (VOID *)EventLogPtr;
204 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
205 Status = EFI_DEVICE_ERROR;
211 TCG_NV_EXTEND_INDEX_FOR_INSTANCE,
218 if (EFI_ERROR (Status)) {
219 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_TCG_EXTEND_TPM_PCR;
222 DEBUG ((DEBUG_INFO,
"TpmMeasureAndLogData (Instance) - %r\n", Status));
225 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID:
228 sizeof (UINT64) + DevicePathSize +
232 if (EventLog ==
NULL) {
233 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_UEFI_OUT_OF_RESOURCE;
234 return EFI_OUT_OF_RESOURCES;
237 EventLogPtr = EventLog;
239 NvIndexInstance = (VOID *)EventLogPtr;
240 CopyMem (NvIndexInstance->Signature, TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE, sizeof (TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE));
241 NvIndexInstance->Version = TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT_VERSION;
242 ZeroMem (NvIndexInstance->Reserved, sizeof (NvIndexInstance->Reserved));
245 EventData2 = (VOID *)EventLogPtr;
246 CopyMem (EventData2->Signature, TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE_2, sizeof (EventData2->Signature));
247 EventData2->Version = TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_2;
248 EventData2->AuthState = AuthState;
249 EventData2->Reserved = 0;
250 EventData2->Length = (UINT32)EventLogSize;
253 EventData2->SubHeaderType = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_CERT_CHAIN;
255 EventData2->SubHeaderUID = SpdmDeviceContext->DeviceUID;
257 EventLogPtr = (VOID *)(EventData2 + 1);
259 *(UINT64 *)EventLogPtr = (UINT64)DevicePathSize;
260 EventLogPtr +=
sizeof (UINT64);
261 CopyMem (EventLogPtr, SpdmDeviceContext->DevicePath, DevicePathSize);
262 EventLogPtr += DevicePathSize;
264 TcgSpdmCertChain = (VOID *)EventLogPtr;
265 TcgSpdmCertChain->SpdmVersion = SpdmDeviceContext->SpdmVersion;
266 TcgSpdmCertChain->SpdmSlotId = SlotId;
267 TcgSpdmCertChain->Reserved = 0;
268 TcgSpdmCertChain->SpdmHashAlgo = BaseHashAlgo;
271 if (DeviceContextSize != 0) {
272 DeviceContext = (VOID *)EventLogPtr;
275 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
276 Status = EFI_DEVICE_ERROR;
282 TCG_NV_EXTEND_INDEX_FOR_INSTANCE,
289 if (EFI_ERROR (Status)) {
290 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_TCG_EXTEND_TPM_PCR;
293 DEBUG ((DEBUG_INFO,
"TpmMeasureAndLogData (Instance) - %r\n", Status));
296 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG:
297 case TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_SPDM:
300 sizeof (UINT64) + DevicePathSize +
303 if (EventLog ==
NULL) {
304 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_UEFI_OUT_OF_RESOURCE;
305 return EFI_OUT_OF_RESOURCES;
308 EventLogPtr = EventLog;
310 NvIndexInstance = (VOID *)EventLogPtr;
311 CopyMem (NvIndexInstance->Signature, TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE, sizeof (TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE));
312 NvIndexInstance->Version = TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT_VERSION;
313 ZeroMem (NvIndexInstance->Reserved, sizeof (NvIndexInstance->Reserved));
316 EventData2 = (VOID *)EventLogPtr;
317 CopyMem (EventData2->Signature, TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE_2, sizeof (EventData2->Signature));
318 EventData2->Version = TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_2;
319 EventData2->AuthState = AuthState;
320 EventData2->Reserved = 0;
321 EventData2->Length = (UINT32)EventLogSize;
324 EventData2->SubHeaderType = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_CERT_CHAIN;
325 EventData2->SubHeaderLength = 0;
326 EventData2->SubHeaderUID = SpdmDeviceContext->DeviceUID;
328 EventLogPtr = (VOID *)(EventData2 + 1);
330 *(UINT64 *)EventLogPtr = (UINT64)DevicePathSize;
331 EventLogPtr +=
sizeof (UINT64);
332 CopyMem (EventLogPtr, SpdmDeviceContext->DevicePath, DevicePathSize);
333 EventLogPtr += DevicePathSize;
335 if (DeviceContextSize != 0) {
336 DeviceContext = (VOID *)EventLogPtr;
339 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
340 Status = EFI_DEVICE_ERROR;
346 TCG_NV_EXTEND_INDEX_FOR_INSTANCE,
353 if (EFI_ERROR (Status)) {
354 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_TCG_EXTEND_TPM_PCR;
357 DEBUG ((DEBUG_INFO,
"TpmMeasureAndLogData (Instance) - %r\n", Status));
361 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_UEFI_UNSUPPORTED;
362 return EFI_UNSUPPORTED;
365 if ((TrustAnchor !=
NULL) && (TrustAnchorSize != 0)) {
366 SignatureDataSize =
sizeof (
EFI_GUID) + TrustAnchorSize;
368 if (SignatureData ==
NULL) {
369 ASSERT (SignatureData !=
NULL);
370 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_UEFI_OUT_OF_RESOURCE;
371 Status = EFI_OUT_OF_RESOURCES;
377 (UINT8 *)SignatureData +
sizeof (
EFI_GUID),
383 PCR_INDEX_FOR_SIGNATURE_DB,
384 EV_EFI_SPDM_DEVICE_AUTHORITY,
385 EFI_DEVICE_SECURITY_DATABASE,
386 &gEfiDeviceSignatureDatabaseGuid,
394 if (EventLog !=
NULL) {
419 IN UINT8 *RequesterNonce,
420 IN UINT8 *ResponderNonce,
430 CopyMem (DynamicEventLogSpdmChallengeEvent.Header.Signature, TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE, sizeof (TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE));
431 DynamicEventLogSpdmChallengeEvent.Header.Version = TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_VERSION;
432 ZeroMem (DynamicEventLogSpdmChallengeEvent.Header.Reserved, sizeof (DynamicEventLogSpdmChallengeEvent.Header.Reserved));
433 DynamicEventLogSpdmChallengeEvent.Header.Uid = SpdmDeviceContext->DeviceUID;
434 DynamicEventLogSpdmChallengeEvent.DescriptionSize =
sizeof (TCG_SPDM_CHALLENGE_DESCRIPTION);
435 CopyMem (DynamicEventLogSpdmChallengeEvent.Description, TCG_SPDM_CHALLENGE_DESCRIPTION, sizeof (TCG_SPDM_CHALLENGE_DESCRIPTION));
436 DynamicEventLogSpdmChallengeEvent.DataSize = SPDM_NONCE_SIZE;
437 CopyMem (DynamicEventLogSpdmChallengeEvent.Data, RequesterNonce, SPDM_NONCE_SIZE);
440 TCG_NV_EXTEND_INDEX_FOR_DYNAMIC,
442 &DynamicEventLogSpdmChallengeEvent,
443 sizeof (DynamicEventLogSpdmChallengeEvent),
444 &DynamicEventLogSpdmChallengeEvent,
445 sizeof (DynamicEventLogSpdmChallengeEvent)
447 if (EFI_ERROR (Status)) {
448 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_TCG_EXTEND_TPM_PCR;
451 DEBUG ((DEBUG_INFO,
"TpmMeasureAndLogData (Dynamic) - %r\n", Status));
453 CopyMem (DynamicEventLogSpdmChallengeAuthEvent.Header.Signature, TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE, sizeof (TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE));
454 DynamicEventLogSpdmChallengeAuthEvent.Header.Version = TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_VERSION;
455 ZeroMem (DynamicEventLogSpdmChallengeAuthEvent.Header.Reserved, sizeof (DynamicEventLogSpdmChallengeAuthEvent.Header.Reserved));
456 DynamicEventLogSpdmChallengeAuthEvent.Header.Uid = SpdmDeviceContext->DeviceUID;
457 DynamicEventLogSpdmChallengeAuthEvent.DescriptionSize =
sizeof (TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION);
458 CopyMem (DynamicEventLogSpdmChallengeAuthEvent.Description, TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION, sizeof (TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION));
459 DynamicEventLogSpdmChallengeAuthEvent.DataSize = SPDM_NONCE_SIZE;
460 CopyMem (DynamicEventLogSpdmChallengeAuthEvent.Data, ResponderNonce, SPDM_NONCE_SIZE);
463 TCG_NV_EXTEND_INDEX_FOR_DYNAMIC,
465 &DynamicEventLogSpdmChallengeAuthEvent,
466 sizeof (DynamicEventLogSpdmChallengeAuthEvent),
467 &DynamicEventLogSpdmChallengeAuthEvent,
468 sizeof (DynamicEventLogSpdmChallengeAuthEvent)
470 if (EFI_ERROR (Status)) {
471 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_TCG_EXTEND_TPM_PCR;
474 DEBUG ((DEBUG_INFO,
"TpmMeasureAndLogData (Dynamic) - %r\n", Status));
499 OUT UINT8 *AuthState,
500 OUT UINT8 *ValidSlotId,
502 OUT BOOLEAN *IsValidCertChain,
503 OUT BOOLEAN *RootCertMatch
507 SPDM_RETURN SpdmReturn;
509 UINT32 CapabilityFlags;
511 SPDM_DATA_PARAMETER Parameter;
513 UINT8 TotalDigestBuffer[LIBSPDM_MAX_HASH_SIZE * SPDM_MAX_SLOT_COUNT];
515 UINT8 CertChain[LIBSPDM_MAX_CERT_CHAIN_SIZE];
517 UINTN TrustAnchorSize;
520 SpdmContext = SpdmDeviceContext->SpdmContext;
522 ZeroMem (&Parameter,
sizeof (Parameter));
523 Parameter.location = SpdmDataLocationConnection;
524 DataSize =
sizeof (CapabilityFlags);
525 SpdmReturn = SpdmGetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
526 if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
527 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
528 return EFI_DEVICE_ERROR;
531 *IsValidCertChain =
FALSE;
532 *RootCertMatch =
FALSE;
533 CertChainSize =
sizeof (CertChain);
534 ZeroMem (CertChain,
sizeof (CertChain));
541 *ValidSlotId = SPDM_MAX_SLOT_COUNT;
543 if ((CapabilityFlags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CERT_CAP) == 0) {
544 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG;
545 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_NO_CAPABILITIES;
549 ZeroMem (TotalDigestBuffer,
sizeof (TotalDigestBuffer));
550 SpdmReturn = SpdmGetDigest (SpdmContext,
NULL, &SlotMask, TotalDigestBuffer);
551 if ((LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) || ((SlotMask & 0x01) == 0)) {
552 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID;
553 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_CERTIFIACTE_FAILURE;
559 for (SlotId = 0; SlotId < SPDM_MAX_SLOT_COUNT; SlotId++) {
560 if (((SlotMask >> SlotId) & 0x01) == 0) {
564 CertChainSize =
sizeof (CertChain);
565 ZeroMem (CertChain,
sizeof (CertChain));
566 SpdmReturn = SpdmGetCertificateEx (SpdmContext,
NULL, SlotId, &CertChainSize, CertChain, (
CONST VOID **)&TrustAnchor, &TrustAnchorSize);
567 if (LIBSPDM_STATUS_IS_SUCCESS (SpdmReturn)) {
568 *IsValidCertChain =
TRUE;
570 }
else if (SpdmReturn == LIBSPDM_STATUS_VERIF_FAIL) {
571 *IsValidCertChain =
FALSE;
572 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID;
573 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_CERTIFIACTE_FAILURE;
575 }
else if (SpdmReturn == LIBSPDM_STATUS_VERIF_NO_AUTHORITY) {
576 *IsValidCertChain =
TRUE;
577 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_AUTH;
578 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_CERTIFIACTE_FAILURE;
579 *ValidSlotId = SlotId;
583 if ((SlotId >= SPDM_MAX_SLOT_COUNT) && (*ValidSlotId == SPDM_MAX_SLOT_COUNT)) {
584 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
585 return EFI_DEVICE_ERROR;
588 if (TrustAnchor !=
NULL) {
589 *RootCertMatch =
TRUE;
590 *ValidSlotId = SlotId;
595 DEBUG ((DEBUG_INFO,
"SpdmGetCertificateEx - SpdmReturn %p, TrustAnchorSize 0x%x, RootCertMatch %d\n", SpdmReturn, TrustAnchorSize, *RootCertMatch));
620 OUT UINT8 *AuthState,
621 IN UINT8 ValidSlotId,
622 IN BOOLEAN IsValidCertChain,
623 IN BOOLEAN RootCertMatch,
628 SPDM_RETURN SpdmReturn;
630 UINT32 CapabilityFlags;
632 SPDM_DATA_PARAMETER Parameter;
634 UINT8 CertChain[LIBSPDM_MAX_CERT_CHAIN_SIZE];
635 UINT8 RequesterNonce[SPDM_NONCE_SIZE];
636 UINT8 ResponderNonce[SPDM_NONCE_SIZE];
638 UINTN TrustAnchorSize;
639 BOOLEAN IsValidChallengeAuthSig;
641 SpdmContext = SpdmDeviceContext->SpdmContext;
643 ZeroMem (&Parameter,
sizeof (Parameter));
644 Parameter.location = SpdmDataLocationConnection;
645 DataSize =
sizeof (CapabilityFlags);
646 SpdmReturn = SpdmGetData (SpdmContext, SpdmDataCapabilityFlags, &Parameter, &CapabilityFlags, &DataSize);
647 if (LIBSPDM_STATUS_IS_ERROR (SpdmReturn)) {
648 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_ERROR;
649 return EFI_DEVICE_ERROR;
652 IsValidChallengeAuthSig =
FALSE;
655 CertChainSize =
sizeof (CertChain);
656 ZeroMem (CertChain,
sizeof (CertChain));
657 SpdmReturn = SpdmGetCertificateEx (SpdmContext,
NULL, ValidSlotId, &CertChainSize, CertChain, (
CONST VOID **)&TrustAnchor, &TrustAnchorSize);
658 if ((!LIBSPDM_STATUS_IS_SUCCESS (SpdmReturn)) && (!(SpdmReturn == LIBSPDM_STATUS_VERIF_NO_AUTHORITY))) {
659 return EFI_DEVICE_ERROR;
662 if ((CapabilityFlags & SPDM_GET_CAPABILITIES_RESPONSE_FLAGS_CHAL_CAP) == 0) {
663 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_BINDING;
664 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_DEVICE_NO_CAPABILITIES;
665 Status =
ExtendCertificate (SpdmDeviceContext, *AuthState, CertChainSize, CertChain,
NULL, 0, ValidSlotId, SecurityState);
668 ZeroMem (RequesterNonce,
sizeof (RequesterNonce));
669 ZeroMem (ResponderNonce,
sizeof (ResponderNonce));
670 SpdmReturn = SpdmChallengeEx (SpdmContext,
NULL, ValidSlotId,
SPDM_CHALLENGE_REQUEST_NO_MEASUREMENT_SUMMARY_HASH,
NULL,
NULL,
NULL, RequesterNonce, ResponderNonce,
NULL, 0);
671 if (SpdmReturn == LIBSPDM_STATUS_SUCCESS) {
672 IsValidChallengeAuthSig =
TRUE;
673 }
else if ((LIBSPDM_STATUS_IS_ERROR (SpdmReturn))) {
674 IsValidChallengeAuthSig =
FALSE;
675 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID;
676 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_CHALLENGE_FAILURE;
680 return EFI_DEVICE_ERROR;
683 if (IsValidCertChain && IsValidChallengeAuthSig && !RootCertMatch) {
684 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_AUTH;
685 SecurityState->AuthenticationState = EDKII_DEVICE_SECURITY_STATE_ERROR_NO_CERT_PROVISION;
686 Status =
ExtendCertificate (SpdmDeviceContext, *AuthState, CertChainSize, CertChain,
NULL, 0, ValidSlotId, SecurityState);
687 }
else if (IsValidCertChain && IsValidChallengeAuthSig && RootCertMatch) {
688 *AuthState = TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_SUCCESS;
690 Status =
ExtendCertificate (SpdmDeviceContext, *AuthState, CertChainSize, CertChain, TrustAnchor, TrustAnchorSize, ValidSlotId, SecurityState);
693 Status =
ExtendAuthentication (SpdmDeviceContext, *AuthState, RequesterNonce, ResponderNonce, SecurityState);
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
#define EDKII_DEVICE_SECURITY_STATE_SUCCESS
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
#define SPDM_CHALLENGE_REQUEST_NO_MEASUREMENT_SUMMARY_HASH
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 ExtendCertificate(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, IN UINT8 AuthState, IN UINTN CertChainSize, IN UINT8 *CertChain, IN VOID *TrustAnchor, IN UINTN TrustAnchorSize, IN UINT8 SlotId, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
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)
EFI_STATUS ExtendAuthentication(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, IN UINT8 AuthState, IN UINT8 *RequesterNonce, IN UINT8 *ResponderNonce, OUT EDKII_DEVICE_SECURITY_STATE *SecurityState)
EFI_STATUS EFIAPI MeasureVariable(IN UINT32 PcrIndex, IN UINT32 EventType, IN CHAR16 *VarName, IN EFI_GUID *VendorGuid, IN VOID *VarData, IN UINTN VarSize)
EFI_STATUS EFIAPI CreateDeviceMeasurementContext(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext, IN OUT VOID *DeviceContext, IN UINTN DeviceContextSize)
UINT32 EFIAPI GetSpdmDeviceType(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext)
UINTN EFIAPI GetDeviceMeasurementContextSize(IN SPDM_DEVICE_CONTEXT *SpdmDeviceContext)
EFI_STATUS EFIAPI TpmMeasureAndLogData(IN UINT32 PcrIndex, IN UINT32 EventType, IN VOID *EventLog, IN UINT32 LogLen, IN VOID *HashData, IN UINT64 HashDataLen)
VOID EFIAPI Exit(IN EFI_STATUS Status)
INT8 VariableData[1]
Driver or platform-specific data.