1 /** @file 2 TCG Service Protocol as defined in TCG_EFI_Protocol_1_22_Final 3 See http://trustedcomputinggroup.org for the latest specification 4 5 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR> 6 This program and the accompanying materials are licensed and made available under 7 the terms and conditions of the BSD License that accompanies this distribution. 8 The full text of the license may be found at 9 http://opensource.org/licenses/bsd-license.php. 10 11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 13 14 **/ 15 16 #ifndef _TCG_SERVICE_PROTOCOL_H_ 17 #define _TCG_SERVICE_PROTOCOL_H_ 18 19 FILE_LICENCE ( BSD3 ); 20 21 #include <ipxe/efi/IndustryStandard/UefiTcgPlatform.h> 22 23 #define EFI_TCG_PROTOCOL_GUID \ 24 {0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd } } 25 26 typedef struct _EFI_TCG_PROTOCOL EFI_TCG_PROTOCOL; 27 28 typedef struct { 29 UINT8 Major; 30 UINT8 Minor; 31 UINT8 RevMajor; 32 UINT8 RevMinor; 33 } TCG_VERSION; 34 35 typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY { 36 UINT8 Size; /// Size of this structure. 37 TCG_VERSION StructureVersion; 38 TCG_VERSION ProtocolSpecVersion; 39 UINT8 HashAlgorithmBitmap; /// Hash algorithms . 40 /// This protocol is capable of : 01=SHA-1. 41 BOOLEAN TPMPresentFlag; /// 00h = TPM not present. 42 BOOLEAN TPMDeactivatedFlag; /// 01h = TPM currently deactivated. 43 } TCG_EFI_BOOT_SERVICE_CAPABILITY; 44 45 typedef UINT32 TCG_ALGORITHM_ID; 46 47 /** 48 This service provides EFI protocol capability information, state information 49 about the TPM, and Event Log state information. 50 51 @param This Indicates the calling context 52 @param ProtocolCapability The callee allocates memory for a TCG_BOOT_SERVICE_CAPABILITY 53 structure and fills in the fields with the EFI protocol 54 capability information and the current TPM state information. 55 @param TCGFeatureFlags This is a pointer to the feature flags. No feature 56 flags are currently defined so this parameter 57 MUST be set to 0. However, in the future, 58 feature flags may be defined that, for example, 59 enable hash algorithm agility. 60 @param EventLogLocation This is a pointer to the address of the event log in memory. 61 @param EventLogLastEntry If the Event Log contains more than one entry, 62 this is a pointer to the address of the start of 63 the last entry in the event log in memory. 64 65 @retval EFI_SUCCESS The operation completed successfully. 66 @retval EFI_INVALID_PARAMETER ProtocolCapability does not match TCG capability. 67 **/ 68 typedef 69 EFI_STATUS 70 (EFIAPI *EFI_TCG_STATUS_CHECK)( 71 IN EFI_TCG_PROTOCOL *This, 72 OUT TCG_EFI_BOOT_SERVICE_CAPABILITY 73 *ProtocolCapability, 74 OUT UINT32 *TCGFeatureFlags, 75 OUT EFI_PHYSICAL_ADDRESS *EventLogLocation, 76 OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry 77 ); 78 79 /** 80 This service abstracts the capability to do a hash operation on a data buffer. 81 82 @param This Indicates the calling context. 83 @param HashData The pointer to the data buffer to be hashed. 84 @param HashDataLen The length of the data buffer to be hashed. 85 @param AlgorithmId Identification of the Algorithm to use for the hashing operation. 86 @param HashedDataLen Resultant length of the hashed data. 87 @param HashedDataResult Resultant buffer of the hashed data. 88 89 @retval EFI_SUCCESS The operation completed successfully. 90 @retval EFI_INVALID_PARAMETER HashDataLen is NULL. 91 @retval EFI_INVALID_PARAMETER HashDataLenResult is NULL. 92 @retval EFI_OUT_OF_RESOURCES Cannot allocate buffer of size *HashedDataLen. 93 @retval EFI_UNSUPPORTED AlgorithmId not supported. 94 @retval EFI_BUFFER_TOO_SMALL *HashedDataLen < sizeof (TCG_DIGEST). 95 **/ 96 typedef 97 EFI_STATUS 98 (EFIAPI *EFI_TCG_HASH_ALL)( 99 IN EFI_TCG_PROTOCOL *This, 100 IN UINT8 *HashData, 101 IN UINT64 HashDataLen, 102 IN TCG_ALGORITHM_ID AlgorithmId, 103 IN OUT UINT64 *HashedDataLen, 104 IN OUT UINT8 **HashedDataResult 105 ); 106 107 /** 108 This service abstracts the capability to add an entry to the Event Log. 109 110 @param This Indicates the calling context 111 @param TCGLogData The pointer to the start of the data buffer containing 112 the TCG_PCR_EVENT data structure. All fields in 113 this structure are properly filled by the caller. 114 @param EventNumber The event number of the event just logged. 115 @param Flags Indicates additional flags. Only one flag has been 116 defined at this time, which is 0x01 and means the 117 extend operation should not be performed. All 118 other bits are reserved. 119 120 @retval EFI_SUCCESS The operation completed successfully. 121 @retval EFI_OUT_OF_RESOURCES Insufficient memory in the event log to complete this action. 122 **/ 123 typedef 124 EFI_STATUS 125 (EFIAPI *EFI_TCG_LOG_EVENT)( 126 IN EFI_TCG_PROTOCOL *This, 127 IN TCG_PCR_EVENT *TCGLogData, 128 IN OUT UINT32 *EventNumber, 129 IN UINT32 Flags 130 ); 131 132 /** 133 This service is a proxy for commands to the TPM. 134 135 @param This Indicates the calling context. 136 @param TpmInputParameterBlockSize Size of the TPM input parameter block. 137 @param TpmInputParameterBlock The pointer to the TPM input parameter block. 138 @param TpmOutputParameterBlockSize Size of the TPM output parameter block. 139 @param TpmOutputParameterBlock The pointer to the TPM output parameter block. 140 141 @retval EFI_SUCCESS The operation completed successfully. 142 @retval EFI_INVALID_PARAMETER Invalid ordinal. 143 @retval EFI_UNSUPPORTED Current Task Priority Level >= EFI_TPL_CALLBACK. 144 @retval EFI_TIMEOUT The TIS timed-out. 145 **/ 146 typedef 147 EFI_STATUS 148 (EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM)( 149 IN EFI_TCG_PROTOCOL *This, 150 IN UINT32 TpmInputParameterBlockSize, 151 IN UINT8 *TpmInputParameterBlock, 152 IN UINT32 TpmOutputParameterBlockSize, 153 IN UINT8 *TpmOutputParameterBlock 154 ); 155 156 /** 157 This service abstracts the capability to do a hash operation on a data buffer, extend a specific TPM PCR with the hash result, and add an entry to the Event Log 158 159 @param This Indicates the calling context 160 @param HashData The physical address of the start of the data buffer 161 to be hashed, extended, and logged. 162 @param HashDataLen The length, in bytes, of the buffer referenced by HashData 163 @param AlgorithmId Identification of the Algorithm to use for the hashing operation 164 @param TCGLogData The physical address of the start of the data 165 buffer containing the TCG_PCR_EVENT data structure. 166 @param EventNumber The event number of the event just logged. 167 @param EventLogLastEntry The physical address of the first byte of the entry 168 just placed in the Event Log. If the Event Log was 169 empty when this function was called then this physical 170 address will be the same as the physical address of 171 the start of the Event Log. 172 173 @retval EFI_SUCCESS The operation completed successfully. 174 @retval EFI_UNSUPPORTED AlgorithmId != TPM_ALG_SHA. 175 @retval EFI_UNSUPPORTED Current TPL >= EFI_TPL_CALLBACK. 176 @retval EFI_DEVICE_ERROR The command was unsuccessful. 177 **/ 178 typedef 179 EFI_STATUS 180 (EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT)( 181 IN EFI_TCG_PROTOCOL *This, 182 IN EFI_PHYSICAL_ADDRESS HashData, 183 IN UINT64 HashDataLen, 184 IN TCG_ALGORITHM_ID AlgorithmId, 185 IN OUT TCG_PCR_EVENT *TCGLogData, 186 IN OUT UINT32 *EventNumber, 187 OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry 188 ); 189 190 /// 191 /// The EFI_TCG Protocol abstracts TCG activity. 192 /// 193 struct _EFI_TCG_PROTOCOL { 194 EFI_TCG_STATUS_CHECK StatusCheck; 195 EFI_TCG_HASH_ALL HashAll; 196 EFI_TCG_LOG_EVENT LogEvent; 197 EFI_TCG_PASS_THROUGH_TO_TPM PassThroughToTpm; 198 EFI_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent; 199 }; 200 201 extern EFI_GUID gEfiTcgProtocolGuid; 202 203 #endif 204