iPXE
Tcg2Protocol.h
Go to the documentation of this file.
1/** @file
2 TPM2 Protocol as defined in TCG PC Client Platform EFI Protocol Specification Family "2.0".
3 See http://trustedcomputinggroup.org for the latest specification
4
5Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef __TCG2_PROTOCOL_H__
11#define __TCG2_PROTOCOL_H__
12
13FILE_LICENCE ( BSD2_PATENT );
14FILE_SECBOOT ( PERMITTED );
15
18
19#define EFI_TCG2_PROTOCOL_GUID \
20 {0x607f766c, 0x7455, 0x42be, { 0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f }}
21
23
28
32
33#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001
34#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
35
37 //
38 // Allocated size of the structure
39 //
41 //
42 // Version of the EFI_TCG2_BOOT_SERVICE_CAPABILITY structure itself.
43 // For this version of the protocol, the Major version shall be set to 1
44 // and the Minor version shall be set to 1.
45 //
47 //
48 // Version of the EFI TCG2 protocol.
49 // For this version of the protocol, the Major version shall be set to 1
50 // and the Minor version shall be set to 1.
51 //
53 //
54 // Supported hash algorithms (this bitmap is determined by the supported PCR
55 // banks in the TPM and the hashing algorithms supported by the firmware)
56 //
58 //
59 // Bitmap of supported event log formats
60 //
62 //
63 // False = TPM not present
64 //
66 //
67 // Max size (in bytes) of a command that can be sent to the TPM
68 //
70 //
71 // Max size (in bytes) of a response that can be provided by the TPM
72 //
74 //
75 // 4-byte Vendor ID
76 // (see TCG Vendor ID registry, Section "TPM Capabilities Vendor ID")
77 //
79 //
80 // Maximum number of PCR banks (hashing algorithms) supported.
81 // No granularity is provided to support a specific set of algorithms.
82 // Minimum value is 1.
83 //
85 //
86 // A bitmap of currently active PCR banks (hashing algorithms).
87 // This is a subset of the supported hashing algorithms reported in HashAlgorithmBitMap.
88 // NumberOfPcrBanks defines the number of bits that are set.
89 //
92
93#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
94#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
95#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
96#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
97#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
98
99//
100// This bit is shall be set when an event shall be extended but not logged.
101//
102#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
103//
104// This bit shall be set when the intent is to measure a PE/COFF image.
105//
106#define PE_COFF_IMAGE 0x0000000000000010
107
108#define MAX_PCR_INDEX 23
109
110#pragma pack(1)
111
112#define EFI_TCG2_EVENT_HEADER_VERSION 1
113
114typedef struct {
115 //
116 // Size of the event header itself (sizeof(EFI_TCG2_EVENT_HEADER)).
117 //
119 //
120 // Header version. For this version of this specification, the value shall be 1.
121 //
123 //
124 // Index of the PCR that shall be extended (0 - 23).
125 //
127 //
128 // Type of the event that shall be extended (and optionally logged).
129 //
132
133typedef struct tdEFI_TCG2_EVENT {
134 //
135 // Total size of the event including the Size component, the header and the Event data.
136 //
141
142#pragma pack()
143
144/**
145 The EFI_TCG2_PROTOCOL GetCapability function call provides protocol
146 capability information and state information.
147
148 @param[in] This Indicates the calling context
149 @param[in, out] ProtocolCapability The caller allocates memory for a EFI_TCG2_BOOT_SERVICE_CAPABILITY
150 structure and sets the size field to the size of the structure allocated.
151 The callee fills in the fields with the EFI protocol capability information
152 and the current EFI TCG2 state information up to the number of fields which
153 fit within the size of the structure passed in.
154
155 @retval EFI_SUCCESS Operation completed successfully.
156 @retval EFI_DEVICE_ERROR The command was unsuccessful.
157 The ProtocolCapability variable will not be populated.
158 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
159 The ProtocolCapability variable will not be populated.
160 @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too small to hold the full response.
161 It will be partially populated (required Size field will be set).
162**/
163typedef
166 IN EFI_TCG2_PROTOCOL *This,
167 IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
168 );
169
170/**
171 The EFI_TCG2_PROTOCOL Get Event Log function call allows a caller to
172 retrieve the address of a given event log and its last entry.
173
174 @param[in] This Indicates the calling context
175 @param[in] EventLogFormat The type of the event log for which the information is requested.
176 @param[out] EventLogLocation A pointer to the memory address of the event log.
177 @param[out] EventLogLastEntry If the Event Log contains more than one entry, this is a pointer to the
178 address of the start of the last entry in the event log in memory.
179 @param[out] EventLogTruncated If the Event Log is missing at least one entry because an event would
180 have exceeded the area allocated for events, this value is set to TRUE.
181 Otherwise, the value will be FALSE and the Event Log will be complete.
182
183 @retval EFI_SUCCESS Operation completed successfully.
184 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect
185 (e.g. asking for an event log whose format is not supported).
186**/
187typedef
190 IN EFI_TCG2_PROTOCOL *This,
191 IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
192 OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
193 OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
194 OUT BOOLEAN *EventLogTruncated
195 );
196
197/**
198 The EFI_TCG2_PROTOCOL HashLogExtendEvent function call provides callers with
199 an opportunity to extend and optionally log events without requiring
200 knowledge of actual TPM commands.
201 The extend operation will occur even if this function cannot create an event
202 log entry (e.g. due to the event log being full).
203
204 @param[in] This Indicates the calling context
205 @param[in] Flags Bitmap providing additional information.
206 @param[in] DataToHash Physical address of the start of the data buffer to be hashed.
207 @param[in] DataToHashLen The length in bytes of the buffer referenced by DataToHash.
208 @param[in] EfiTcgEvent Pointer to data buffer containing information about the event.
209
210 @retval EFI_SUCCESS Operation completed successfully.
211 @retval EFI_DEVICE_ERROR The command was unsuccessful.
212 @retval EFI_VOLUME_FULL The extend operation occurred, but the event could not be written to one or more event logs.
213 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
214 @retval EFI_UNSUPPORTED The PE/COFF image type is not supported.
215**/
216typedef
219 IN EFI_TCG2_PROTOCOL *This,
221 IN EFI_PHYSICAL_ADDRESS DataToHash,
222 IN UINT64 DataToHashLen,
223 IN EFI_TCG2_EVENT *EfiTcgEvent
224 );
225
226/**
227 This service enables the sending of commands to the TPM.
228
229 @param[in] This Indicates the calling context
230 @param[in] InputParameterBlockSize Size of the TPM input parameter block.
231 @param[in] InputParameterBlock Pointer to the TPM input parameter block.
232 @param[in] OutputParameterBlockSize Size of the TPM output parameter block.
233 @param[in] OutputParameterBlock Pointer to the TPM output parameter block.
234
235 @retval EFI_SUCCESS The command byte stream was successfully sent to the device and a response was successfully received.
236 @retval EFI_DEVICE_ERROR The command was not successfully sent to the device or a response was not successfully received from the device.
237 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
238 @retval EFI_BUFFER_TOO_SMALL The output parameter block is too small.
239**/
240typedef
243 IN EFI_TCG2_PROTOCOL *This,
244 IN UINT32 InputParameterBlockSize,
245 IN UINT8 *InputParameterBlock,
246 IN UINT32 OutputParameterBlockSize,
247 IN UINT8 *OutputParameterBlock
248 );
249
250/**
251 This service returns the currently active PCR banks.
252
253 @param[in] This Indicates the calling context
254 @param[out] ActivePcrBanks Pointer to the variable receiving the bitmap of currently active PCR banks.
255
256 @retval EFI_SUCCESS The bitmap of active PCR banks was stored in the ActivePcrBanks parameter.
257 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
258**/
259typedef
262 IN EFI_TCG2_PROTOCOL *This,
263 OUT UINT32 *ActivePcrBanks
264 );
265
266/**
267 This service sets the currently active PCR banks.
268
269 @param[in] This Indicates the calling context
270 @param[in] ActivePcrBanks Bitmap of the requested active PCR banks. At least one bit SHALL be set.
271
272 @retval EFI_SUCCESS The bitmap in ActivePcrBank parameter is already active.
273 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
274**/
275typedef
278 IN EFI_TCG2_PROTOCOL *This,
279 IN UINT32 ActivePcrBanks
280 );
281
282/**
283 This service retrieves the result of a previous invocation of SetActivePcrBanks.
284
285 @param[in] This Indicates the calling context
286 @param[out] OperationPresent Non-zero value to indicate a SetActivePcrBank operation was invoked during the last boot.
287 @param[out] Response The response from the SetActivePcrBank request.
288
289 @retval EFI_SUCCESS The result value could be returned.
290 @retval EFI_INVALID_PARAMETER One or more of the parameters are incorrect.
291**/
292typedef
295 IN EFI_TCG2_PROTOCOL *This,
296 OUT UINT32 *OperationPresent,
297 OUT UINT32 *Response
298 );
299
309
311
312//
313// Log entries after Get Event Log service
314//
315
316#define EFI_TCG2_FINAL_EVENTS_TABLE_GUID \
317 {0x1e2ed096, 0x30e2, 0x4254, { 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25 }}
318
320
322 //
323 // The version of this structure.
324 //
326 //
327 // Number of events recorded after invocation of GetEventLog API
328 //
330 //
331 // List of events of type TCG_PCR_EVENT2.
332 //
333 // TCG_PCR_EVENT2 Event[1];
335
336#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
337
338#endif
unsigned short UINT16
2-byte unsigned value.
unsigned char BOOLEAN
Logical Boolean.
unsigned long long UINT64
8-byte unsigned value.
#define EFIAPI
unsigned char UINT8
1-byte unsigned value.
unsigned int UINT32
4-byte unsigned value.
struct tdEFI_TCG2_VERSION EFI_TCG2_VERSION
UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP
EFI_STATUS(EFIAPI * EFI_TCG2_GET_EVENT_LOG)(IN EFI_TCG2_PROTOCOL *This, IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat, OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry, OUT BOOLEAN *EventLogTruncated)
The EFI_TCG2_PROTOCOL Get Event Log function call allows a caller to retrieve the address of a given ...
EFI_STATUS(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS)(IN EFI_TCG2_PROTOCOL *This, OUT UINT32 *OperationPresent, OUT UINT32 *Response)
This service retrieves the result of a previous invocation of SetActivePcrBanks.
EFI_STATUS(EFIAPI * EFI_TCG2_GET_CAPABILITY)(IN EFI_TCG2_PROTOCOL *This, IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability)
The EFI_TCG2_PROTOCOL GetCapability function call provides protocol capability information and state ...
EFI_STATUS(EFIAPI * EFI_TCG2_SET_ACTIVE_PCR_BANKS)(IN EFI_TCG2_PROTOCOL *This, IN UINT32 ActivePcrBanks)
This service sets the currently active PCR banks.
EFI_STATUS(EFIAPI * EFI_TCG2_SUBMIT_COMMAND)(IN EFI_TCG2_PROTOCOL *This, IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN UINT32 OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
This service enables the sending of commands to the TPM.
struct tdEFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL
EFI_GUID gEfiTcg2ProtocolGuid
EFI_STATUS(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT)(IN EFI_TCG2_PROTOCOL *This, IN UINT64 Flags, IN EFI_PHYSICAL_ADDRESS DataToHash, IN UINT64 DataToHashLen, IN EFI_TCG2_EVENT *EfiTcgEvent)
The EFI_TCG2_PROTOCOL HashLogExtendEvent function call provides callers with an opportunity to extend...
EFI_STATUS(EFIAPI * EFI_TCG2_GET_ACTIVE_PCR_BANKS)(IN EFI_TCG2_PROTOCOL *This, OUT UINT32 *ActivePcrBanks)
This service returns the currently active PCR banks.
struct tdEFI_TCG2_EVENT EFI_TCG2_EVENT
UINT32 EFI_TCG2_EVENT_LOG_FORMAT
struct tdEFI_TCG2_BOOT_SERVICE_CAPABILITY EFI_TCG2_BOOT_SERVICE_CAPABILITY
UINT32 EFI_TCG2_EVENT_LOG_BITMAP
EFI_GUID gEfiTcg2FinalEventsTableGuid
struct tdEFI_TCG2_FINAL_EVENTS_TABLE EFI_TCG2_FINAL_EVENTS_TABLE
TPM2.0 Specification data structures (Trusted Platform Module Library Specification,...
UINT64 EFI_PHYSICAL_ADDRESS
64-bit physical memory address.
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
GUID EFI_GUID
128-bit buffer containing a unique identifier value.
TCG EFI Platform Definition in TCG_EFI_Platform_1_20_Final and TCG PC Client Platform Firmware Profil...
UINT32 TCG_EVENTTYPE
TPM_PCRINDEX TCG_PCRINDEX
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:926
#define IN
Definition mlx_utils.h:28
#define OUT
Definition mlx_utils.h:29
UINT16_t Flags
Flags.
Definition pxe_api.h:30
TCG_EVENTTYPE EventType
EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs
EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks
EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap
EFI_TCG2_EVENT_HEADER Header
EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks
EFI_TCG2_SUBMIT_COMMAND SubmitCommand
EFI_TCG2_GET_CAPABILITY GetCapability
EFI_TCG2_GET_EVENT_LOG GetEventLog
EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks
EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks
EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent