]>
Commit | Line | Data |
---|---|---|
a63b2601 LP |
1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
2 | #pragma once | |
3 | ||
4 | #include <uchar.h> | |
5 | ||
6 | #include "tpm2-util.h" | |
7 | ||
8 | /* Definitions as per "TCG PC Client Specific Platform Firmware Profile Specification" | |
9 | * (https://trustedcomputinggroup.org/resource/pc-client-specific-platform-firmware-profile-specification/), | |
10 | * section 10.4.1 "Event Types" (at least in version 1.05 Revision 23 of the spec) */ | |
11 | #ifndef EV_PREBOOT_CERT | |
12 | #define EV_PREBOOT_CERT UINT32_C(0x00000000) | |
13 | #define EV_POST_CODE UINT32_C(0x00000001) | |
14 | #define EV_NO_ACTION UINT32_C(0x00000003) | |
15 | #define EV_SEPARATOR UINT32_C(0x00000004) | |
16 | #define EV_ACTION UINT32_C(0x00000005) | |
17 | #define EV_EVENT_TAG UINT32_C(0x00000006) | |
18 | #define EV_S_CRTM_CONTENTS UINT32_C(0x00000007) | |
19 | #define EV_S_CRTM_VERSION UINT32_C(0x00000008) | |
20 | #define EV_CPU_MICROCODE UINT32_C(0x00000009) | |
21 | #define EV_PLATFORM_CONFIG_FLAGS UINT32_C(0x0000000a) | |
22 | #define EV_TABLE_OF_DEVICES UINT32_C(0x0000000b) | |
23 | #define EV_COMPACT_HASH UINT32_C(0x0000000c) | |
24 | #define EV_IPL UINT32_C(0x0000000d) | |
25 | #define EV_IPL_PARTITION_DATA UINT32_C(0x0000000e) | |
26 | #define EV_NONHOST_CODE UINT32_C(0x0000000f) | |
27 | #define EV_NONHOST_CONFIG UINT32_C(0x00000010) | |
28 | #define EV_NONHOST_INFO UINT32_C(0x00000011) | |
29 | #define EV_OMIT_BOOT_DEVICE_EVENTS UINT32_C(0x00000012) | |
30 | #define EV_EFI_EVENT_BASE UINT32_C(0x80000000) | |
31 | #define EV_EFI_VARIABLE_DRIVER_CONFIG UINT32_C(0x80000001) | |
32 | #define EV_EFI_VARIABLE_BOOT UINT32_C(0x80000002) | |
33 | #define EV_EFI_BOOT_SERVICES_APPLICATION UINT32_C(0x80000003) | |
34 | #define EV_EFI_BOOT_SERVICES_DRIVER UINT32_C(0x80000004) | |
35 | #define EV_EFI_RUNTIME_SERVICES_DRIVER UINT32_C(0x80000005) | |
36 | #define EV_EFI_GPT_EVENT UINT32_C(0x80000006) | |
37 | #define EV_EFI_ACTION UINT32_C(0x80000007) | |
38 | #define EV_EFI_PLATFORM_FIRMWARE_BLOB UINT32_C(0x80000008) | |
39 | #define EV_EFI_HANDOFF_TABLES UINT32_C(0x80000009) | |
40 | #define EV_EFI_PLATFORM_FIRMWARE_BLOB2 UINT32_C(0x8000000A) | |
41 | #define EV_EFI_HANDOFF_TABLES2 UINT32_C(0x8000000B) | |
42 | #define EV_EFI_VARIABLE_BOOT2 UINT32_C(0x8000000C) | |
43 | #define EV_EFI_HCRTM_EVENT UINT32_C(0x80000010) | |
44 | #define EV_EFI_VARIABLE_AUTHORITY UINT32_C(0x800000E0) | |
45 | #define EV_EFI_SPDM_FIRMWARE_BLOB UINT32_C(0x800000E1) | |
46 | #define EV_EFI_SPDM_FIRMWARE_CONFIG UINT32_C(0x800000E2) | |
47 | #endif | |
48 | ||
49 | /* Defined in drivers/firmware/efi/libstub/efistub.h in the Linux kernel sources */ | |
50 | #ifndef INITRD_EVENT_TAG_ID | |
51 | #define INITRD_EVENT_TAG_ID UINT32_C(0x8F3B22EC) | |
52 | #endif | |
53 | ||
54 | #ifndef LOAD_OPTIONS_EVENT_TAG_ID | |
55 | #define LOAD_OPTIONS_EVENT_TAG_ID UINT32_C(0x8F3B22ED) | |
56 | #endif | |
57 | ||
58 | const char *tpm2_log_event_type_to_string(uint32_t type) _const_; | |
59 | ||
60 | #if HAVE_TPM2 | |
61 | ||
62 | /* UEFI event log data structures */ | |
63 | typedef struct _packed_ TCG_PCClientPCREvent { | |
64 | uint32_t pcrIndex; | |
65 | uint32_t eventType; | |
66 | uint8_t digest[20]; | |
67 | uint32_t eventDataSize; | |
68 | uint32_t event[]; | |
69 | } TCG_PCClientPCREvent; | |
70 | ||
71 | typedef struct _packed_ packed_TPMT_HA { | |
72 | uint16_t hashAlg; | |
73 | TPMU_HA digest; | |
74 | } packed_TPMT_HA; | |
75 | ||
76 | typedef struct _packed_ packed_TPML_DIGEST_VALUES { | |
77 | uint32_t count; | |
78 | packed_TPMT_HA digests[]; | |
79 | } packed_TPML_DIGEST_VALUES; | |
80 | ||
81 | typedef struct _packed_ TCG_PCR_EVENT2 { | |
82 | uint32_t pcrIndex; | |
83 | uint32_t eventType; | |
84 | packed_TPML_DIGEST_VALUES digests; | |
85 | /* … */ | |
86 | } TCG_PCR_EVENT2; | |
87 | ||
88 | typedef struct _packed_ TCG_EfiSpecIdEventAlgorithmSize { | |
89 | uint16_t algorithmId; | |
90 | uint16_t digestSize; | |
91 | } TCG_EfiSpecIdEventAlgorithmSize; | |
92 | ||
93 | typedef struct _packed_ tdTCG_EfiSpecIdEvent { | |
94 | uint8_t signature[16]; | |
95 | uint32_t platformClass; | |
96 | uint8_t specVersionMinor; | |
97 | uint8_t specVersionMajor; | |
98 | uint8_t specErrata; | |
99 | uint8_t uintnSize; | |
100 | uint32_t numberOfAlgorithms; | |
101 | TCG_EfiSpecIdEventAlgorithmSize digestSizes[]; | |
102 | /* … */ | |
103 | } TCG_EfiSpecIDEvent; | |
104 | ||
105 | typedef struct _packed_ UEFI_VARIABLE_DATA { | |
106 | uint8_t variableName[16]; | |
107 | uint64_t unicodeNameLength; | |
108 | uint64_t variableDataLength; | |
109 | char16_t unicodeName[]; | |
110 | /* … */ | |
111 | } UEFI_VARIABLE_DATA; | |
112 | ||
113 | typedef struct _packed_ TCG_PCClientTaggedEvent{ | |
114 | uint32_t taggedEventID; | |
115 | uint32_t taggedEventDataSize; | |
116 | uint8_t taggedEventData[]; | |
117 | } TCG_PCClientTaggedEvent; | |
118 | ||
119 | typedef struct _packed_ packed_EFI_DEVICE_PATH { | |
120 | uint8_t type; | |
121 | uint8_t subType; | |
122 | uint16_t length; | |
123 | uint8_t path[]; | |
124 | } packed_EFI_DEVICE_PATH; | |
125 | ||
126 | typedef struct _packed_ UEFI_IMAGE_LOAD_EVENT { | |
127 | uint64_t imageLocationInMemory; | |
128 | uint64_t imageLengthInMemory; | |
129 | uint64_t imageLinkTimeAddress; | |
130 | uint64_t lengthOfDevicePath; | |
131 | packed_EFI_DEVICE_PATH devicePath[]; | |
132 | } UEFI_IMAGE_LOAD_EVENT; | |
133 | ||
134 | typedef struct _packed_ UEFI_PLATFORM_FIRMWARE_BLOB { | |
135 | uint64_t blobBase; | |
136 | uint64_t blobLength; | |
137 | } UEFI_PLATFORM_FIRMWARE_BLOB; | |
138 | ||
139 | #endif |