tpm-v1.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2013 The Chromium OS Authors.
  4. * Coypright (c) 2013 Guntermann & Drunck GmbH
  5. */
  6. #ifndef __TPM_V1_H
  7. #define __TPM_V1_H
  8. #include <tpm-common.h>
  9. #include <linux/bitops.h>
  10. /* Useful constants */
  11. enum {
  12. TPM_REQUEST_HEADER_LENGTH = 10,
  13. TPM_RESPONSE_HEADER_LENGTH = 10,
  14. PCR_DIGEST_LENGTH = 20,
  15. DIGEST_LENGTH = 20,
  16. TPM_REQUEST_AUTH_LENGTH = 45,
  17. TPM_RESPONSE_AUTH_LENGTH = 41,
  18. /* some max lengths, valid for RSA keys <= 2048 bits */
  19. TPM_KEY12_MAX_LENGTH = 618,
  20. TPM_PUBKEY_MAX_LENGTH = 288,
  21. };
  22. enum tpm_startup_type {
  23. TPM_ST_CLEAR = 0x0001,
  24. TPM_ST_STATE = 0x0002,
  25. TPM_ST_DEACTIVATED = 0x0003,
  26. };
  27. enum tpm_physical_presence {
  28. TPM_PHYSICAL_PRESENCE_HW_DISABLE = 0x0200,
  29. TPM_PHYSICAL_PRESENCE_CMD_DISABLE = 0x0100,
  30. TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK = 0x0080,
  31. TPM_PHYSICAL_PRESENCE_HW_ENABLE = 0x0040,
  32. TPM_PHYSICAL_PRESENCE_CMD_ENABLE = 0x0020,
  33. TPM_PHYSICAL_PRESENCE_NOTPRESENT = 0x0010,
  34. TPM_PHYSICAL_PRESENCE_PRESENT = 0x0008,
  35. TPM_PHYSICAL_PRESENCE_LOCK = 0x0004,
  36. };
  37. enum tpm_nv_index {
  38. TPM_NV_INDEX_LOCK = 0xffffffff,
  39. TPM_NV_INDEX_0 = 0x00000000,
  40. TPM_NV_INDEX_DIR = 0x10000001,
  41. };
  42. enum tpm_resource_type {
  43. TPM_RT_KEY = 0x00000001,
  44. TPM_RT_AUTH = 0x00000002,
  45. TPM_RT_HASH = 0x00000003,
  46. TPM_RT_TRANS = 0x00000004,
  47. TPM_RT_CONTEXT = 0x00000005,
  48. TPM_RT_COUNTER = 0x00000006,
  49. TPM_RT_DELEGATE = 0x00000007,
  50. TPM_RT_DAA_TPM = 0x00000008,
  51. TPM_RT_DAA_V0 = 0x00000009,
  52. TPM_RT_DAA_V1 = 0x0000000A,
  53. };
  54. enum tpm_capability_areas {
  55. TPM_CAP_ORD = 0x00000001,
  56. TPM_CAP_ALG = 0x00000002,
  57. TPM_CAP_PID = 0x00000003,
  58. TPM_CAP_FLAG = 0x00000004,
  59. TPM_CAP_PROPERTY = 0x00000005,
  60. TPM_CAP_VERSION = 0x00000006,
  61. TPM_CAP_KEY_HANDLE = 0x00000007,
  62. TPM_CAP_CHECK_LOADED = 0x00000008,
  63. TPM_CAP_SYM_MODE = 0x00000009,
  64. TPM_CAP_KEY_STATUS = 0x0000000C,
  65. TPM_CAP_NV_LIST = 0x0000000D,
  66. TPM_CAP_MFR = 0x00000010,
  67. TPM_CAP_NV_INDEX = 0x00000011,
  68. TPM_CAP_TRANS_ALG = 0x00000012,
  69. TPM_CAP_HANDLE = 0x00000014,
  70. TPM_CAP_TRANS_ES = 0x00000015,
  71. TPM_CAP_AUTH_ENCRYPT = 0x00000017,
  72. TPM_CAP_SELECT_SIZE = 0x00000018,
  73. TPM_CAP_DA_LOGIC = 0x00000019,
  74. TPM_CAP_VERSION_VAL = 0x0000001A,
  75. };
  76. enum tmp_cap_flag {
  77. TPM_CAP_FLAG_PERMANENT = 0x108,
  78. };
  79. #define TPM_TAG_PERMANENT_FLAGS 0x001f
  80. #define TPM_NV_PER_GLOBALLOCK BIT(15)
  81. #define TPM_NV_PER_PPREAD BIT(16)
  82. #define TPM_NV_PER_PPWRITE BIT(0)
  83. #define TPM_NV_PER_READ_STCLEAR BIT(31)
  84. #define TPM_NV_PER_WRITE_STCLEAR BIT(14)
  85. #define TPM_NV_PER_WRITEDEFINE BIT(13)
  86. #define TPM_NV_PER_WRITEALL BIT(12)
  87. enum {
  88. TPM_PUBEK_SIZE = 256,
  89. };
  90. enum {
  91. TPM_CMD_EXTEND = 0x14,
  92. TPM_CMD_GET_CAPABILITY = 0x65,
  93. TPM_CMD_NV_DEFINE_SPACE = 0xcc,
  94. TPM_CMD_NV_WRITE_VALUE = 0xcd,
  95. TPM_CMD_NV_READ_VALUE = 0xcf,
  96. };
  97. /**
  98. * TPM return codes as defined in the TCG Main specification
  99. * (TPM Main Part 2 Structures; Specification version 1.2)
  100. */
  101. enum tpm_return_code {
  102. TPM_BASE = 0x00000000,
  103. TPM_NON_FATAL = 0x00000800,
  104. TPM_SUCCESS = TPM_BASE,
  105. /* TPM-defined fatal error codes */
  106. TPM_AUTHFAIL = TPM_BASE + 1,
  107. TPM_BADINDEX = TPM_BASE + 2,
  108. TPM_BAD_PARAMETER = TPM_BASE + 3,
  109. TPM_AUDITFAILURE = TPM_BASE + 4,
  110. TPM_CLEAR_DISABLED = TPM_BASE + 5,
  111. TPM_DEACTIVATED = TPM_BASE + 6,
  112. TPM_DISABLED = TPM_BASE + 7,
  113. TPM_DISABLED_CMD = TPM_BASE + 8,
  114. TPM_FAIL = TPM_BASE + 9,
  115. TPM_BAD_ORDINAL = TPM_BASE + 10,
  116. TPM_INSTALL_DISABLED = TPM_BASE + 11,
  117. TPM_INVALID_KEYHANDLE = TPM_BASE + 12,
  118. TPM_KEYNOTFOUND = TPM_BASE + 13,
  119. TPM_INAPPROPRIATE_ENC = TPM_BASE + 14,
  120. TPM_MIGRATE_FAIL = TPM_BASE + 15,
  121. TPM_INVALID_PCR_INFO = TPM_BASE + 16,
  122. TPM_NOSPACE = TPM_BASE + 17,
  123. TPM_NOSRK = TPM_BASE + 18,
  124. TPM_NOTSEALED_BLOB = TPM_BASE + 19,
  125. TPM_OWNER_SET = TPM_BASE + 20,
  126. TPM_RESOURCES = TPM_BASE + 21,
  127. TPM_SHORTRANDOM = TPM_BASE + 22,
  128. TPM_SIZE = TPM_BASE + 23,
  129. TPM_WRONGPCRVAL = TPM_BASE + 24,
  130. TPM_BAD_PARAM_SIZE = TPM_BASE + 25,
  131. TPM_SHA_THREAD = TPM_BASE + 26,
  132. TPM_SHA_ERROR = TPM_BASE + 27,
  133. TPM_FAILEDSELFTEST = TPM_BASE + 28,
  134. TPM_AUTH2FAIL = TPM_BASE + 29,
  135. TPM_BADTAG = TPM_BASE + 30,
  136. TPM_IOERROR = TPM_BASE + 31,
  137. TPM_ENCRYPT_ERROR = TPM_BASE + 32,
  138. TPM_DECRYPT_ERROR = TPM_BASE + 33,
  139. TPM_INVALID_AUTHHANDLE = TPM_BASE + 34,
  140. TPM_NO_ENDORSEMENT = TPM_BASE + 35,
  141. TPM_INVALID_KEYUSAGE = TPM_BASE + 36,
  142. TPM_WRONG_ENTITYTYPE = TPM_BASE + 37,
  143. TPM_INVALID_POSTINIT = TPM_BASE + 38,
  144. TPM_INAPPROPRIATE_SIG = TPM_BASE + 39,
  145. TPM_BAD_KEY_PROPERTY = TPM_BASE + 40,
  146. TPM_BAD_MIGRATION = TPM_BASE + 41,
  147. TPM_BAD_SCHEME = TPM_BASE + 42,
  148. TPM_BAD_DATASIZE = TPM_BASE + 43,
  149. TPM_BAD_MODE = TPM_BASE + 44,
  150. TPM_BAD_PRESENCE = TPM_BASE + 45,
  151. TPM_BAD_VERSION = TPM_BASE + 46,
  152. TPM_NO_WRAP_TRANSPORT = TPM_BASE + 47,
  153. TPM_AUDITFAIL_UNSUCCESSFUL = TPM_BASE + 48,
  154. TPM_AUDITFAIL_SUCCESSFUL = TPM_BASE + 49,
  155. TPM_NOTRESETABLE = TPM_BASE + 50,
  156. TPM_NOTLOCAL = TPM_BASE + 51,
  157. TPM_BAD_TYPE = TPM_BASE + 52,
  158. TPM_INVALID_RESOURCE = TPM_BASE + 53,
  159. TPM_NOTFIPS = TPM_BASE + 54,
  160. TPM_INVALID_FAMILY = TPM_BASE + 55,
  161. TPM_NO_NV_PERMISSION = TPM_BASE + 56,
  162. TPM_REQUIRES_SIGN = TPM_BASE + 57,
  163. TPM_KEY_NOTSUPPORTED = TPM_BASE + 58,
  164. TPM_AUTH_CONFLICT = TPM_BASE + 59,
  165. TPM_AREA_LOCKED = TPM_BASE + 60,
  166. TPM_BAD_LOCALITY = TPM_BASE + 61,
  167. TPM_READ_ONLY = TPM_BASE + 62,
  168. TPM_PER_NOWRITE = TPM_BASE + 63,
  169. TPM_FAMILY_COUNT = TPM_BASE + 64,
  170. TPM_WRITE_LOCKED = TPM_BASE + 65,
  171. TPM_BAD_ATTRIBUTES = TPM_BASE + 66,
  172. TPM_INVALID_STRUCTURE = TPM_BASE + 67,
  173. TPM_KEY_OWNER_CONTROL = TPM_BASE + 68,
  174. TPM_BAD_COUNTER = TPM_BASE + 69,
  175. TPM_NOT_FULLWRITE = TPM_BASE + 70,
  176. TPM_CONTEXT_GAP = TPM_BASE + 71,
  177. TPM_MAXNVWRITES = TPM_BASE + 72,
  178. TPM_NOOPERATOR = TPM_BASE + 73,
  179. TPM_RESOURCEMISSING = TPM_BASE + 74,
  180. TPM_DELEGATE_LOCK = TPM_BASE + 75,
  181. TPM_DELEGATE_FAMILY = TPM_BASE + 76,
  182. TPM_DELEGATE_ADMIN = TPM_BASE + 77,
  183. TPM_TRANSPORT_NOTEXCLUSIVE = TPM_BASE + 78,
  184. TPM_OWNER_CONTROL = TPM_BASE + 79,
  185. TPM_DAA_RESOURCES = TPM_BASE + 80,
  186. TPM_DAA_INPUT_DATA0 = TPM_BASE + 81,
  187. TPM_DAA_INPUT_DATA1 = TPM_BASE + 82,
  188. TPM_DAA_ISSUER_SETTINGS = TPM_BASE + 83,
  189. TPM_DAA_TPM_SETTINGS = TPM_BASE + 84,
  190. TPM_DAA_STAGE = TPM_BASE + 85,
  191. TPM_DAA_ISSUER_VALIDITY = TPM_BASE + 86,
  192. TPM_DAA_WRONG_W = TPM_BASE + 87,
  193. TPM_BAD_HANDLE = TPM_BASE + 88,
  194. TPM_BAD_DELEGATE = TPM_BASE + 89,
  195. TPM_BADCONTEXT = TPM_BASE + 90,
  196. TPM_TOOMANYCONTEXTS = TPM_BASE + 91,
  197. TPM_MA_TICKET_SIGNATURE = TPM_BASE + 92,
  198. TPM_MA_DESTINATION = TPM_BASE + 93,
  199. TPM_MA_SOURCE = TPM_BASE + 94,
  200. TPM_MA_AUTHORITY = TPM_BASE + 95,
  201. TPM_PERMANENTEK = TPM_BASE + 97,
  202. TPM_BAD_SIGNATURE = TPM_BASE + 98,
  203. TPM_NOCONTEXTSPACE = TPM_BASE + 99,
  204. /* TPM-defined non-fatal errors */
  205. TPM_RETRY = TPM_BASE + TPM_NON_FATAL,
  206. TPM_NEEDS_SELFTEST = TPM_BASE + TPM_NON_FATAL + 1,
  207. TPM_DOING_SELFTEST = TPM_BASE + TPM_NON_FATAL + 2,
  208. TPM_DEFEND_LOCK_RUNNING = TPM_BASE + TPM_NON_FATAL + 3,
  209. };
  210. struct tpm_permanent_flags {
  211. __be16 tag;
  212. u8 disable;
  213. u8 ownership;
  214. u8 deactivated;
  215. u8 read_pubek;
  216. u8 disable_owner_clear;
  217. u8 allow_maintenance;
  218. u8 physical_presence_lifetime_lock;
  219. u8 physical_presence_hw_enable;
  220. u8 physical_presence_cmd_enable;
  221. u8 cekp_used;
  222. u8 tpm_post;
  223. u8 tpm_post_lock;
  224. u8 fips;
  225. u8 operator;
  226. u8 enable_revoke_ek;
  227. u8 nv_locked;
  228. u8 read_srk_pub;
  229. u8 tpm_established;
  230. u8 maintenance_done;
  231. u8 disable_full_da_logic_info;
  232. } __packed;
  233. #define TPM_SHA1_160_HASH_LEN 0x14
  234. struct __packed tpm_composite_hash {
  235. u8 digest[TPM_SHA1_160_HASH_LEN];
  236. };
  237. struct __packed tpm_pcr_selection {
  238. __be16 size_of_select;
  239. u8 pcr_select[3]; /* matches vboot's struct */
  240. };
  241. struct __packed tpm_pcr_info_short {
  242. struct tpm_pcr_selection pcr_selection;
  243. u8 locality_at_release;
  244. struct tpm_composite_hash digest_at_release;
  245. };
  246. struct __packed tpm_nv_attributes {
  247. __be16 tag;
  248. __be32 attributes;
  249. };
  250. struct __packed tpm_nv_data_public {
  251. __be16 tag;
  252. __be32 nv_index;
  253. struct tpm_pcr_info_short pcr_info_read;
  254. struct tpm_pcr_info_short pcr_info_write;
  255. struct tpm_nv_attributes permission;
  256. u8 read_st_clear;
  257. u8 write_st_clear;
  258. u8 write_define;
  259. __be32 data_size;
  260. };
  261. /**
  262. * Issue a TPM_Startup command.
  263. *
  264. * @param dev TPM device
  265. * @param mode TPM startup mode
  266. * @return return code of the operation
  267. */
  268. u32 tpm_startup(struct udevice *dev, enum tpm_startup_type mode);
  269. /**
  270. * Issue a TPM_SelfTestFull command.
  271. *
  272. * @param dev TPM device
  273. * @return return code of the operation
  274. */
  275. u32 tpm_self_test_full(struct udevice *dev);
  276. /**
  277. * Issue a TPM_ContinueSelfTest command.
  278. *
  279. * @param dev TPM device
  280. * @return return code of the operation
  281. */
  282. u32 tpm_continue_self_test(struct udevice *dev);
  283. /**
  284. * Issue a TPM_NV_DefineSpace command. The implementation is limited
  285. * to specify TPM_NV_ATTRIBUTES and size of the area. The area index
  286. * could be one of the special value listed in enum tpm_nv_index.
  287. *
  288. * @param dev TPM device
  289. * @param index index of the area
  290. * @param perm TPM_NV_ATTRIBUTES of the area
  291. * @param size size of the area
  292. * @return return code of the operation
  293. */
  294. u32 tpm_nv_define_space(struct udevice *dev, u32 index, u32 perm, u32 size);
  295. /**
  296. * Issue a TPM_NV_ReadValue command. This implementation is limited
  297. * to read the area from offset 0. The area index could be one of
  298. * the special value listed in enum tpm_nv_index.
  299. *
  300. * @param dev TPM device
  301. * @param index index of the area
  302. * @param data output buffer of the area contents
  303. * @param count size of output buffer
  304. * @return return code of the operation
  305. */
  306. u32 tpm_nv_read_value(struct udevice *dev, u32 index, void *data, u32 count);
  307. /**
  308. * Issue a TPM_NV_WriteValue command. This implementation is limited
  309. * to write the area from offset 0. The area index could be one of
  310. * the special value listed in enum tpm_nv_index.
  311. *
  312. * @param dev TPM device
  313. * @param index index of the area
  314. * @param data input buffer to be wrote to the area
  315. * @param length length of data bytes of input buffer
  316. * @return return code of the operation
  317. */
  318. u32 tpm_nv_write_value(struct udevice *dev, u32 index, const void *data,
  319. u32 length);
  320. /**
  321. * Issue a TPM_Extend command.
  322. *
  323. * @param dev TPM device
  324. * @param index index of the PCR
  325. * @param in_digest 160-bit value representing the event to be
  326. * recorded
  327. * @param out_digest 160-bit PCR value after execution of the
  328. * command
  329. * @return return code of the operation
  330. */
  331. u32 tpm_extend(struct udevice *dev, u32 index, const void *in_digest,
  332. void *out_digest);
  333. /**
  334. * Issue a TPM_PCRRead command.
  335. *
  336. * @param dev TPM device
  337. * @param index index of the PCR
  338. * @param data output buffer for contents of the named PCR
  339. * @param count size of output buffer
  340. * @return return code of the operation
  341. */
  342. u32 tpm_pcr_read(struct udevice *dev, u32 index, void *data, size_t count);
  343. /**
  344. * Issue a TSC_PhysicalPresence command. TPM physical presence flag
  345. * is bit-wise OR'ed of flags listed in enum tpm_physical_presence.
  346. *
  347. * @param dev TPM device
  348. * @param presence TPM physical presence flag
  349. * @return return code of the operation
  350. */
  351. u32 tpm_tsc_physical_presence(struct udevice *dev, u16 presence);
  352. /**
  353. * Issue a TPM_ReadPubek command.
  354. *
  355. * @param dev TPM device
  356. * @param data output buffer for the public endorsement key
  357. * @param count size of output buffer
  358. * @return return code of the operation
  359. */
  360. u32 tpm_read_pubek(struct udevice *dev, void *data, size_t count);
  361. /**
  362. * Issue a TPM_ForceClear command.
  363. *
  364. * @param dev TPM device
  365. * @return return code of the operation
  366. */
  367. u32 tpm_force_clear(struct udevice *dev);
  368. /**
  369. * Issue a TPM_PhysicalEnable command.
  370. *
  371. * @param dev TPM device
  372. * @return return code of the operation
  373. */
  374. u32 tpm_physical_enable(struct udevice *dev);
  375. /**
  376. * Issue a TPM_PhysicalDisable command.
  377. *
  378. * @param dev TPM device
  379. * @return return code of the operation
  380. */
  381. u32 tpm_physical_disable(struct udevice *dev);
  382. /**
  383. * Issue a TPM_PhysicalSetDeactivated command.
  384. *
  385. * @param dev TPM device
  386. * @param state boolean state of the deactivated flag
  387. * @return return code of the operation
  388. */
  389. u32 tpm_physical_set_deactivated(struct udevice *dev, u8 state);
  390. /**
  391. * Issue a TPM_GetCapability command. This implementation is limited
  392. * to query sub_cap index that is 4-byte wide.
  393. *
  394. * @param dev TPM device
  395. * @param cap_area partition of capabilities
  396. * @param sub_cap further definition of capability, which is
  397. * limited to be 4-byte wide
  398. * @param cap output buffer for capability information
  399. * @param count size of output buffer
  400. * @return return code of the operation
  401. */
  402. u32 tpm_get_capability(struct udevice *dev, u32 cap_area, u32 sub_cap,
  403. void *cap, size_t count);
  404. /**
  405. * Issue a TPM_FlushSpecific command for a AUTH resource.
  406. *
  407. * @param dev TPM device
  408. * @param auth_handle handle of the auth session
  409. * @return return code of the operation
  410. */
  411. u32 tpm_terminate_auth_session(struct udevice *dev, u32 auth_handle);
  412. /**
  413. * Issue a TPM_OIAP command to setup an object independent authorization
  414. * session.
  415. * Information about the session is stored internally.
  416. * If there was already an OIAP session active it is terminated and a new
  417. * session is set up.
  418. *
  419. * @param dev TPM device
  420. * @param auth_handle pointer to the (new) auth handle or NULL.
  421. * @return return code of the operation
  422. */
  423. u32 tpm_oiap(struct udevice *dev, u32 *auth_handle);
  424. /**
  425. * Ends an active OIAP session.
  426. *
  427. * @param dev TPM device
  428. * @return return code of the operation
  429. */
  430. u32 tpm_end_oiap(struct udevice *dev);
  431. /**
  432. * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
  433. * the usage of the parent key.
  434. *
  435. * @param dev TPM device
  436. * @param parent_handle handle of the parent key.
  437. * @param key pointer to the key structure (TPM_KEY or TPM_KEY12).
  438. * @param key_length size of the key structure
  439. * @param parent_key_usage_auth usage auth for the parent key
  440. * @param key_handle pointer to the key handle
  441. * @return return code of the operation
  442. */
  443. u32 tpm_load_key2_oiap(struct udevice *dev, u32 parent_handle, const void *key,
  444. size_t key_length, const void *parent_key_usage_auth,
  445. u32 *key_handle);
  446. /**
  447. * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
  448. * authenticating the usage of the key.
  449. *
  450. * @param dev TPM device
  451. * @param key_handle handle of the key
  452. * @param usage_auth usage auth for the key
  453. * @param pubkey pointer to the pub key buffer; may be NULL if the pubkey
  454. * should not be stored.
  455. * @param pubkey_len pointer to the pub key buffer len. On entry: the size of
  456. * the provided pubkey buffer. On successful exit: the size
  457. * of the stored TPM_PUBKEY structure (iff pubkey != NULL).
  458. * @return return code of the operation
  459. */
  460. u32 tpm_get_pub_key_oiap(struct udevice *dev, u32 key_handle,
  461. const void *usage_auth, void *pubkey,
  462. size_t *pubkey_len);
  463. /**
  464. * Get the TPM permanent flags value
  465. *
  466. * @param dev TPM device
  467. * @param pflags Place to put permanent flags
  468. * @return return code of the operation
  469. */
  470. u32 tpm_get_permanent_flags(struct udevice *dev,
  471. struct tpm_permanent_flags *pflags);
  472. /**
  473. * Get the TPM permissions
  474. *
  475. * @param dev TPM device
  476. * @param perm Returns permissions value
  477. * @return return code of the operation
  478. */
  479. u32 tpm_get_permissions(struct udevice *dev, u32 index, u32 *perm);
  480. /**
  481. * Flush a resource with a given handle and type from the TPM
  482. *
  483. * @param dev TPM device
  484. * @param key_handle handle of the resource
  485. * @param resource_type type of the resource
  486. * @return return code of the operation
  487. */
  488. u32 tpm_flush_specific(struct udevice *dev, u32 key_handle, u32 resource_type);
  489. #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
  490. /**
  491. * Search for a key by usage AuthData and the hash of the parent's pub key.
  492. *
  493. * @param dev TPM device
  494. * @param auth Usage auth of the key to search for
  495. * @param pubkey_digest SHA1 hash of the pub key structure of the key
  496. * @param[out] handle The handle of the key (Non-null iff found)
  497. * @return 0 if key was found in TPM; != 0 if not.
  498. */
  499. u32 tpm_find_key_sha1(struct udevice *dev, const u8 auth[20],
  500. const u8 pubkey_digest[20], u32 *handle);
  501. #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
  502. /**
  503. * Read random bytes from the TPM RNG. The implementation deals with the fact
  504. * that the TPM may legally return fewer bytes than requested by retrying
  505. * until @p count bytes have been received.
  506. *
  507. * @param dev TPM device
  508. * @param data output buffer for the random bytes
  509. * @param count size of output buffer
  510. * @return return code of the operation
  511. */
  512. u32 tpm_get_random(struct udevice *dev, void *data, u32 count);
  513. /**
  514. * tpm_finalise_physical_presence() - Finalise physical presence
  515. *
  516. * @param dev TPM device
  517. * @return return code of the operation (0 = success)
  518. */
  519. u32 tpm_finalise_physical_presence(struct udevice *dev);
  520. /**
  521. * tpm_nv_set_locked() - lock the non-volatile space
  522. *
  523. * @param dev TPM device
  524. * @return return code of the operation (0 = success)
  525. */
  526. u32 tpm_nv_set_locked(struct udevice *dev);
  527. /**
  528. * tpm_set_global_lock() - set the global lock
  529. *
  530. * @param dev TPM device
  531. * @return return code of the operation (0 = success)
  532. */
  533. u32 tpm_set_global_lock(struct udevice *dev);
  534. /**
  535. * tpm_resume() - start up the TPM from resume (after suspend)
  536. *
  537. * @param dev TPM device
  538. * @return return code of the operation (0 = success)
  539. */
  540. u32 tpm_resume(struct udevice *dev);
  541. #endif /* __TPM_V1_H */