iPXE
TcgService.h
Go to the documentation of this file.
00001 /** @file
00002   TCG Service Protocol as defined in TCG_EFI_Protocol_1_22_Final
00003   See http://trustedcomputinggroup.org for the latest specification
00004 
00005 Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
00006 This program and the accompanying materials are licensed and made available under
00007 the terms and conditions of the BSD License that accompanies this distribution.
00008 The full text of the license may be found at
00009 http://opensource.org/licenses/bsd-license.php.
00010 
00011 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00012 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00013 
00014 **/
00015 
00016 #ifndef _TCG_SERVICE_PROTOCOL_H_
00017 #define _TCG_SERVICE_PROTOCOL_H_
00018 
00019 FILE_LICENCE ( BSD3 );
00020 
00021 #include <ipxe/efi/IndustryStandard/UefiTcgPlatform.h>
00022 
00023 #define EFI_TCG_PROTOCOL_GUID  \
00024   {0xf541796d, 0xa62e, 0x4954, { 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd } }
00025 
00026 typedef struct _EFI_TCG_PROTOCOL EFI_TCG_PROTOCOL;
00027 
00028 typedef struct {
00029   UINT8  Major;
00030   UINT8  Minor;
00031   UINT8  RevMajor;
00032   UINT8  RevMinor;
00033 } TCG_VERSION;
00034 
00035 typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY {
00036   UINT8          Size;                /// Size of this structure.
00037   TCG_VERSION    StructureVersion;
00038   TCG_VERSION    ProtocolSpecVersion;
00039   UINT8          HashAlgorithmBitmap; /// Hash algorithms .
00040                                       /// This protocol is capable of : 01=SHA-1.
00041   BOOLEAN        TPMPresentFlag;      /// 00h = TPM not present.
00042   BOOLEAN        TPMDeactivatedFlag;  /// 01h = TPM currently deactivated.
00043 } TCG_EFI_BOOT_SERVICE_CAPABILITY;
00044 
00045 typedef UINT32   TCG_ALGORITHM_ID;
00046 
00047 /**
00048   This service provides EFI protocol capability information, state information
00049   about the TPM, and Event Log state information.
00050 
00051   @param  This                   Indicates the calling context
00052   @param  ProtocolCapability     The callee allocates memory for a TCG_BOOT_SERVICE_CAPABILITY
00053                                  structure and fills in the fields with the EFI protocol
00054                                  capability information and the current TPM state information.
00055   @param  TCGFeatureFlags        This is a pointer to the feature flags. No feature
00056                                  flags are currently defined so this parameter
00057                                  MUST be set to 0. However, in the future,
00058                                  feature flags may be defined that, for example,
00059                                  enable hash algorithm agility.
00060   @param  EventLogLocation       This is a pointer to the address of the event log in memory.
00061   @param  EventLogLastEntry      If the Event Log contains more than one entry,
00062                                  this is a pointer to the address of the start of
00063                                  the last entry in the event log in memory.
00064 
00065   @retval EFI_SUCCESS            The operation completed successfully.
00066   @retval EFI_INVALID_PARAMETER  ProtocolCapability does not match TCG capability.
00067 **/
00068 typedef
00069 EFI_STATUS
00070 (EFIAPI *EFI_TCG_STATUS_CHECK)(
00071   IN      EFI_TCG_PROTOCOL          *This,
00072   OUT     TCG_EFI_BOOT_SERVICE_CAPABILITY
00073                                     *ProtocolCapability,
00074   OUT     UINT32                    *TCGFeatureFlags,
00075   OUT     EFI_PHYSICAL_ADDRESS      *EventLogLocation,
00076   OUT     EFI_PHYSICAL_ADDRESS      *EventLogLastEntry
00077   );
00078 
00079 /**
00080   This service abstracts the capability to do a hash operation on a data buffer.
00081 
00082   @param  This                   Indicates the calling context.
00083   @param  HashData               The pointer to the data buffer to be hashed.
00084   @param  HashDataLen            The length of the data buffer to be hashed.
00085   @param  AlgorithmId            Identification of the Algorithm to use for the hashing operation.
00086   @param  HashedDataLen          Resultant length of the hashed data.
00087   @param  HashedDataResult       Resultant buffer of the hashed data.
00088 
00089   @retval EFI_SUCCESS            The operation completed successfully.
00090   @retval EFI_INVALID_PARAMETER  HashDataLen is NULL.
00091   @retval EFI_INVALID_PARAMETER  HashDataLenResult is NULL.
00092   @retval EFI_OUT_OF_RESOURCES   Cannot allocate buffer of size *HashedDataLen.
00093   @retval EFI_UNSUPPORTED        AlgorithmId not supported.
00094   @retval EFI_BUFFER_TOO_SMALL   *HashedDataLen < sizeof (TCG_DIGEST).
00095 **/
00096 typedef
00097 EFI_STATUS
00098 (EFIAPI *EFI_TCG_HASH_ALL)(
00099   IN      EFI_TCG_PROTOCOL          *This,
00100   IN      UINT8                     *HashData,
00101   IN      UINT64                    HashDataLen,
00102   IN      TCG_ALGORITHM_ID          AlgorithmId,
00103   IN OUT  UINT64                    *HashedDataLen,
00104   IN OUT  UINT8                     **HashedDataResult
00105   );
00106 
00107 /**
00108   This service abstracts the capability to add an entry to the Event Log.
00109 
00110   @param  This                   Indicates the calling context
00111   @param  TCGLogData             The pointer to the start of the data buffer containing
00112                                  the TCG_PCR_EVENT data structure. All fields in
00113                                  this structure are properly filled by the caller.
00114   @param  EventNumber            The event number of the event just logged.
00115   @param  Flags                  Indicates additional flags. Only one flag has been
00116                                  defined at this time, which is 0x01 and means the
00117                                  extend operation should not be performed. All
00118                                  other bits are reserved.
00119 
00120   @retval EFI_SUCCESS            The operation completed successfully.
00121   @retval EFI_OUT_OF_RESOURCES   Insufficient memory in the event log to complete this action.
00122 **/
00123 typedef
00124 EFI_STATUS
00125 (EFIAPI *EFI_TCG_LOG_EVENT)(
00126   IN      EFI_TCG_PROTOCOL          *This,
00127   IN      TCG_PCR_EVENT             *TCGLogData,
00128   IN OUT  UINT32                    *EventNumber,
00129   IN      UINT32                    Flags
00130   );
00131 
00132 /**
00133   This service is a proxy for commands to the TPM.
00134 
00135   @param  This                        Indicates the calling context.
00136   @param  TpmInputParameterBlockSize  Size of the TPM input parameter block.
00137   @param  TpmInputParameterBlock      The pointer to the TPM input parameter block.
00138   @param  TpmOutputParameterBlockSize Size of the TPM output parameter block.
00139   @param  TpmOutputParameterBlock     The pointer to the TPM output parameter block.
00140 
00141   @retval EFI_SUCCESS            The operation completed successfully.
00142   @retval EFI_INVALID_PARAMETER  Invalid ordinal.
00143   @retval EFI_UNSUPPORTED        Current Task Priority Level  >= EFI_TPL_CALLBACK.
00144   @retval EFI_TIMEOUT            The TIS timed-out.
00145 **/
00146 typedef
00147 EFI_STATUS
00148 (EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM)(
00149   IN      EFI_TCG_PROTOCOL          *This,
00150   IN      UINT32                    TpmInputParameterBlockSize,
00151   IN      UINT8                     *TpmInputParameterBlock,
00152   IN      UINT32                    TpmOutputParameterBlockSize,
00153   IN      UINT8                     *TpmOutputParameterBlock
00154   );
00155 
00156 /**
00157   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
00158 
00159   @param  This                   Indicates the calling context
00160   @param  HashData               The physical address of the start of the data buffer
00161                                  to be hashed, extended, and logged.
00162   @param  HashDataLen            The length, in bytes, of the buffer referenced by HashData
00163   @param  AlgorithmId            Identification of the Algorithm to use for the hashing operation
00164   @param  TCGLogData             The physical address of the start of the data
00165                                  buffer containing the TCG_PCR_EVENT data structure.
00166   @param  EventNumber            The event number of the event just logged.
00167   @param  EventLogLastEntry      The physical address of the first byte of the entry
00168                                  just placed in the Event Log. If the Event Log was
00169                                  empty when this function was called then this physical
00170                                  address will be the same as the physical address of
00171                                  the start of the Event Log.
00172 
00173   @retval EFI_SUCCESS            The operation completed successfully.
00174   @retval EFI_UNSUPPORTED        AlgorithmId != TPM_ALG_SHA.
00175   @retval EFI_UNSUPPORTED        Current TPL >= EFI_TPL_CALLBACK.
00176   @retval EFI_DEVICE_ERROR       The command was unsuccessful.
00177 **/
00178 typedef
00179 EFI_STATUS
00180 (EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT)(
00181   IN      EFI_TCG_PROTOCOL          *This,
00182   IN      EFI_PHYSICAL_ADDRESS      HashData,
00183   IN      UINT64                    HashDataLen,
00184   IN      TCG_ALGORITHM_ID          AlgorithmId,
00185   IN OUT  TCG_PCR_EVENT             *TCGLogData,
00186   IN OUT  UINT32                    *EventNumber,
00187      OUT  EFI_PHYSICAL_ADDRESS      *EventLogLastEntry
00188   );
00189 
00190 ///
00191 /// The EFI_TCG Protocol abstracts TCG activity.
00192 ///
00193 struct _EFI_TCG_PROTOCOL {
00194   EFI_TCG_STATUS_CHECK              StatusCheck;
00195   EFI_TCG_HASH_ALL                  HashAll;
00196   EFI_TCG_LOG_EVENT                 LogEvent;
00197   EFI_TCG_PASS_THROUGH_TO_TPM       PassThroughToTpm;
00198   EFI_TCG_HASH_LOG_EXTEND_EVENT     HashLogExtendEvent;
00199 };
00200 
00201 extern EFI_GUID gEfiTcgProtocolGuid;
00202 
00203 #endif