xref: /rk3399_rockchip-uboot/include/tpm.h (revision be6c1529c1ce9718cc955f23fdaa5891d15b6551)
15e124724SVadim Bendebury /*
28732b070SChe-liang Chiou  * Copyright (c) 2013 The Chromium OS Authors.
3*be6c1529SReinhard Pfau  * Coypright (c) 2013 Guntermann & Drunck GmbH
45e124724SVadim Bendebury  *
55e124724SVadim Bendebury  * See file CREDITS for list of people who contributed to this
65e124724SVadim Bendebury  * project.
75e124724SVadim Bendebury  *
85e124724SVadim Bendebury  * This program is free software; you can redistribute it and/or
95e124724SVadim Bendebury  * modify it under the terms of the GNU General Public License as
105e124724SVadim Bendebury  * published by the Free Software Foundation; either version 2 of
115e124724SVadim Bendebury  * the License, or (at your option) any later version.
125e124724SVadim Bendebury  *
135e124724SVadim Bendebury  * This program is distributed in the hope that it will be useful,
145e124724SVadim Bendebury  * but WITHOUT ANY WARRANTY; without even the implied warranty of
155e124724SVadim Bendebury  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
165e124724SVadim Bendebury  * GNU General Public License for more details.
175e124724SVadim Bendebury  *
185e124724SVadim Bendebury  * You should have received a copy of the GNU General Public License
195e124724SVadim Bendebury  * along with this program; if not, write to the Free Software
205e124724SVadim Bendebury  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
215e124724SVadim Bendebury  * MA 02111-1307 USA
225e124724SVadim Bendebury  */
235e124724SVadim Bendebury 
248732b070SChe-liang Chiou #ifndef __TPM_H
258732b070SChe-liang Chiou #define __TPM_H
265e124724SVadim Bendebury 
278732b070SChe-liang Chiou #include <tis.h>
285e124724SVadim Bendebury 
295e124724SVadim Bendebury /*
308732b070SChe-liang Chiou  * Here is a partial implementation of TPM commands.  Please consult TCG Main
318732b070SChe-liang Chiou  * Specification for definitions of TPM commands.
325e124724SVadim Bendebury  */
335e124724SVadim Bendebury 
348732b070SChe-liang Chiou enum tpm_startup_type {
358732b070SChe-liang Chiou 	TPM_ST_CLEAR		= 0x0001,
368732b070SChe-liang Chiou 	TPM_ST_STATE		= 0x0002,
378732b070SChe-liang Chiou 	TPM_ST_DEACTIVATED	= 0x0003,
388732b070SChe-liang Chiou };
398732b070SChe-liang Chiou 
408732b070SChe-liang Chiou enum tpm_physical_presence {
418732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_HW_DISABLE	= 0x0200,
428732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_CMD_DISABLE	= 0x0100,
438732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK	= 0x0080,
448732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_HW_ENABLE		= 0x0040,
458732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_CMD_ENABLE	= 0x0020,
468732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_NOTPRESENT	= 0x0010,
478732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_PRESENT		= 0x0008,
488732b070SChe-liang Chiou 	TPM_PHYSICAL_PRESENCE_LOCK		= 0x0004,
498732b070SChe-liang Chiou };
508732b070SChe-liang Chiou 
518732b070SChe-liang Chiou enum tpm_nv_index {
528732b070SChe-liang Chiou 	TPM_NV_INDEX_LOCK	= 0xffffffff,
538732b070SChe-liang Chiou 	TPM_NV_INDEX_0		= 0x00000000,
548732b070SChe-liang Chiou 	TPM_NV_INDEX_DIR	= 0x10000001,
558732b070SChe-liang Chiou };
568732b070SChe-liang Chiou 
578732b070SChe-liang Chiou /**
58*be6c1529SReinhard Pfau  * TPM return codes as defined in the TCG Main specification
59*be6c1529SReinhard Pfau  * (TPM Main Part 2 Structures; Specification version 1.2)
60*be6c1529SReinhard Pfau  */
61*be6c1529SReinhard Pfau enum tpm_return_code {
62*be6c1529SReinhard Pfau 	TPM_BASE	= 0x00000000,
63*be6c1529SReinhard Pfau 	TPM_NON_FATAL	= 0x00000800,
64*be6c1529SReinhard Pfau 	TPM_SUCCESS	= TPM_BASE,
65*be6c1529SReinhard Pfau 	/* TPM-defined fatal error codes */
66*be6c1529SReinhard Pfau 	TPM_AUTHFAIL			= TPM_BASE +  1,
67*be6c1529SReinhard Pfau 	TPM_BADINDEX			= TPM_BASE +  2,
68*be6c1529SReinhard Pfau 	TPM_BAD_PARAMETER		= TPM_BASE +  3,
69*be6c1529SReinhard Pfau 	TPM_AUDITFAILURE		= TPM_BASE +  4,
70*be6c1529SReinhard Pfau 	TPM_CLEAR_DISABLED		= TPM_BASE +  5,
71*be6c1529SReinhard Pfau 	TPM_DEACTIVATED			= TPM_BASE +  6,
72*be6c1529SReinhard Pfau 	TPM_DISABLED			= TPM_BASE +  7,
73*be6c1529SReinhard Pfau 	TPM_DISABLED_CMD		= TPM_BASE +  8,
74*be6c1529SReinhard Pfau 	TPM_FAIL			= TPM_BASE +  9,
75*be6c1529SReinhard Pfau 	TPM_BAD_ORDINAL			= TPM_BASE + 10,
76*be6c1529SReinhard Pfau 	TPM_INSTALL_DISABLED		= TPM_BASE + 11,
77*be6c1529SReinhard Pfau 	TPM_INVALID_KEYHANDLE		= TPM_BASE + 12,
78*be6c1529SReinhard Pfau 	TPM_KEYNOTFOUND			= TPM_BASE + 13,
79*be6c1529SReinhard Pfau 	TPM_INAPPROPRIATE_ENC		= TPM_BASE + 14,
80*be6c1529SReinhard Pfau 	TPM_MIGRATE_FAIL		= TPM_BASE + 15,
81*be6c1529SReinhard Pfau 	TPM_INVALID_PCR_INFO		= TPM_BASE + 16,
82*be6c1529SReinhard Pfau 	TPM_NOSPACE			= TPM_BASE + 17,
83*be6c1529SReinhard Pfau 	TPM_NOSRK			= TPM_BASE + 18,
84*be6c1529SReinhard Pfau 	TPM_NOTSEALED_BLOB		= TPM_BASE + 19,
85*be6c1529SReinhard Pfau 	TPM_OWNER_SET			= TPM_BASE + 20,
86*be6c1529SReinhard Pfau 	TPM_RESOURCES			= TPM_BASE + 21,
87*be6c1529SReinhard Pfau 	TPM_SHORTRANDOM			= TPM_BASE + 22,
88*be6c1529SReinhard Pfau 	TPM_SIZE			= TPM_BASE + 23,
89*be6c1529SReinhard Pfau 	TPM_WRONGPCRVAL			= TPM_BASE + 24,
90*be6c1529SReinhard Pfau 	TPM_BAD_PARAM_SIZE		= TPM_BASE + 25,
91*be6c1529SReinhard Pfau 	TPM_SHA_THREAD			= TPM_BASE + 26,
92*be6c1529SReinhard Pfau 	TPM_SHA_ERROR			= TPM_BASE + 27,
93*be6c1529SReinhard Pfau 	TPM_FAILEDSELFTEST		= TPM_BASE + 28,
94*be6c1529SReinhard Pfau 	TPM_AUTH2FAIL			= TPM_BASE + 29,
95*be6c1529SReinhard Pfau 	TPM_BADTAG			= TPM_BASE + 30,
96*be6c1529SReinhard Pfau 	TPM_IOERROR			= TPM_BASE + 31,
97*be6c1529SReinhard Pfau 	TPM_ENCRYPT_ERROR		= TPM_BASE + 32,
98*be6c1529SReinhard Pfau 	TPM_DECRYPT_ERROR		= TPM_BASE + 33,
99*be6c1529SReinhard Pfau 	TPM_INVALID_AUTHHANDLE		= TPM_BASE + 34,
100*be6c1529SReinhard Pfau 	TPM_NO_ENDORSEMENT		= TPM_BASE + 35,
101*be6c1529SReinhard Pfau 	TPM_INVALID_KEYUSAGE		= TPM_BASE + 36,
102*be6c1529SReinhard Pfau 	TPM_WRONG_ENTITYTYPE		= TPM_BASE + 37,
103*be6c1529SReinhard Pfau 	TPM_INVALID_POSTINIT		= TPM_BASE + 38,
104*be6c1529SReinhard Pfau 	TPM_INAPPROPRIATE_SIG		= TPM_BASE + 39,
105*be6c1529SReinhard Pfau 	TPM_BAD_KEY_PROPERTY		= TPM_BASE + 40,
106*be6c1529SReinhard Pfau 	TPM_BAD_MIGRATION		= TPM_BASE + 41,
107*be6c1529SReinhard Pfau 	TPM_BAD_SCHEME			= TPM_BASE + 42,
108*be6c1529SReinhard Pfau 	TPM_BAD_DATASIZE		= TPM_BASE + 43,
109*be6c1529SReinhard Pfau 	TPM_BAD_MODE			= TPM_BASE + 44,
110*be6c1529SReinhard Pfau 	TPM_BAD_PRESENCE		= TPM_BASE + 45,
111*be6c1529SReinhard Pfau 	TPM_BAD_VERSION			= TPM_BASE + 46,
112*be6c1529SReinhard Pfau 	TPM_NO_WRAP_TRANSPORT		= TPM_BASE + 47,
113*be6c1529SReinhard Pfau 	TPM_AUDITFAIL_UNSUCCESSFUL	= TPM_BASE + 48,
114*be6c1529SReinhard Pfau 	TPM_AUDITFAIL_SUCCESSFUL	= TPM_BASE + 49,
115*be6c1529SReinhard Pfau 	TPM_NOTRESETABLE		= TPM_BASE + 50,
116*be6c1529SReinhard Pfau 	TPM_NOTLOCAL			= TPM_BASE + 51,
117*be6c1529SReinhard Pfau 	TPM_BAD_TYPE			= TPM_BASE + 52,
118*be6c1529SReinhard Pfau 	TPM_INVALID_RESOURCE		= TPM_BASE + 53,
119*be6c1529SReinhard Pfau 	TPM_NOTFIPS			= TPM_BASE + 54,
120*be6c1529SReinhard Pfau 	TPM_INVALID_FAMILY		= TPM_BASE + 55,
121*be6c1529SReinhard Pfau 	TPM_NO_NV_PERMISSION		= TPM_BASE + 56,
122*be6c1529SReinhard Pfau 	TPM_REQUIRES_SIGN		= TPM_BASE + 57,
123*be6c1529SReinhard Pfau 	TPM_KEY_NOTSUPPORTED		= TPM_BASE + 58,
124*be6c1529SReinhard Pfau 	TPM_AUTH_CONFLICT		= TPM_BASE + 59,
125*be6c1529SReinhard Pfau 	TPM_AREA_LOCKED			= TPM_BASE + 60,
126*be6c1529SReinhard Pfau 	TPM_BAD_LOCALITY		= TPM_BASE + 61,
127*be6c1529SReinhard Pfau 	TPM_READ_ONLY			= TPM_BASE + 62,
128*be6c1529SReinhard Pfau 	TPM_PER_NOWRITE			= TPM_BASE + 63,
129*be6c1529SReinhard Pfau 	TPM_FAMILY_COUNT		= TPM_BASE + 64,
130*be6c1529SReinhard Pfau 	TPM_WRITE_LOCKED		= TPM_BASE + 65,
131*be6c1529SReinhard Pfau 	TPM_BAD_ATTRIBUTES		= TPM_BASE + 66,
132*be6c1529SReinhard Pfau 	TPM_INVALID_STRUCTURE		= TPM_BASE + 67,
133*be6c1529SReinhard Pfau 	TPM_KEY_OWNER_CONTROL		= TPM_BASE + 68,
134*be6c1529SReinhard Pfau 	TPM_BAD_COUNTER			= TPM_BASE + 69,
135*be6c1529SReinhard Pfau 	TPM_NOT_FULLWRITE		= TPM_BASE + 70,
136*be6c1529SReinhard Pfau 	TPM_CONTEXT_GAP			= TPM_BASE + 71,
137*be6c1529SReinhard Pfau 	TPM_MAXNVWRITES			= TPM_BASE + 72,
138*be6c1529SReinhard Pfau 	TPM_NOOPERATOR			= TPM_BASE + 73,
139*be6c1529SReinhard Pfau 	TPM_RESOURCEMISSING		= TPM_BASE + 74,
140*be6c1529SReinhard Pfau 	TPM_DELEGATE_LOCK		= TPM_BASE + 75,
141*be6c1529SReinhard Pfau 	TPM_DELEGATE_FAMILY		= TPM_BASE + 76,
142*be6c1529SReinhard Pfau 	TPM_DELEGATE_ADMIN		= TPM_BASE + 77,
143*be6c1529SReinhard Pfau 	TPM_TRANSPORT_NOTEXCLUSIVE	= TPM_BASE + 78,
144*be6c1529SReinhard Pfau 	TPM_OWNER_CONTROL		= TPM_BASE + 79,
145*be6c1529SReinhard Pfau 	TPM_DAA_RESOURCES		= TPM_BASE + 80,
146*be6c1529SReinhard Pfau 	TPM_DAA_INPUT_DATA0		= TPM_BASE + 81,
147*be6c1529SReinhard Pfau 	TPM_DAA_INPUT_DATA1		= TPM_BASE + 82,
148*be6c1529SReinhard Pfau 	TPM_DAA_ISSUER_SETTINGS		= TPM_BASE + 83,
149*be6c1529SReinhard Pfau 	TPM_DAA_TPM_SETTINGS		= TPM_BASE + 84,
150*be6c1529SReinhard Pfau 	TPM_DAA_STAGE			= TPM_BASE + 85,
151*be6c1529SReinhard Pfau 	TPM_DAA_ISSUER_VALIDITY		= TPM_BASE + 86,
152*be6c1529SReinhard Pfau 	TPM_DAA_WRONG_W			= TPM_BASE + 87,
153*be6c1529SReinhard Pfau 	TPM_BAD_HANDLE			= TPM_BASE + 88,
154*be6c1529SReinhard Pfau 	TPM_BAD_DELEGATE		= TPM_BASE + 89,
155*be6c1529SReinhard Pfau 	TPM_BADCONTEXT			= TPM_BASE + 90,
156*be6c1529SReinhard Pfau 	TPM_TOOMANYCONTEXTS		= TPM_BASE + 91,
157*be6c1529SReinhard Pfau 	TPM_MA_TICKET_SIGNATURE		= TPM_BASE + 92,
158*be6c1529SReinhard Pfau 	TPM_MA_DESTINATION		= TPM_BASE + 93,
159*be6c1529SReinhard Pfau 	TPM_MA_SOURCE			= TPM_BASE + 94,
160*be6c1529SReinhard Pfau 	TPM_MA_AUTHORITY		= TPM_BASE + 95,
161*be6c1529SReinhard Pfau 	TPM_PERMANENTEK			= TPM_BASE + 97,
162*be6c1529SReinhard Pfau 	TPM_BAD_SIGNATURE		= TPM_BASE + 98,
163*be6c1529SReinhard Pfau 	TPM_NOCONTEXTSPACE		= TPM_BASE + 99,
164*be6c1529SReinhard Pfau 	/* TPM-defined non-fatal errors */
165*be6c1529SReinhard Pfau 	TPM_RETRY		= TPM_BASE + TPM_NON_FATAL,
166*be6c1529SReinhard Pfau 	TPM_NEEDS_SELFTEST	= TPM_BASE + TPM_NON_FATAL + 1,
167*be6c1529SReinhard Pfau 	TPM_DOING_SELFTEST	= TPM_BASE + TPM_NON_FATAL + 2,
168*be6c1529SReinhard Pfau 	TPM_DEFEND_LOCK_RUNNING	= TPM_BASE + TPM_NON_FATAL + 3,
169*be6c1529SReinhard Pfau };
170*be6c1529SReinhard Pfau 
171*be6c1529SReinhard Pfau /**
1728732b070SChe-liang Chiou  * Initialize TPM device.  It must be called before any TPM commands.
1735e124724SVadim Bendebury  *
1748732b070SChe-liang Chiou  * @return 0 on success, non-0 on error.
1755e124724SVadim Bendebury  */
1768732b070SChe-liang Chiou uint32_t tpm_init(void);
1775e124724SVadim Bendebury 
1788732b070SChe-liang Chiou /**
1798732b070SChe-liang Chiou  * Issue a TPM_Startup command.
1805e124724SVadim Bendebury  *
1818732b070SChe-liang Chiou  * @param mode		TPM startup mode
1828732b070SChe-liang Chiou  * @return return code of the operation
1835e124724SVadim Bendebury  */
1848732b070SChe-liang Chiou uint32_t tpm_startup(enum tpm_startup_type mode);
1855e124724SVadim Bendebury 
1868732b070SChe-liang Chiou /**
1878732b070SChe-liang Chiou  * Issue a TPM_SelfTestFull command.
1885e124724SVadim Bendebury  *
1898732b070SChe-liang Chiou  * @return return code of the operation
1905e124724SVadim Bendebury  */
1918732b070SChe-liang Chiou uint32_t tpm_self_test_full(void);
1925e124724SVadim Bendebury 
1938732b070SChe-liang Chiou /**
1948732b070SChe-liang Chiou  * Issue a TPM_ContinueSelfTest command.
1958732b070SChe-liang Chiou  *
1968732b070SChe-liang Chiou  * @return return code of the operation
1978732b070SChe-liang Chiou  */
1988732b070SChe-liang Chiou uint32_t tpm_continue_self_test(void);
1998732b070SChe-liang Chiou 
2008732b070SChe-liang Chiou /**
2018732b070SChe-liang Chiou  * Issue a TPM_NV_DefineSpace command.  The implementation is limited
2028732b070SChe-liang Chiou  * to specify TPM_NV_ATTRIBUTES and size of the area.  The area index
2038732b070SChe-liang Chiou  * could be one of the special value listed in enum tpm_nv_index.
2048732b070SChe-liang Chiou  *
2058732b070SChe-liang Chiou  * @param index		index of the area
2068732b070SChe-liang Chiou  * @param perm		TPM_NV_ATTRIBUTES of the area
2078732b070SChe-liang Chiou  * @param size		size of the area
2088732b070SChe-liang Chiou  * @return return code of the operation
2098732b070SChe-liang Chiou  */
2108732b070SChe-liang Chiou uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size);
2118732b070SChe-liang Chiou 
2128732b070SChe-liang Chiou /**
2138732b070SChe-liang Chiou  * Issue a TPM_NV_ReadValue command.  This implementation is limited
2148732b070SChe-liang Chiou  * to read the area from offset 0.  The area index could be one of
2158732b070SChe-liang Chiou  * the special value listed in enum tpm_nv_index.
2168732b070SChe-liang Chiou  *
2178732b070SChe-liang Chiou  * @param index		index of the area
2188732b070SChe-liang Chiou  * @param data		output buffer of the area contents
2198732b070SChe-liang Chiou  * @param count		size of output buffer
2208732b070SChe-liang Chiou  * @return return code of the operation
2218732b070SChe-liang Chiou  */
2228732b070SChe-liang Chiou uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count);
2238732b070SChe-liang Chiou 
2248732b070SChe-liang Chiou /**
2258732b070SChe-liang Chiou  * Issue a TPM_NV_WriteValue command.  This implementation is limited
2268732b070SChe-liang Chiou  * to write the area from offset 0.  The area index could be one of
2278732b070SChe-liang Chiou  * the special value listed in enum tpm_nv_index.
2288732b070SChe-liang Chiou  *
2298732b070SChe-liang Chiou  * @param index		index of the area
2308732b070SChe-liang Chiou  * @param data		input buffer to be wrote to the area
2318732b070SChe-liang Chiou  * @param length	length of data bytes of input buffer
2328732b070SChe-liang Chiou  * @return return code of the operation
2338732b070SChe-liang Chiou  */
2348732b070SChe-liang Chiou uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length);
2358732b070SChe-liang Chiou 
2368732b070SChe-liang Chiou /**
2378732b070SChe-liang Chiou  * Issue a TPM_Extend command.
2388732b070SChe-liang Chiou  *
2398732b070SChe-liang Chiou  * @param index		index of the PCR
2408732b070SChe-liang Chiou  * @param in_digest	160-bit value representing the event to be
2418732b070SChe-liang Chiou  *			recorded
2428732b070SChe-liang Chiou  * @param out_digest	160-bit PCR value after execution of the
2438732b070SChe-liang Chiou  *			command
2448732b070SChe-liang Chiou  * @return return code of the operation
2458732b070SChe-liang Chiou  */
2468732b070SChe-liang Chiou uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest);
2478732b070SChe-liang Chiou 
2488732b070SChe-liang Chiou /**
2498732b070SChe-liang Chiou  * Issue a TPM_PCRRead command.
2508732b070SChe-liang Chiou  *
2518732b070SChe-liang Chiou  * @param index		index of the PCR
2528732b070SChe-liang Chiou  * @param data		output buffer for contents of the named PCR
2538732b070SChe-liang Chiou  * @param count		size of output buffer
2548732b070SChe-liang Chiou  * @return return code of the operation
2558732b070SChe-liang Chiou  */
2568732b070SChe-liang Chiou uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count);
2578732b070SChe-liang Chiou 
2588732b070SChe-liang Chiou /**
2598732b070SChe-liang Chiou  * Issue a TSC_PhysicalPresence command.  TPM physical presence flag
2608732b070SChe-liang Chiou  * is bit-wise OR'ed of flags listed in enum tpm_physical_presence.
2618732b070SChe-liang Chiou  *
2628732b070SChe-liang Chiou  * @param presence	TPM physical presence flag
2638732b070SChe-liang Chiou  * @return return code of the operation
2648732b070SChe-liang Chiou  */
2658732b070SChe-liang Chiou uint32_t tpm_tsc_physical_presence(uint16_t presence);
2668732b070SChe-liang Chiou 
2678732b070SChe-liang Chiou /**
2688732b070SChe-liang Chiou  * Issue a TPM_ReadPubek command.
2698732b070SChe-liang Chiou  *
2708732b070SChe-liang Chiou  * @param data		output buffer for the public endorsement key
2718732b070SChe-liang Chiou  * @param count		size of ouput buffer
2728732b070SChe-liang Chiou  * @return return code of the operation
2738732b070SChe-liang Chiou  */
2748732b070SChe-liang Chiou uint32_t tpm_read_pubek(void *data, size_t count);
2758732b070SChe-liang Chiou 
2768732b070SChe-liang Chiou /**
2778732b070SChe-liang Chiou  * Issue a TPM_ForceClear command.
2788732b070SChe-liang Chiou  *
2798732b070SChe-liang Chiou  * @return return code of the operation
2808732b070SChe-liang Chiou  */
2818732b070SChe-liang Chiou uint32_t tpm_force_clear(void);
2828732b070SChe-liang Chiou 
2838732b070SChe-liang Chiou /**
2848732b070SChe-liang Chiou  * Issue a TPM_PhysicalEnable command.
2858732b070SChe-liang Chiou  *
2868732b070SChe-liang Chiou  * @return return code of the operation
2878732b070SChe-liang Chiou  */
2888732b070SChe-liang Chiou uint32_t tpm_physical_enable(void);
2898732b070SChe-liang Chiou 
2908732b070SChe-liang Chiou /**
2918732b070SChe-liang Chiou  * Issue a TPM_PhysicalDisable command.
2928732b070SChe-liang Chiou  *
2938732b070SChe-liang Chiou  * @return return code of the operation
2948732b070SChe-liang Chiou  */
2958732b070SChe-liang Chiou uint32_t tpm_physical_disable(void);
2968732b070SChe-liang Chiou 
2978732b070SChe-liang Chiou /**
2988732b070SChe-liang Chiou  * Issue a TPM_PhysicalSetDeactivated command.
2998732b070SChe-liang Chiou  *
3008732b070SChe-liang Chiou  * @param state		boolean state of the deactivated flag
3018732b070SChe-liang Chiou  * @return return code of the operation
3028732b070SChe-liang Chiou  */
3038732b070SChe-liang Chiou uint32_t tpm_physical_set_deactivated(uint8_t state);
3048732b070SChe-liang Chiou 
3058732b070SChe-liang Chiou /**
3068732b070SChe-liang Chiou  * Issue a TPM_GetCapability command.  This implementation is limited
3078732b070SChe-liang Chiou  * to query sub_cap index that is 4-byte wide.
3088732b070SChe-liang Chiou  *
3098732b070SChe-liang Chiou  * @param cap_area	partition of capabilities
3108732b070SChe-liang Chiou  * @param sub_cap	further definition of capability, which is
3118732b070SChe-liang Chiou  *			limited to be 4-byte wide
3128732b070SChe-liang Chiou  * @param cap		output buffer for capability information
3138732b070SChe-liang Chiou  * @param count		size of ouput buffer
3148732b070SChe-liang Chiou  * @return return code of the operation
3158732b070SChe-liang Chiou  */
3168732b070SChe-liang Chiou uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
3178732b070SChe-liang Chiou 		void *cap, size_t count);
3188732b070SChe-liang Chiou 
319*be6c1529SReinhard Pfau /**
320*be6c1529SReinhard Pfau  * Issue a TPM_FlushSpecific command for a AUTH ressource.
321*be6c1529SReinhard Pfau  *
322*be6c1529SReinhard Pfau  * @param auth_handle	handle of the auth session
323*be6c1529SReinhard Pfau  * @return return code of the operation
324*be6c1529SReinhard Pfau  */
325*be6c1529SReinhard Pfau uint32_t tpm_terminate_auth_session(uint32_t auth_handle);
326*be6c1529SReinhard Pfau 
327*be6c1529SReinhard Pfau /**
328*be6c1529SReinhard Pfau  * Issue a TPM_OIAP command to setup an object independant authorization
329*be6c1529SReinhard Pfau  * session.
330*be6c1529SReinhard Pfau  * Information about the session is stored internally.
331*be6c1529SReinhard Pfau  * If there was already an OIAP session active it is terminated and a new
332*be6c1529SReinhard Pfau  * session is set up.
333*be6c1529SReinhard Pfau  *
334*be6c1529SReinhard Pfau  * @param auth_handle	pointer to the (new) auth handle or NULL.
335*be6c1529SReinhard Pfau  * @return return code of the operation
336*be6c1529SReinhard Pfau  */
337*be6c1529SReinhard Pfau uint32_t tpm_oiap(uint32_t *auth_handle);
338*be6c1529SReinhard Pfau 
339*be6c1529SReinhard Pfau /**
340*be6c1529SReinhard Pfau  * Ends an active OIAP session.
341*be6c1529SReinhard Pfau  *
342*be6c1529SReinhard Pfau  * @return return code of the operation
343*be6c1529SReinhard Pfau  */
344*be6c1529SReinhard Pfau uint32_t tpm_end_oiap(void);
345*be6c1529SReinhard Pfau 
346*be6c1529SReinhard Pfau /**
347*be6c1529SReinhard Pfau  * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
348*be6c1529SReinhard Pfau  * the usage of the parent key.
349*be6c1529SReinhard Pfau  *
350*be6c1529SReinhard Pfau  * @param parent_handle	handle of the parent key.
351*be6c1529SReinhard Pfau  * @param key		pointer to the key structure (TPM_KEY or TPM_KEY12).
352*be6c1529SReinhard Pfau  * @param key_length	size of the key structure
353*be6c1529SReinhard Pfau  * @param parent_key_usage_auth	usage auth for the parent key
354*be6c1529SReinhard Pfau  * @param key_handle	pointer to the key handle
355*be6c1529SReinhard Pfau  * @return return code of the operation
356*be6c1529SReinhard Pfau  */
357*be6c1529SReinhard Pfau uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
358*be6c1529SReinhard Pfau 		const void *key, size_t key_length,
359*be6c1529SReinhard Pfau 		const void *parent_key_usage_auth,
360*be6c1529SReinhard Pfau 		uint32_t *key_handle);
361*be6c1529SReinhard Pfau 
362*be6c1529SReinhard Pfau /**
363*be6c1529SReinhard Pfau  * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
364*be6c1529SReinhard Pfau  * authenticating the usage of the key.
365*be6c1529SReinhard Pfau  *
366*be6c1529SReinhard Pfau  * @param key_handle	handle of the key
367*be6c1529SReinhard Pfau  * @param usage_auth	usage auth for the key
368*be6c1529SReinhard Pfau  * @param pubkey	pointer to the pub key buffer; may be NULL if the pubkey
369*be6c1529SReinhard Pfau  *			should not be stored.
370*be6c1529SReinhard Pfau  * @param pubkey_len	pointer to the pub key buffer len. On entry: the size of
371*be6c1529SReinhard Pfau  *			the provided pubkey buffer. On successful exit: the size
372*be6c1529SReinhard Pfau  *			of the stored TPM_PUBKEY structure (iff pubkey != NULL).
373*be6c1529SReinhard Pfau  * @return return code of the operation
374*be6c1529SReinhard Pfau  */
375*be6c1529SReinhard Pfau uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
376*be6c1529SReinhard Pfau 		void *pubkey, size_t *pubkey_len);
377*be6c1529SReinhard Pfau 
3788732b070SChe-liang Chiou #endif /* __TPM_H */
379