tpm-v1.h 17 KB

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