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