Path: blob/main/sys/contrib/edk2/Include/IndustryStandard/UefiTcgPlatform.h
96339 views
/** @file1TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and2TCG PC Client Platform Firmware Profile Specification, Revision 1.0634Copyright (c) 2006 - 2024, Intel Corporation. All rights reserved.<BR>5SPDX-License-Identifier: BSD-2-Clause-Patent67**/89#ifndef __UEFI_TCG_PLATFORM_H__10#define __UEFI_TCG_PLATFORM_H__1112#include <IndustryStandard/Tpm12.h>13#include <IndustryStandard/Tpm20.h>14#include <Uefi.h>1516//17// Standard event types18//19#define EV_PREBOOT_CERT ((TCG_EVENTTYPE) 0x00000000)20#define EV_POST_CODE ((TCG_EVENTTYPE) 0x00000001)21#define EV_NO_ACTION ((TCG_EVENTTYPE) 0x00000003)22#define EV_SEPARATOR ((TCG_EVENTTYPE) 0x00000004)23#define EV_ACTION ((TCG_EVENTTYPE) 0x00000005)24#define EV_EVENT_TAG ((TCG_EVENTTYPE) 0x00000006)25#define EV_S_CRTM_CONTENTS ((TCG_EVENTTYPE) 0x00000007)26#define EV_S_CRTM_VERSION ((TCG_EVENTTYPE) 0x00000008)27#define EV_CPU_MICROCODE ((TCG_EVENTTYPE) 0x00000009)28#define EV_PLATFORM_CONFIG_FLAGS ((TCG_EVENTTYPE) 0x0000000A)29#define EV_TABLE_OF_DEVICES ((TCG_EVENTTYPE) 0x0000000B)30#define EV_COMPACT_HASH ((TCG_EVENTTYPE) 0x0000000C)31#define EV_NONHOST_CODE ((TCG_EVENTTYPE) 0x0000000F)32#define EV_NONHOST_CONFIG ((TCG_EVENTTYPE) 0x00000010)33#define EV_NONHOST_INFO ((TCG_EVENTTYPE) 0x00000011)34#define EV_OMIT_BOOT_DEVICE_EVENTS ((TCG_EVENTTYPE) 0x00000012)3536//37// EFI specific event types38//39#define EV_EFI_EVENT_BASE ((TCG_EVENTTYPE) 0x80000000)40#define EV_EFI_VARIABLE_DRIVER_CONFIG (EV_EFI_EVENT_BASE + 1)41#define EV_EFI_VARIABLE_BOOT (EV_EFI_EVENT_BASE + 2)42#define EV_EFI_BOOT_SERVICES_APPLICATION (EV_EFI_EVENT_BASE + 3)43#define EV_EFI_BOOT_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 4)44#define EV_EFI_RUNTIME_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 5)45#define EV_EFI_GPT_EVENT (EV_EFI_EVENT_BASE + 6)46#define EV_EFI_ACTION (EV_EFI_EVENT_BASE + 7)47#define EV_EFI_PLATFORM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 8)48#define EV_EFI_HANDOFF_TABLES (EV_EFI_EVENT_BASE + 9)49#define EV_EFI_PLATFORM_FIRMWARE_BLOB2 (EV_EFI_EVENT_BASE + 0xA)50#define EV_EFI_HANDOFF_TABLES2 (EV_EFI_EVENT_BASE + 0xB)51#define EV_EFI_HCRTM_EVENT (EV_EFI_EVENT_BASE + 0x10)52#define EV_EFI_VARIABLE_AUTHORITY (EV_EFI_EVENT_BASE + 0xE0)53#define EV_EFI_SPDM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 0xE1)54#define EV_EFI_SPDM_FIRMWARE_CONFIG (EV_EFI_EVENT_BASE + 0xE2)55#define EV_EFI_SPDM_DEVICE_BLOB EV_EFI_SPDM_FIRMWARE_BLOB56#define EV_EFI_SPDM_DEVICE_CONFIG EV_EFI_SPDM_FIRMWARE_CONFIG57//58// The SPDM policy database for SPDM verification.59// It goes to PCR760//61#define EV_EFI_SPDM_DEVICE_POLICY (EV_EFI_EVENT_BASE + 0xE3)62//63// The SPDM policy authority for SPDM verification for the signature64// of GET_MEASUREMENT or CHALLENGE_AUTH. It goes to PCR7.65//66#define EV_EFI_SPDM_DEVICE_AUTHORITY (EV_EFI_EVENT_BASE + 0xE4)6768#define EFI_CALLING_EFI_APPLICATION \69"Calling EFI Application from Boot Option"70#define EFI_RETURNING_FROM_EFI_APPLICATION \71"Returning from EFI Application from Boot Option"72#define EFI_EXIT_BOOT_SERVICES_INVOCATION \73"Exit Boot Services Invocation"74#define EFI_EXIT_BOOT_SERVICES_FAILED \75"Exit Boot Services Returned with Failure"76#define EFI_EXIT_BOOT_SERVICES_SUCCEEDED \77"Exit Boot Services Returned with Success"7879#define EV_POSTCODE_INFO_POST_CODE "POST CODE"80#define POST_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_POST_CODE) - 1)8182#define EV_POSTCODE_INFO_SMM_CODE "SMM CODE"83#define SMM_CODE_STR_LEN (sizeof(EV_POSTCODE_INFO_SMM_CODE) - 1)8485#define EV_POSTCODE_INFO_ACPI_DATA "ACPI DATA"86#define ACPI_DATA_LEN (sizeof(EV_POSTCODE_INFO_ACPI_DATA) - 1)8788#define EV_POSTCODE_INFO_BIS_CODE "BIS CODE"89#define BIS_CODE_LEN (sizeof(EV_POSTCODE_INFO_BIS_CODE) - 1)9091#define EV_POSTCODE_INFO_UEFI_PI "UEFI PI"92#define UEFI_PI_LEN (sizeof(EV_POSTCODE_INFO_UEFI_PI) - 1)9394#define EV_POSTCODE_INFO_OPROM "Embedded Option ROM"95#define OPROM_LEN (sizeof(EV_POSTCODE_INFO_OPROM) - 1)9697#define EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER "Embedded UEFI Driver"98#define EMBEDDED_UEFI_DRIVER_LEN (sizeof(EV_POSTCODE_INFO_EMBEDDED_UEFI_DRIVER) - 1)99100#define FIRMWARE_DEBUGGER_EVENT_STRING "UEFI Debug Mode"101#define FIRMWARE_DEBUGGER_EVENT_STRING_LEN (sizeof(FIRMWARE_DEBUGGER_EVENT_STRING) - 1)102103//104// Set structure alignment to 1-byte105//106#pragma pack (1)107108typedef UINT32 TCG_EVENTTYPE;109typedef TPM_PCRINDEX TCG_PCRINDEX;110typedef TPM_DIGEST TCG_DIGEST;111///112/// Event Log Entry Structure Definition113///114typedef struct tdTCG_PCR_EVENT {115TCG_PCRINDEX PCRIndex; ///< PCRIndex event extended to116TCG_EVENTTYPE EventType; ///< TCG EFI event type117TCG_DIGEST Digest; ///< Value extended into PCRIndex118UINT32 EventSize; ///< Size of the event data119UINT8 Event[1]; ///< The event data120} TCG_PCR_EVENT;121122#define TSS_EVENT_DATA_MAX_SIZE 256123124///125/// TCG_PCR_EVENT_HDR126///127typedef struct tdTCG_PCR_EVENT_HDR {128TCG_PCRINDEX PCRIndex;129TCG_EVENTTYPE EventType;130TCG_DIGEST Digest;131UINT32 EventSize;132} TCG_PCR_EVENT_HDR;133134///135/// EFI_PLATFORM_FIRMWARE_BLOB136///137/// BlobLength should be of type UINTN but we use UINT64 here138/// because PEI is 32-bit while DXE is 64-bit on x64 platforms139///140typedef struct tdEFI_PLATFORM_FIRMWARE_BLOB {141EFI_PHYSICAL_ADDRESS BlobBase;142UINT64 BlobLength;143} EFI_PLATFORM_FIRMWARE_BLOB;144145///146/// UEFI_PLATFORM_FIRMWARE_BLOB147///148/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB149/// event to facilitate the measurement of firmware volume.150///151typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB {152EFI_PHYSICAL_ADDRESS BlobBase;153UINT64 BlobLength;154} UEFI_PLATFORM_FIRMWARE_BLOB;155156///157/// UEFI_PLATFORM_FIRMWARE_BLOB2158///159/// This structure is used in EV_EFI_PLATFORM_FIRMWARE_BLOB2160/// event to facilitate the measurement of firmware volume.161///162typedef struct tdUEFI_PLATFORM_FIRMWARE_BLOB2 {163UINT8 BlobDescriptionSize;164// UINT8 BlobDescription[BlobDescriptionSize];165// EFI_PHYSICAL_ADDRESS BlobBase;166// UINT64 BlobLength;167} UEFI_PLATFORM_FIRMWARE_BLOB2;168169///170/// EFI_IMAGE_LOAD_EVENT171///172/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,173/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER174///175typedef struct tdEFI_IMAGE_LOAD_EVENT {176EFI_PHYSICAL_ADDRESS ImageLocationInMemory;177UINTN ImageLengthInMemory;178UINTN ImageLinkTimeAddress;179UINTN LengthOfDevicePath;180EFI_DEVICE_PATH_PROTOCOL DevicePath[1];181} EFI_IMAGE_LOAD_EVENT;182183///184/// UEFI_IMAGE_LOAD_EVENT185///186/// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,187/// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER188///189typedef struct tdUEFI_IMAGE_LOAD_EVENT {190EFI_PHYSICAL_ADDRESS ImageLocationInMemory;191UINT64 ImageLengthInMemory;192UINT64 ImageLinkTimeAddress;193UINT64 LengthOfDevicePath;194EFI_DEVICE_PATH_PROTOCOL DevicePath[1];195} UEFI_IMAGE_LOAD_EVENT;196197///198/// EFI_HANDOFF_TABLE_POINTERS199///200/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate201/// the measurement of given configuration tables.202///203typedef struct tdEFI_HANDOFF_TABLE_POINTERS {204UINTN NumberOfTables;205EFI_CONFIGURATION_TABLE TableEntry[1];206} EFI_HANDOFF_TABLE_POINTERS;207208///209/// UEFI_HANDOFF_TABLE_POINTERS210///211/// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate212/// the measurement of given configuration tables.213///214typedef struct tdUEFI_HANDOFF_TABLE_POINTERS {215UINT64 NumberOfTables;216EFI_CONFIGURATION_TABLE TableEntry[1];217} UEFI_HANDOFF_TABLE_POINTERS;218219///220/// UEFI_HANDOFF_TABLE_POINTERS2221///222/// This structure is used in EV_EFI_HANDOFF_TABLES2 event to facilitate223/// the measurement of given configuration tables.224///225typedef struct tdUEFI_HANDOFF_TABLE_POINTERS2 {226UINT8 TableDescriptionSize;227// UINT8 TableDescription[TableDescriptionSize];228// UINT64 NumberOfTables;229// EFI_CONFIGURATION_TABLE TableEntry[1];230} UEFI_HANDOFF_TABLE_POINTERS2;231232///233/// EFI_VARIABLE_DATA234///235/// This structure serves as the header for measuring variables. The name of the236/// variable (in Unicode format) should immediately follow, then the variable237/// data.238/// This is defined in TCG EFI Platform Spec for TPM1.1 or 1.2 V1.22239///240typedef struct tdEFI_VARIABLE_DATA {241EFI_GUID VariableName;242UINTN UnicodeNameLength;243UINTN VariableDataLength;244CHAR16 UnicodeName[1];245INT8 VariableData[1]; ///< Driver or platform-specific data246} EFI_VARIABLE_DATA;247248///249/// UEFI_VARIABLE_DATA250///251/// This structure serves as the header for measuring variables. The name of the252/// variable (in Unicode format) should immediately follow, then the variable253/// data.254/// This is defined in TCG PC Client Firmware Profile Spec 00.21255///256typedef struct tdUEFI_VARIABLE_DATA {257EFI_GUID VariableName;258UINT64 UnicodeNameLength;259UINT64 VariableDataLength;260CHAR16 UnicodeName[1];261INT8 VariableData[1]; ///< Driver or platform-specific data262} UEFI_VARIABLE_DATA;263264//265// For TrEE1.0 compatibility266//267typedef struct {268EFI_GUID VariableName;269UINT64 UnicodeNameLength; // The TCG Definition used UINTN270UINT64 VariableDataLength; // The TCG Definition used UINTN271CHAR16 UnicodeName[1];272INT8 VariableData[1];273} EFI_VARIABLE_DATA_TREE;274275typedef struct tdEFI_GPT_DATA {276EFI_PARTITION_TABLE_HEADER EfiPartitionHeader;277UINTN NumberOfPartitions;278EFI_PARTITION_ENTRY Partitions[1];279} EFI_GPT_DATA;280281typedef struct tdUEFI_GPT_DATA {282EFI_PARTITION_TABLE_HEADER EfiPartitionHeader;283UINT64 NumberOfPartitions;284EFI_PARTITION_ENTRY Partitions[1];285} UEFI_GPT_DATA;286287#define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE "SPDM Device Sec"288#define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION 1289290#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_NULL 0291#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_PCI 1292#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_TYPE_USB 2293294///295/// TCG_DEVICE_SECURITY_EVENT_DATA_HEADER296/// This is the header of TCG_DEVICE_SECURITY_EVENT_DATA, which is297/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.298///299typedef struct {300UINT8 Signature[16];301UINT16 Version;302UINT16 Length;303UINT32 SpdmHashAlgo;304UINT32 DeviceType;305// SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock;306} TCG_DEVICE_SECURITY_EVENT_DATA_HEADER;307308#define TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT_VERSION 0309310///311/// TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT312/// This is the PCI context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is313/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.314///315typedef struct {316UINT16 Version;317UINT16 Length;318UINT16 VendorId;319UINT16 DeviceId;320UINT8 RevisionID;321UINT8 ClassCode[3];322UINT16 SubsystemVendorID;323UINT16 SubsystemID;324} TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT;325326#define TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT_VERSION 0327328///329/// TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT330/// This is the USB context data of TCG_DEVICE_SECURITY_EVENT_DATA, which is331/// used in EV_EFI_SPDM_FIRMWARE_BLOB and EV_EFI_SPDM_FIRMWARE_CONFIG.332///333typedef struct {334UINT16 Version;335UINT16 Length;336// UINT8 DeviceDescriptor[DescLen];337// UINT8 BodDescriptor[DescLen];338// UINT8 ConfigurationDescriptor[DescLen][NumOfConfiguration];339} TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT;340341//342// Crypto Agile Log Entry Format343//344typedef struct tdTCG_PCR_EVENT2 {345TCG_PCRINDEX PCRIndex;346TCG_EVENTTYPE EventType;347TPML_DIGEST_VALUES Digest;348UINT32 EventSize;349UINT8 Event[1];350} TCG_PCR_EVENT2;351352//353// TCG PCR Event2 Header354// Follow TCG EFI Protocol Spec 5.2 Crypto Agile Log Entry Format355//356typedef struct tdTCG_PCR_EVENT2_HDR {357TCG_PCRINDEX PCRIndex;358TCG_EVENTTYPE EventType;359TPML_DIGEST_VALUES Digests;360UINT32 EventSize;361} TCG_PCR_EVENT2_HDR;362363//364// Log Header Entry Data365//366typedef struct {367//368// TCG defined hashing algorithm ID.369//370UINT16 algorithmId;371//372// The size of the digest for the respective hashing algorithm.373//374UINT16 digestSize;375} TCG_EfiSpecIdEventAlgorithmSize;376377#define TCG_EfiSpecIDEventStruct_SIGNATURE_02 "Spec ID Event02"378#define TCG_EfiSpecIDEventStruct_SIGNATURE_03 "Spec ID Event03"379380#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM12 1381#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM12 2382#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM12 2383384#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MAJOR_TPM2 2385#define TCG_EfiSpecIDEventStruct_SPEC_VERSION_MINOR_TPM2 0386#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2 0387#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_105 105388#define TCG_EfiSpecIDEventStruct_SPEC_ERRATA_TPM2_REV_106 106389390typedef struct {391UINT8 signature[16];392//393// The value for the Platform Class.394// The enumeration is defined in the TCG ACPI Specification Client Common Header.395//396UINT32 platformClass;397//398// The TCG EFI Platform Specification minor version number this BIOS supports.399// Any BIOS supporting version (1.22) MUST set this value to 02h.400// Any BIOS supporting version (2.0) SHALL set this value to 0x00.401//402UINT8 specVersionMinor;403//404// The TCG EFI Platform Specification major version number this BIOS supports.405// Any BIOS supporting version (1.22) MUST set this value to 01h.406// Any BIOS supporting version (2.0) SHALL set this value to 0x02.407//408UINT8 specVersionMajor;409//410// The TCG EFI Platform Specification errata for this specification this BIOS supports.411// Any BIOS supporting version and errata (1.22) MUST set this value to 02h.412// Any BIOS supporting version and errata (2.0) SHALL set this value to 0x00.413//414UINT8 specErrata;415//416// Specifies the size of the UINTN fields used in various data structures used in this specification.417// 0x01 indicates UINT32 and 0x02 indicates UINT64.418//419UINT8 uintnSize;420//421// This field is added in "Spec ID Event03".422// The number of hashing algorithms used in this event log (except the first event).423// All events in this event log use all hashing algorithms defined here.424//425UINT32 numberOfAlgorithms;426//427// This field is added in "Spec ID Event03".428// An array of size numberOfAlgorithms of value pairs.429//430//TCG_EfiSpecIdEventAlgorithmSize digestSize[numberOfAlgorithms];431TCG_EfiSpecIdEventAlgorithmSize digestSize[];432//433// Size in bytes of the VendorInfo field.434// Maximum value SHALL be FFh bytes.435//436//UINT8 vendorInfoSize;437//438// Provided for use by the BIOS implementer.439// The value might be used, for example, to provide more detailed information about the specific BIOS such as BIOS revision numbers, etc.440// The values within this field are not standardized and are implementer-specific.441// Platform-specific or -unique information SHALL NOT be provided in this field.442//443//UINT8 vendorInfo[vendorInfoSize];444} TCG_EfiSpecIDEventStruct;445446typedef struct tdTCG_PCClientTaggedEvent {447UINT32 taggedEventID;448UINT32 taggedEventDataSize;449// UINT8 taggedEventData[taggedEventDataSize];450} TCG_PCClientTaggedEvent;451452#define TCG_Sp800_155_PlatformId_Event_SIGNATURE "SP800-155 Event"453#define TCG_Sp800_155_PlatformId_Event2_SIGNATURE "SP800-155 Event2"454#define TCG_Sp800_155_PlatformId_Event3_SIGNATURE "SP800-155 Event3"455456typedef struct tdTCG_Sp800_155_PlatformId_Event2 {457UINT8 Signature[16];458//459// Where Vendor ID is an integer defined460// at http://www.iana.org/assignments/enterprisenumbers461//462UINT32 VendorId;463//464// 16-byte identifier of a given platform's static configuration of code465//466EFI_GUID ReferenceManifestGuid;467//468// Below structure is newly added in TCG_Sp800_155_PlatformId_Event2.469//470// UINT8 PlatformManufacturerStrSize;471// UINT8 PlatformManufacturerStr[PlatformManufacturerStrSize];472// UINT8 PlatformModelSize;473// UINT8 PlatformModel[PlatformModelSize];474// UINT8 PlatformVersionSize;475// UINT8 PlatformVersion[PlatformVersionSize];476// UINT8 FirmwareManufacturerStrSize;477// UINT8 FirmwareManufacturerStr[FirmwareManufacturerStrSize];478// UINT32 FirmwareManufacturerId;479// UINT8 FirmwareVersion;480// UINT8 FirmwareVersion[FirmwareVersionSize];481} TCG_Sp800_155_PlatformId_Event2;482483typedef struct tdTCG_Sp800_155_PlatformId_Event3 {484UINT8 Signature[16];485//486// Where Vendor ID is an integer defined487// at http://www.iana.org/assignments/enterprisenumbers488//489UINT32 VendorId;490//491// 16-byte identifier of a given platform's static configuration of code492//493EFI_GUID ReferenceManifestGuid;494// UINT8 PlatformManufacturerStrSize;495// UINT8 PlatformManufacturerStr[PlatformManufacturerStrSize];496// UINT8 PlatformModelSize;497// UINT8 PlatformModel[PlatformModelSize];498// UINT8 PlatformVersionSize;499// UINT8 PlatformVersion[PlatformVersionSize];500// UINT8 FirmwareManufacturerStrSize;501// UINT8 FirmwareManufacturerStr[FirmwareManufacturerStrSize];502// UINT32 FirmwareManufacturerId;503// UINT8 FirmwareVersion;504// UINT8 FirmwareVersion[FirmwareVersionSize];505//506// Below structure is newly added in TCG_Sp800_155_PlatformId_Event3507//508// UINT32 RimLocatorType;509// UINT32 RimLocatorLength;510// UINT8 RimLocator[RimLocatorLength];511// UINT32 PlatformCertLocatorType;512// UINT32 PlatformCertLocatorLength;513// UINT8 PlatformCertLocator[PlatformCertLocatorLength];514} TCG_Sp800_155_PlatformId_Event3;515516/**517* TCG specifies a locator type with the following values518* 0 - Raw data in the locator itself.519* 1 - URI in rtf2396 format.520* 2 - local device path in EFI_DEVICE_PATH_PROTOCOL format.521* 3 - UEFI variable (16 byte EFI_GUID, then 00-terminated UCS2 string)522**/523#define TCG_LOCATOR_TYPE_RAW_DATA 0524#define TCG_LOCATOR_TYPE_URI 1525#define TCG_LOCATOR_TYPE_DEVICE_PATH 2526#define TCG_LOCATOR_TYPE_UEFI_VARIABLE 3527528#define TCG_EfiStartupLocalityEvent_SIGNATURE "StartupLocality"529530//531// The Locality Indicator which sent the TPM2_Startup command532//533#define LOCALITY_0_INDICATOR 0x00534#define LOCALITY_3_INDICATOR 0x03535536//537// Startup Locality Event538//539typedef struct tdTCG_EfiStartupLocalityEvent {540UINT8 Signature[16];541//542// The Locality Indicator which sent the TPM2_Startup command543//544UINT8 StartupLocality;545} TCG_EfiStartupLocalityEvent;546547//548// Restore original structure alignment549//550#pragma pack ()551552//553// ======================================================================================================================554// Event Type PCR Event Log Usage555// ======================================================================================================================556// EV_EFI_SPDM_DEVICE_BLOB 2 SPDM_MEASUREMENT_BLOCK (subtype) MEASUREMENT from device557// EV_EFI_SPDM_DEVICE_CONFIG 3 SPDM_MEASUREMENT_BLOCK (subtype) MEASUREMENT from device558// EV_EFI_SPDM_DEVICE_BLOB 2 SPDM_MEASUREMENT_SUMMARY_HASH.TCB (subtype) SUMMARY_HASH from device559560// EV_EFI_SPDM_DEVICE_POLICY 7 UEFI_VARIABLE_DATA with EFI_SIGNATURE_LIST Provisioned device public cert.561// EV_EFI_SPDM_DEVICE_AUTHORITY 7 UEFI_VARIABLE_DATA with EFI_SIGNATURE_DATA CHALLENGE_AUTH signature verification562// ======================================================================================================================563//564565#define PCR_INDEX_FOR_SIGNATURE_DB 7566567#pragma pack(1)568569#define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_1 1570#define TCG_DEVICE_SECURITY_EVENT_DATA_VERSION_2 2571#define TCG_DEVICE_SECURITY_EVENT_DATA_SIGNATURE_2 "SPDM Device Sec2"572573typedef struct {574UINT8 Signature[16];575UINT16 Version;576UINT8 AuthState;577UINT8 Reserved;578UINT32 Length; // Length in bytes for all following structures.579UINT32 DeviceType;580UINT32 SubHeaderType;581UINT32 SubHeaderLength; // Length in bytes of the sub header followed by.582UINT64 SubHeaderUID; // Universal identifier assigned by the event log creator. It can be used to bind two sub header structure together.583// UINT64 DevicePathLength;584// UINT8 DevicePath[DevicePathLength];585} TCG_DEVICE_SECURITY_EVENT_DATA_HEADER2;586587#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_SUCCESS 0588#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_AUTH 1589#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_BINDING 2590#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_NO_SIG 3591#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_FAIL_INVALID 4592#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_AUTH_STATE_NO_SPDM 0xFF593594#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_MEASUREMENT_BLOCK 0595#define TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_SUB_HEADER_TYPE_SPDM_CERT_CHAIN 1596597typedef struct {598UINT16 SpdmVersion;599UINT8 SpdmMeasurementBlockCount;600UINT8 Reserved;601UINT32 SpdmMeasurementHashAlgo;602// SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock;603} TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK;604605typedef struct {606UINT16 SpdmVersion;607UINT8 SpdmSlotId;608UINT8 Reserved;609UINT32 SpdmHashAlgo;610// SPDM_CERT_CHAIN SpdmCertChain;611} TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN;612613typedef struct {614UINT32 Type;615UINT32 Length;616UINT8 Value[1];617} TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_OEM_MEASUREMENT;618619typedef union {620TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_MEASUREMENT_BLOCK SpdmMeasurementBlock;621TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_SPDM_CERT_CHAIN SpdmCertChain;622TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER_OEM_MEASUREMENT OemMeasurement;623} TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER;624625typedef union {626TCG_DEVICE_SECURITY_EVENT_DATA_PCI_CONTEXT Pci;627TCG_DEVICE_SECURITY_EVENT_DATA_USB_CONTEXT Usb;628} TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT;629630typedef struct {631TCG_DEVICE_SECURITY_EVENT_DATA_HEADER2 EventDataHeader;632TCG_DEVICE_SECURITY_EVENT_DATA_SUB_HEADER EventDataSubHeader;633TCG_DEVICE_SECURITY_EVENT_DATA_DEVICE_CONTEXT DeviceContext;634} TCG_DEVICE_SECURITY_EVENT_DATA2;635636#pragma pack()637638//639// EventType:EV_NO_ACTION640// ======================================================================================================================641// NVIndex Name PCR/NvIndex Event Log Usage642// ======================================================================================================================643// NV_EXTEND_INDEX_FOR_INSTANCE 0x01C40200 NV_INDEX_INSTANCE_EVENT_LOG_STRUCT NV Extend Record for instance data (CertChain)644// NV_EXTEND_INDEX_FOR_DYNAMIC 0x01C40201 NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT NV Extend Record for dynamic data (Nonce)645646// EVENT_LOG_INTEGRITY_NV_INDEX_EXIT_PM_AUTH 0x01C40202 EVENT_LOG_INTEGRITY_NV_INDEX_STRUCT Event Log Integrity for ExitPmAuth647// EVENT_LOG_INTEGRITY_NV_INDEX_READY_TO_BOOT 0x01C40203 EVENT_LOG_INTEGRITY_NV_INDEX_STRUCT Event Log Integrity for ReadyToBoot648// ======================================================================================================================649//650651#define TCG_NV_EXTEND_INDEX_FOR_INSTANCE 0x01C40200652#define TCG_NV_EXTEND_INDEX_FOR_DYNAMIC 0x01C40201653#define TCG_EVENT_LOG_INTEGRITY_NV_INDEX_EXIT_PM_AUTH 0x01C40202654#define TCG_EVENT_LOG_INTEGRITY_NV_INDEX_READY_TO_BOOT 0x01C40203655656#pragma pack(1)657658#define TCG_NV_EXTEND_INDEX_FOR_INSTANCE_SIGNATURE "NvIndexInstance"659#define TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT_VERSION 1660661typedef struct {662UINT8 Signature[16];663UINT16 Version;664UINT8 Reserved[6];665// TCG_DEVICE_SECURITY_EVENT_DATA2 Data;666} TCG_NV_INDEX_INSTANCE_EVENT_LOG_STRUCT;667668#define TCG_NV_EXTEND_INDEX_FOR_DYNAMIC_SIGNATURE "NvIndexDynamic "669#define TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_VERSION 1670671#define TCG_SPDM_CHALLENGE_DESCRIPTION "SPDM CHALLENGE"672#define TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION "SPDM CHALLENGE_AUTH"673#define TCG_SPDM_GET_MEASUREMENTS_DESCRIPTION "SPDM GET_MEASUREMENTS"674#define TCG_SPDM_MEASUREMENTS_DESCRIPTION "SPDM MEASUREMENTS"675676typedef struct {677UINT8 Signature[16];678UINT16 Version;679UINT8 Reserved[6];680UINT64 Uid;681// UINT16 DescriptionSize;682// UINT8 Description[DescriptionSize];683// UINT16 DataSize;684// UINT8 Data[DataSize];685} TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT;686687typedef struct {688TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT Header;689UINT16 DescriptionSize;690UINT8 Description[sizeof (TCG_SPDM_CHALLENGE_DESCRIPTION)];691UINT16 DataSize;692UINT8 Data[32];693} TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_CHALLENGE;694695typedef struct {696TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT Header;697UINT16 DescriptionSize;698UINT8 Description[sizeof (TCG_SPDM_CHALLENGE_AUTH_DESCRIPTION)];699UINT16 DataSize;700UINT8 Data[32];701} TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_CHALLENGE_AUTH;702703typedef struct {704TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT Header;705UINT16 DescriptionSize;706UINT8 Description[sizeof (TCG_SPDM_GET_MEASUREMENTS_DESCRIPTION)];707UINT16 DataSize;708UINT8 Data[32];709} TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_GET_MEASUREMENTS;710711typedef struct {712TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT Header;713UINT16 DescriptionSize;714UINT8 Description[sizeof (TCG_SPDM_MEASUREMENTS_DESCRIPTION)];715UINT16 DataSize;716UINT8 Data[32];717} TCG_NV_INDEX_DYNAMIC_EVENT_LOG_STRUCT_SPDM_MEASUREMENTS;718719#pragma pack()720721#endif722723724