1 
2 /*
3  * Licensed Materials - Property of IBM
4  *
5  * trousers - An open source TCG Software Stack
6  *
7  * (C) Copyright International Business Machines Corp. 2004, 2007
8  *
9  */
10 
11 
12 #ifndef _SPI_UTILS_H_
13 #define _SPI_UTILS_H_
14 
15 #include "threads.h"
16 #include <netinet/in.h> // for endian routines
17 
18 #include "trousers_types.h"
19 #include "trousers/trousers.h"
20 
21 struct key_mem_cache
22 {
23 	TCS_KEY_HANDLE tcs_handle;
24 	TSS_HKEY tsp_handle;
25 	UINT16 flags;
26 	UINT32 time_stamp;
27 	TSS_UUID uuid;
28 	TSS_UUID p_uuid;
29 	TSS_KEY *blob;
30 	struct key_mem_cache *parent;
31 	struct key_mem_cache *next;
32 };
33 
34 extern struct key_mem_cache *key_mem_cache_head;
35 MUTEX_DECLARE_EXTERN(mem_cache_lock);
36 
37 #ifndef MIN
38 #define MIN(a,b) ((a) < (b) ? (a) : (b))
39 #endif
40 
41 #define BOOL(x)		((x) == 0) ? FALSE : TRUE
42 #define INVBOOL(x)	((x) == 0) ? TRUE : FALSE
43 
44 #define TSS_PSFILE_INCREMENT_NUM_KEYS	1
45 #define TSS_PSFILE_DECREMENT_NUM_KEYS	0
46 
47 #ifdef __GNUC__
48 #define __no_optimize __attribute__((optimize("O0")))
49 #else
50 #define __no_optimize
51 #endif
52 
53 void *calloc_tspi(TSS_HCONTEXT, UINT32);
54 TSS_RESULT free_tspi(TSS_HCONTEXT, void *);
55 TSS_RESULT __tspi_add_mem_entry(TSS_HCONTEXT, void *);
56 void * __no_optimize __tspi_memset(void *, int, size_t);
57 
58 /* secrets.c */
59 
60 TSS_RESULT policy_UsesAuth(TSS_HPOLICY, TSS_BOOL *);
61 
62 TSS_RESULT secret_PerformAuth_OIAP(TSS_HOBJECT, UINT32, TSS_HPOLICY, TSS_BOOL, TCPA_DIGEST *,
63 				   TPM_AUTH *);
64 #if 0
65 TSS_RESULT secret_PerformXOR_OSAP(TSS_HPOLICY, TSS_HPOLICY, TSS_HPOLICY, TSS_HOBJECT,
66 				  UINT16, UINT32, TCPA_ENCAUTH *, TCPA_ENCAUTH *,
67 				  BYTE *, TPM_AUTH *, TCPA_NONCE *);
68 TSS_RESULT secret_PerformAuth_OSAP(TSS_HOBJECT, UINT32, TSS_HPOLICY,
69 				   TSS_HPOLICY, TSS_HPOLICY, BYTE *,
70 				   TPM_AUTH *, BYTE *, TCPA_NONCE *);
71 
72 TSS_RESULT secret_ValidateAuth_OSAP(TSS_HOBJECT, UINT32, TSS_HPOLICY,
73 				    TSS_HPOLICY, TSS_HPOLICY, BYTE *,
74 				    TPM_AUTH *, BYTE *, TCPA_NONCE *);
75 #endif
76 TSS_RESULT secret_TakeOwnership(TSS_HKEY, TSS_HTPM, TSS_HKEY, TPM_AUTH *,
77 				UINT32 *, BYTE *, UINT32 *, BYTE *);
78 
79 TSS_RESULT changeauth_owner(TSS_HCONTEXT, TSS_HOBJECT, TSS_HOBJECT, TSS_HPOLICY);
80 TSS_RESULT changeauth_srk(TSS_HCONTEXT, TSS_HOBJECT, TSS_HOBJECT, TSS_HPOLICY);
81 TSS_RESULT changeauth_key(TSS_HCONTEXT, TSS_HOBJECT, TSS_HOBJECT, TSS_HPOLICY);
82 TSS_RESULT changeauth_encdata(TSS_HCONTEXT, TSS_HOBJECT, TSS_HOBJECT, TSS_HPOLICY);
83 
84 TSS_RESULT sealx_mask_cb(PVOID, TSS_HKEY, TSS_HENCDATA, TSS_ALGORITHM_ID, UINT32, BYTE *, BYTE *,
85 			 BYTE *, BYTE *, UINT32, BYTE *, BYTE *);
86 
87 TSS_RESULT __tspi_free_resource(TSS_HCONTEXT, UINT32, UINT32);
88 TSS_RESULT owner_get_pubek(TSS_HCONTEXT, TSS_HTPM, TSS_HKEY *);
89 
90 #define next( x )	x = x->next
91 
92 /* spi_utils.c */
93 
94 UINT16 get_num_pcrs(TSS_HCONTEXT);
95 void   free_key_refs(TSS_KEY *);
96 
97 #define UI_MAX_SECRET_STRING_LENGTH	256
98 #define UI_MAX_POPUP_STRING_LENGTH	256
99 
100 #ifdef TSS_NO_GUI
101 #define DisplayPINWindow(a,b,c)			\
102 	do {					\
103 		*(b) = 0;			\
104 	} while (0)
105 #define DisplayNewPINWindow(a,b,c)			\
106 	do {					\
107 		*(b) = 0;			\
108 	} while (0)
109 #else
110 TSS_RESULT DisplayPINWindow(BYTE *, UINT32 *, BYTE *);
111 TSS_RESULT DisplayNewPINWindow(BYTE *, UINT32 *, BYTE *);
112 #endif
113 
114 TSS_RESULT merge_key_hierarchies(TSS_HCONTEXT, UINT32, TSS_KM_KEYINFO *, UINT32, TSS_KM_KEYINFO *,
115 				 UINT32 *, TSS_KM_KEYINFO **);
116 TSS_RESULT merge_key_hierarchies2(TSS_HCONTEXT, UINT32, TSS_KM_KEYINFO2 *, UINT32, TSS_KM_KEYINFO2 *,
117 				 UINT32 *, TSS_KM_KEYINFO2 **);
118 
119 
120 int pin_mem(void *, size_t);
121 int unpin_mem(void *, size_t);
122 
123 
124 #define TSS_MAX_SYM_BLOCK_SIZE	16
125 
126 TSS_RESULT internal_GetCap(TSS_HCONTEXT, TSS_FLAG, UINT32, UINT32 *, BYTE **);
127 
128 /* For an unconnected context that wants to do PCR operations, assume that
129  * the TPM has TSS_DEFAULT_NUM_PCRS pcrs */
130 #define TSS_DEFAULT_NUM_PCRS		16
131 #define TSS_LOCAL_RANDOM_DEVICE		"/dev/urandom"
132 #define TSS_LOCALHOST_STRING		"localhost"
133 TSS_RESULT get_local_random(TSS_HCONTEXT, TSS_BOOL, UINT32, BYTE **);
134 
135 #define AUTH_RETRY_NANOSECS	500000000
136 #define AUTH_RETRY_COUNT	5
137 #define TPM_AUTH_RQU_SIZE	(sizeof(TPM_AUTHHANDLE) + sizeof(TPM_NONCE) \
138 				 + sizeof(TPM_BOOL) + sizeof(TPM_AUTHDATA))
139 #define TPM_AUTH_RSP_SIZE	(sizeof(TPM_NONCE) + sizeof(TPM_BOOL) + sizeof(TPM_AUTHDATA))
140 
141 #define endian32(x)	htonl(x)
142 #define endian16(x)	htons(x)
143 
144 extern TSS_VERSION VERSION_1_1;
145 
146 TSS_RESULT __tspi_rsa_encrypt(TSS_HKEY, UINT32, BYTE*, UINT32*, BYTE*);
147 TSS_RESULT __tspi_rsa_verify(TSS_HKEY, UINT32, UINT32, BYTE*, UINT32, BYTE*);
148 
149 TSS_RESULT Init_AuthNonce(TCS_CONTEXT_HANDLE, TSS_BOOL, TPM_AUTH *);
150 TSS_BOOL validateReturnAuth(BYTE *, BYTE *, TPM_AUTH *);
151 void HMAC_Auth(BYTE *, BYTE *, TPM_AUTH *);
152 TSS_RESULT OSAP_Calc(TCS_CONTEXT_HANDLE, UINT16, UINT32, BYTE *, BYTE *, BYTE *,
153 			TCPA_ENCAUTH *, TCPA_ENCAUTH *, BYTE *, TPM_AUTH *);
154 
155 void UINT64ToArray(UINT64, BYTE *);
156 void UINT32ToArray(UINT32, BYTE *);
157 void UINT16ToArray(UINT16, BYTE *);
158 UINT16 Decode_UINT16(BYTE *);
159 UINT32 Decode_UINT32(BYTE *);
160 UINT64 Decode_UINT64(BYTE *);
161 
162 TSS_RESULT popup_GetSecret(UINT32, UINT32, BYTE *, void *);
163 
164 TSS_RESULT get_tpm_flags(TSS_HCONTEXT, TSS_HTPM, UINT32 *, UINT32 *);
165 TSS_RESULT pcrs_calc_composite(TCPA_PCR_SELECTION *, TCPA_PCRVALUE *, TCPA_DIGEST *);
166 struct tr_pcrs_obj;
167 TSS_RESULT pcrs_sanity_check_selection(TCS_CONTEXT_HANDLE, struct tr_pcrs_obj *, TPM_PCR_SELECTION *);
168 
169 void LoadBlob_AUTH(UINT64 *, BYTE *, TPM_AUTH *);
170 void UnloadBlob_AUTH(UINT64 *, BYTE *, TPM_AUTH *);
171 void LoadBlob_LOADKEY_INFO(UINT64 *, BYTE *, TCS_LOADKEY_INFO *);
172 void UnloadBlob_LOADKEY_INFO(UINT64 *, BYTE *, TCS_LOADKEY_INFO *);
173 void LoadBlob_TSS_KEY(UINT64 *, BYTE *, TSS_KEY *);
174 TSS_RESULT UnloadBlob_TSS_KEY(UINT64 *, BYTE *, TSS_KEY *);
175 TSS_RESULT Hash_TSS_KEY(Trspi_HashCtx *, TSS_KEY *);
176 void LoadBlob_TSS_PRIVKEY_DIGEST(UINT64 *, BYTE *, TSS_KEY *);
177 TSS_RESULT Hash_TSS_PRIVKEY_DIGEST(Trspi_HashCtx *, TSS_KEY *);
178 
179 TSS_RESULT TSP_SetCapability(TSS_HCONTEXT, TSS_HTPM, TSS_HPOLICY, TPM_CAPABILITY_AREA,
180 			     UINT32, TSS_BOOL);
181 
182 TSS_RESULT RPC_OpenContext(TSS_HCONTEXT, BYTE *, int);
183 TSS_RESULT RPC_FreeMemory(TSS_HCONTEXT, BYTE *);
184 TSS_RESULT RPC_GetRegisteredKeyByPublicInfo(TSS_HCONTEXT, TCPA_ALGORITHM_ID, UINT32,
185                                               BYTE *, UINT32 *, BYTE **);
186 TSS_RESULT RPC_CloseContext(TSS_HCONTEXT);
187 TSS_RESULT RPC_GetCapability(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32 *, BYTE **);
188 TSS_RESULT RPC_GetTPMCapability(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32 *, BYTE **);
189 TSS_RESULT Transport_GetTPMCapability(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32 *, BYTE **);
190 TSS_RESULT RPC_SetCapability(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *);
191 TSS_RESULT Transport_SetCapability(TSS_HCONTEXT, TCPA_CAPABILITY_AREA,	UINT32, BYTE *, UINT32,
192 				   BYTE *, TPM_AUTH *);
193 TSS_RESULT RPC_LoadKeyByBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *,
194                                TCS_KEY_HANDLE *, TCS_KEY_HANDLE *);
195 TSS_RESULT Transport_LoadKeyByBlob(TSS_HCONTEXT, TSS_HKEY, UINT32, BYTE *,
196 				   TPM_AUTH *, TCS_KEY_HANDLE *, TPM_KEY_HANDLE *);
197 TSS_RESULT RPC_LoadKeyByUUID(TSS_HCONTEXT, TSS_UUID, TCS_LOADKEY_INFO *, TCS_KEY_HANDLE *);
198 TSS_RESULT RPC_GetRegisteredKey(TSS_HCONTEXT, TSS_UUID, TSS_KM_KEYINFO **);
199 TSS_RESULT RPC_GetRegisteredKeyBlob(TSS_HCONTEXT, TSS_UUID, UINT32 *, BYTE **);
200 TSS_RESULT RPC_RegisterKey(TSS_HCONTEXT, TSS_UUID, TSS_UUID, UINT32, BYTE *, UINT32, BYTE *);
201 TSS_RESULT RPC_UnregisterKey(TSS_HCONTEXT, TSS_UUID);
202 TSS_RESULT RPC_EnumRegisteredKeys(TSS_HCONTEXT, TSS_UUID *, UINT32 *, TSS_KM_KEYINFO **);
203 TSS_RESULT RPC_EnumRegisteredKeys2(TSS_HCONTEXT, TSS_UUID *, UINT32 *, TSS_KM_KEYINFO2 **);
204 TSS_RESULT RPC_ChangeAuth(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *,
205 				TCPA_ENTITY_TYPE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
206 	                        UINT32 *, BYTE **);
207 TSS_RESULT Transport_ChangeAuth(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *,
208 				TCPA_ENTITY_TYPE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
209 	                        UINT32 *, BYTE **);
210 TSS_RESULT RPC_ChangeAuthOwner(TSS_HCONTEXT, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *, TCPA_ENTITY_TYPE,
211                                  TPM_AUTH *);
212 TSS_RESULT Transport_ChangeAuthOwner(TSS_HCONTEXT, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *, TCPA_ENTITY_TYPE,
213                                  TPM_AUTH *);
214 TSS_RESULT RPC_TerminateHandle(TSS_HCONTEXT, TCS_AUTHHANDLE);
215 TSS_RESULT Transport_TerminateHandle(TSS_HCONTEXT, TCS_AUTHHANDLE);
216 TSS_RESULT RPC_GetRandom(TSS_HCONTEXT, UINT32, BYTE **);
217 TSS_RESULT Transport_GetRandom(TSS_HCONTEXT, UINT32, BYTE **);
218 TSS_RESULT RPC_ChangeAuthAsymStart(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, UINT32, BYTE *,
219                                      TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **, UINT32 *,
220                                      BYTE **, TCS_KEY_HANDLE *);
221 TSS_RESULT RPC_ChangeAuthAsymFinish(TSS_HCONTEXT, TCS_KEY_HANDLE, TCS_KEY_HANDLE,
222 					TCPA_ENTITY_TYPE, TCPA_HMAC, UINT32, BYTE *, UINT32,
223 					BYTE *, TPM_AUTH *, UINT32 *, BYTE **, TCPA_SALT_NONCE *,
224 					TCPA_DIGEST *);
225 TSS_RESULT RPC_GetPubKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH *, UINT32 *, BYTE **);
226 TSS_RESULT Transport_GetPubKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH *, UINT32 *, BYTE **);
227 TSS_RESULT RPC_CreateWrapKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, TCPA_ENCAUTH *,
228 				UINT32, BYTE *, UINT32 *, BYTE **, TPM_AUTH *);
229 TSS_RESULT Transport_CreateWrapKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, TCPA_ENCAUTH *,
230 				   UINT32, BYTE *, UINT32 *, BYTE **, TPM_AUTH *);
231 TSS_RESULT RPC_CertifyKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TCS_KEY_HANDLE, TPM_NONCE *, TPM_AUTH *,
232 				TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
233 TSS_RESULT Transport_CertifyKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TCS_KEY_HANDLE, TPM_NONCE *,
234 				TPM_AUTH *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
235 TSS_RESULT RPC_CreateMigrationBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_MIGRATE_SCHEME, UINT32,
236 					BYTE *, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *, UINT32 *,
237 					BYTE **, UINT32 *, BYTE **);
238 TSS_RESULT Transport_CreateMigrationBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_MIGRATE_SCHEME, UINT32,
239 					BYTE *, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *, UINT32 *,
240 					BYTE **, UINT32 *, BYTE **);
241 TSS_RESULT RPC_ConvertMigrationBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, UINT32,
242 				     BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
243 TSS_RESULT Transport_ConvertMigrationBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, UINT32,
244 				     BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
245 TSS_RESULT RPC_PcrRead(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_PCRVALUE *);
246 TSS_RESULT Transport_PcrRead(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_PCRVALUE *);
247 TSS_RESULT RPC_PcrReset(TSS_HCONTEXT, UINT32, BYTE *);
248 TSS_RESULT Transport_PcrReset(TSS_HCONTEXT, UINT32, BYTE *);
249 TSS_RESULT RPC_OSAP(TSS_HCONTEXT, TCPA_ENTITY_TYPE, UINT32, TPM_NONCE *, TCS_AUTHHANDLE *,
250 		    TCPA_NONCE *, TCPA_NONCE *);
251 TSS_RESULT Transport_OSAP(TSS_HCONTEXT, TCPA_ENTITY_TYPE, UINT32, TPM_NONCE *, TCS_AUTHHANDLE *,
252 			  TCPA_NONCE *, TCPA_NONCE *);
253 TSS_RESULT RPC_GetCapabilityOwner(TSS_HCONTEXT, TPM_AUTH *, TCPA_VERSION *, UINT32 *, UINT32 *);
254 TSS_RESULT Transport_GetCapabilityOwner(TSS_HCONTEXT, TPM_AUTH *, TCPA_VERSION *, UINT32 *, UINT32 *);
255 TSS_RESULT RPC_OIAP(TSS_HCONTEXT, TCS_AUTHHANDLE *, TCPA_NONCE *);
256 TSS_RESULT Transport_OIAP(TSS_HCONTEXT, TCS_AUTHHANDLE *, TCPA_NONCE *);
257 TSS_RESULT RPC_Seal(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32, BYTE *,
258 		    TPM_AUTH *, UINT32 *, BYTE **);
259 TSS_RESULT Transport_Seal(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32,
260 			  BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
261 TSS_RESULT RPC_Sealx(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32, BYTE *,
262                                        TPM_AUTH *, UINT32 *, BYTE **);
263 TSS_RESULT Transport_Sealx(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32,
264 			   BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
265 TSS_RESULT RPC_Unseal(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
266                                          UINT32 *, BYTE **);
267 TSS_RESULT Transport_Unseal(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
268 			    UINT32 *, BYTE **);
269 TSS_RESULT RPC_UnBind(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *,
270                                          BYTE **);
271 TSS_RESULT Transport_UnBind(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *,
272                                          BYTE **);
273 TSS_RESULT RPC_Sign(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
274 TSS_RESULT Transport_Sign(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
275 TSS_RESULT RPC_CreateEndorsementKeyPair(TSS_HCONTEXT, TCPA_NONCE, UINT32, BYTE *, UINT32 *,
276 						BYTE **, TCPA_DIGEST *);
277 TSS_RESULT RPC_ReadPubek(TSS_HCONTEXT, TCPA_NONCE, UINT32 *, BYTE **, TCPA_DIGEST *);
278 TSS_RESULT RPC_OwnerReadPubek(TSS_HCONTEXT, TPM_AUTH *, UINT32 *, BYTE **);
279 TSS_RESULT RPC_TakeOwnership(TSS_HCONTEXT, UINT16, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
280 TSS_RESULT RPC_CreateRevocableEndorsementKeyPair(TSS_HCONTEXT, TPM_NONCE, UINT32, BYTE *, TSS_BOOL, TPM_DIGEST *, UINT32 *, BYTE **, TPM_DIGEST *);
281 TSS_RESULT RPC_RevokeEndorsementKeyPair(TSS_HCONTEXT, TPM_DIGEST *);
282 TSS_RESULT RPC_MakeIdentity(TSS_HCONTEXT, TCPA_ENCAUTH, TCPA_CHOSENID_HASH, UINT32, BYTE *,
283 			    TPM_AUTH *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **, UINT32 *,
284 			    BYTE **, UINT32 *, BYTE **, UINT32 *, BYTE **);
285 TSS_RESULT Transport_MakeIdentity2(TSS_HCONTEXT, TCPA_ENCAUTH, TCPA_CHOSENID_HASH, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
286 TSS_RESULT RPC_ActivateTPMIdentity(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *,
287 					TPM_AUTH *, UINT32 *, BYTE **);
288 TSS_RESULT Transport_ActivateTPMIdentity(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *,
289 					 TPM_AUTH *, UINT32 *, BYTE **);
290 TSS_RESULT RPC_OwnerClear(TSS_HCONTEXT, TPM_AUTH *);
291 TSS_RESULT Transport_OwnerClear(TSS_HCONTEXT, TPM_AUTH *);
292 TSS_RESULT RPC_ForceClear(TSS_HCONTEXT);
293 TSS_RESULT Transport_ForceClear(TSS_HCONTEXT);
294 TSS_RESULT RPC_DisableOwnerClear(TSS_HCONTEXT, TPM_AUTH *);
295 TSS_RESULT Transport_DisableOwnerClear(TSS_HCONTEXT, TPM_AUTH *);
296 TSS_RESULT RPC_DisableForceClear(TSS_HCONTEXT);
297 TSS_RESULT Transport_DisableForceClear(TSS_HCONTEXT);
298 TSS_RESULT RPC_PhysicalDisable(TSS_HCONTEXT);
299 TSS_RESULT Transport_PhysicalDisable(TSS_HCONTEXT);
300 TSS_RESULT RPC_PhysicalEnable(TSS_HCONTEXT);
301 TSS_RESULT Transport_PhysicalEnable(TSS_HCONTEXT);
302 TSS_RESULT RPC_PhysicalSetDeactivated(TSS_HCONTEXT, TSS_BOOL);
303 TSS_RESULT Transport_PhysicalSetDeactivated(TSS_HCONTEXT, TSS_BOOL);
304 TSS_RESULT RPC_PhysicalPresence(TSS_HCONTEXT, TCPA_PHYSICAL_PRESENCE);
305 TSS_RESULT Transport_PhysicalPresence(TSS_HCONTEXT, TCPA_PHYSICAL_PRESENCE);
306 TSS_RESULT RPC_SetTempDeactivated(TSS_HCONTEXT);
307 TSS_RESULT Transport_SetTempDeactivated(TSS_HCONTEXT);
308 TSS_RESULT RPC_SetTempDeactivated2(TSS_HCONTEXT, TPM_AUTH *);
309 TSS_RESULT Transport_SetTempDeactivated2(TSS_HCONTEXT, TPM_AUTH *);
310 TSS_RESULT RPC_OwnerSetDisable(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *);
311 TSS_RESULT Transport_OwnerSetDisable(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *);
312 TSS_RESULT RPC_ResetLockValue(TSS_HCONTEXT, TPM_AUTH *);
313 TSS_RESULT Transport_ResetLockValue(TSS_HCONTEXT, TPM_AUTH *);
314 TSS_RESULT RPC_SetOwnerInstall(TSS_HCONTEXT, TSS_BOOL);
315 TSS_RESULT Transport_SetOwnerInstall(TSS_HCONTEXT, TSS_BOOL);
316 TSS_RESULT RPC_DisablePubekRead(TSS_HCONTEXT, TPM_AUTH *);
317 TSS_RESULT Transport_DisablePubekRead(TSS_HCONTEXT, TPM_AUTH *);
318 TSS_RESULT RPC_SelfTestFull(TSS_HCONTEXT);
319 TSS_RESULT Transport_SelfTestFull(TSS_HCONTEXT);
320 TSS_RESULT RPC_CertifySelfTest(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, TPM_AUTH *, UINT32 *,
321 				BYTE **);
322 TSS_RESULT Transport_CertifySelfTest(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, TPM_AUTH *, UINT32 *,
323 				BYTE **);
324 TSS_RESULT RPC_GetTestResult(TSS_HCONTEXT, UINT32 *, BYTE **);
325 TSS_RESULT Transport_GetTestResult(TSS_HCONTEXT, UINT32 *, BYTE **);
326 TSS_RESULT RPC_StirRandom(TSS_HCONTEXT, UINT32, BYTE *);
327 TSS_RESULT Transport_StirRandom(TSS_HCONTEXT, UINT32, BYTE *);
328 TSS_RESULT RPC_AuthorizeMigrationKey(TSS_HCONTEXT, TCPA_MIGRATE_SCHEME, UINT32, BYTE *,
329 					TPM_AUTH *, UINT32 *, BYTE **);
330 TSS_RESULT Transport_AuthorizeMigrationKey(TSS_HCONTEXT, TCPA_MIGRATE_SCHEME, UINT32, BYTE *,
331 					TPM_AUTH *, UINT32 *, BYTE **);
332 TSS_RESULT RPC_GetPcrEvent(TSS_HCONTEXT, UINT32, UINT32 *, TSS_PCR_EVENT **);
333 TSS_RESULT RPC_GetPcrEventsByPcr(TSS_HCONTEXT, UINT32, UINT32, UINT32 *, TSS_PCR_EVENT **);
334 TSS_RESULT RPC_GetPcrEventLog(TSS_HCONTEXT, UINT32 *, TSS_PCR_EVENT **);
335 TSS_RESULT RPC_Quote(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TPM_AUTH *,
336 			UINT32 *, BYTE **, UINT32 *, BYTE **);
337 TSS_RESULT Transport_Quote(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TPM_AUTH *,
338 			UINT32 *, BYTE **, UINT32 *, BYTE **);
339 TSS_RESULT RPC_Quote2(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TSS_BOOL, TPM_AUTH *,
340 			UINT32 *, BYTE **, UINT32 *, BYTE **, UINT32 *, BYTE **);
341 TSS_RESULT Transport_Quote2(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TSS_BOOL,
342 			     TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **, UINT32 *, BYTE **);
343 TSS_RESULT RPC_Extend(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_DIGEST, TCPA_PCRVALUE *);
344 TSS_RESULT Transport_Extend(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_DIGEST, TCPA_PCRVALUE *);
345 TSS_RESULT RPC_DirWriteAuth(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *, TPM_AUTH *);
346 TSS_RESULT Transport_DirWriteAuth(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *, TPM_AUTH *);
347 TSS_RESULT RPC_DirRead(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *);
348 TSS_RESULT Transport_DirRead(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *);
349 TSS_RESULT RPC_LogPcrEvent(TSS_HCONTEXT, TSS_PCR_EVENT, UINT32 *);
350 TSS_RESULT RPC_EvictKey(TSS_HCONTEXT, TCS_KEY_HANDLE);
351 TSS_RESULT Transport_EvictKey(TSS_HCONTEXT, TCS_KEY_HANDLE);
352 TSS_RESULT RPC_CreateMaintenanceArchive(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
353 TSS_RESULT Transport_CreateMaintenanceArchive(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
354 TSS_RESULT RPC_KillMaintenanceFeature(TSS_HCONTEXT, TPM_AUTH *);
355 TSS_RESULT Transport_KillMaintenanceFeature(TSS_HCONTEXT, TPM_AUTH *);
356 TSS_RESULT RPC_LoadMaintenanceArchive(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
357 TSS_RESULT Transport_LoadMaintenanceArchive(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
358 TSS_RESULT RPC_LoadManuMaintPub(TSS_HCONTEXT, TCPA_NONCE, UINT32, BYTE *, TCPA_DIGEST *);
359 TSS_RESULT Transport_LoadManuMaintPub(TSS_HCONTEXT, TCPA_NONCE, UINT32, BYTE *, TCPA_DIGEST *);
360 TSS_RESULT RPC_ReadManuMaintPub(TSS_HCONTEXT, TCPA_NONCE, TCPA_DIGEST *);
361 TSS_RESULT Transport_ReadManuMaintPub(TSS_HCONTEXT, TCPA_NONCE, TCPA_DIGEST *);
362 TSS_RESULT RPC_DaaJoin(TSS_HCONTEXT,  TPM_HANDLE, BYTE, UINT32, BYTE *, UINT32, BYTE *,
363 			TPM_AUTH *, UINT32 *, BYTE **);
364 TSS_RESULT RPC_DaaSign(TSS_HCONTEXT,  TPM_HANDLE, BYTE, UINT32, BYTE *, UINT32, BYTE *,
365 			TPM_AUTH *, UINT32 *, BYTE **);
366 TSS_RESULT RPC_ReadCounter(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_COUNTER_VALUE *);
367 TSS_RESULT Transport_ReadCounter(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_COUNTER_VALUE *);
368 TSS_RESULT RPC_CreateCounter(TSS_HCONTEXT, UINT32, BYTE *, TPM_ENCAUTH, TPM_AUTH *,
369 			      TSS_COUNTER_ID *, TPM_COUNTER_VALUE *);
370 TSS_RESULT RPC_IncrementCounter(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH *, TPM_COUNTER_VALUE *);
371 TSS_RESULT RPC_ReleaseCounter(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH *);
372 TSS_RESULT RPC_ReleaseCounterOwner(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH *);
373 TSS_RESULT RPC_ReadCurrentTicks(TSS_HCONTEXT, UINT32 *, BYTE **);
374 TSS_RESULT Transport_ReadCurrentTicks(TSS_HCONTEXT, UINT32 *, BYTE **);
375 TSS_RESULT RPC_TickStampBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_NONCE *, TPM_DIGEST *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
376 TSS_RESULT Transport_TickStampBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_NONCE *, TPM_DIGEST *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
377 TSS_RESULT RPC_EstablishTransport(TSS_HCONTEXT, UINT32, TCS_KEY_HANDLE, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, TPM_MODIFIER_INDICATOR *, TCS_HANDLE *, UINT32 *, BYTE **, TPM_NONCE *);
378 TSS_RESULT RPC_ExecuteTransport(TSS_HCONTEXT, TPM_COMMAND_CODE, UINT32, BYTE *, UINT32 *, TCS_HANDLE **, TPM_AUTH *, TPM_AUTH *, TPM_AUTH *, UINT64 *, TPM_MODIFIER_INDICATOR *, TPM_RESULT *, UINT32 *, BYTE **);
379 TSS_RESULT RPC_ReleaseTransportSigned(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_NONCE *, TPM_AUTH *, TPM_AUTH *, TPM_MODIFIER_INDICATOR *, UINT32 *, BYTE **, UINT32 *, BYTE **);
380 TSS_RESULT RPC_NV_DefineOrReleaseSpace(TSS_HCONTEXT, UINT32, BYTE *, TCPA_ENCAUTH, TPM_AUTH *);
381 TSS_RESULT Transport_NV_DefineOrReleaseSpace(TSS_HCONTEXT, UINT32, BYTE *, TCPA_ENCAUTH, TPM_AUTH *);
382 TSS_RESULT RPC_NV_WriteValue(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE *, TPM_AUTH *);
383 TSS_RESULT Transport_NV_WriteValue(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE *, TPM_AUTH *);
384 TSS_RESULT RPC_NV_WriteValueAuth(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE *, TPM_AUTH *);
385 TSS_RESULT Transport_NV_WriteValueAuth(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE *, TPM_AUTH *);
386 TSS_RESULT RPC_NV_ReadValue(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32 *, TPM_AUTH *, BYTE **);
387 TSS_RESULT Transport_NV_ReadValue(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32 *, TPM_AUTH *, BYTE **);
388 TSS_RESULT RPC_NV_ReadValueAuth(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32 *, TPM_AUTH *, BYTE **);
389 TSS_RESULT Transport_NV_ReadValueAuth(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32 *, TPM_AUTH *, BYTE **);
390 TSS_RESULT RPC_SetOrdinalAuditStatus(TSS_HCONTEXT, TPM_AUTH *, UINT32, TSS_BOOL);
391 TSS_RESULT Transport_SetOrdinalAuditStatus(TSS_HCONTEXT, TPM_AUTH *, UINT32, TSS_BOOL);
392 TSS_RESULT RPC_GetAuditDigest(TSS_HCONTEXT, UINT32, TPM_DIGEST *, UINT32 *, BYTE **, TSS_BOOL *, UINT32 *, UINT32 **);
393 TSS_RESULT Transport_GetAuditDigest(TSS_HCONTEXT, UINT32, TPM_DIGEST *, UINT32 *, BYTE **, TSS_BOOL *, UINT32 *, UINT32 **);
394 TSS_RESULT RPC_GetAuditDigestSigned(TSS_HCONTEXT, TCS_KEY_HANDLE, TSS_BOOL, TPM_NONCE *,
395 				    TPM_AUTH *, UINT32 *, BYTE **, TPM_DIGEST *, TPM_DIGEST *,
396 				    UINT32 *, BYTE **);
397 TSS_RESULT Transport_GetAuditDigestSigned(TSS_HCONTEXT, TCS_KEY_HANDLE, TSS_BOOL, TPM_NONCE *,
398 					  TPM_AUTH *, UINT32 *, BYTE **, TPM_DIGEST *, TPM_DIGEST *,
399 					  UINT32 *, BYTE **);
400 TSS_RESULT RPC_SetOperatorAuth(TSS_HCONTEXT, TCPA_SECRET *);
401 TSS_RESULT Transport_SetOperatorAuth(TSS_HCONTEXT, TCPA_SECRET *);
402 TSS_RESULT RPC_OwnerReadInternalPub(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH *, UINT32 *, BYTE **);
403 TSS_RESULT Transport_OwnerReadInternalPub(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH *, UINT32 *, BYTE **);
404 TSS_RESULT RPC_KeyControlOwner(TCS_CONTEXT_HANDLE, TCS_KEY_HANDLE, UINT32, BYTE *, UINT32, TSS_BOOL, TPM_AUTH *, TSS_UUID *);
405 TSS_RESULT RPC_GetCredential(TSS_HCONTEXT, UINT32, UINT32, UINT32 *, BYTE **);
406 TSS_RESULT RPC_GetCapabilitySigned(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, TCPA_CAPABILITY_AREA, UINT32, BYTE *, TPM_AUTH *, TCPA_VERSION *, UINT32 *, BYTE **, UINT32 *, BYTE **);
407 TSS_RESULT RPC_FieldUpgrade(TSS_HCONTEXT, UINT32, BYTE *, UINT32 *, BYTE **, TPM_AUTH *);
408 TSS_RESULT RPC_SetRedirection(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, UINT32, TPM_AUTH *);
409 TSS_RESULT RPC_Delegate_Manage(TSS_HCONTEXT, TPM_FAMILY_ID, TPM_FAMILY_OPERATION, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
410 TSS_RESULT Transport_Delegate_Manage(TSS_HCONTEXT, TPM_FAMILY_ID, TPM_FAMILY_OPERATION, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
411 TSS_RESULT RPC_Delegate_CreateKeyDelegation(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
412 TSS_RESULT Transport_Delegate_CreateKeyDelegation(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
413 TSS_RESULT RPC_Delegate_CreateOwnerDelegation(TSS_HCONTEXT, TSS_BOOL, UINT32, BYTE *, TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
414 TSS_RESULT Transport_Delegate_CreateOwnerDelegation(TSS_HCONTEXT, TSS_BOOL, UINT32, BYTE *, TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
415 TSS_RESULT RPC_Delegate_LoadOwnerDelegation(TSS_HCONTEXT, TPM_DELEGATE_INDEX, UINT32, BYTE *, TPM_AUTH *);
416 TSS_RESULT Transport_Delegate_LoadOwnerDelegation(TSS_HCONTEXT, TPM_DELEGATE_INDEX, UINT32, BYTE *, TPM_AUTH *);
417 TSS_RESULT RPC_Delegate_ReadTable(TSS_HCONTEXT, UINT32 *, BYTE **, UINT32 *, BYTE **);
418 TSS_RESULT Transport_Delegate_ReadTable(TSS_HCONTEXT, UINT32 *, BYTE **, UINT32 *, BYTE **);
419 TSS_RESULT RPC_Delegate_UpdateVerificationCount(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
420 TSS_RESULT Transport_Delegate_UpdateVerificationCount(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
421 TSS_RESULT RPC_Delegate_VerifyDelegation(TSS_HCONTEXT, UINT32, BYTE *);
422 TSS_RESULT Transport_Delegate_VerifyDelegation(TSS_HCONTEXT, UINT32, BYTE *);
423 TSS_RESULT RPC_DSAP(TSS_HCONTEXT, TPM_ENTITY_TYPE, TCS_KEY_HANDLE, TPM_NONCE *, UINT32, BYTE *, TCS_AUTHHANDLE *, TPM_NONCE *, TPM_NONCE *);
424 TSS_RESULT Transport_DSAP(TSS_HCONTEXT, TPM_ENTITY_TYPE, TCS_KEY_HANDLE, TPM_NONCE *, UINT32, BYTE *, TCS_AUTHHANDLE *, TPM_NONCE *, TPM_NONCE *);
425 TSS_RESULT RPC_CMK_SetRestrictions(TSS_HCONTEXT, TSS_CMK_DELEGATE, TPM_AUTH *);
426 TSS_RESULT Transport_CMK_SetRestrictions(TSS_HCONTEXT, TSS_CMK_DELEGATE, TPM_AUTH *);
427 TSS_RESULT RPC_CMK_ApproveMA(TSS_HCONTEXT, TPM_DIGEST, TPM_AUTH *, TPM_HMAC *);
428 TSS_RESULT Transport_CMK_ApproveMA(TSS_HCONTEXT, TPM_DIGEST, TPM_AUTH *, TPM_HMAC *);
429 TSS_RESULT RPC_CMK_CreateKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_ENCAUTH *, TPM_HMAC *, TPM_DIGEST *, UINT32 *, BYTE **, TPM_AUTH *);
430 TSS_RESULT Transport_CMK_CreateKey(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_ENCAUTH, TPM_HMAC, TPM_DIGEST, UINT32 *, BYTE **, TPM_AUTH *);
431 TSS_RESULT RPC_CMK_CreateTicket(TSS_HCONTEXT, UINT32, BYTE *, TPM_DIGEST, UINT32, BYTE *, TPM_AUTH *, TPM_HMAC *);
432 TSS_RESULT Transport_CMK_CreateTicket(TSS_HCONTEXT, UINT32, BYTE *, TPM_DIGEST, UINT32, BYTE *, TPM_AUTH *, TPM_HMAC *);
433 TSS_RESULT RPC_CMK_CreateBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TSS_MIGRATE_SCHEME, UINT32, BYTE *, TPM_DIGEST, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
434 TSS_RESULT Transport_CMK_CreateBlob(TSS_HCONTEXT, TCS_KEY_HANDLE, TSS_MIGRATE_SCHEME, UINT32, BYTE *, TPM_DIGEST, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
435 TSS_RESULT RPC_CMK_ConvertMigration(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_CMK_AUTH, TPM_HMAC, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
436 TSS_RESULT Transport_CMK_ConvertMigration(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_CMK_AUTH, TPM_HMAC, UINT32, BYTE *, UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
437 TSS_RESULT RPC_FlushSpecific(TSS_HCONTEXT, TCS_HANDLE, TPM_RESOURCE_TYPE);
438 TSS_RESULT Transport_FlushSpecific(TSS_HCONTEXT, TCS_HANDLE, TPM_RESOURCE_TYPE);
439 
440 TSS_RESULT RPC_Error(TSS_HCONTEXT, ...);
441 
442 struct tcs_api_table {
443 #ifdef TSS_BUILD_KEY
444 	TSS_RESULT (*LoadKeyByBlob)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *,
445 				    TCS_KEY_HANDLE *, TCS_KEY_HANDLE *);
446 	TSS_RESULT (*EvictKey)(TSS_HCONTEXT, TCS_KEY_HANDLE);
447 	TSS_RESULT (*CreateWrapKey)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, TCPA_ENCAUTH *,
448 				    UINT32, BYTE *, UINT32 *, BYTE **, TPM_AUTH *);
449 	TSS_RESULT (*GetPubKey)(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH *, UINT32 *, BYTE **);
450 	TSS_RESULT (*OwnerReadInternalPub)(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_AUTH*, UINT32*,
451 					   BYTE**);
452 #ifdef TSS_BUILD_CERTIFY
453 	TSS_RESULT (*CertifyKey)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCS_KEY_HANDLE, TPM_NONCE *,
454 				 TPM_AUTH *, TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **);
455 #endif
456 #endif
457 #ifdef TSS_BUILD_OWN
458 	TSS_RESULT (*OwnerClear)(TSS_HCONTEXT, TPM_AUTH *);
459 	TSS_RESULT (*ForceClear)(TSS_HCONTEXT);
460 #endif
461 #ifdef TSS_BUILD_AUTH
462 	TSS_RESULT (*OIAP)(TSS_HCONTEXT, TCS_AUTHHANDLE *, TCPA_NONCE *);
463 	TSS_RESULT (*OSAP)(TSS_HCONTEXT, TCPA_ENTITY_TYPE, UINT32, TPM_NONCE *, TCS_AUTHHANDLE *,
464 			   TCPA_NONCE *, TCPA_NONCE *);
465 	TSS_RESULT (*TerminateHandle)(TSS_HCONTEXT, TCS_AUTHHANDLE);
466 #endif
467 #ifdef TSS_BUILD_CHANGEAUTH
468 	TSS_RESULT (*ChangeAuth)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *,
469 				 TCPA_ENTITY_TYPE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *, UINT32 *,
470 				 BYTE **);
471 	TSS_RESULT (*ChangeAuthOwner)(TSS_HCONTEXT, TCPA_PROTOCOL_ID, TCPA_ENCAUTH *,
472 				      TCPA_ENTITY_TYPE, TPM_AUTH *);
473 	TSS_RESULT (*ChangeAuthAsymStart)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, UINT32, BYTE *,
474 					  TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **,
475 					  UINT32 *, BYTE **, TCS_KEY_HANDLE *);
476 	TSS_RESULT (*ChangeAuthAsymFinish)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCS_KEY_HANDLE,
477 					   TCPA_ENTITY_TYPE, TCPA_HMAC, UINT32, BYTE *, UINT32,
478 					   BYTE *, TPM_AUTH *, UINT32 *, BYTE **, TPM_NONCE *,
479 					   TCPA_DIGEST *);
480 #endif
481 #ifdef TSS_BUILD_AIK
482 	TSS_RESULT (*ActivateTPMIdentity)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *,
483 					  TPM_AUTH *, UINT32 *, BYTE **);
484 #endif
485 #ifdef TSS_BUILD_PCR_EXTEND
486 	TSS_RESULT (*Extend)(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_DIGEST, TCPA_PCRVALUE *);
487 	TSS_RESULT (*PcrRead)(TSS_HCONTEXT, TCPA_PCRINDEX, TCPA_PCRVALUE *);
488 	TSS_RESULT (*PcrReset)(TSS_HCONTEXT, UINT32, BYTE *);
489 #endif
490 #ifdef TSS_BUILD_QUOTE
491 	TSS_RESULT (*Quote)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TPM_AUTH *,
492 			    UINT32 *, BYTE **, UINT32 *, BYTE **);
493 #endif
494 #ifdef TSS_BUILD_QUOTE2
495 	TSS_RESULT (*Quote2)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE *, UINT32, BYTE *, TSS_BOOL,
496 			     TPM_AUTH *, UINT32 *, BYTE **, UINT32 *, BYTE **, UINT32 *, BYTE **);
497 #endif
498 #ifdef TSS_BUILD_DIR
499 	TSS_RESULT (*DirWriteAuth)(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *, TPM_AUTH *);
500 	TSS_RESULT (*DirRead)(TSS_HCONTEXT, TCPA_DIRINDEX, TCPA_DIRVALUE *);
501 #endif
502 #ifdef TSS_BUILD_SEAL
503 	TSS_RESULT (*Seal)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32,
504 			   BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
505 	TSS_RESULT (*Sealx)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_ENCAUTH *, UINT32, BYTE *, UINT32,
506 			    BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
507 	TSS_RESULT (*Unseal)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
508 			     UINT32 *, BYTE **);
509 #endif
510 #ifdef TSS_BUILD_BIND
511 	TSS_RESULT (*UnBind)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *,
512 			     BYTE **);
513 #endif
514 #ifdef TSS_BUILD_MIGRATION
515 	TSS_RESULT (*CreateMigrationBlob)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_MIGRATE_SCHEME,
516 					  UINT32, BYTE *, UINT32, BYTE *, TPM_AUTH *, TPM_AUTH *,
517 					  UINT32 *, BYTE **, UINT32 *, BYTE **);
518 	TSS_RESULT (*ConvertMigrationBlob)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, UINT32,
519 					   BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
520 	TSS_RESULT (*AuthorizeMigrationKey)(TSS_HCONTEXT, TCPA_MIGRATE_SCHEME, UINT32, BYTE *,
521 					    TPM_AUTH *, UINT32 *, BYTE **);
522 #endif
523 #ifdef TSS_BUILD_SIGN
524 	TSS_RESULT (*Sign)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *, TPM_AUTH *, UINT32 *,
525 			   BYTE **);
526 #endif
527 #ifdef TSS_BUILD_RANDOM
528 	TSS_RESULT (*GetRandom)(TSS_HCONTEXT, UINT32, BYTE **);
529 	TSS_RESULT (*StirRandom)(TSS_HCONTEXT, UINT32, BYTE *);
530 #endif
531 #ifdef TSS_BUILD_CAPS_TPM
532 	TSS_RESULT (*GetTPMCapability)(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32 *,
533 				       BYTE **);
534 	TSS_RESULT (*SetCapability)(TSS_HCONTEXT, TCPA_CAPABILITY_AREA, UINT32, BYTE *, UINT32,
535 				    BYTE *, TPM_AUTH *);
536 	TSS_RESULT (*GetCapabilityOwner)(TSS_HCONTEXT, TPM_AUTH *, TCPA_VERSION *, UINT32 *,
537 					 UINT32 *);
538 #endif
539 #ifdef TSS_BUILD_EK
540 	TSS_RESULT (*CreateEndorsementKeyPair)(TSS_HCONTEXT, TCPA_NONCE, UINT32, BYTE *, UINT32 *,
541 					       BYTE **, TCPA_DIGEST *);
542 	TSS_RESULT (*ReadPubek)(TSS_HCONTEXT, TCPA_NONCE, UINT32 *, BYTE **, TCPA_DIGEST *);
543 	TSS_RESULT (*OwnerReadPubek)(TSS_HCONTEXT, TPM_AUTH *, UINT32 *, BYTE **);
544 #endif
545 #ifdef TSS_BUILD_SELFTEST
546 	TSS_RESULT (*SelfTestFull)(TSS_HCONTEXT);
547 	TSS_RESULT (*CertifySelfTest)(TSS_HCONTEXT, TCS_KEY_HANDLE, TCPA_NONCE, TPM_AUTH *,
548 				      UINT32 *, BYTE **);
549 	TSS_RESULT (*GetTestResult)(TSS_HCONTEXT, UINT32 *, BYTE **);
550 #endif
551 #ifdef TSS_BUILD_ADMIN
552 	TSS_RESULT (*DisablePubekRead)(TSS_HCONTEXT, TPM_AUTH *);
553 	TSS_RESULT (*SetOwnerInstall)(TSS_HCONTEXT, TSS_BOOL);
554 	TSS_RESULT (*OwnerSetDisable)(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *);
555 	TSS_RESULT (*ResetLockValue)(TSS_HCONTEXT, TPM_AUTH *);
556 	TSS_RESULT (*DisableOwnerClear)(TSS_HCONTEXT, TPM_AUTH *);
557 	TSS_RESULT (*DisableForceClear)(TSS_HCONTEXT);
558 	TSS_RESULT (*PhysicalDisable)(TSS_HCONTEXT);
559 	TSS_RESULT (*PhysicalEnable)(TSS_HCONTEXT);
560 	TSS_RESULT (*PhysicalSetDeactivated)(TSS_HCONTEXT, TSS_BOOL);
561 	TSS_RESULT (*PhysicalPresence)(TSS_HCONTEXT, TCPA_PHYSICAL_PRESENCE);
562 	TSS_RESULT (*SetTempDeactivated)(TSS_HCONTEXT);
563 	TSS_RESULT (*SetTempDeactivated2)(TSS_HCONTEXT, TPM_AUTH *);
564 #endif
565 #ifdef TSS_BUILD_MAINT
566 	TSS_RESULT (*CreateMaintenanceArchive)(TSS_HCONTEXT, TSS_BOOL, TPM_AUTH *, UINT32 *,
567 					       BYTE **, UINT32 *, BYTE **);
568 	TSS_RESULT (*LoadMaintenanceArchive)(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *, UINT32 *,
569 					     BYTE **);
570 	TSS_RESULT (*KillMaintenanceFeature)(TSS_HCONTEXT, TPM_AUTH *);
571 	TSS_RESULT (*LoadManuMaintPub)(TSS_HCONTEXT, TCPA_NONCE, UINT32, BYTE *, TCPA_DIGEST *);
572 	TSS_RESULT (*ReadManuMaintPub)(TSS_HCONTEXT, TCPA_NONCE, TCPA_DIGEST *);
573 #endif
574 #ifdef TSS_BUILD_DAA
575 	TSS_RESULT (*DaaJoin)(TSS_HCONTEXT, TPM_HANDLE, BYTE, UINT32, BYTE*, UINT32, BYTE*,
576 			      TPM_AUTH*, UINT32*, BYTE**);
577 	TSS_RESULT (*DaaSign)(TSS_HCONTEXT, TPM_HANDLE, BYTE, UINT32, BYTE*, UINT32, BYTE*,
578 			      TPM_AUTH*, UINT32*, BYTE**);
579 #endif
580 #ifdef TSS_BUILD_COUNTER
581 	TSS_RESULT (*ReadCounter)(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_COUNTER_VALUE*);
582 	TSS_RESULT (*CreateCounter)(TSS_HCONTEXT, UINT32, BYTE*, TPM_ENCAUTH, TPM_AUTH*,
583 				    TSS_COUNTER_ID*, TPM_COUNTER_VALUE*);
584 	TSS_RESULT (*IncrementCounter)(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH*, TPM_COUNTER_VALUE*);
585 	TSS_RESULT (*ReleaseCounter)(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH*);
586 	TSS_RESULT (*ReleaseCounterOwner)(TSS_HCONTEXT, TSS_COUNTER_ID, TPM_AUTH*);
587 #endif
588 #ifdef TSS_BUILD_TICK
589 	TSS_RESULT (*ReadCurrentTicks)(TSS_HCONTEXT, UINT32*, BYTE**);
590 	TSS_RESULT (*TickStampBlob)(TSS_HCONTEXT, TCS_KEY_HANDLE, TPM_NONCE*, TPM_DIGEST*,
591 				    TPM_AUTH*, UINT32*, BYTE**,UINT32*, BYTE**);
592 #endif
593 #ifdef TSS_BUILD_NV
594 	TSS_RESULT (*NV_DefineOrReleaseSpace)(TSS_HCONTEXT, UINT32, BYTE*, TCPA_ENCAUTH, TPM_AUTH*);
595 	TSS_RESULT (*NV_WriteValue)(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE*, TPM_AUTH*);
596 	TSS_RESULT (*NV_WriteValueAuth)(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32, BYTE*,
597 					TPM_AUTH*);
598 	TSS_RESULT (*NV_ReadValue)(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32*, TPM_AUTH*, BYTE**);
599 	TSS_RESULT (*NV_ReadValueAuth)(TSS_HCONTEXT, TSS_NV_INDEX, UINT32, UINT32*, TPM_AUTH*,
600 				       BYTE**);
601 #endif
602 #ifdef TSS_BUILD_AUDIT
603 	TSS_RESULT (*SetOrdinalAuditStatus)(TSS_HCONTEXT, TPM_AUTH *, UINT32, TSS_BOOL);
604 	TSS_RESULT (*GetAuditDigest)(TSS_HCONTEXT, UINT32, TPM_DIGEST *, UINT32 *, BYTE **,
605 				     TSS_BOOL *, UINT32 *, UINT32 **);
606 	TSS_RESULT (*GetAuditDigestSigned)(TSS_HCONTEXT, TCS_KEY_HANDLE, TSS_BOOL, TPM_NONCE *,
607 					   TPM_AUTH *, UINT32 *, BYTE **, TPM_DIGEST *,
608 					   TPM_DIGEST *, UINT32 *, BYTE **);
609 #endif
610 #ifdef TSS_BUILD_TSS12
611 	TSS_RESULT (*SetOperatorAuth)(TSS_HCONTEXT, TPM_SECRET *);
612 	TSS_RESULT (*FlushSpecific)(TSS_HCONTEXT, TCS_HANDLE, TPM_RESOURCE_TYPE);
613 #endif
614 #ifdef TSS_BUILD_DELEGATION
615 	TSS_RESULT (*Delegate_Manage)(TSS_HCONTEXT, TPM_FAMILY_ID, TPM_FAMILY_OPERATION, UINT32,
616 				      BYTE *, TPM_AUTH *, UINT32 *, BYTE **);
617 	TSS_RESULT (*Delegate_CreateKeyDelegation)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, BYTE *,
618 						   TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
619 	TSS_RESULT (*Delegate_CreateOwnerDelegation)(TSS_HCONTEXT, TSS_BOOL, UINT32, BYTE *,
620 						     TPM_ENCAUTH *, TPM_AUTH *, UINT32 *, BYTE **);
621 	TSS_RESULT (*Delegate_LoadOwnerDelegation)(TSS_HCONTEXT, TPM_DELEGATE_INDEX, UINT32, BYTE *,
622 						   TPM_AUTH *);
623 	TSS_RESULT (*Delegate_ReadTable)(TSS_HCONTEXT, UINT32 *, BYTE **, UINT32 *, BYTE **);
624 	TSS_RESULT (*Delegate_UpdateVerificationCount)(TSS_HCONTEXT, UINT32, BYTE *, TPM_AUTH *,
625 						       UINT32 *, BYTE **);
626 	TSS_RESULT (*Delegate_VerifyDelegation)(TSS_HCONTEXT, UINT32, BYTE *);
627 	TSS_RESULT (*DSAP)(TSS_HCONTEXT, TPM_ENTITY_TYPE, TCS_KEY_HANDLE, TPM_NONCE *, UINT32,
628 			   BYTE *, TCS_AUTHHANDLE *, TPM_NONCE *, TPM_NONCE *);
629 #endif
630 	TSS_RESULT (*FieldUpgrade)(TSS_HCONTEXT, UINT32, BYTE *, UINT32 *, BYTE **, TPM_AUTH *);
631 	TSS_RESULT (*SetRedirection)(TSS_HCONTEXT, TCS_KEY_HANDLE, UINT32, UINT32, TPM_AUTH *);
632 };
633 
634 extern struct tcs_api_table tcs_normal_api;
635 #ifdef TSS_BUILD_TRANSPORT
636 extern struct tcs_api_table tcs_transport_api;
637 #endif
638 
639 #endif
640