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