Tpm12CommandLib.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /** @file
  2. This library is used by other modules to send TPM12 command.
  3. Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _TPM12_COMMAND_LIB_H_
  7. #define _TPM12_COMMAND_LIB_H_
  8. #include <IndustryStandard/Tpm12.h>
  9. /**
  10. Send Startup command to TPM1.2.
  11. @param TpmSt Startup Type.
  12. @retval EFI_SUCCESS Operation completed successfully.
  13. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  14. **/
  15. EFI_STATUS
  16. EFIAPI
  17. Tpm12Startup (
  18. IN TPM_STARTUP_TYPE TpmSt
  19. );
  20. /**
  21. Send SaveState command to TPM1.2.
  22. @retval EFI_SUCCESS Operation completed successfully.
  23. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  24. **/
  25. EFI_STATUS
  26. EFIAPI
  27. Tpm12SaveState (
  28. VOID
  29. );
  30. /**
  31. Send ForceClear command to TPM1.2.
  32. @retval EFI_SUCCESS Operation completed successfully.
  33. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  34. **/
  35. EFI_STATUS
  36. EFIAPI
  37. Tpm12ForceClear (
  38. VOID
  39. );
  40. #pragma pack(1)
  41. typedef struct {
  42. UINT16 sizeOfSelect;
  43. UINT8 pcrSelect[3];
  44. } TPM12_PCR_SELECTION;
  45. typedef struct {
  46. TPM12_PCR_SELECTION pcrSelection;
  47. TPM_LOCALITY_SELECTION localityAtRelease;
  48. TPM_COMPOSITE_HASH digestAtRelease;
  49. } TPM12_PCR_INFO_SHORT;
  50. typedef struct {
  51. TPM_STRUCTURE_TAG tag;
  52. TPM_NV_INDEX nvIndex;
  53. TPM12_PCR_INFO_SHORT pcrInfoRead;
  54. TPM12_PCR_INFO_SHORT pcrInfoWrite;
  55. TPM_NV_ATTRIBUTES permission;
  56. BOOLEAN bReadSTClear;
  57. BOOLEAN bWriteSTClear;
  58. BOOLEAN bWriteDefine;
  59. UINT32 dataSize;
  60. } TPM12_NV_DATA_PUBLIC;
  61. #pragma pack()
  62. /**
  63. Send NV DefineSpace command to TPM1.2.
  64. @param PubInfo The public parameters of the NV area.
  65. @param EncAuth The encrypted AuthData, only valid if the attributes require subsequent authorization.
  66. @retval EFI_SUCCESS Operation completed successfully.
  67. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  68. **/
  69. EFI_STATUS
  70. EFIAPI
  71. Tpm12NvDefineSpace (
  72. IN TPM12_NV_DATA_PUBLIC *PubInfo,
  73. IN TPM_ENCAUTH *EncAuth
  74. );
  75. /**
  76. Send NV ReadValue command to TPM1.2.
  77. @param NvIndex The index of the area to set.
  78. @param Offset The offset into the area.
  79. @param DataSize The size of the data area.
  80. @param Data The data to set the area to.
  81. @retval EFI_SUCCESS Operation completed successfully.
  82. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  83. **/
  84. EFI_STATUS
  85. EFIAPI
  86. Tpm12NvReadValue (
  87. IN TPM_NV_INDEX NvIndex,
  88. IN UINT32 Offset,
  89. IN OUT UINT32 *DataSize,
  90. OUT UINT8 *Data
  91. );
  92. /**
  93. Send NV WriteValue command to TPM1.2.
  94. @param NvIndex The index of the area to set.
  95. @param Offset The offset into the NV Area.
  96. @param DataSize The size of the data parameter.
  97. @param Data The data to set the area to.
  98. @retval EFI_SUCCESS Operation completed successfully.
  99. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  100. **/
  101. EFI_STATUS
  102. EFIAPI
  103. Tpm12NvWriteValue (
  104. IN TPM_NV_INDEX NvIndex,
  105. IN UINT32 Offset,
  106. IN UINT32 DataSize,
  107. IN UINT8 *Data
  108. );
  109. /**
  110. Extend a TPM PCR.
  111. @param[in] DigestToExtend The 160 bit value representing the event to be recorded.
  112. @param[in] PcrIndex The PCR to be updated.
  113. @param[out] NewPcrValue New PCR value after extend.
  114. @retval EFI_SUCCESS Operation completed successfully.
  115. @retval EFI_TIMEOUT The register can't run into the expected status in time.
  116. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
  117. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  118. **/
  119. EFI_STATUS
  120. EFIAPI
  121. Tpm12Extend (
  122. IN TPM_DIGEST *DigestToExtend,
  123. IN TPM_PCRINDEX PcrIndex,
  124. OUT TPM_DIGEST *NewPcrValue
  125. );
  126. /**
  127. Send TSC_PhysicalPresence command to TPM.
  128. @param[in] PhysicalPresence The state to set the TPMs Physical Presence flags.
  129. @retval EFI_SUCCESS Operation completed successfully.
  130. @retval EFI_TIMEOUT The register can't run into the expected status in time.
  131. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
  132. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  133. **/
  134. EFI_STATUS
  135. EFIAPI
  136. Tpm12PhysicalPresence (
  137. IN TPM_PHYSICAL_PRESENCE PhysicalPresence
  138. );
  139. /**
  140. Send TPM_ContinueSelfTest command to TPM.
  141. @retval EFI_SUCCESS Operation completed successfully.
  142. @retval EFI_TIMEOUT The register can't run into the expected status in time.
  143. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
  144. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  145. **/
  146. EFI_STATUS
  147. EFIAPI
  148. Tpm12ContinueSelfTest (
  149. VOID
  150. );
  151. /**
  152. Get TPM capability permanent flags.
  153. @param[out] TpmPermanentFlags Pointer to the buffer for returned flag structure.
  154. @retval EFI_SUCCESS Operation completed successfully.
  155. @retval EFI_TIMEOUT The register can't run into the expected status in time.
  156. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
  157. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  158. **/
  159. EFI_STATUS
  160. EFIAPI
  161. Tpm12GetCapabilityFlagPermanent (
  162. OUT TPM_PERMANENT_FLAGS *TpmPermanentFlags
  163. );
  164. /**
  165. Get TPM capability volatile flags.
  166. @param[out] VolatileFlags Pointer to the buffer for returned flag structure.
  167. @retval EFI_SUCCESS Operation completed successfully.
  168. @retval EFI_DEVICE_ERROR The command was unsuccessful.
  169. **/
  170. EFI_STATUS
  171. EFIAPI
  172. Tpm12GetCapabilityFlagVolatile (
  173. OUT TPM_STCLEAR_FLAGS *VolatileFlags
  174. );
  175. #endif