15e124724SVadim Bendebury /* 28732b070SChe-liang Chiou * Copyright (c) 2013 The Chromium OS Authors. 3be6c1529SReinhard Pfau * Coypright (c) 2013 Guntermann & Drunck GmbH 45e124724SVadim Bendebury * 5*1a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 65e124724SVadim Bendebury */ 75e124724SVadim Bendebury 88732b070SChe-liang Chiou #ifndef __TPM_H 98732b070SChe-liang Chiou #define __TPM_H 105e124724SVadim Bendebury 118732b070SChe-liang Chiou #include <tis.h> 125e124724SVadim Bendebury 135e124724SVadim Bendebury /* 148732b070SChe-liang Chiou * Here is a partial implementation of TPM commands. Please consult TCG Main 158732b070SChe-liang Chiou * Specification for definitions of TPM commands. 165e124724SVadim Bendebury */ 175e124724SVadim Bendebury 188732b070SChe-liang Chiou enum tpm_startup_type { 198732b070SChe-liang Chiou TPM_ST_CLEAR = 0x0001, 208732b070SChe-liang Chiou TPM_ST_STATE = 0x0002, 218732b070SChe-liang Chiou TPM_ST_DEACTIVATED = 0x0003, 228732b070SChe-liang Chiou }; 238732b070SChe-liang Chiou 248732b070SChe-liang Chiou enum tpm_physical_presence { 258732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_HW_DISABLE = 0x0200, 268732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_CMD_DISABLE = 0x0100, 278732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK = 0x0080, 288732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_HW_ENABLE = 0x0040, 298732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_CMD_ENABLE = 0x0020, 308732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_NOTPRESENT = 0x0010, 318732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_PRESENT = 0x0008, 328732b070SChe-liang Chiou TPM_PHYSICAL_PRESENCE_LOCK = 0x0004, 338732b070SChe-liang Chiou }; 348732b070SChe-liang Chiou 358732b070SChe-liang Chiou enum tpm_nv_index { 368732b070SChe-liang Chiou TPM_NV_INDEX_LOCK = 0xffffffff, 378732b070SChe-liang Chiou TPM_NV_INDEX_0 = 0x00000000, 388732b070SChe-liang Chiou TPM_NV_INDEX_DIR = 0x10000001, 398732b070SChe-liang Chiou }; 408732b070SChe-liang Chiou 418732b070SChe-liang Chiou /** 42be6c1529SReinhard Pfau * TPM return codes as defined in the TCG Main specification 43be6c1529SReinhard Pfau * (TPM Main Part 2 Structures; Specification version 1.2) 44be6c1529SReinhard Pfau */ 45be6c1529SReinhard Pfau enum tpm_return_code { 46be6c1529SReinhard Pfau TPM_BASE = 0x00000000, 47be6c1529SReinhard Pfau TPM_NON_FATAL = 0x00000800, 48be6c1529SReinhard Pfau TPM_SUCCESS = TPM_BASE, 49be6c1529SReinhard Pfau /* TPM-defined fatal error codes */ 50be6c1529SReinhard Pfau TPM_AUTHFAIL = TPM_BASE + 1, 51be6c1529SReinhard Pfau TPM_BADINDEX = TPM_BASE + 2, 52be6c1529SReinhard Pfau TPM_BAD_PARAMETER = TPM_BASE + 3, 53be6c1529SReinhard Pfau TPM_AUDITFAILURE = TPM_BASE + 4, 54be6c1529SReinhard Pfau TPM_CLEAR_DISABLED = TPM_BASE + 5, 55be6c1529SReinhard Pfau TPM_DEACTIVATED = TPM_BASE + 6, 56be6c1529SReinhard Pfau TPM_DISABLED = TPM_BASE + 7, 57be6c1529SReinhard Pfau TPM_DISABLED_CMD = TPM_BASE + 8, 58be6c1529SReinhard Pfau TPM_FAIL = TPM_BASE + 9, 59be6c1529SReinhard Pfau TPM_BAD_ORDINAL = TPM_BASE + 10, 60be6c1529SReinhard Pfau TPM_INSTALL_DISABLED = TPM_BASE + 11, 61be6c1529SReinhard Pfau TPM_INVALID_KEYHANDLE = TPM_BASE + 12, 62be6c1529SReinhard Pfau TPM_KEYNOTFOUND = TPM_BASE + 13, 63be6c1529SReinhard Pfau TPM_INAPPROPRIATE_ENC = TPM_BASE + 14, 64be6c1529SReinhard Pfau TPM_MIGRATE_FAIL = TPM_BASE + 15, 65be6c1529SReinhard Pfau TPM_INVALID_PCR_INFO = TPM_BASE + 16, 66be6c1529SReinhard Pfau TPM_NOSPACE = TPM_BASE + 17, 67be6c1529SReinhard Pfau TPM_NOSRK = TPM_BASE + 18, 68be6c1529SReinhard Pfau TPM_NOTSEALED_BLOB = TPM_BASE + 19, 69be6c1529SReinhard Pfau TPM_OWNER_SET = TPM_BASE + 20, 70be6c1529SReinhard Pfau TPM_RESOURCES = TPM_BASE + 21, 71be6c1529SReinhard Pfau TPM_SHORTRANDOM = TPM_BASE + 22, 72be6c1529SReinhard Pfau TPM_SIZE = TPM_BASE + 23, 73be6c1529SReinhard Pfau TPM_WRONGPCRVAL = TPM_BASE + 24, 74be6c1529SReinhard Pfau TPM_BAD_PARAM_SIZE = TPM_BASE + 25, 75be6c1529SReinhard Pfau TPM_SHA_THREAD = TPM_BASE + 26, 76be6c1529SReinhard Pfau TPM_SHA_ERROR = TPM_BASE + 27, 77be6c1529SReinhard Pfau TPM_FAILEDSELFTEST = TPM_BASE + 28, 78be6c1529SReinhard Pfau TPM_AUTH2FAIL = TPM_BASE + 29, 79be6c1529SReinhard Pfau TPM_BADTAG = TPM_BASE + 30, 80be6c1529SReinhard Pfau TPM_IOERROR = TPM_BASE + 31, 81be6c1529SReinhard Pfau TPM_ENCRYPT_ERROR = TPM_BASE + 32, 82be6c1529SReinhard Pfau TPM_DECRYPT_ERROR = TPM_BASE + 33, 83be6c1529SReinhard Pfau TPM_INVALID_AUTHHANDLE = TPM_BASE + 34, 84be6c1529SReinhard Pfau TPM_NO_ENDORSEMENT = TPM_BASE + 35, 85be6c1529SReinhard Pfau TPM_INVALID_KEYUSAGE = TPM_BASE + 36, 86be6c1529SReinhard Pfau TPM_WRONG_ENTITYTYPE = TPM_BASE + 37, 87be6c1529SReinhard Pfau TPM_INVALID_POSTINIT = TPM_BASE + 38, 88be6c1529SReinhard Pfau TPM_INAPPROPRIATE_SIG = TPM_BASE + 39, 89be6c1529SReinhard Pfau TPM_BAD_KEY_PROPERTY = TPM_BASE + 40, 90be6c1529SReinhard Pfau TPM_BAD_MIGRATION = TPM_BASE + 41, 91be6c1529SReinhard Pfau TPM_BAD_SCHEME = TPM_BASE + 42, 92be6c1529SReinhard Pfau TPM_BAD_DATASIZE = TPM_BASE + 43, 93be6c1529SReinhard Pfau TPM_BAD_MODE = TPM_BASE + 44, 94be6c1529SReinhard Pfau TPM_BAD_PRESENCE = TPM_BASE + 45, 95be6c1529SReinhard Pfau TPM_BAD_VERSION = TPM_BASE + 46, 96be6c1529SReinhard Pfau TPM_NO_WRAP_TRANSPORT = TPM_BASE + 47, 97be6c1529SReinhard Pfau TPM_AUDITFAIL_UNSUCCESSFUL = TPM_BASE + 48, 98be6c1529SReinhard Pfau TPM_AUDITFAIL_SUCCESSFUL = TPM_BASE + 49, 99be6c1529SReinhard Pfau TPM_NOTRESETABLE = TPM_BASE + 50, 100be6c1529SReinhard Pfau TPM_NOTLOCAL = TPM_BASE + 51, 101be6c1529SReinhard Pfau TPM_BAD_TYPE = TPM_BASE + 52, 102be6c1529SReinhard Pfau TPM_INVALID_RESOURCE = TPM_BASE + 53, 103be6c1529SReinhard Pfau TPM_NOTFIPS = TPM_BASE + 54, 104be6c1529SReinhard Pfau TPM_INVALID_FAMILY = TPM_BASE + 55, 105be6c1529SReinhard Pfau TPM_NO_NV_PERMISSION = TPM_BASE + 56, 106be6c1529SReinhard Pfau TPM_REQUIRES_SIGN = TPM_BASE + 57, 107be6c1529SReinhard Pfau TPM_KEY_NOTSUPPORTED = TPM_BASE + 58, 108be6c1529SReinhard Pfau TPM_AUTH_CONFLICT = TPM_BASE + 59, 109be6c1529SReinhard Pfau TPM_AREA_LOCKED = TPM_BASE + 60, 110be6c1529SReinhard Pfau TPM_BAD_LOCALITY = TPM_BASE + 61, 111be6c1529SReinhard Pfau TPM_READ_ONLY = TPM_BASE + 62, 112be6c1529SReinhard Pfau TPM_PER_NOWRITE = TPM_BASE + 63, 113be6c1529SReinhard Pfau TPM_FAMILY_COUNT = TPM_BASE + 64, 114be6c1529SReinhard Pfau TPM_WRITE_LOCKED = TPM_BASE + 65, 115be6c1529SReinhard Pfau TPM_BAD_ATTRIBUTES = TPM_BASE + 66, 116be6c1529SReinhard Pfau TPM_INVALID_STRUCTURE = TPM_BASE + 67, 117be6c1529SReinhard Pfau TPM_KEY_OWNER_CONTROL = TPM_BASE + 68, 118be6c1529SReinhard Pfau TPM_BAD_COUNTER = TPM_BASE + 69, 119be6c1529SReinhard Pfau TPM_NOT_FULLWRITE = TPM_BASE + 70, 120be6c1529SReinhard Pfau TPM_CONTEXT_GAP = TPM_BASE + 71, 121be6c1529SReinhard Pfau TPM_MAXNVWRITES = TPM_BASE + 72, 122be6c1529SReinhard Pfau TPM_NOOPERATOR = TPM_BASE + 73, 123be6c1529SReinhard Pfau TPM_RESOURCEMISSING = TPM_BASE + 74, 124be6c1529SReinhard Pfau TPM_DELEGATE_LOCK = TPM_BASE + 75, 125be6c1529SReinhard Pfau TPM_DELEGATE_FAMILY = TPM_BASE + 76, 126be6c1529SReinhard Pfau TPM_DELEGATE_ADMIN = TPM_BASE + 77, 127be6c1529SReinhard Pfau TPM_TRANSPORT_NOTEXCLUSIVE = TPM_BASE + 78, 128be6c1529SReinhard Pfau TPM_OWNER_CONTROL = TPM_BASE + 79, 129be6c1529SReinhard Pfau TPM_DAA_RESOURCES = TPM_BASE + 80, 130be6c1529SReinhard Pfau TPM_DAA_INPUT_DATA0 = TPM_BASE + 81, 131be6c1529SReinhard Pfau TPM_DAA_INPUT_DATA1 = TPM_BASE + 82, 132be6c1529SReinhard Pfau TPM_DAA_ISSUER_SETTINGS = TPM_BASE + 83, 133be6c1529SReinhard Pfau TPM_DAA_TPM_SETTINGS = TPM_BASE + 84, 134be6c1529SReinhard Pfau TPM_DAA_STAGE = TPM_BASE + 85, 135be6c1529SReinhard Pfau TPM_DAA_ISSUER_VALIDITY = TPM_BASE + 86, 136be6c1529SReinhard Pfau TPM_DAA_WRONG_W = TPM_BASE + 87, 137be6c1529SReinhard Pfau TPM_BAD_HANDLE = TPM_BASE + 88, 138be6c1529SReinhard Pfau TPM_BAD_DELEGATE = TPM_BASE + 89, 139be6c1529SReinhard Pfau TPM_BADCONTEXT = TPM_BASE + 90, 140be6c1529SReinhard Pfau TPM_TOOMANYCONTEXTS = TPM_BASE + 91, 141be6c1529SReinhard Pfau TPM_MA_TICKET_SIGNATURE = TPM_BASE + 92, 142be6c1529SReinhard Pfau TPM_MA_DESTINATION = TPM_BASE + 93, 143be6c1529SReinhard Pfau TPM_MA_SOURCE = TPM_BASE + 94, 144be6c1529SReinhard Pfau TPM_MA_AUTHORITY = TPM_BASE + 95, 145be6c1529SReinhard Pfau TPM_PERMANENTEK = TPM_BASE + 97, 146be6c1529SReinhard Pfau TPM_BAD_SIGNATURE = TPM_BASE + 98, 147be6c1529SReinhard Pfau TPM_NOCONTEXTSPACE = TPM_BASE + 99, 148be6c1529SReinhard Pfau /* TPM-defined non-fatal errors */ 149be6c1529SReinhard Pfau TPM_RETRY = TPM_BASE + TPM_NON_FATAL, 150be6c1529SReinhard Pfau TPM_NEEDS_SELFTEST = TPM_BASE + TPM_NON_FATAL + 1, 151be6c1529SReinhard Pfau TPM_DOING_SELFTEST = TPM_BASE + TPM_NON_FATAL + 2, 152be6c1529SReinhard Pfau TPM_DEFEND_LOCK_RUNNING = TPM_BASE + TPM_NON_FATAL + 3, 153be6c1529SReinhard Pfau }; 154be6c1529SReinhard Pfau 155be6c1529SReinhard Pfau /** 1568732b070SChe-liang Chiou * Initialize TPM device. It must be called before any TPM commands. 1575e124724SVadim Bendebury * 1588732b070SChe-liang Chiou * @return 0 on success, non-0 on error. 1595e124724SVadim Bendebury */ 1608732b070SChe-liang Chiou uint32_t tpm_init(void); 1615e124724SVadim Bendebury 1628732b070SChe-liang Chiou /** 1638732b070SChe-liang Chiou * Issue a TPM_Startup command. 1645e124724SVadim Bendebury * 1658732b070SChe-liang Chiou * @param mode TPM startup mode 1668732b070SChe-liang Chiou * @return return code of the operation 1675e124724SVadim Bendebury */ 1688732b070SChe-liang Chiou uint32_t tpm_startup(enum tpm_startup_type mode); 1695e124724SVadim Bendebury 1708732b070SChe-liang Chiou /** 1718732b070SChe-liang Chiou * Issue a TPM_SelfTestFull command. 1725e124724SVadim Bendebury * 1738732b070SChe-liang Chiou * @return return code of the operation 1745e124724SVadim Bendebury */ 1758732b070SChe-liang Chiou uint32_t tpm_self_test_full(void); 1765e124724SVadim Bendebury 1778732b070SChe-liang Chiou /** 1788732b070SChe-liang Chiou * Issue a TPM_ContinueSelfTest command. 1798732b070SChe-liang Chiou * 1808732b070SChe-liang Chiou * @return return code of the operation 1818732b070SChe-liang Chiou */ 1828732b070SChe-liang Chiou uint32_t tpm_continue_self_test(void); 1838732b070SChe-liang Chiou 1848732b070SChe-liang Chiou /** 1858732b070SChe-liang Chiou * Issue a TPM_NV_DefineSpace command. The implementation is limited 1868732b070SChe-liang Chiou * to specify TPM_NV_ATTRIBUTES and size of the area. The area index 1878732b070SChe-liang Chiou * could be one of the special value listed in enum tpm_nv_index. 1888732b070SChe-liang Chiou * 1898732b070SChe-liang Chiou * @param index index of the area 1908732b070SChe-liang Chiou * @param perm TPM_NV_ATTRIBUTES of the area 1918732b070SChe-liang Chiou * @param size size of the area 1928732b070SChe-liang Chiou * @return return code of the operation 1938732b070SChe-liang Chiou */ 1948732b070SChe-liang Chiou uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size); 1958732b070SChe-liang Chiou 1968732b070SChe-liang Chiou /** 1978732b070SChe-liang Chiou * Issue a TPM_NV_ReadValue command. This implementation is limited 1988732b070SChe-liang Chiou * to read the area from offset 0. The area index could be one of 1998732b070SChe-liang Chiou * the special value listed in enum tpm_nv_index. 2008732b070SChe-liang Chiou * 2018732b070SChe-liang Chiou * @param index index of the area 2028732b070SChe-liang Chiou * @param data output buffer of the area contents 2038732b070SChe-liang Chiou * @param count size of output buffer 2048732b070SChe-liang Chiou * @return return code of the operation 2058732b070SChe-liang Chiou */ 2068732b070SChe-liang Chiou uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count); 2078732b070SChe-liang Chiou 2088732b070SChe-liang Chiou /** 2098732b070SChe-liang Chiou * Issue a TPM_NV_WriteValue command. This implementation is limited 2108732b070SChe-liang Chiou * to write the area from offset 0. The area index could be one of 2118732b070SChe-liang Chiou * the special value listed in enum tpm_nv_index. 2128732b070SChe-liang Chiou * 2138732b070SChe-liang Chiou * @param index index of the area 2148732b070SChe-liang Chiou * @param data input buffer to be wrote to the area 2158732b070SChe-liang Chiou * @param length length of data bytes of input buffer 2168732b070SChe-liang Chiou * @return return code of the operation 2178732b070SChe-liang Chiou */ 2188732b070SChe-liang Chiou uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length); 2198732b070SChe-liang Chiou 2208732b070SChe-liang Chiou /** 2218732b070SChe-liang Chiou * Issue a TPM_Extend command. 2228732b070SChe-liang Chiou * 2238732b070SChe-liang Chiou * @param index index of the PCR 2248732b070SChe-liang Chiou * @param in_digest 160-bit value representing the event to be 2258732b070SChe-liang Chiou * recorded 2268732b070SChe-liang Chiou * @param out_digest 160-bit PCR value after execution of the 2278732b070SChe-liang Chiou * command 2288732b070SChe-liang Chiou * @return return code of the operation 2298732b070SChe-liang Chiou */ 2308732b070SChe-liang Chiou uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest); 2318732b070SChe-liang Chiou 2328732b070SChe-liang Chiou /** 2338732b070SChe-liang Chiou * Issue a TPM_PCRRead command. 2348732b070SChe-liang Chiou * 2358732b070SChe-liang Chiou * @param index index of the PCR 2368732b070SChe-liang Chiou * @param data output buffer for contents of the named PCR 2378732b070SChe-liang Chiou * @param count size of output buffer 2388732b070SChe-liang Chiou * @return return code of the operation 2398732b070SChe-liang Chiou */ 2408732b070SChe-liang Chiou uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count); 2418732b070SChe-liang Chiou 2428732b070SChe-liang Chiou /** 2438732b070SChe-liang Chiou * Issue a TSC_PhysicalPresence command. TPM physical presence flag 2448732b070SChe-liang Chiou * is bit-wise OR'ed of flags listed in enum tpm_physical_presence. 2458732b070SChe-liang Chiou * 2468732b070SChe-liang Chiou * @param presence TPM physical presence flag 2478732b070SChe-liang Chiou * @return return code of the operation 2488732b070SChe-liang Chiou */ 2498732b070SChe-liang Chiou uint32_t tpm_tsc_physical_presence(uint16_t presence); 2508732b070SChe-liang Chiou 2518732b070SChe-liang Chiou /** 2528732b070SChe-liang Chiou * Issue a TPM_ReadPubek command. 2538732b070SChe-liang Chiou * 2548732b070SChe-liang Chiou * @param data output buffer for the public endorsement key 2558732b070SChe-liang Chiou * @param count size of ouput buffer 2568732b070SChe-liang Chiou * @return return code of the operation 2578732b070SChe-liang Chiou */ 2588732b070SChe-liang Chiou uint32_t tpm_read_pubek(void *data, size_t count); 2598732b070SChe-liang Chiou 2608732b070SChe-liang Chiou /** 2618732b070SChe-liang Chiou * Issue a TPM_ForceClear command. 2628732b070SChe-liang Chiou * 2638732b070SChe-liang Chiou * @return return code of the operation 2648732b070SChe-liang Chiou */ 2658732b070SChe-liang Chiou uint32_t tpm_force_clear(void); 2668732b070SChe-liang Chiou 2678732b070SChe-liang Chiou /** 2688732b070SChe-liang Chiou * Issue a TPM_PhysicalEnable command. 2698732b070SChe-liang Chiou * 2708732b070SChe-liang Chiou * @return return code of the operation 2718732b070SChe-liang Chiou */ 2728732b070SChe-liang Chiou uint32_t tpm_physical_enable(void); 2738732b070SChe-liang Chiou 2748732b070SChe-liang Chiou /** 2758732b070SChe-liang Chiou * Issue a TPM_PhysicalDisable command. 2768732b070SChe-liang Chiou * 2778732b070SChe-liang Chiou * @return return code of the operation 2788732b070SChe-liang Chiou */ 2798732b070SChe-liang Chiou uint32_t tpm_physical_disable(void); 2808732b070SChe-liang Chiou 2818732b070SChe-liang Chiou /** 2828732b070SChe-liang Chiou * Issue a TPM_PhysicalSetDeactivated command. 2838732b070SChe-liang Chiou * 2848732b070SChe-liang Chiou * @param state boolean state of the deactivated flag 2858732b070SChe-liang Chiou * @return return code of the operation 2868732b070SChe-liang Chiou */ 2878732b070SChe-liang Chiou uint32_t tpm_physical_set_deactivated(uint8_t state); 2888732b070SChe-liang Chiou 2898732b070SChe-liang Chiou /** 2908732b070SChe-liang Chiou * Issue a TPM_GetCapability command. This implementation is limited 2918732b070SChe-liang Chiou * to query sub_cap index that is 4-byte wide. 2928732b070SChe-liang Chiou * 2938732b070SChe-liang Chiou * @param cap_area partition of capabilities 2948732b070SChe-liang Chiou * @param sub_cap further definition of capability, which is 2958732b070SChe-liang Chiou * limited to be 4-byte wide 2968732b070SChe-liang Chiou * @param cap output buffer for capability information 2978732b070SChe-liang Chiou * @param count size of ouput buffer 2988732b070SChe-liang Chiou * @return return code of the operation 2998732b070SChe-liang Chiou */ 3008732b070SChe-liang Chiou uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap, 3018732b070SChe-liang Chiou void *cap, size_t count); 3028732b070SChe-liang Chiou 303be6c1529SReinhard Pfau /** 304be6c1529SReinhard Pfau * Issue a TPM_FlushSpecific command for a AUTH ressource. 305be6c1529SReinhard Pfau * 306be6c1529SReinhard Pfau * @param auth_handle handle of the auth session 307be6c1529SReinhard Pfau * @return return code of the operation 308be6c1529SReinhard Pfau */ 309be6c1529SReinhard Pfau uint32_t tpm_terminate_auth_session(uint32_t auth_handle); 310be6c1529SReinhard Pfau 311be6c1529SReinhard Pfau /** 312be6c1529SReinhard Pfau * Issue a TPM_OIAP command to setup an object independant authorization 313be6c1529SReinhard Pfau * session. 314be6c1529SReinhard Pfau * Information about the session is stored internally. 315be6c1529SReinhard Pfau * If there was already an OIAP session active it is terminated and a new 316be6c1529SReinhard Pfau * session is set up. 317be6c1529SReinhard Pfau * 318be6c1529SReinhard Pfau * @param auth_handle pointer to the (new) auth handle or NULL. 319be6c1529SReinhard Pfau * @return return code of the operation 320be6c1529SReinhard Pfau */ 321be6c1529SReinhard Pfau uint32_t tpm_oiap(uint32_t *auth_handle); 322be6c1529SReinhard Pfau 323be6c1529SReinhard Pfau /** 324be6c1529SReinhard Pfau * Ends an active OIAP session. 325be6c1529SReinhard Pfau * 326be6c1529SReinhard Pfau * @return return code of the operation 327be6c1529SReinhard Pfau */ 328be6c1529SReinhard Pfau uint32_t tpm_end_oiap(void); 329be6c1529SReinhard Pfau 330be6c1529SReinhard Pfau /** 331be6c1529SReinhard Pfau * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating 332be6c1529SReinhard Pfau * the usage of the parent key. 333be6c1529SReinhard Pfau * 334be6c1529SReinhard Pfau * @param parent_handle handle of the parent key. 335be6c1529SReinhard Pfau * @param key pointer to the key structure (TPM_KEY or TPM_KEY12). 336be6c1529SReinhard Pfau * @param key_length size of the key structure 337be6c1529SReinhard Pfau * @param parent_key_usage_auth usage auth for the parent key 338be6c1529SReinhard Pfau * @param key_handle pointer to the key handle 339be6c1529SReinhard Pfau * @return return code of the operation 340be6c1529SReinhard Pfau */ 341be6c1529SReinhard Pfau uint32_t tpm_load_key2_oiap(uint32_t parent_handle, 342be6c1529SReinhard Pfau const void *key, size_t key_length, 343be6c1529SReinhard Pfau const void *parent_key_usage_auth, 344be6c1529SReinhard Pfau uint32_t *key_handle); 345be6c1529SReinhard Pfau 346be6c1529SReinhard Pfau /** 347be6c1529SReinhard Pfau * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for 348be6c1529SReinhard Pfau * authenticating the usage of the key. 349be6c1529SReinhard Pfau * 350be6c1529SReinhard Pfau * @param key_handle handle of the key 351be6c1529SReinhard Pfau * @param usage_auth usage auth for the key 352be6c1529SReinhard Pfau * @param pubkey pointer to the pub key buffer; may be NULL if the pubkey 353be6c1529SReinhard Pfau * should not be stored. 354be6c1529SReinhard Pfau * @param pubkey_len pointer to the pub key buffer len. On entry: the size of 355be6c1529SReinhard Pfau * the provided pubkey buffer. On successful exit: the size 356be6c1529SReinhard Pfau * of the stored TPM_PUBKEY structure (iff pubkey != NULL). 357be6c1529SReinhard Pfau * @return return code of the operation 358be6c1529SReinhard Pfau */ 359be6c1529SReinhard Pfau uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth, 360be6c1529SReinhard Pfau void *pubkey, size_t *pubkey_len); 361be6c1529SReinhard Pfau 3628732b070SChe-liang Chiou #endif /* __TPM_H */ 363