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#include <stdlib.h>
13#include <syslog.h>
14#include <unistd.h>
15
16#include "trousers/tss.h"
17#include "trousers_types.h"
18#include "trousers_types.h"
19#include "spi_utils.h"
20#include "hosttable.h"
21#include "tsplog.h"
22#include "rpc_tcstp_tsp.h"
23#include "obj_context.h"
24
25
26TSS_RESULT
27RPC_Error(TSS_HCONTEXT tspContext, ...)
28{
29	LogDebugFn("Context: 0x%x", tspContext);
30	return TSPERR(TSS_E_INTERNAL_ERROR);
31}
32
33TSS_RESULT
34RPC_OpenContext(TSS_HCONTEXT tspContext, BYTE *hostname, int type)
35{
36	TSS_RESULT result;
37	TCS_CONTEXT_HANDLE tcsContext;
38	struct host_table_entry *entry;
39	UINT32 tpm_version;
40
41	/* __tspi_add_table_entry() will make sure an entry doesn't already exist for this tsp context */
42	if ((result = __tspi_add_table_entry(tspContext, hostname, type, &entry)))
43		return result;
44
45	switch (type) {
46		case CONNECTION_TYPE_TCP_PERSISTANT:
47			if ((result = RPC_OpenContext_TP(entry, &tpm_version, &tcsContext)))
48				remove_table_entry(tspContext);
49			else {
50				entry->tcsContext = tcsContext;
51				if (obj_context_set_tpm_version(tspContext, tpm_version)) {
52					remove_table_entry(tspContext);
53					result = TSPERR(TSS_E_INTERNAL_ERROR);
54				}
55			}
56			return result;
57		default:
58			break;
59	}
60
61	return TSPERR(TSS_E_INTERNAL_ERROR);
62}
63
64TSS_RESULT RPC_GetRegisteredKeyByPublicInfo(TSS_HCONTEXT tspContext,
65					    TCPA_ALGORITHM_ID algID, /* in */
66					    UINT32 ulPublicInfoLength, /* in */
67					    BYTE * rgbPublicInfo, /* in */
68					    UINT32 * keySize, BYTE ** keyBlob)
69{
70	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
71	struct host_table_entry *entry = get_table_entry(tspContext);
72
73	if (entry == NULL)
74		return TSPERR(TSS_E_NO_CONNECTION);
75
76	switch (entry->type) {
77		case CONNECTION_TYPE_TCP_PERSISTANT:
78			result = RPC_GetRegisteredKeyByPublicInfo_TP(entry, algID,
79								     ulPublicInfoLength,
80								     rgbPublicInfo, keySize,
81								     keyBlob);
82			break;
83		default:
84			break;
85	}
86
87	put_table_entry(entry);
88
89	return result;
90}
91
92TSS_RESULT RPC_CloseContext(TSS_HCONTEXT tspContext)	/* in */
93{
94	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
95	struct host_table_entry *entry = get_table_entry(tspContext);
96
97	if (entry == NULL)
98		return TSPERR(TSS_E_NO_CONNECTION);
99
100	switch (entry->type) {
101		case CONNECTION_TYPE_TCP_PERSISTANT:
102			if ((result = RPC_CloseContext_TP(entry)) == TSS_SUCCESS) {
103				close(entry->socket);
104				remove_table_entry(tspContext);
105			}
106			break;
107		default:
108			break;
109	}
110
111	if (result != TSS_SUCCESS)
112		put_table_entry(entry);
113
114	return result;
115}
116
117TSS_RESULT RPC_FreeMemory(TSS_HCONTEXT tspContext,	/* in */
118			  BYTE * pMemory)	/* in */
119{
120	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
121	struct host_table_entry *entry = get_table_entry(tspContext);
122
123	if (entry == NULL)
124		return TSPERR(TSS_E_NO_CONNECTION);
125
126	switch (entry->type) {
127		case CONNECTION_TYPE_TCP_PERSISTANT:
128			result = RPC_FreeMemory_TP(entry, pMemory);
129			break;
130		default:
131			break;
132	}
133
134	put_table_entry(entry);
135
136	return result;
137}
138
139TSS_RESULT RPC_LogPcrEvent(TSS_HCONTEXT tspContext,	/* in */
140			   TSS_PCR_EVENT Event,	/* in */
141			   UINT32 * pNumber)	/* out */
142{
143	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
144	struct host_table_entry *entry = get_table_entry(tspContext);
145
146	if (entry == NULL)
147		return TSPERR(TSS_E_NO_CONNECTION);
148
149	switch (entry->type) {
150		case CONNECTION_TYPE_TCP_PERSISTANT:
151			result = RPC_LogPcrEvent_TP(entry, Event, pNumber);
152			break;
153		default:
154			break;
155	}
156
157	put_table_entry(entry);
158
159	return result;
160}
161
162TSS_RESULT RPC_GetPcrEvent(TSS_HCONTEXT tspContext,	/* in */
163			   UINT32 PcrIndex,	/* in */
164			   UINT32 * pNumber,	/* in, out */
165			   TSS_PCR_EVENT ** ppEvent)	/* out */
166{
167	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
168	struct host_table_entry *entry = get_table_entry(tspContext);
169
170	if (entry == NULL)
171		return TSPERR(TSS_E_NO_CONNECTION);
172
173	switch (entry->type) {
174		case CONNECTION_TYPE_TCP_PERSISTANT:
175		result =
176			RPC_GetPcrEvent_TP(entry, PcrIndex, pNumber, ppEvent);
177			break;
178		default:
179			break;
180	}
181
182	put_table_entry(entry);
183
184	return result;
185}
186
187TSS_RESULT RPC_GetPcrEventsByPcr(TSS_HCONTEXT tspContext,	/* in */
188				 UINT32 PcrIndex,	/* in */
189				 UINT32 FirstEvent,	/* in */
190				 UINT32 * pEventCount,	/* in,out */
191				 TSS_PCR_EVENT ** ppEvents)	/* out */
192{
193	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
194	struct host_table_entry *entry = get_table_entry(tspContext);
195
196	if (entry == NULL)
197		return TSPERR(TSS_E_NO_CONNECTION);
198
199	switch (entry->type) {
200		case CONNECTION_TYPE_TCP_PERSISTANT:
201			result = RPC_GetPcrEventsByPcr_TP(entry, PcrIndex, FirstEvent,
202							  pEventCount, ppEvents);
203			break;
204		default:
205			break;
206	}
207
208	put_table_entry(entry);
209
210	return result;
211}
212
213TSS_RESULT RPC_GetPcrEventLog(TSS_HCONTEXT tspContext,	/* in */
214			      UINT32 * pEventCount,	/* out */
215			      TSS_PCR_EVENT ** ppEvents)	/* out */
216{
217	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
218	struct host_table_entry *entry = get_table_entry(tspContext);
219
220	if (entry == NULL)
221		return TSPERR(TSS_E_NO_CONNECTION);
222
223	switch (entry->type) {
224		case CONNECTION_TYPE_TCP_PERSISTANT:
225			result = RPC_GetPcrEventLog_TP(entry, pEventCount, ppEvents);
226			break;
227		default:
228			break;
229	}
230
231	put_table_entry(entry);
232
233	return result;
234}
235
236TSS_RESULT RPC_RegisterKey(TSS_HCONTEXT tspContext,	/* in */
237			   TSS_UUID WrappingKeyUUID,	/* in */
238			   TSS_UUID KeyUUID,	/* in */
239			   UINT32 cKeySize,	/* in */
240			   BYTE * rgbKey,	/* in */
241			   UINT32 cVendorData,	/* in */
242			   BYTE * gbVendorData)	/* in */
243{
244	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
245	struct host_table_entry *entry = get_table_entry(tspContext);
246
247	if (entry == NULL)
248		return TSPERR(TSS_E_NO_CONNECTION);
249
250	switch (entry->type) {
251		case CONNECTION_TYPE_TCP_PERSISTANT:
252			result = RPC_RegisterKey_TP(entry, WrappingKeyUUID, KeyUUID, cKeySize,
253						    rgbKey, cVendorData, gbVendorData);
254			break;
255		default:
256			break;
257	}
258
259	put_table_entry(entry);
260
261	return result;
262}
263
264TSS_RESULT RPC_UnregisterKey(TSS_HCONTEXT tspContext,	/* in */
265			     TSS_UUID KeyUUID)	/* in */
266{
267	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
268	struct host_table_entry *entry = get_table_entry(tspContext);
269
270	if (entry == NULL)
271		return TSPERR(TSS_E_NO_CONNECTION);
272
273	switch (entry->type) {
274		case CONNECTION_TYPE_TCP_PERSISTANT:
275			result = RPC_UnregisterKey_TP(entry, KeyUUID);
276			break;
277		default:
278			break;
279	}
280
281	put_table_entry(entry);
282
283	return result;
284}
285
286TSS_RESULT RPC_EnumRegisteredKeys(TSS_HCONTEXT tspContext,	/* in */
287				  TSS_UUID * pKeyUUID,	/* in */
288				  UINT32 * pcKeyHierarchySize,	/* out */
289				  TSS_KM_KEYINFO ** ppKeyHierarchy)	/* out */
290{
291	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
292	struct host_table_entry *entry = get_table_entry(tspContext);
293
294	if (entry == NULL)
295		return TSPERR(TSS_E_NO_CONNECTION);
296
297	switch (entry->type) {
298		case CONNECTION_TYPE_TCP_PERSISTANT:
299			result = RPC_EnumRegisteredKeys_TP(entry, pKeyUUID, pcKeyHierarchySize,
300							   ppKeyHierarchy);
301			break;
302		default:
303			break;
304	}
305
306	put_table_entry(entry);
307
308	return result;
309}
310
311TSS_RESULT RPC_EnumRegisteredKeys2(TSS_HCONTEXT tspContext,	/* in */
312				   TSS_UUID * pKeyUUID,	/* in */
313				   UINT32 * pcKeyHierarchySize,	/* out */
314				   TSS_KM_KEYINFO2 ** ppKeyHierarchy)	/* out */
315{
316	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
317	struct host_table_entry *entry = get_table_entry(tspContext);
318
319	if (entry == NULL)
320		return TSPERR(TSS_E_NO_CONNECTION);
321
322	switch (entry->type) {
323		case CONNECTION_TYPE_TCP_PERSISTANT:
324			result = RPC_EnumRegisteredKeys2_TP(entry, pKeyUUID, pcKeyHierarchySize,
325							    ppKeyHierarchy);
326			break;
327		default:
328			break;
329	}
330
331	put_table_entry(entry);
332
333	return result;
334}
335
336
337TSS_RESULT RPC_GetRegisteredKey(TSS_HCONTEXT tspContext,	/* in */
338				TSS_UUID KeyUUID,	/* in */
339				TSS_KM_KEYINFO ** ppKeyInfo)	/* out */
340{
341	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
342	struct host_table_entry *entry = get_table_entry(tspContext);
343
344	if (entry == NULL)
345		return TSPERR(TSS_E_NO_CONNECTION);
346
347	switch (entry->type) {
348		case CONNECTION_TYPE_TCP_PERSISTANT:
349			result = RPC_GetRegisteredKey_TP(entry, KeyUUID, ppKeyInfo);
350			break;
351		default:
352			break;
353	}
354
355	put_table_entry(entry);
356
357	return result;
358}
359
360TSS_RESULT RPC_GetRegisteredKeyBlob(TSS_HCONTEXT tspContext,	/* in */
361				    TSS_UUID KeyUUID,	/* in */
362				    UINT32 * pcKeySize,	/* out */
363				    BYTE ** prgbKey)	/* out */
364{
365	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
366	struct host_table_entry *entry = get_table_entry(tspContext);
367
368	if (entry == NULL)
369		return TSPERR(TSS_E_NO_CONNECTION);
370
371	switch (entry->type) {
372		case CONNECTION_TYPE_TCP_PERSISTANT:
373			result = RPC_GetRegisteredKeyBlob_TP(entry, KeyUUID, pcKeySize, prgbKey);
374			break;
375		default:
376			break;
377	}
378
379	put_table_entry(entry);
380
381	return result;
382}
383
384TSS_RESULT RPC_LoadKeyByBlob(TSS_HCONTEXT tspContext,	/* in */
385			     TCS_KEY_HANDLE hUnwrappingKey,	/* in */
386			     UINT32 cWrappedKeyBlobSize,	/* in */
387			     BYTE * rgbWrappedKeyBlob,	/* in */
388			     TPM_AUTH * pAuth,	/* in, out */
389			     TCS_KEY_HANDLE * phKeyTCSI,	/* out */
390			     TCS_KEY_HANDLE * phKeyHMAC)	/* out */
391{
392	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
393	struct host_table_entry *entry = get_table_entry(tspContext);
394
395	if (entry == NULL)
396		return TSPERR(TSS_E_NO_CONNECTION);
397
398	switch (entry->type) {
399		case CONNECTION_TYPE_TCP_PERSISTANT:
400			result = RPC_LoadKeyByBlob_TP(entry, hUnwrappingKey, cWrappedKeyBlobSize,
401						      rgbWrappedKeyBlob, pAuth, phKeyTCSI,
402						      phKeyHMAC);
403			break;
404		default:
405			break;
406	}
407
408	put_table_entry(entry);
409
410	return result;
411}
412
413TSS_RESULT RPC_LoadKeyByUUID(TSS_HCONTEXT tspContext,	/* in */
414			     TSS_UUID KeyUUID,	/* in */
415			     TCS_LOADKEY_INFO * pLoadKeyInfo,	/* in, out */
416			     TCS_KEY_HANDLE * phKeyTCSI)	/* out */
417{
418	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
419	struct host_table_entry *entry = get_table_entry(tspContext);
420
421	if (entry == NULL)
422		return TSPERR(TSS_E_NO_CONNECTION);
423
424	switch (entry->type) {
425		case CONNECTION_TYPE_TCP_PERSISTANT:
426			result = RPC_LoadKeyByUUID_TP(entry, KeyUUID, pLoadKeyInfo, phKeyTCSI);
427			break;
428		default:
429			break;
430	}
431
432	put_table_entry(entry);
433
434	return result;
435}
436
437TSS_RESULT RPC_EvictKey(TSS_HCONTEXT tspContext,	/* in */
438			TCS_KEY_HANDLE hKey)	/* in */
439{
440	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
441	struct host_table_entry *entry = get_table_entry(tspContext);
442
443	if (entry == NULL)
444		return TSPERR(TSS_E_NO_CONNECTION);
445
446	switch (entry->type) {
447		case CONNECTION_TYPE_TCP_PERSISTANT:
448			result = RPC_EvictKey_TP(entry, hKey);
449			break;
450		default:
451			break;
452	}
453
454	put_table_entry(entry);
455
456	return result;
457}
458
459TSS_RESULT RPC_CreateWrapKey(TSS_HCONTEXT tspContext,	/* in */
460			     TCS_KEY_HANDLE hWrappingKey,	/* in */
461			     TCPA_ENCAUTH *KeyUsageAuth,	/* in */
462			     TCPA_ENCAUTH *KeyMigrationAuth,	/* in */
463			     UINT32 keyInfoSize,	/* in */
464			     BYTE * keyInfo,	/* in */
465			     UINT32 * keyDataSize,	/* out */
466			     BYTE ** keyData,	/* out */
467			     TPM_AUTH * pAuth)	/* in, out */
468{
469	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
470	struct host_table_entry *entry = get_table_entry(tspContext);
471
472	if (entry == NULL)
473		return TSPERR(TSS_E_NO_CONNECTION);
474
475	switch (entry->type) {
476		case CONNECTION_TYPE_TCP_PERSISTANT:
477			result = RPC_CreateWrapKey_TP(entry, hWrappingKey, KeyUsageAuth,
478						      KeyMigrationAuth, keyInfoSize, keyInfo,
479						      keyDataSize, keyData, pAuth);
480			break;
481		default:
482			break;
483	}
484
485	put_table_entry(entry);
486
487	return result;
488}
489
490TSS_RESULT RPC_GetPubKey(TSS_HCONTEXT tspContext,	/* in */
491			 TCS_KEY_HANDLE hKey,	/* in */
492			 TPM_AUTH * pAuth,	/* in, out */
493			 UINT32 * pcPubKeySize,	/* out */
494			 BYTE ** prgbPubKey)	/* out */
495{
496	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
497	struct host_table_entry *entry = get_table_entry(tspContext);
498
499	if (entry == NULL)
500		return TSPERR(TSS_E_NO_CONNECTION);
501
502	switch (entry->type) {
503		case CONNECTION_TYPE_TCP_PERSISTANT:
504			result = RPC_GetPubKey_TP(entry, hKey, pAuth, pcPubKeySize, prgbPubKey);
505			break;
506		default:
507			break;
508	}
509
510	put_table_entry(entry);
511
512	return result;
513}
514
515TSS_RESULT RPC_MakeIdentity(TSS_HCONTEXT tspContext,	/* in */
516			    TCPA_ENCAUTH identityAuth,	/* in */
517			    TCPA_CHOSENID_HASH IDLabel_PrivCAHash,	/* in */
518			    UINT32 idKeyInfoSize,	/* in */
519			    BYTE * idKeyInfo,	/* in */
520			    TPM_AUTH * pSrkAuth,	/* in, out */
521			    TPM_AUTH * pOwnerAuth,	/* in, out */
522			    UINT32 * idKeySize,	/* out */
523			    BYTE ** idKey,	/* out */
524			    UINT32 * pcIdentityBindingSize,	/* out */
525			    BYTE ** prgbIdentityBinding,	/* out */
526			    UINT32 * pcEndorsementCredentialSize,	/* out */
527			    BYTE ** prgbEndorsementCredential,	/* out */
528			    UINT32 * pcPlatformCredentialSize,	/* out */
529			    BYTE ** prgbPlatformCredential,	/* out */
530			    UINT32 * pcConformanceCredentialSize,	/* out */
531			    BYTE ** prgbConformanceCredential)	/* out */
532{
533	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
534	struct host_table_entry *entry = get_table_entry(tspContext);
535
536	if (entry == NULL)
537		return TSPERR(TSS_E_NO_CONNECTION);
538
539	switch (entry->type) {
540		case CONNECTION_TYPE_TCP_PERSISTANT:
541			result = RPC_MakeIdentity_TP(entry, identityAuth,
542						     IDLabel_PrivCAHash, idKeyInfoSize, idKeyInfo,
543						     pSrkAuth, pOwnerAuth, idKeySize, idKey,
544						     pcIdentityBindingSize, prgbIdentityBinding,
545						     pcEndorsementCredentialSize,
546						     prgbEndorsementCredential,
547						     pcPlatformCredentialSize,
548						     prgbPlatformCredential,
549						     pcConformanceCredentialSize,
550						     prgbConformanceCredential);
551			break;
552		default:
553			break;
554	}
555
556	put_table_entry(entry);
557
558	return result;
559}
560
561#ifdef TSS_BUILD_TSS12
562TSS_RESULT RPC_GetCredential(TSS_HCONTEXT tspContext,	/* in */
563			     UINT32 ulCredentialType,          /* in */
564			     UINT32 ulCredentialAccessMode,    /* in */
565			     UINT32 * pulCredentialSize,       /* out */
566			     BYTE ** prgbCredentialData)	/* out */
567{
568	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
569	struct host_table_entry *entry = get_table_entry(tspContext);
570
571	if (entry == NULL)
572		return TSPERR(TSS_E_NO_CONNECTION);
573
574	switch (entry->type) {
575		case CONNECTION_TYPE_TCP_PERSISTANT:
576			result = RPC_GetCredential_TP(entry, ulCredentialType,
577						      ulCredentialAccessMode, pulCredentialSize,
578						      prgbCredentialData);
579			break;
580		default:
581			break;
582	}
583
584	put_table_entry(entry);
585
586	return result;
587}
588#endif
589
590TSS_RESULT RPC_SetOwnerInstall(TSS_HCONTEXT tspContext,	/* in */
591			       TSS_BOOL state)	/* in */
592{
593	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
594	struct host_table_entry *entry = get_table_entry(tspContext);
595
596	if (entry == NULL)
597		return TSPERR(TSS_E_NO_CONNECTION);
598
599	switch (entry->type) {
600		case CONNECTION_TYPE_TCP_PERSISTANT:
601			result = RPC_SetOwnerInstall_TP(entry, state);
602			break;
603		default:
604			break;
605	}
606
607	put_table_entry(entry);
608
609	return result;
610}
611
612TSS_RESULT RPC_TakeOwnership(TSS_HCONTEXT tspContext,	/* in */
613			     UINT16 protocolID,	/* in */
614			     UINT32 encOwnerAuthSize,	/* in */
615			     BYTE * encOwnerAuth,	/* in */
616			     UINT32 encSrkAuthSize,	/* in */
617			     BYTE * encSrkAuth,	/* in */
618			     UINT32 srkInfoSize,	/* in */
619			     BYTE * srkInfo,	/* in */
620			     TPM_AUTH * ownerAuth,	/* in, out */
621			     UINT32 * srkKeySize,
622			     BYTE ** srkKey)
623{
624	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
625	struct host_table_entry *entry = get_table_entry(tspContext);
626
627	if (entry == NULL)
628		return TSPERR(TSS_E_NO_CONNECTION);
629
630	switch (entry->type) {
631		case CONNECTION_TYPE_TCP_PERSISTANT:
632			result = RPC_TakeOwnership_TP(entry, protocolID,
633						      encOwnerAuthSize, encOwnerAuth,
634						      encSrkAuthSize, encSrkAuth, srkInfoSize,
635						      srkInfo, ownerAuth, srkKeySize, srkKey);
636			break;
637		default:
638			break;
639	}
640
641	put_table_entry(entry);
642
643	return result;
644}
645
646TSS_RESULT RPC_OIAP(TSS_HCONTEXT tspContext,	/* in */
647		    TCS_AUTHHANDLE * authHandle,	/* out */
648		    TCPA_NONCE * nonce0)	/* out */
649{
650	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
651	struct host_table_entry *entry = get_table_entry(tspContext);
652
653	if (entry == NULL)
654		return TSPERR(TSS_E_NO_CONNECTION);
655
656	switch (entry->type) {
657		case CONNECTION_TYPE_TCP_PERSISTANT:
658			result = RPC_OIAP_TP(entry, authHandle, nonce0);
659			break;
660		default:
661			break;
662	}
663
664	put_table_entry(entry);
665
666	return result;
667}
668
669TSS_RESULT RPC_OSAP(TSS_HCONTEXT tspContext,	/* in */
670		    TCPA_ENTITY_TYPE entityType,	/* in */
671		    UINT32 entityValue,	/* in */
672		    TPM_NONCE *nonceOddOSAP,	/* in */
673		    TCS_AUTHHANDLE * authHandle,	/* out */
674		    TCPA_NONCE * nonceEven,	/* out */
675		    TCPA_NONCE * nonceEvenOSAP)	/* out */
676{
677	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
678	struct host_table_entry *entry = get_table_entry(tspContext);
679
680	if (entry == NULL)
681		return TSPERR(TSS_E_NO_CONNECTION);
682
683	switch (entry->type) {
684		case CONNECTION_TYPE_TCP_PERSISTANT:
685			result = RPC_OSAP_TP(entry, entityType, entityValue, nonceOddOSAP,
686					     authHandle, nonceEven, nonceEvenOSAP);
687			break;
688		default:
689			break;
690	}
691
692	put_table_entry(entry);
693
694	return result;
695}
696
697TSS_RESULT RPC_ChangeAuth(TSS_HCONTEXT tspContext,	/* in */
698			  TCS_KEY_HANDLE parentHandle,	/* in */
699			  TCPA_PROTOCOL_ID protocolID,	/* in */
700			  TCPA_ENCAUTH *newAuth,	/* in */
701			  TCPA_ENTITY_TYPE entityType,	/* in */
702			  UINT32 encDataSize,	/* in */
703			  BYTE * encData,	/* in */
704			  TPM_AUTH * ownerAuth,	/* in, out */
705			  TPM_AUTH * entityAuth,	/* in, out */
706			  UINT32 * outDataSize,	/* out */
707			  BYTE ** outData)	/* out */
708{
709	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
710	struct host_table_entry *entry = get_table_entry(tspContext);
711
712	if (entry == NULL)
713		return TSPERR(TSS_E_NO_CONNECTION);
714
715	switch (entry->type) {
716		case CONNECTION_TYPE_TCP_PERSISTANT:
717			result = RPC_ChangeAuth_TP(entry, parentHandle, protocolID, newAuth,
718						   entityType, encDataSize, encData, ownerAuth,
719						   entityAuth, outDataSize, outData);
720			break;
721		default:
722			break;
723	}
724
725	put_table_entry(entry);
726
727	return result;
728}
729
730TSS_RESULT RPC_ChangeAuthOwner(TSS_HCONTEXT tspContext,	/* in */
731				TCPA_PROTOCOL_ID protocolID,	/* in */
732				TCPA_ENCAUTH *newAuth,	/* in */
733				TCPA_ENTITY_TYPE entityType,	/* in */
734				TPM_AUTH * ownerAuth)	/* in, out */
735{
736	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
737	struct host_table_entry *entry = get_table_entry(tspContext);
738
739	if (entry == NULL)
740		return TSPERR(TSS_E_NO_CONNECTION);
741
742	switch (entry->type) {
743		case CONNECTION_TYPE_TCP_PERSISTANT:
744			result = RPC_ChangeAuthOwner_TP(entry, protocolID, newAuth, entityType,
745							ownerAuth);
746			break;
747		default:
748			break;
749	}
750
751	put_table_entry(entry);
752
753	return result;
754}
755
756TSS_RESULT RPC_ChangeAuthAsymStart(TSS_HCONTEXT tspContext,	/* in */
757				   TCS_KEY_HANDLE idHandle,	/* in */
758				   TCPA_NONCE antiReplay,	/* in */
759				   UINT32 KeySizeIn,	/* in */
760				   BYTE * KeyDataIn,	/* in */
761				   TPM_AUTH * pAuth,	/* in, out */
762				   UINT32 * KeySizeOut,	/* out */
763				   BYTE ** KeyDataOut,	/* out */
764				   UINT32 * CertifyInfoSize,	/* out */
765				   BYTE ** CertifyInfo,	/* out */
766				   UINT32 * sigSize,	/* out */
767				   BYTE ** sig,	/* out */
768				   TCS_KEY_HANDLE * ephHandle)	/* out */
769{
770	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
771	struct host_table_entry *entry = get_table_entry(tspContext);
772
773	if (entry == NULL)
774		return TSPERR(TSS_E_NO_CONNECTION);
775
776	switch (entry->type) {
777		case CONNECTION_TYPE_TCP_PERSISTANT:
778			result = RPC_ChangeAuthAsymStart_TP(entry, idHandle, antiReplay,
779							    KeySizeIn, KeyDataIn, pAuth,
780							    KeySizeOut, KeyDataOut,
781							    CertifyInfoSize, CertifyInfo, sigSize,
782							    sig, ephHandle);
783			break;
784		default:
785			break;
786	}
787
788	put_table_entry(entry);
789
790	return result;
791}
792
793TSS_RESULT RPC_ChangeAuthAsymFinish(TSS_HCONTEXT tspContext,	/* in */
794				    TCS_KEY_HANDLE parentHandle,	/* in */
795				    TCS_KEY_HANDLE ephHandle,	/* in */
796				    TCPA_ENTITY_TYPE entityType,	/* in */
797				    TCPA_HMAC newAuthLink,	/* in */
798				    UINT32 newAuthSize,	/* in */
799				    BYTE * encNewAuth,	/* in */
800				    UINT32 encDataSizeIn,	/* in */
801				    BYTE * encDataIn,	/* in */
802				    TPM_AUTH * ownerAuth,	/* in, out */
803				    UINT32 * encDataSizeOut,	/* out */
804				    BYTE ** encDataOut,	/* out */
805				    TCPA_SALT_NONCE * saltNonce,	/* out */
806				    TCPA_DIGEST * changeProof)	/* out */
807{
808	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
809	struct host_table_entry *entry = get_table_entry(tspContext);
810
811	if (entry == NULL)
812		return TSPERR(TSS_E_NO_CONNECTION);
813
814	switch (entry->type) {
815		case CONNECTION_TYPE_TCP_PERSISTANT:
816			result = RPC_ChangeAuthAsymFinish_TP(entry, parentHandle, ephHandle,
817							     entityType, newAuthLink,
818							     newAuthSize, encNewAuth,
819							     encDataSizeIn, encDataIn, ownerAuth,
820							     encDataSizeOut, encDataOut, saltNonce,
821							     changeProof);
822			break;
823		default:
824			break;
825	}
826
827	put_table_entry(entry);
828
829	return result;
830}
831
832TSS_RESULT RPC_TerminateHandle(TSS_HCONTEXT tspContext,	/* in */
833			       TCS_AUTHHANDLE handle)	/* in */
834{
835	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
836	struct host_table_entry *entry = get_table_entry(tspContext);
837
838	if (entry == NULL)
839		return TSPERR(TSS_E_NO_CONNECTION);
840
841	switch (entry->type) {
842		case CONNECTION_TYPE_TCP_PERSISTANT:
843			result = RPC_TerminateHandle_TP(entry, handle);
844			break;
845		default:
846			break;
847	}
848
849	put_table_entry(entry);
850
851	return result;
852}
853
854TSS_RESULT RPC_ActivateTPMIdentity(TSS_HCONTEXT tspContext,	/* in */
855				   TCS_KEY_HANDLE idKey,	/* in */
856				   UINT32 blobSize,	/* in */
857				   BYTE * blob,	/* in */
858				   TPM_AUTH * idKeyAuth,	/* in, out */
859				   TPM_AUTH * ownerAuth,	/* in, out */
860				   UINT32 * SymmetricKeySize,	/* out */
861				   BYTE ** SymmetricKey)	/* out */
862{
863	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
864	struct host_table_entry *entry = get_table_entry(tspContext);
865
866	if (entry == NULL)
867		return TSPERR(TSS_E_NO_CONNECTION);
868
869	switch (entry->type) {
870		case CONNECTION_TYPE_TCP_PERSISTANT:
871			result = RPC_ActivateTPMIdentity_TP(entry, idKey, blobSize, blob, idKeyAuth,
872							    ownerAuth, SymmetricKeySize,
873							    SymmetricKey);
874			break;
875		default:
876			break;
877	}
878
879	put_table_entry(entry);
880
881	return result;
882}
883
884TSS_RESULT RPC_Extend(TSS_HCONTEXT tspContext,	/* in */
885		      TCPA_PCRINDEX pcrNum,	/* in */
886		      TCPA_DIGEST inDigest,	/* in */
887		      TCPA_PCRVALUE * outDigest)	/* out */
888{
889	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
890	struct host_table_entry *entry = get_table_entry(tspContext);
891
892	if (entry == NULL)
893		return TSPERR(TSS_E_NO_CONNECTION);
894
895	switch (entry->type) {
896		case CONNECTION_TYPE_TCP_PERSISTANT:
897			result = RPC_Extend_TP(entry, pcrNum, inDigest, outDigest);
898			break;
899		default:
900			break;
901	}
902
903	put_table_entry(entry);
904
905	return result;
906}
907
908TSS_RESULT RPC_PcrRead(TSS_HCONTEXT tspContext,	/* in */
909		       TCPA_PCRINDEX pcrNum,	/* in */
910		       TCPA_PCRVALUE * outDigest)	/* out */
911{
912	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
913	struct host_table_entry *entry = get_table_entry(tspContext);
914
915	if (entry == NULL)
916		return TSPERR(TSS_E_NO_CONNECTION);
917
918	switch (entry->type) {
919		case CONNECTION_TYPE_TCP_PERSISTANT:
920			result = RPC_PcrRead_TP(entry, pcrNum, outDigest);
921			break;
922		default:
923			break;
924	}
925
926	put_table_entry(entry);
927
928	return result;
929}
930
931TSS_RESULT RPC_PcrReset(TSS_HCONTEXT tspContext,	/* in */
932			UINT32 pcrDataSizeIn,		/* in */
933			BYTE * pcrDataIn)		/* in */
934{
935	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
936	struct host_table_entry *entry = get_table_entry(tspContext);
937
938	if (entry == NULL)
939		return TSPERR(TSS_E_NO_CONNECTION);
940
941	switch (entry->type) {
942		case CONNECTION_TYPE_TCP_PERSISTANT:
943			result = RPC_PcrReset_TP(entry, pcrDataSizeIn, pcrDataIn);
944			break;
945		default:
946			break;
947	}
948
949	put_table_entry(entry);
950
951	return result;
952}
953
954
955TSS_RESULT RPC_Quote(TSS_HCONTEXT tspContext,	/* in */
956		     TCS_KEY_HANDLE keyHandle,	/* in */
957		     TCPA_NONCE *antiReplay,	/* in */
958		     UINT32 pcrDataSizeIn,	/* in */
959		     BYTE * pcrDataIn,	/* in */
960		     TPM_AUTH * privAuth,	/* in, out */
961		     UINT32 * pcrDataSizeOut,	/* out */
962		     BYTE ** pcrDataOut,	/* out */
963		     UINT32 * sigSize,	/* out */
964		     BYTE ** sig)	/* out */
965{
966	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
967	struct host_table_entry *entry = get_table_entry(tspContext);
968
969	if (entry == NULL)
970		return TSPERR(TSS_E_NO_CONNECTION);
971
972	switch (entry->type) {
973		case CONNECTION_TYPE_TCP_PERSISTANT:
974			result = RPC_Quote_TP(entry, keyHandle, antiReplay, pcrDataSizeIn,
975					      pcrDataIn, privAuth, pcrDataSizeOut, pcrDataOut,
976					      sigSize, sig);
977			break;
978		default:
979			break;
980	}
981
982	put_table_entry(entry);
983
984	return result;
985}
986
987#ifdef TSS_BUILD_TSS12
988TSS_RESULT RPC_Quote2(TSS_HCONTEXT tspContext, /* in */
989		      TCS_KEY_HANDLE keyHandle, /* in */
990		      TCPA_NONCE *antiReplay, /* in */
991		      UINT32 pcrDataSizeIn, /* in */
992		      BYTE * pcrDataIn, /* in */
993		      TSS_BOOL addVersion, /* in */
994		      TPM_AUTH * privAuth, /* in,out */
995		      UINT32 * pcrDataSizeOut, /* out */
996		      BYTE ** pcrDataOut, /* out */
997		      UINT32 * versionInfoSize, /* out */
998		      BYTE ** versionInfo, /* out */
999		      UINT32 * sigSize, /* out */
1000		      BYTE ** sig) /* out */
1001{
1002	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1003	struct host_table_entry *entry = get_table_entry(tspContext);
1004
1005	if (entry == NULL)
1006		return TSPERR(TSS_E_NO_CONNECTION);
1007
1008	switch (entry->type) {
1009	case CONNECTION_TYPE_TCP_PERSISTANT:
1010		result = RPC_Quote2_TP(entry, keyHandle, antiReplay, pcrDataSizeIn, pcrDataIn,
1011				       addVersion,privAuth, pcrDataSizeOut, pcrDataOut,
1012				       versionInfoSize, versionInfo,sigSize, sig);
1013		break;
1014	default:
1015		break;
1016	}
1017
1018	put_table_entry(entry);
1019
1020	return result;
1021}
1022#endif
1023
1024TSS_RESULT RPC_DirWriteAuth(TSS_HCONTEXT tspContext,	/* in */
1025			    TCPA_DIRINDEX dirIndex,	/* in */
1026			    TCPA_DIRVALUE *newContents,	/* in */
1027			    TPM_AUTH * ownerAuth)	/* in, out */
1028{
1029	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1030	struct host_table_entry *entry = get_table_entry(tspContext);
1031
1032	if (entry == NULL)
1033		return TSPERR(TSS_E_NO_CONNECTION);
1034
1035	switch (entry->type) {
1036		case CONNECTION_TYPE_TCP_PERSISTANT:
1037			result = RPC_DirWriteAuth_TP(entry, dirIndex, newContents, ownerAuth);
1038			break;
1039		default:
1040			break;
1041	}
1042
1043	put_table_entry(entry);
1044
1045	return result;
1046}
1047
1048TSS_RESULT RPC_DirRead(TSS_HCONTEXT tspContext,	/* in */
1049		       TCPA_DIRINDEX dirIndex,	/* in */
1050		       TCPA_DIRVALUE * dirValue)	/* out */
1051{
1052	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1053	struct host_table_entry *entry = get_table_entry(tspContext);
1054
1055	if (entry == NULL)
1056		return TSPERR(TSS_E_NO_CONNECTION);
1057
1058	switch (entry->type) {
1059		case CONNECTION_TYPE_TCP_PERSISTANT:
1060			result = RPC_DirRead_TP(entry, dirIndex, dirValue);
1061			break;
1062		default:
1063			break;
1064	}
1065
1066	put_table_entry(entry);
1067
1068	return result;
1069}
1070
1071TSS_RESULT RPC_Seal(TSS_HCONTEXT tspContext,	/* in */
1072		    TCS_KEY_HANDLE keyHandle,	/* in */
1073		    TCPA_ENCAUTH *encAuth,	/* in */
1074		    UINT32 pcrInfoSize,	/* in */
1075		    BYTE * PcrInfo,	/* in */
1076		    UINT32 inDataSize,	/* in */
1077		    BYTE * inData,	/* in */
1078		    TPM_AUTH * pubAuth,	/* in, out */
1079		    UINT32 * SealedDataSize,	/* out */
1080		    BYTE ** SealedData)	/* out */
1081{
1082	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1083	struct host_table_entry *entry = get_table_entry(tspContext);
1084
1085	if (entry == NULL)
1086		return TSPERR(TSS_E_NO_CONNECTION);
1087
1088	switch (entry->type) {
1089		case CONNECTION_TYPE_TCP_PERSISTANT:
1090			result = RPC_Seal_TP(entry, keyHandle, encAuth, pcrInfoSize, PcrInfo,
1091					     inDataSize, inData, pubAuth, SealedDataSize,
1092					     SealedData);
1093			break;
1094		default:
1095			break;
1096	}
1097
1098	put_table_entry(entry);
1099
1100	return result;
1101}
1102
1103#ifdef TSS_BUILD_SEALX
1104TSS_RESULT RPC_Sealx(TSS_HCONTEXT tspContext,	/* in */
1105		     TCS_KEY_HANDLE keyHandle,	/* in */
1106		     TCPA_ENCAUTH *encAuth,	/* in */
1107		     UINT32 pcrInfoSize,	/* in */
1108		     BYTE * PcrInfo,	/* in */
1109		     UINT32 inDataSize,	/* in */
1110		     BYTE * inData,	/* in */
1111		     TPM_AUTH * pubAuth,	/* in, out */
1112		     UINT32 * SealedDataSize,	/* out */
1113		     BYTE ** SealedData)	/* out */
1114{
1115	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1116	struct host_table_entry *entry = get_table_entry(tspContext);
1117
1118	if (entry == NULL)
1119		return TSPERR(TSS_E_NO_CONNECTION);
1120
1121	switch (entry->type) {
1122		case CONNECTION_TYPE_TCP_PERSISTANT:
1123			result = RPC_Sealx_TP(entry, keyHandle, encAuth, pcrInfoSize, PcrInfo,
1124					      inDataSize, inData, pubAuth, SealedDataSize,
1125					      SealedData);
1126			break;
1127		default:
1128			break;
1129	}
1130
1131	put_table_entry(entry);
1132
1133	return result;
1134}
1135#endif
1136
1137TSS_RESULT RPC_Unseal(TSS_HCONTEXT tspContext,	/* in */
1138		      TCS_KEY_HANDLE parentHandle,	/* in */
1139		      UINT32 SealedDataSize,	/* in */
1140		      BYTE * SealedData,	/* in */
1141		      TPM_AUTH * parentAuth,	/* in, out */
1142		      TPM_AUTH * dataAuth,	/* in, out */
1143		      UINT32 * DataSize,	/* out */
1144		      BYTE ** Data)	/* out */
1145{
1146	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1147	struct host_table_entry *entry = get_table_entry(tspContext);
1148
1149	if (entry == NULL)
1150		return TSPERR(TSS_E_NO_CONNECTION);
1151
1152	switch (entry->type) {
1153		case CONNECTION_TYPE_TCP_PERSISTANT:
1154			result = RPC_Unseal_TP(entry, parentHandle, SealedDataSize, SealedData,
1155					       parentAuth, dataAuth, DataSize, Data);
1156			break;
1157		default:
1158			break;
1159	}
1160
1161	put_table_entry(entry);
1162
1163	return result;
1164}
1165
1166TSS_RESULT RPC_UnBind(TSS_HCONTEXT tspContext,	/* in */
1167		       TCS_KEY_HANDLE keyHandle,	/* in */
1168		       UINT32 inDataSize,	/* in */
1169		       BYTE * inData,	/* in */
1170		       TPM_AUTH * privAuth,	/* in, out */
1171		       UINT32 * outDataSize,	/* out */
1172		       BYTE ** outData)	/* out */
1173{
1174	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1175	struct host_table_entry *entry = get_table_entry(tspContext);
1176
1177	if (entry == NULL)
1178		return TSPERR(TSS_E_NO_CONNECTION);
1179
1180	switch (entry->type) {
1181		case CONNECTION_TYPE_TCP_PERSISTANT:
1182			result = RPC_UnBind_TP(entry, keyHandle, inDataSize, inData, privAuth,
1183					       outDataSize, outData);
1184			break;
1185		default:
1186			break;
1187	}
1188
1189	put_table_entry(entry);
1190
1191	return result;
1192}
1193
1194TSS_RESULT RPC_CreateMigrationBlob(TSS_HCONTEXT tspContext,	/* in */
1195				   TCS_KEY_HANDLE parentHandle,	/* in */
1196				   TCPA_MIGRATE_SCHEME migrationType,	/* in */
1197				   UINT32 MigrationKeyAuthSize,	/* in */
1198				   BYTE * MigrationKeyAuth,	/* in */
1199				   UINT32 encDataSize,	/* in */
1200				   BYTE * encData,	/* in */
1201				   TPM_AUTH * parentAuth,	/* in, out */
1202				   TPM_AUTH * entityAuth,	/* in, out */
1203				   UINT32 * randomSize,	/* out */
1204				   BYTE ** random,	/* out */
1205				   UINT32 * outDataSize,	/* out */
1206				   BYTE ** outData)	/* out */
1207{
1208	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1209	struct host_table_entry *entry = get_table_entry(tspContext);
1210
1211	if (entry == NULL)
1212		return TSPERR(TSS_E_NO_CONNECTION);
1213
1214	switch (entry->type) {
1215		case CONNECTION_TYPE_TCP_PERSISTANT:
1216			result = RPC_CreateMigrationBlob_TP(entry, parentHandle,
1217							    migrationType, MigrationKeyAuthSize,
1218							    MigrationKeyAuth, encDataSize, encData,
1219							    parentAuth, entityAuth, randomSize,
1220							    random, outDataSize, outData);
1221			break;
1222		default:
1223			break;
1224	}
1225
1226	put_table_entry(entry);
1227
1228	return result;
1229}
1230
1231TSS_RESULT RPC_ConvertMigrationBlob(TSS_HCONTEXT tspContext,	/* in */
1232				    TCS_KEY_HANDLE parentHandle,	/* in */
1233				    UINT32 inDataSize,	/* in */
1234				    BYTE * inData,	/* in */
1235				    UINT32 randomSize,	/* in */
1236				    BYTE * random,	/* in */
1237				    TPM_AUTH * parentAuth,	/* in, out */
1238				    UINT32 * outDataSize,	/* out */
1239				    BYTE ** outData)	/* out */
1240{
1241	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1242	struct host_table_entry *entry = get_table_entry(tspContext);
1243
1244	if (entry == NULL)
1245		return TSPERR(TSS_E_NO_CONNECTION);
1246
1247	switch (entry->type) {
1248		case CONNECTION_TYPE_TCP_PERSISTANT:
1249			result = RPC_ConvertMigrationBlob_TP(entry, parentHandle,
1250							     inDataSize, inData, randomSize,
1251							     random, parentAuth, outDataSize,
1252							     outData);
1253			break;
1254		default:
1255			break;
1256	}
1257
1258	put_table_entry(entry);
1259
1260	return result;
1261}
1262
1263TSS_RESULT RPC_AuthorizeMigrationKey(TSS_HCONTEXT tspContext,	/* in */
1264				     TCPA_MIGRATE_SCHEME migrateScheme,	/* in */
1265				     UINT32 MigrationKeySize,	/* in */
1266				     BYTE * MigrationKey,	/* in */
1267				     TPM_AUTH * ownerAuth,	/* in, out */
1268				     UINT32 * MigrationKeyAuthSize,	/* out */
1269				     BYTE ** MigrationKeyAuth)	/* out */
1270{
1271	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1272	struct host_table_entry *entry = get_table_entry(tspContext);
1273
1274	if (entry == NULL)
1275		return TSPERR(TSS_E_NO_CONNECTION);
1276
1277	switch (entry->type) {
1278		case CONNECTION_TYPE_TCP_PERSISTANT:
1279			result = RPC_AuthorizeMigrationKey_TP(entry, migrateScheme,
1280							      MigrationKeySize, MigrationKey,
1281							      ownerAuth, MigrationKeyAuthSize,
1282							      MigrationKeyAuth);
1283			break;
1284		default:
1285			break;
1286	}
1287
1288	put_table_entry(entry);
1289
1290	return result;
1291}
1292
1293TSS_RESULT RPC_CertifyKey(TSS_HCONTEXT tspContext,	/* in */
1294			  TCS_KEY_HANDLE certHandle,	/* in */
1295			  TCS_KEY_HANDLE keyHandle,	/* in */
1296			  TPM_NONCE * antiReplay,	/* in */
1297			  TPM_AUTH * certAuth,	/* in, out */
1298			  TPM_AUTH * keyAuth,	/* in, out */
1299			  UINT32 * CertifyInfoSize,	/* out */
1300			  BYTE ** CertifyInfo,	/* out */
1301			  UINT32 * outDataSize,	/* out */
1302			  BYTE ** outData)	/* out */
1303{
1304	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1305	struct host_table_entry *entry = get_table_entry(tspContext);
1306
1307	if (entry == NULL)
1308		return TSPERR(TSS_E_NO_CONNECTION);
1309
1310	switch (entry->type) {
1311		case CONNECTION_TYPE_TCP_PERSISTANT:
1312			result = RPC_CertifyKey_TP(entry, certHandle, keyHandle, antiReplay,
1313						   certAuth, keyAuth, CertifyInfoSize, CertifyInfo,
1314						   outDataSize, outData);
1315			break;
1316		default:
1317			break;
1318	}
1319
1320	put_table_entry(entry);
1321
1322	return result;
1323}
1324
1325TSS_RESULT RPC_Sign(TSS_HCONTEXT tspContext,	/* in */
1326		    TCS_KEY_HANDLE keyHandle,	/* in */
1327		    UINT32 areaToSignSize,	/* in */
1328		    BYTE * areaToSign,	/* in */
1329		    TPM_AUTH * privAuth,	/* in, out */
1330		    UINT32 * sigSize,	/* out */
1331		    BYTE ** sig)	/* out */
1332{
1333	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1334	struct host_table_entry *entry = get_table_entry(tspContext);
1335
1336	if (entry == NULL)
1337		return TSPERR(TSS_E_NO_CONNECTION);
1338
1339	switch (entry->type) {
1340		case CONNECTION_TYPE_TCP_PERSISTANT:
1341			result = RPC_Sign_TP(entry, keyHandle, areaToSignSize, areaToSign, privAuth,
1342					     sigSize, sig);
1343			break;
1344		default:
1345			break;
1346	}
1347
1348	put_table_entry(entry);
1349
1350	return result;
1351}
1352
1353TSS_RESULT RPC_GetRandom(TSS_HCONTEXT tspContext,	/* in */
1354			 UINT32 bytesRequested,	/* in */
1355			 BYTE ** randomBytes)	/* out */
1356{
1357	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1358	struct host_table_entry *entry = get_table_entry(tspContext);
1359
1360	if (entry == NULL)
1361		return TSPERR(TSS_E_NO_CONNECTION);
1362
1363	switch (entry->type) {
1364		case CONNECTION_TYPE_TCP_PERSISTANT:
1365			result = RPC_GetRandom_TP(entry, bytesRequested, randomBytes);
1366			break;
1367		default:
1368			break;
1369	}
1370
1371	put_table_entry(entry);
1372
1373	return result;
1374}
1375
1376TSS_RESULT RPC_StirRandom(TSS_HCONTEXT tspContext,	/* in */
1377			  UINT32 inDataSize,	/* in */
1378			  BYTE * inData)	/* in */
1379{
1380	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1381	struct host_table_entry *entry = get_table_entry(tspContext);
1382
1383	if (entry == NULL)
1384		return TSPERR(TSS_E_NO_CONNECTION);
1385
1386	switch (entry->type) {
1387		case CONNECTION_TYPE_TCP_PERSISTANT:
1388			result = RPC_StirRandom_TP(entry, inDataSize, inData);
1389			break;
1390		default:
1391			break;
1392	}
1393
1394	put_table_entry(entry);
1395
1396	return result;
1397}
1398
1399TSS_RESULT RPC_GetTPMCapability(TSS_HCONTEXT tspContext,	/* in */
1400			        TCPA_CAPABILITY_AREA capArea,	/* in */
1401			        UINT32 subCapSize,	/* in */
1402			        BYTE * subCap,	/* in */
1403			        UINT32 * respSize,	/* out */
1404			        BYTE ** resp)	/* out */
1405{
1406	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1407	struct host_table_entry *entry = get_table_entry(tspContext);
1408
1409	if (entry == NULL)
1410		return TSPERR(TSS_E_NO_CONNECTION);
1411
1412	switch (entry->type) {
1413		case CONNECTION_TYPE_TCP_PERSISTANT:
1414			result = RPC_GetTPMCapability_TP(entry, capArea, subCapSize, subCap,
1415							 respSize, resp);
1416			break;
1417		default:
1418			break;
1419	}
1420
1421	put_table_entry(entry);
1422
1423	return result;
1424}
1425
1426TSS_RESULT RPC_SetCapability(TSS_HCONTEXT tspContext,	/* in */
1427			     TCPA_CAPABILITY_AREA capArea,	/* in */
1428			     UINT32 subCapSize,	/* in */
1429			     BYTE * subCap,	/* in */
1430			     UINT32 valueSize,	/* in */
1431			     BYTE * value,	/* in */
1432			     TPM_AUTH *ownerAuth) /* in, out */
1433{
1434	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1435	struct host_table_entry *entry = get_table_entry(tspContext);
1436
1437	if (entry == NULL)
1438		return TSPERR(TSS_E_NO_CONNECTION);
1439
1440	switch (entry->type) {
1441		case CONNECTION_TYPE_TCP_PERSISTANT:
1442			result = RPC_SetCapability_TP(entry, capArea, subCapSize, subCap,
1443						      valueSize, value, ownerAuth);
1444			break;
1445		default:
1446			break;
1447	}
1448
1449	put_table_entry(entry);
1450
1451	return result;
1452}
1453
1454TSS_RESULT RPC_GetCapability(TSS_HCONTEXT tspContext,	/* in */
1455			     TCPA_CAPABILITY_AREA capArea,	/* in */
1456			     UINT32 subCapSize,	/* in */
1457			     BYTE * subCap,	/* in */
1458			     UINT32 * respSize,	/* out */
1459			     BYTE ** resp)	/* out */
1460{
1461	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1462	struct host_table_entry *entry = get_table_entry(tspContext);
1463
1464	if (entry == NULL)
1465		return TSPERR(TSS_E_NO_CONNECTION);
1466
1467	switch (entry->type) {
1468		case CONNECTION_TYPE_TCP_PERSISTANT:
1469			result = RPC_GetCapability_TP(entry, capArea, subCapSize, subCap, respSize,
1470						      resp);
1471			break;
1472		default:
1473			break;
1474	}
1475
1476	put_table_entry(entry);
1477
1478	return result;
1479}
1480
1481TSS_RESULT RPC_GetCapabilitySigned(TSS_HCONTEXT tspContext,	/* in */
1482				   TCS_KEY_HANDLE keyHandle,	/* in */
1483				   TCPA_NONCE antiReplay,	/* in */
1484				   TCPA_CAPABILITY_AREA capArea,	/* in */
1485				   UINT32 subCapSize,	/* in */
1486				   BYTE * subCap,	/* in */
1487				   TPM_AUTH * privAuth,	/* in, out */
1488				   TCPA_VERSION * Version,	/* out */
1489				   UINT32 * respSize,	/* out */
1490				   BYTE ** resp,	/* out */
1491				   UINT32 * sigSize,	/* out */
1492				   BYTE ** sig)	/* out */
1493{
1494	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1495	struct host_table_entry *entry = get_table_entry(tspContext);
1496
1497	if (entry == NULL)
1498		return TSPERR(TSS_E_NO_CONNECTION);
1499
1500	switch (entry->type) {
1501		case CONNECTION_TYPE_TCP_PERSISTANT:
1502			result = RPC_GetCapabilitySigned_TP(entry, keyHandle, antiReplay, capArea,
1503							    subCapSize, subCap, privAuth, Version,
1504							    respSize, resp, sigSize, sig);
1505			break;
1506		default:
1507			break;
1508	}
1509
1510	put_table_entry(entry);
1511
1512	return result;
1513}
1514
1515TSS_RESULT RPC_GetCapabilityOwner(TSS_HCONTEXT tspContext,	/* in */
1516				  TPM_AUTH * pOwnerAuth,	/* out */
1517				  TCPA_VERSION * pVersion,	/* out */
1518				  UINT32 * pNonVolatileFlags,	/* out */
1519				  UINT32 * pVolatileFlags)	/* out */
1520{
1521	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1522	struct host_table_entry *entry = get_table_entry(tspContext);
1523
1524	if (entry == NULL)
1525		return TSPERR(TSS_E_NO_CONNECTION);
1526
1527	switch (entry->type) {
1528		case CONNECTION_TYPE_TCP_PERSISTANT:
1529			result = RPC_GetCapabilityOwner_TP(entry, pOwnerAuth, pVersion,
1530							   pNonVolatileFlags, pVolatileFlags);
1531			break;
1532		default:
1533			break;
1534	}
1535
1536	put_table_entry(entry);
1537
1538	return result;
1539}
1540
1541TSS_RESULT RPC_CreateEndorsementKeyPair(TSS_HCONTEXT tspContext,	/* in */
1542					TCPA_NONCE antiReplay,	/* in */
1543					UINT32 endorsementKeyInfoSize,	/* in */
1544					BYTE * endorsementKeyInfo,	/* in */
1545					UINT32 * endorsementKeySize,	/* out */
1546					BYTE ** endorsementKey,	/* out */
1547					TCPA_DIGEST * checksum)	/* out */
1548{
1549	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1550	struct host_table_entry *entry = get_table_entry(tspContext);
1551
1552	if (entry == NULL)
1553		return TSPERR(TSS_E_NO_CONNECTION);
1554
1555	switch (entry->type) {
1556		case CONNECTION_TYPE_TCP_PERSISTANT:
1557			result = RPC_CreateEndorsementKeyPair_TP(entry, antiReplay,
1558								 endorsementKeyInfoSize,
1559								 endorsementKeyInfo,
1560								 endorsementKeySize,
1561								 endorsementKey, checksum);
1562			break;
1563		default:
1564			break;
1565	}
1566
1567	put_table_entry(entry);
1568
1569	return result;
1570}
1571
1572TSS_RESULT RPC_ReadPubek(TSS_HCONTEXT tspContext,	/* in */
1573			 TCPA_NONCE antiReplay,	/* in */
1574			 UINT32 * pubEndorsementKeySize,	/* out */
1575			 BYTE ** pubEndorsementKey,	/* out */
1576			 TCPA_DIGEST * checksum)	/* out */
1577{
1578	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1579	struct host_table_entry *entry = get_table_entry(tspContext);
1580
1581	if (entry == NULL)
1582		return TSPERR(TSS_E_NO_CONNECTION);
1583
1584	switch (entry->type) {
1585		case CONNECTION_TYPE_TCP_PERSISTANT:
1586			result = RPC_ReadPubek_TP(entry, antiReplay, pubEndorsementKeySize,
1587						  pubEndorsementKey, checksum);
1588			break;
1589		default:
1590			break;
1591	}
1592
1593	put_table_entry(entry);
1594
1595	return result;
1596}
1597
1598TSS_RESULT RPC_DisablePubekRead(TSS_HCONTEXT tspContext,	/* in */
1599				TPM_AUTH * ownerAuth)	/* in, out */
1600{
1601	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1602	struct host_table_entry *entry = get_table_entry(tspContext);
1603
1604	if (entry == NULL)
1605		return TSPERR(TSS_E_NO_CONNECTION);
1606
1607	switch (entry->type) {
1608		case CONNECTION_TYPE_TCP_PERSISTANT:
1609			result = RPC_DisablePubekRead_TP(entry, ownerAuth);
1610			break;
1611		default:
1612			break;
1613	}
1614
1615	put_table_entry(entry);
1616
1617	return result;
1618}
1619
1620TSS_RESULT RPC_OwnerReadPubek(TSS_HCONTEXT tspContext,	/* in */
1621			      TPM_AUTH * ownerAuth,	/* in, out */
1622			      UINT32 * pubEndorsementKeySize,	/* out */
1623			      BYTE ** pubEndorsementKey)	/* out */
1624{
1625	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1626	struct host_table_entry *entry = get_table_entry(tspContext);
1627
1628	if (entry == NULL)
1629		return TSPERR(TSS_E_NO_CONNECTION);
1630
1631	switch (entry->type) {
1632		case CONNECTION_TYPE_TCP_PERSISTANT:
1633			result = RPC_OwnerReadPubek_TP(entry, ownerAuth, pubEndorsementKeySize,
1634						       pubEndorsementKey);
1635			break;
1636		default:
1637			break;
1638	}
1639
1640	put_table_entry(entry);
1641
1642	return result;
1643}
1644
1645#ifdef TSS_BUILD_TSS12
1646TSS_RESULT RPC_CreateRevocableEndorsementKeyPair(TSS_HCONTEXT tspContext,	/* in */
1647						 TPM_NONCE antiReplay,		/* in */
1648						 UINT32 endorsementKeyInfoSize,/* in */
1649						 BYTE * endorsementKeyInfo,	/* in */
1650						 TSS_BOOL genResetAuth,	/* in */
1651						 TPM_DIGEST * eKResetAuth,	/* in, out */
1652						 UINT32 * endorsementKeySize,	/* out */
1653						 BYTE ** endorsementKey,	/* out */
1654						 TPM_DIGEST * checksum)	/* out */
1655{
1656	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1657	struct host_table_entry *entry = get_table_entry(tspContext);
1658
1659	if (entry == NULL)
1660		return TSPERR(TSS_E_NO_CONNECTION);
1661
1662	switch (entry->type) {
1663		case CONNECTION_TYPE_TCP_PERSISTANT:
1664			result = RPC_CreateRevocableEndorsementKeyPair_TP(entry, antiReplay,
1665									  endorsementKeyInfoSize,
1666									  endorsementKeyInfo,
1667									  genResetAuth,
1668									  eKResetAuth,
1669									  endorsementKeySize,
1670									  endorsementKey, checksum);
1671			break;
1672		default:
1673			break;
1674	}
1675
1676	put_table_entry(entry);
1677
1678	return result;
1679}
1680
1681TSS_RESULT RPC_RevokeEndorsementKeyPair(TSS_HCONTEXT tspContext,	/* in */
1682					TPM_DIGEST *EKResetAuth)	/* in */
1683{
1684	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1685	struct host_table_entry *entry = get_table_entry(tspContext);
1686
1687	if (entry == NULL)
1688		return TSPERR(TSS_E_NO_CONNECTION);
1689
1690	switch (entry->type) {
1691		case CONNECTION_TYPE_TCP_PERSISTANT:
1692			result = RPC_RevokeEndorsementKeyPair_TP(entry, EKResetAuth);
1693			break;
1694		default:
1695			break;
1696	}
1697
1698	put_table_entry(entry);
1699
1700	return result;
1701}
1702#endif
1703
1704TSS_RESULT RPC_SelfTestFull(TSS_HCONTEXT tspContext)	/* in */
1705{
1706	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1707	struct host_table_entry *entry = get_table_entry(tspContext);
1708
1709	if (entry == NULL)
1710		return TSPERR(TSS_E_NO_CONNECTION);
1711
1712	switch (entry->type) {
1713		case CONNECTION_TYPE_TCP_PERSISTANT:
1714			result = RPC_SelfTestFull_TP(entry);
1715			break;
1716		default:
1717			break;
1718	}
1719
1720	put_table_entry(entry);
1721
1722	return result;
1723}
1724
1725TSS_RESULT RPC_CertifySelfTest(TSS_HCONTEXT tspContext,	/* in */
1726			       TCS_KEY_HANDLE keyHandle,	/* in */
1727			       TCPA_NONCE antiReplay,	/* in */
1728			       TPM_AUTH * privAuth,	/* in, out */
1729			       UINT32 * sigSize,	/* out */
1730			       BYTE ** sig)	/* out */
1731{
1732	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1733	struct host_table_entry *entry = get_table_entry(tspContext);
1734
1735	if (entry == NULL)
1736		return TSPERR(TSS_E_NO_CONNECTION);
1737
1738	switch (entry->type) {
1739		case CONNECTION_TYPE_TCP_PERSISTANT:
1740			result = RPC_CertifySelfTest_TP(entry, keyHandle, antiReplay, privAuth,
1741							sigSize, sig);
1742			break;
1743		default:
1744			break;
1745	}
1746
1747	put_table_entry(entry);
1748
1749	return result;
1750}
1751
1752TSS_RESULT RPC_GetTestResult(TSS_HCONTEXT tspContext,	/* in */
1753			     UINT32 * outDataSize,	/* out */
1754			     BYTE ** outData)	/* out */
1755{
1756	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1757	struct host_table_entry *entry = get_table_entry(tspContext);
1758
1759	if (entry == NULL)
1760		return TSPERR(TSS_E_NO_CONNECTION);
1761
1762	switch (entry->type) {
1763		case CONNECTION_TYPE_TCP_PERSISTANT:
1764			result = RPC_GetTestResult_TP(entry, outDataSize, outData);
1765			break;
1766		default:
1767			break;
1768	}
1769
1770	put_table_entry(entry);
1771
1772	return result;
1773}
1774
1775TSS_RESULT RPC_OwnerSetDisable(TSS_HCONTEXT tspContext,	/* in */
1776			       TSS_BOOL disableState,	/* in */
1777			       TPM_AUTH * ownerAuth)	/* in, out */
1778{
1779	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1780	struct host_table_entry *entry = get_table_entry(tspContext);
1781
1782	if (entry == NULL)
1783		return TSPERR(TSS_E_NO_CONNECTION);
1784
1785	switch (entry->type) {
1786		case CONNECTION_TYPE_TCP_PERSISTANT:
1787			result = RPC_OwnerSetDisable_TP(entry, disableState, ownerAuth);
1788			break;
1789		default:
1790			break;
1791	}
1792
1793	put_table_entry(entry);
1794
1795	return result;
1796}
1797
1798#ifdef TSS_BUILD_TSS12
1799TSS_RESULT RPC_ResetLockValue(TSS_HCONTEXT tspContext,	/* in */
1800			      TPM_AUTH * ownerAuth)	/* in, out */
1801{
1802	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1803	struct host_table_entry *entry = get_table_entry(tspContext);
1804
1805	if (entry == NULL)
1806		return TSPERR(TSS_E_NO_CONNECTION);
1807
1808	switch (entry->type) {
1809		case CONNECTION_TYPE_TCP_PERSISTANT:
1810			result = RPC_ResetLockValue_TP(entry, ownerAuth);
1811			break;
1812		default:
1813			break;
1814	}
1815
1816	put_table_entry(entry);
1817
1818	return result;
1819}
1820#endif
1821
1822TSS_RESULT RPC_OwnerClear(TSS_HCONTEXT tspContext,	/* in */
1823			  TPM_AUTH * ownerAuth)	/* in, out */
1824{
1825	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1826	struct host_table_entry *entry = get_table_entry(tspContext);
1827
1828	if (entry == NULL)
1829		return TSPERR(TSS_E_NO_CONNECTION);
1830
1831	switch (entry->type) {
1832		case CONNECTION_TYPE_TCP_PERSISTANT:
1833			result = RPC_OwnerClear_TP(entry, ownerAuth);
1834			break;
1835		default:
1836			break;
1837	}
1838
1839	put_table_entry(entry);
1840
1841	return result;
1842}
1843
1844TSS_RESULT RPC_DisableOwnerClear(TSS_HCONTEXT tspContext,	/* in */
1845				 TPM_AUTH * ownerAuth)	/* in, out */
1846{
1847	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1848	struct host_table_entry *entry = get_table_entry(tspContext);
1849
1850	if (entry == NULL)
1851		return TSPERR(TSS_E_NO_CONNECTION);
1852
1853	switch (entry->type) {
1854		case CONNECTION_TYPE_TCP_PERSISTANT:
1855			result = RPC_DisableOwnerClear_TP(entry, ownerAuth);
1856			break;
1857		default:
1858			break;
1859	}
1860
1861	put_table_entry(entry);
1862
1863	return result;
1864}
1865
1866TSS_RESULT RPC_ForceClear(TSS_HCONTEXT tspContext)	/* in */
1867{
1868	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1869	struct host_table_entry *entry = get_table_entry(tspContext);
1870
1871	if (entry == NULL)
1872		return TSPERR(TSS_E_NO_CONNECTION);
1873
1874	switch (entry->type) {
1875		case CONNECTION_TYPE_TCP_PERSISTANT:
1876			result = RPC_ForceClear_TP(entry);
1877			break;
1878		default:
1879			break;
1880	}
1881
1882	put_table_entry(entry);
1883
1884	return result;
1885}
1886
1887TSS_RESULT RPC_DisableForceClear(TSS_HCONTEXT tspContext)	/* in */
1888{
1889	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1890	struct host_table_entry *entry = get_table_entry(tspContext);
1891
1892	if (entry == NULL)
1893		return TSPERR(TSS_E_NO_CONNECTION);
1894
1895	switch (entry->type) {
1896		case CONNECTION_TYPE_TCP_PERSISTANT:
1897			result = RPC_DisableForceClear_TP(entry);
1898			break;
1899		default:
1900			break;
1901	}
1902
1903	put_table_entry(entry);
1904
1905	return result;
1906}
1907
1908TSS_RESULT RPC_PhysicalDisable(TSS_HCONTEXT tspContext)	/* in */
1909{
1910	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1911	struct host_table_entry *entry = get_table_entry(tspContext);
1912
1913	if (entry == NULL)
1914		return TSPERR(TSS_E_NO_CONNECTION);
1915
1916	switch (entry->type) {
1917		case CONNECTION_TYPE_TCP_PERSISTANT:
1918			result = RPC_PhysicalDisable_TP(entry);
1919			break;
1920		default:
1921			break;
1922	}
1923
1924	put_table_entry(entry);
1925
1926	return result;
1927}
1928
1929TSS_RESULT RPC_PhysicalEnable(TSS_HCONTEXT tspContext)	/* in */
1930{
1931	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1932	struct host_table_entry *entry = get_table_entry(tspContext);
1933
1934	if (entry == NULL)
1935		return TSPERR(TSS_E_NO_CONNECTION);
1936
1937	switch (entry->type) {
1938		case CONNECTION_TYPE_TCP_PERSISTANT:
1939			result = RPC_PhysicalEnable_TP(entry);
1940			break;
1941		default:
1942			break;
1943	}
1944
1945	put_table_entry(entry);
1946
1947	return result;
1948}
1949
1950TSS_RESULT RPC_PhysicalSetDeactivated(TSS_HCONTEXT tspContext,	/* in */
1951				      TSS_BOOL state)	/* in */
1952{
1953	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1954	struct host_table_entry *entry = get_table_entry(tspContext);
1955
1956	if (entry == NULL)
1957		return TSPERR(TSS_E_NO_CONNECTION);
1958
1959	switch (entry->type) {
1960		case CONNECTION_TYPE_TCP_PERSISTANT:
1961			result = RPC_PhysicalSetDeactivated_TP(entry, state);
1962			break;
1963		default:
1964			break;
1965	}
1966
1967	put_table_entry(entry);
1968
1969	return result;
1970}
1971
1972TSS_RESULT RPC_PhysicalPresence(TSS_HCONTEXT tspContext,	/* in */
1973				TCPA_PHYSICAL_PRESENCE fPhysicalPresence)	/* in */
1974{
1975	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1976	struct host_table_entry *entry = get_table_entry(tspContext);
1977
1978	if (entry == NULL)
1979		return TSPERR(TSS_E_NO_CONNECTION);
1980
1981	switch (entry->type) {
1982		case CONNECTION_TYPE_TCP_PERSISTANT:
1983			result = RPC_PhysicalPresence_TP(entry, fPhysicalPresence);
1984			break;
1985		default:
1986			break;
1987	}
1988
1989	put_table_entry(entry);
1990
1991	return result;
1992}
1993
1994TSS_RESULT RPC_SetTempDeactivated(TSS_HCONTEXT tspContext)	/* in */
1995{
1996	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
1997	struct host_table_entry *entry = get_table_entry(tspContext);
1998
1999	if (entry == NULL)
2000		return TSPERR(TSS_E_NO_CONNECTION);
2001
2002	switch (entry->type) {
2003		case CONNECTION_TYPE_TCP_PERSISTANT:
2004			result = RPC_SetTempDeactivated_TP(entry);
2005			break;
2006		default:
2007			break;
2008	}
2009
2010	put_table_entry(entry);
2011
2012	return result;
2013}
2014
2015#ifdef TSS_BUILD_TSS12
2016TSS_RESULT RPC_SetTempDeactivated2(TSS_HCONTEXT tspContext,	/* in */
2017				   TPM_AUTH *operatorAuth)	/* in, out */
2018{
2019	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2020	struct host_table_entry *entry = get_table_entry(tspContext);
2021
2022	if (entry == NULL)
2023		return TSPERR(TSS_E_NO_CONNECTION);
2024
2025	switch (entry->type) {
2026		case CONNECTION_TYPE_TCP_PERSISTANT:
2027			result = RPC_SetTempDeactivated2_TP(entry, operatorAuth);
2028			break;
2029		default:
2030			break;
2031	}
2032
2033	put_table_entry(entry);
2034
2035	return result;
2036}
2037#endif
2038
2039TSS_RESULT RPC_FieldUpgrade(TSS_HCONTEXT tspContext,	/* in */
2040			    UINT32 dataInSize,	/* in */
2041			    BYTE * dataIn,	/* in */
2042			    UINT32 * dataOutSize,	/* out */
2043			    BYTE ** dataOut,	/* out */
2044			    TPM_AUTH * ownerAuth)	/* in, out */
2045{
2046	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2047	struct host_table_entry *entry = get_table_entry(tspContext);
2048
2049	if (entry == NULL)
2050		return TSPERR(TSS_E_NO_CONNECTION);
2051
2052	switch (entry->type) {
2053		case CONNECTION_TYPE_TCP_PERSISTANT:
2054			result = (UINT32) TSPERR(TSS_E_INTERNAL_ERROR);
2055			break;
2056		default:
2057			break;
2058	}
2059
2060	put_table_entry(entry);
2061
2062	return result;
2063}
2064
2065TSS_RESULT RPC_SetRedirection(TSS_HCONTEXT tspContext,	/* in */
2066			      TCS_KEY_HANDLE keyHandle,	/* in */
2067			      UINT32 c1,	/* in */
2068			      UINT32 c2,	/* in */
2069			      TPM_AUTH * privAuth)	/* in, out */
2070{
2071	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2072	struct host_table_entry *entry = get_table_entry(tspContext);
2073
2074	if (entry == NULL)
2075		return TSPERR(TSS_E_NO_CONNECTION);
2076
2077	switch (entry->type) {
2078		case CONNECTION_TYPE_TCP_PERSISTANT:
2079			result = (UINT32) TSPERR(TSS_E_INTERNAL_ERROR);
2080			break;
2081		default:
2082			break;
2083	}
2084
2085	put_table_entry(entry);
2086
2087	return result;
2088}
2089
2090TSS_RESULT RPC_CreateMaintenanceArchive(TSS_HCONTEXT tspContext,	/* in */
2091					TSS_BOOL generateRandom,	/* in */
2092					TPM_AUTH * ownerAuth,	/* in, out */
2093					UINT32 * randomSize,	/* out */
2094					BYTE ** random,	/* out */
2095					UINT32 * archiveSize,	/* out */
2096					BYTE ** archive)	/* out */
2097{
2098	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2099	struct host_table_entry *entry = get_table_entry(tspContext);
2100
2101	if (entry == NULL)
2102		return TSPERR(TSS_E_NO_CONNECTION);
2103
2104	switch (entry->type) {
2105		case CONNECTION_TYPE_TCP_PERSISTANT:
2106			result = RPC_CreateMaintenanceArchive_TP(entry, generateRandom, ownerAuth,
2107								 randomSize, random, archiveSize,
2108								 archive);
2109			break;
2110		default:
2111			break;
2112	}
2113
2114	put_table_entry(entry);
2115
2116	return result;
2117}
2118
2119TSS_RESULT RPC_LoadMaintenanceArchive(TSS_HCONTEXT tspContext,	/* in */
2120				      UINT32 dataInSize,	/* in */
2121				      BYTE * dataIn, /* in */
2122				      TPM_AUTH * ownerAuth,	/* in, out */
2123				      UINT32 * dataOutSize,	/* out */
2124				      BYTE ** dataOut)	/* out */
2125{
2126	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2127	struct host_table_entry *entry = get_table_entry(tspContext);
2128
2129	if (entry == NULL)
2130		return TSPERR(TSS_E_NO_CONNECTION);
2131
2132	switch (entry->type) {
2133		case CONNECTION_TYPE_TCP_PERSISTANT:
2134			result = RPC_LoadMaintenanceArchive_TP(entry, dataInSize, dataIn, ownerAuth,
2135							       dataOutSize, dataOut);
2136			break;
2137		default:
2138			break;
2139	}
2140
2141	put_table_entry(entry);
2142
2143	return result;
2144}
2145
2146TSS_RESULT RPC_KillMaintenanceFeature(TSS_HCONTEXT tspContext,	/* in */
2147				      TPM_AUTH * ownerAuth)	/* in, out */
2148{
2149	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2150	struct host_table_entry *entry = get_table_entry(tspContext);
2151
2152	if (entry == NULL)
2153		return TSPERR(TSS_E_NO_CONNECTION);
2154
2155	switch (entry->type) {
2156		case CONNECTION_TYPE_TCP_PERSISTANT:
2157			result = RPC_KillMaintenanceFeature_TP(entry, ownerAuth);
2158			break;
2159		default:
2160			break;
2161	}
2162
2163	put_table_entry(entry);
2164
2165	return result;
2166}
2167
2168TSS_RESULT RPC_LoadManuMaintPub(TSS_HCONTEXT tspContext,	/* in */
2169				TCPA_NONCE antiReplay,	/* in */
2170				UINT32 PubKeySize,	/* in */
2171				BYTE * PubKey,	/* in */
2172				TCPA_DIGEST * checksum)	/* out */
2173{
2174	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2175	struct host_table_entry *entry = get_table_entry(tspContext);
2176
2177	if (entry == NULL)
2178		return TSPERR(TSS_E_NO_CONNECTION);
2179
2180	switch (entry->type) {
2181		case CONNECTION_TYPE_TCP_PERSISTANT:
2182			result = RPC_LoadManuMaintPub_TP(entry, antiReplay, PubKeySize, PubKey,
2183							 checksum);
2184			break;
2185		default:
2186			break;
2187	}
2188
2189	put_table_entry(entry);
2190
2191	return result;
2192}
2193
2194TSS_RESULT RPC_ReadManuMaintPub(TSS_HCONTEXT tspContext,	/* in */
2195				TCPA_NONCE antiReplay,	/* in */
2196				TCPA_DIGEST * checksum)	/* out */
2197{
2198	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2199	struct host_table_entry *entry = get_table_entry(tspContext);
2200
2201	if (entry == NULL)
2202		return TSPERR(TSS_E_NO_CONNECTION);
2203
2204	switch (entry->type) {
2205		case CONNECTION_TYPE_TCP_PERSISTANT:
2206			result = RPC_ReadManuMaintPub_TP(entry, antiReplay, checksum);
2207			break;
2208		default:
2209			break;
2210	}
2211
2212	put_table_entry(entry);
2213
2214	return result;
2215}
2216
2217#ifdef TSS_BUILD_DAA
2218TSS_RESULT
2219RPC_DaaJoin(TSS_HCONTEXT tspContext,	/* in */
2220	    TPM_HANDLE daa_session,		/* in */
2221	    BYTE stage,			/* in */
2222	    UINT32 inputSize0,			/* in */
2223	    BYTE* inputData0,			/* in */
2224	    UINT32 inputSize1,			/* in */
2225	    BYTE* inputData1,			/* in */
2226	    TPM_AUTH* ownerAuth,		/* in, out */
2227	    UINT32* outputSize,		/* out */
2228	    BYTE** outputData)			/* out */
2229{
2230	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2231	struct host_table_entry *entry = get_table_entry(tspContext);
2232
2233	if (entry == NULL)
2234		return TSPERR(TSS_E_NO_CONNECTION);
2235
2236	switch (entry->type) {
2237		case CONNECTION_TYPE_TCP_PERSISTANT:
2238			result = RPC_DaaJoin_TP(entry, daa_session, stage, inputSize0, inputData0,
2239						inputSize1, inputData1, ownerAuth, outputSize,
2240						outputData);
2241			break;
2242		default:
2243			break;
2244	}
2245
2246	put_table_entry(entry);
2247
2248	return result;
2249
2250}
2251
2252TSS_RESULT
2253RPC_DaaSign(TSS_HCONTEXT tspContext,	/* in */
2254	    TPM_HANDLE daa_session,		/* in */
2255	    BYTE stage,			/* in */
2256	    UINT32 inputSize0,			/* in */
2257	    BYTE* inputData0,			/* in */
2258	    UINT32 inputSize1,			/* in */
2259	    BYTE* inputData1,			/* in */
2260	    TPM_AUTH* ownerAuth,		/* in, out */
2261	    UINT32* outputSize,		/* out */
2262	    BYTE** outputData)			/* out */
2263{
2264	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2265	struct host_table_entry *entry = get_table_entry(tspContext);
2266
2267	if (entry == NULL)
2268		return TSPERR(TSS_E_NO_CONNECTION);
2269
2270	switch (entry->type) {
2271		case CONNECTION_TYPE_TCP_PERSISTANT:
2272			result = RPC_DaaSign_TP(entry, daa_session, stage, inputSize0, inputData0,
2273						inputSize1, inputData1, ownerAuth, outputSize,
2274						outputData);
2275			break;
2276		default:
2277			break;
2278	}
2279
2280	put_table_entry(entry);
2281
2282	return result;
2283}
2284#endif
2285
2286#ifdef TSS_BUILD_COUNTER
2287TSS_RESULT
2288RPC_ReadCounter(TSS_HCONTEXT       tspContext,		/* in */
2289		TSS_COUNTER_ID     idCounter,		/* in */
2290		TPM_COUNTER_VALUE* counterValue)	/* out */
2291{
2292	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2293	struct host_table_entry *entry = get_table_entry(tspContext);
2294
2295	if (entry == NULL)
2296		return TSPERR(TSS_E_NO_CONNECTION);
2297
2298	switch (entry->type) {
2299		case CONNECTION_TYPE_TCP_PERSISTANT:
2300			result = RPC_ReadCounter_TP(entry, idCounter, counterValue);
2301			break;
2302		default:
2303			break;
2304	}
2305
2306	put_table_entry(entry);
2307
2308	return result;
2309}
2310
2311TSS_RESULT
2312RPC_CreateCounter(TSS_HCONTEXT       tspContext,	/* in */
2313		  UINT32             LabelSize,	/* in (=4) */
2314		  BYTE*              pLabel,		/* in */
2315		  TPM_ENCAUTH        CounterAuth,	/* in */
2316		  TPM_AUTH*          pOwnerAuth,	/* in, out */
2317		  TSS_COUNTER_ID*    idCounter,	/* out */
2318		  TPM_COUNTER_VALUE* counterValue)	/* out */
2319{
2320	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2321	struct host_table_entry *entry = get_table_entry(tspContext);
2322
2323	if (entry == NULL)
2324		return TSPERR(TSS_E_NO_CONNECTION);
2325
2326	switch (entry->type) {
2327		case CONNECTION_TYPE_TCP_PERSISTANT:
2328			result = RPC_CreateCounter_TP(entry, LabelSize, pLabel, CounterAuth,
2329						      pOwnerAuth, idCounter, counterValue);
2330			break;
2331		default:
2332			break;
2333	}
2334
2335	put_table_entry(entry);
2336
2337	return result;
2338}
2339
2340TSS_RESULT
2341RPC_IncrementCounter(TSS_HCONTEXT       tspContext,	/* in */
2342		     TSS_COUNTER_ID     idCounter,	/* in */
2343		     TPM_AUTH*          pCounterAuth,	/* in, out */
2344		     TPM_COUNTER_VALUE* counterValue)	/* out */
2345{
2346	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2347	struct host_table_entry *entry = get_table_entry(tspContext);
2348
2349	if (entry == NULL)
2350		return TSPERR(TSS_E_NO_CONNECTION);
2351
2352	switch (entry->type) {
2353		case CONNECTION_TYPE_TCP_PERSISTANT:
2354			result = RPC_IncrementCounter_TP(entry, idCounter, pCounterAuth,
2355							 counterValue);
2356			break;
2357		default:
2358			break;
2359	}
2360
2361	put_table_entry(entry);
2362
2363	return result;
2364}
2365
2366TSS_RESULT
2367RPC_ReleaseCounter(TSS_HCONTEXT   tspContext,		/* in */
2368		   TSS_COUNTER_ID idCounter,		/* in */
2369		   TPM_AUTH*      pCounterAuth)	/* in, out */
2370{
2371	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2372	struct host_table_entry *entry = get_table_entry(tspContext);
2373
2374	if (entry == NULL)
2375		return TSPERR(TSS_E_NO_CONNECTION);
2376
2377	switch (entry->type) {
2378		case CONNECTION_TYPE_TCP_PERSISTANT:
2379			result = RPC_ReleaseCounter_TP(entry, idCounter, pCounterAuth);
2380			break;
2381		default:
2382			break;
2383	}
2384
2385	put_table_entry(entry);
2386
2387	return result;
2388}
2389
2390TSS_RESULT
2391RPC_ReleaseCounterOwner(TSS_HCONTEXT   tspContext,	/* in */
2392			TSS_COUNTER_ID idCounter,	/* in */
2393			TPM_AUTH*      pOwnerAuth)	/* in, out */
2394{
2395	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2396	struct host_table_entry *entry = get_table_entry(tspContext);
2397
2398	if (entry == NULL)
2399		return TSPERR(TSS_E_NO_CONNECTION);
2400
2401	switch (entry->type) {
2402		case CONNECTION_TYPE_TCP_PERSISTANT:
2403			result = RPC_ReleaseCounterOwner_TP(entry, idCounter, pOwnerAuth);
2404			break;
2405		default:
2406			break;
2407	}
2408
2409	put_table_entry(entry);
2410
2411	return result;
2412}
2413#endif
2414
2415#ifdef TSS_BUILD_TICK
2416TSS_RESULT
2417RPC_ReadCurrentTicks(TSS_HCONTEXT tspContext,		/* in */
2418		     UINT32*      pulCurrentTime,	/* out */
2419		     BYTE**       prgbCurrentTime)	/* out */
2420{
2421	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2422	struct host_table_entry *entry = get_table_entry(tspContext);
2423
2424	if (entry == NULL)
2425		return TSPERR(TSS_E_NO_CONNECTION);
2426
2427	switch (entry->type) {
2428		case CONNECTION_TYPE_TCP_PERSISTANT:
2429			result = RPC_ReadCurrentTicks_TP(entry, pulCurrentTime, prgbCurrentTime);
2430			break;
2431		default:
2432			break;
2433	}
2434
2435	put_table_entry(entry);
2436
2437	return result;
2438}
2439
2440TSS_RESULT
2441RPC_TickStampBlob(TSS_HCONTEXT   tspContext,		/* in */
2442		  TCS_KEY_HANDLE hKey,			/* in */
2443		  TPM_NONCE*     antiReplay,		/* in */
2444		  TPM_DIGEST*    digestToStamp,	/* in */
2445		  TPM_AUTH*      privAuth,		/* in, out */
2446		  UINT32*        pulSignatureLength,	/* out */
2447		  BYTE**         prgbSignature,	/* out */
2448		  UINT32*        pulTickCountLength,	/* out */
2449		  BYTE**         prgbTickCount)	/* out */
2450{
2451	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2452	struct host_table_entry *entry = get_table_entry(tspContext);
2453
2454	if (entry == NULL)
2455		return TSPERR(TSS_E_NO_CONNECTION);
2456
2457	switch (entry->type) {
2458		case CONNECTION_TYPE_TCP_PERSISTANT:
2459			result = RPC_TickStampBlob_TP(entry, hKey, antiReplay, digestToStamp,
2460						      privAuth, pulSignatureLength,
2461						      prgbSignature, pulTickCountLength,
2462						      prgbTickCount);
2463			break;
2464		default:
2465			break;
2466	}
2467
2468	put_table_entry(entry);
2469
2470	return result;
2471}
2472#endif
2473
2474#ifdef TSS_BUILD_TRANSPORT
2475TSS_RESULT
2476RPC_EstablishTransport(TSS_HCONTEXT            tspContext,
2477		       UINT32                  ulTransControlFlags,
2478		       TCS_KEY_HANDLE          hEncKey,
2479		       UINT32                  ulTransSessionInfoSize,
2480		       BYTE*                   rgbTransSessionInfo,
2481		       UINT32                  ulSecretSize,
2482		       BYTE*                   rgbSecret,
2483		       TPM_AUTH*               pEncKeyAuth,		/* in, out */
2484		       TPM_MODIFIER_INDICATOR* pbLocality,
2485		       TCS_HANDLE*             hTransSession,
2486		       UINT32*                 ulCurrentTicksSize,
2487		       BYTE**                  prgbCurrentTicks,
2488		       TPM_NONCE*              pTransNonce)
2489{
2490	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2491	struct host_table_entry *entry = get_table_entry(tspContext);
2492
2493	if (entry == NULL)
2494		return TSPERR(TSS_E_NO_CONNECTION);
2495
2496	switch (entry->type) {
2497		case CONNECTION_TYPE_TCP_PERSISTANT:
2498			result = RPC_EstablishTransport_TP(entry, ulTransControlFlags, hEncKey,
2499							   ulTransSessionInfoSize,
2500							   rgbTransSessionInfo, ulSecretSize,
2501							   rgbSecret, pEncKeyAuth, pbLocality,
2502							   hTransSession, ulCurrentTicksSize,
2503							   prgbCurrentTicks, pTransNonce);
2504			break;
2505		default:
2506			break;
2507	}
2508
2509	put_table_entry(entry);
2510
2511	return result;
2512}
2513
2514
2515TSS_RESULT
2516RPC_ExecuteTransport(TSS_HCONTEXT            tspContext,
2517		     TPM_COMMAND_CODE        unWrappedCommandOrdinal,
2518		     UINT32                  ulWrappedCmdParamInSize,
2519		     BYTE*                   rgbWrappedCmdParamIn,
2520		     UINT32*                 pulHandleListSize,	/* in, out */
2521		     TCS_HANDLE**            rghHandles,		/* in, out */
2522		     TPM_AUTH*               pWrappedCmdAuth1,		/* in, out */
2523		     TPM_AUTH*               pWrappedCmdAuth2,		/* in, out */
2524		     TPM_AUTH*               pTransAuth,		/* in, out */
2525		     UINT64*                 punCurrentTicks,
2526		     TPM_MODIFIER_INDICATOR* pbLocality,
2527		     TPM_RESULT*             pulWrappedCmdReturnCode,
2528		     UINT32*                 ulWrappedCmdParamOutSize,
2529		     BYTE**                  rgbWrappedCmdParamOut)
2530{
2531	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2532	struct host_table_entry *entry = get_table_entry(tspContext);
2533
2534	if (entry == NULL)
2535		return TSPERR(TSS_E_NO_CONNECTION);
2536
2537	switch (entry->type) {
2538		case CONNECTION_TYPE_TCP_PERSISTANT:
2539			result = RPC_ExecuteTransport_TP(entry, unWrappedCommandOrdinal,
2540							 ulWrappedCmdParamInSize,
2541							 rgbWrappedCmdParamIn, pulHandleListSize,
2542							 rghHandles, pWrappedCmdAuth1,
2543							 pWrappedCmdAuth2, pTransAuth,
2544							 punCurrentTicks, pbLocality,
2545							 pulWrappedCmdReturnCode,
2546							 ulWrappedCmdParamOutSize,
2547							 rgbWrappedCmdParamOut);
2548			break;
2549		default:
2550			break;
2551	}
2552
2553	put_table_entry(entry);
2554
2555	return result;
2556}
2557
2558TSS_RESULT
2559RPC_ReleaseTransportSigned(TSS_HCONTEXT            tspContext,
2560			   TCS_KEY_HANDLE          hSignatureKey,
2561			   TPM_NONCE*              AntiReplayNonce,
2562			   TPM_AUTH*               pKeyAuth,		/* in, out */
2563			   TPM_AUTH*               pTransAuth,		/* in, out */
2564			   TPM_MODIFIER_INDICATOR* pbLocality,
2565			   UINT32*                 pulCurrentTicksSize,
2566			   BYTE**                  prgbCurrentTicks,
2567			   UINT32*                 pulSignatureSize,
2568			   BYTE**                  prgbSignature)
2569{
2570	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2571	struct host_table_entry *entry = get_table_entry(tspContext);
2572
2573	if (entry == NULL)
2574		return TSPERR(TSS_E_NO_CONNECTION);
2575
2576	switch (entry->type) {
2577		case CONNECTION_TYPE_TCP_PERSISTANT:
2578			result = RPC_ReleaseTransportSigned_TP(entry, hSignatureKey,
2579							       AntiReplayNonce, pKeyAuth,
2580							       pTransAuth, pbLocality,
2581							       pulCurrentTicksSize,
2582							       prgbCurrentTicks, pulSignatureSize,
2583							       prgbSignature);
2584			break;
2585		default:
2586			break;
2587	}
2588
2589	put_table_entry(entry);
2590
2591	return result;
2592}
2593#endif
2594
2595#ifdef TSS_BUILD_NV
2596TSS_RESULT
2597RPC_NV_DefineOrReleaseSpace(TSS_HCONTEXT hContext,	/* in */
2598			    UINT32 cPubInfoSize,	/* in */
2599			    BYTE* pPubInfo,		/* in */
2600			    TCPA_ENCAUTH encAuth,	/* in */
2601			    TPM_AUTH* pAuth)		/* in, out */
2602{
2603	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2604	struct host_table_entry *entry = get_table_entry(hContext);
2605
2606	if (entry == NULL)
2607		return TSPERR(TSS_E_NO_CONNECTION);
2608
2609	switch (entry->type) {
2610		case CONNECTION_TYPE_TCP_PERSISTANT:
2611			result = RPC_NV_DefineOrReleaseSpace_TP(entry, cPubInfoSize, pPubInfo,
2612								encAuth, pAuth);
2613			break;
2614		default:
2615			break;
2616	}
2617
2618	put_table_entry(entry);
2619
2620	return result;
2621}
2622
2623TSS_RESULT
2624RPC_NV_WriteValue(TSS_HCONTEXT hContext,	/* in */
2625		  TSS_NV_INDEX hNVStore,	/* in */
2626		  UINT32 offset,		/* in */
2627		  UINT32 ulDataLength,		/* in */
2628		  BYTE* rgbDataToWrite,	/* in */
2629		  TPM_AUTH* privAuth)		/* in, out */
2630{
2631	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2632	struct host_table_entry *entry = get_table_entry(hContext);
2633
2634	if (entry == NULL)
2635		return TSPERR(TSS_E_NO_CONNECTION);
2636
2637	switch (entry->type) {
2638		case CONNECTION_TYPE_TCP_PERSISTANT:
2639			result = RPC_NV_WriteValue_TP(entry, hNVStore, offset, ulDataLength,
2640						      rgbDataToWrite, privAuth);
2641			break;
2642		default:
2643			break;
2644	}
2645
2646	put_table_entry(entry);
2647
2648	return result;
2649}
2650
2651
2652TSS_RESULT
2653RPC_NV_WriteValueAuth(TSS_HCONTEXT hContext,	/* in */
2654		      TSS_NV_INDEX hNVStore,		/* in */
2655		      UINT32 offset,			/* in */
2656		      UINT32 ulDataLength,		/* in */
2657		      BYTE* rgbDataToWrite,		/* in */
2658		      TPM_AUTH* NVAuth)		/* in, out */
2659{
2660
2661	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2662	struct host_table_entry *entry = get_table_entry(hContext);
2663
2664	if (entry == NULL)
2665		return TSPERR(TSS_E_NO_CONNECTION);
2666
2667	switch (entry->type) {
2668		case CONNECTION_TYPE_TCP_PERSISTANT:
2669			result = RPC_NV_WriteValueAuth_TP(entry, hNVStore, offset, ulDataLength,
2670							  rgbDataToWrite, NVAuth);
2671			break;
2672		default:
2673			break;
2674	}
2675
2676	put_table_entry(entry);
2677
2678	return result;
2679}
2680
2681
2682TSS_RESULT
2683RPC_NV_ReadValue(TSS_HCONTEXT hContext,	/* in */
2684		 TSS_NV_INDEX hNVStore,	/* in */
2685		 UINT32 offset,		/* in */
2686		 UINT32* pulDataLength,	/* in, out */
2687		 TPM_AUTH* privAuth,		/* in, out */
2688		 BYTE** rgbDataRead)		/* out */
2689{
2690
2691	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2692	struct host_table_entry *entry = get_table_entry(hContext);
2693
2694	if (entry == NULL)
2695		return TSPERR(TSS_E_NO_CONNECTION);
2696
2697	switch (entry->type) {
2698		case CONNECTION_TYPE_TCP_PERSISTANT:
2699			result = RPC_NV_ReadValue_TP(entry, hNVStore, offset, pulDataLength,
2700						     privAuth, rgbDataRead);
2701			break;
2702		default:
2703			break;
2704	}
2705
2706	put_table_entry(entry);
2707
2708	return result;
2709}
2710
2711TSS_RESULT
2712RPC_NV_ReadValueAuth(TSS_HCONTEXT hContext,	/* in */
2713		     TSS_NV_INDEX hNVStore,    /* in */
2714		     UINT32 offset,		/* in */
2715		     UINT32* pulDataLength,    /* in, out */
2716		     TPM_AUTH* NVAuth,		/* in, out */
2717		     BYTE** rgbDataRead)       /* out */
2718{
2719	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2720	struct host_table_entry *entry = get_table_entry(hContext);
2721
2722	if (entry == NULL)
2723		return TSPERR(TSS_E_NO_CONNECTION);
2724
2725	switch (entry->type) {
2726		case CONNECTION_TYPE_TCP_PERSISTANT:
2727			result = RPC_NV_ReadValueAuth_TP(entry, hNVStore, offset, pulDataLength,
2728							 NVAuth, rgbDataRead);
2729			break;
2730		default:
2731			break;
2732	}
2733
2734	put_table_entry(entry);
2735
2736	return result;
2737}
2738#endif
2739
2740#ifdef TSS_BUILD_AUDIT
2741TSS_RESULT
2742RPC_SetOrdinalAuditStatus(TSS_HCONTEXT hContext,	/* in */
2743			  TPM_AUTH *ownerAuth,		/* in/out */
2744			  UINT32 ulOrdinal,		/* in */
2745			  TSS_BOOL bAuditState)	/* in */
2746{
2747	TSS_RESULT result = TSS_SUCCESS;
2748	struct host_table_entry *entry = get_table_entry(hContext);
2749
2750	if (entry == NULL)
2751		return TSPERR(TSS_E_NO_CONNECTION);
2752
2753	switch (entry->type) {
2754		case CONNECTION_TYPE_TCP_PERSISTANT:
2755			result = RPC_SetOrdinalAuditStatus_TP(entry, ownerAuth, ulOrdinal,
2756							      bAuditState);
2757			break;
2758		default:
2759			break;
2760	}
2761
2762	put_table_entry(entry);
2763
2764	return result;
2765}
2766
2767TSS_RESULT
2768RPC_GetAuditDigest(TSS_HCONTEXT hContext,	/* in */
2769		   UINT32 startOrdinal,		/* in */
2770		   TPM_DIGEST *auditDigest,		/* out */
2771		   UINT32 *counterValueSize,		/* out */
2772		   BYTE **counterValue,		/* out */
2773		   TSS_BOOL *more,			/* out */
2774		   UINT32 *ordSize,			/* out */
2775		   UINT32 **ordList)			/* out */
2776{
2777	TSS_RESULT result = TSS_SUCCESS;
2778	struct host_table_entry *entry = get_table_entry(hContext);
2779
2780	if (entry == NULL)
2781		return TSPERR(TSS_E_NO_CONNECTION);
2782
2783	switch (entry->type) {
2784		case CONNECTION_TYPE_TCP_PERSISTANT:
2785			result = RPC_GetAuditDigest_TP(entry, startOrdinal, auditDigest,
2786						       counterValueSize, counterValue, more,
2787						       ordSize, ordList);
2788			break;
2789		default:
2790			break;
2791	}
2792
2793	put_table_entry(entry);
2794
2795	return result;
2796}
2797
2798TSS_RESULT
2799RPC_GetAuditDigestSigned(TSS_HCONTEXT hContext,		/* in */
2800			 TCS_KEY_HANDLE keyHandle,	/* in */
2801			 TSS_BOOL closeAudit,		/* in */
2802			 TPM_NONCE *antiReplay,		/* in */
2803			 TPM_AUTH *privAuth,		/* in/out */
2804			 UINT32 *counterValueSize,	/* out */
2805			 BYTE **counterValue,		/* out */
2806			 TPM_DIGEST *auditDigest,	/* out */
2807			 TPM_DIGEST *ordinalDigest,	/* out */
2808			 UINT32 *sigSize,		/* out */
2809			 BYTE **sig)			/* out */
2810{
2811	TSS_RESULT result = TSS_SUCCESS;
2812	struct host_table_entry *entry = get_table_entry(hContext);
2813
2814	if (entry == NULL)
2815		return TSPERR(TSS_E_NO_CONNECTION);
2816
2817	switch (entry->type) {
2818		case CONNECTION_TYPE_TCP_PERSISTANT:
2819			result = RPC_GetAuditDigestSigned_TP(entry, keyHandle, closeAudit,
2820							     antiReplay, privAuth,
2821							     counterValueSize, counterValue,
2822							     auditDigest, ordinalDigest,
2823							     sigSize, sig);
2824			break;
2825		default:
2826			break;
2827	}
2828
2829	put_table_entry(entry);
2830
2831	return result;
2832}
2833#endif
2834
2835#ifdef TSS_BUILD_TSS12
2836TSS_RESULT
2837RPC_SetOperatorAuth(TSS_HCONTEXT hContext,	/* in */
2838		    TCPA_SECRET *operatorAuth)		/* in */
2839{
2840	TSS_RESULT result = TSS_SUCCESS;
2841	struct host_table_entry *entry = get_table_entry(hContext);
2842
2843	if (entry == NULL)
2844		return TSPERR(TSS_E_NO_CONNECTION);
2845
2846	switch (entry->type) {
2847		case CONNECTION_TYPE_TCP_PERSISTANT:
2848			result = RPC_SetOperatorAuth_TP(entry, operatorAuth);
2849			break;
2850		default:
2851			break;
2852	}
2853
2854	put_table_entry(entry);
2855
2856	return result;
2857}
2858
2859TSS_RESULT
2860RPC_OwnerReadInternalPub(TSS_HCONTEXT hContext,	/* in */
2861			 TCS_KEY_HANDLE hKey,		/* in */
2862			 TPM_AUTH* pOwnerAuth,		/* in, out */
2863			 UINT32* punPubKeySize,	/* out */
2864			 BYTE** ppbPubKeyData)		/* out */
2865{
2866	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2867	struct host_table_entry *entry = get_table_entry(hContext);
2868
2869	if (entry == NULL)
2870		return TSPERR(TSS_E_NO_CONNECTION);
2871
2872	switch (entry->type) {
2873		case CONNECTION_TYPE_TCP_PERSISTANT:
2874			result = RPC_OwnerReadInternalPub_TP(entry, hKey, pOwnerAuth, punPubKeySize,
2875							     ppbPubKeyData);
2876			break;
2877		default:
2878			break;
2879	}
2880
2881	put_table_entry(entry);
2882
2883	return result;
2884}
2885#endif
2886
2887#ifdef TSS_BUILD_DELEGATION
2888TSS_RESULT
2889RPC_Delegate_Manage(TSS_HCONTEXT hContext,		/* in */
2890		    TPM_FAMILY_ID familyID,		/* in */
2891		    TPM_FAMILY_OPERATION opFlag,	/* in */
2892		    UINT32 opDataSize,			/* in */
2893		    BYTE *opData,			/* in */
2894		    TPM_AUTH *ownerAuth,		/* in, out */
2895		    UINT32 *retDataSize,		/* out */
2896		    BYTE **retData)			/* out */
2897{
2898	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2899	struct host_table_entry *entry = get_table_entry(hContext);
2900
2901	if (entry == NULL)
2902		return TSPERR(TSS_E_NO_CONNECTION);
2903
2904	switch (entry->type) {
2905		case CONNECTION_TYPE_TCP_PERSISTANT:
2906			result = RPC_Delegate_Manage_TP(entry, familyID, opFlag, opDataSize, opData,
2907							ownerAuth, retDataSize, retData);
2908			break;
2909		default:
2910			break;
2911	}
2912
2913	put_table_entry(entry);
2914
2915	return result;
2916}
2917
2918TSS_RESULT
2919RPC_Delegate_CreateKeyDelegation(TSS_HCONTEXT hContext,		/* in */
2920				 TCS_KEY_HANDLE hKey,		/* in */
2921				 UINT32 publicInfoSize,		/* in */
2922				 BYTE *publicInfo,		/* in */
2923				 TPM_ENCAUTH *encDelAuth,	/* in */
2924				 TPM_AUTH *keyAuth,		/* in, out */
2925				 UINT32 *blobSize,		/* out */
2926				 BYTE **blob)			/* out */
2927{
2928	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2929	struct host_table_entry *entry = get_table_entry(hContext);
2930
2931	if (entry == NULL)
2932		return TSPERR(TSS_E_NO_CONNECTION);
2933
2934	switch (entry->type) {
2935		case CONNECTION_TYPE_TCP_PERSISTANT:
2936			result = RPC_Delegate_CreateKeyDelegation_TP(entry, hKey, publicInfoSize,
2937								     publicInfo, encDelAuth,
2938								     keyAuth, blobSize, blob);
2939			break;
2940		default:
2941			break;
2942	}
2943
2944	put_table_entry(entry);
2945
2946	return result;
2947}
2948
2949TSS_RESULT
2950RPC_Delegate_CreateOwnerDelegation(TSS_HCONTEXT hContext,	/* in */
2951				   TSS_BOOL increment,		/* in */
2952				   UINT32 publicInfoSize,	/* in */
2953				   BYTE *publicInfo,		/* in */
2954				   TPM_ENCAUTH *encDelAuth,	/* in */
2955				   TPM_AUTH *ownerAuth,		/* in, out */
2956				   UINT32 *blobSize,		/* out */
2957				   BYTE **blob)			/* out */
2958{
2959	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2960	struct host_table_entry *entry = get_table_entry(hContext);
2961
2962	if (entry == NULL)
2963		return TSPERR(TSS_E_NO_CONNECTION);
2964
2965	switch (entry->type) {
2966		case CONNECTION_TYPE_TCP_PERSISTANT:
2967			result = RPC_Delegate_CreateOwnerDelegation_TP(entry, increment,
2968								       publicInfoSize, publicInfo,
2969								       encDelAuth, ownerAuth,
2970								       blobSize, blob);
2971			break;
2972		default:
2973			break;
2974	}
2975
2976	put_table_entry(entry);
2977
2978	return result;
2979}
2980
2981TSS_RESULT
2982RPC_Delegate_LoadOwnerDelegation(TSS_HCONTEXT hContext,	/* in */
2983				 TPM_DELEGATE_INDEX index,	/* in */
2984				 UINT32 blobSize,		/* in */
2985				 BYTE *blob,			/* in */
2986				 TPM_AUTH *ownerAuth)		/* in, out */
2987{
2988	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
2989	struct host_table_entry *entry = get_table_entry(hContext);
2990
2991	if (entry == NULL)
2992		return TSPERR(TSS_E_NO_CONNECTION);
2993
2994	switch (entry->type) {
2995		case CONNECTION_TYPE_TCP_PERSISTANT:
2996			result = RPC_Delegate_LoadOwnerDelegation_TP(entry, index, blobSize, blob,
2997								     ownerAuth);
2998			break;
2999		default:
3000			break;
3001	}
3002
3003	put_table_entry(entry);
3004
3005	return result;
3006}
3007
3008TSS_RESULT
3009RPC_Delegate_ReadTable(TSS_HCONTEXT hContext,		/* in */
3010		       UINT32 *familyTableSize,		/* out */
3011		       BYTE **familyTable,		/* out */
3012		       UINT32 *delegateTableSize,	/* out */
3013		       BYTE **delegateTable)		/* out */
3014{
3015	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3016	struct host_table_entry *entry = get_table_entry(hContext);
3017
3018	if (entry == NULL)
3019		return TSPERR(TSS_E_NO_CONNECTION);
3020
3021	switch (entry->type) {
3022		case CONNECTION_TYPE_TCP_PERSISTANT:
3023			result = RPC_Delegate_ReadTable_TP(entry, familyTableSize, familyTable,
3024							   delegateTableSize, delegateTable);
3025			break;
3026		default:
3027			break;
3028	}
3029
3030	put_table_entry(entry);
3031
3032	return result;
3033}
3034
3035TSS_RESULT
3036RPC_Delegate_UpdateVerificationCount(TSS_HCONTEXT hContext,	/* in */
3037				     UINT32 inputSize,		/* in */
3038				     BYTE *input,		/* in */
3039				     TPM_AUTH *ownerAuth,	/* in, out */
3040				     UINT32 *outputSize,	/* out */
3041				     BYTE **output)		/* out */
3042{
3043	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3044	struct host_table_entry *entry = get_table_entry(hContext);
3045
3046	if (entry == NULL)
3047		return TSPERR(TSS_E_NO_CONNECTION);
3048
3049	switch (entry->type) {
3050		case CONNECTION_TYPE_TCP_PERSISTANT:
3051			result = RPC_Delegate_UpdateVerificationCount_TP(entry, inputSize, input,
3052									 ownerAuth, outputSize,
3053									 output);
3054			break;
3055		default:
3056			break;
3057	}
3058
3059	put_table_entry(entry);
3060
3061	return result;
3062}
3063
3064TSS_RESULT
3065RPC_Delegate_VerifyDelegation(TSS_HCONTEXT hContext,	/* in */
3066			      UINT32 delegateSize,	/* in */
3067			      BYTE *delegate)		/* in */
3068{
3069	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3070	struct host_table_entry *entry = get_table_entry(hContext);
3071
3072	if (entry == NULL)
3073		return TSPERR(TSS_E_NO_CONNECTION);
3074
3075	switch (entry->type) {
3076		case CONNECTION_TYPE_TCP_PERSISTANT:
3077			result = RPC_Delegate_VerifyDelegation_TP(entry, delegateSize, delegate);
3078			break;
3079		default:
3080			break;
3081	}
3082
3083	put_table_entry(entry);
3084
3085	return result;
3086}
3087
3088TSS_RESULT
3089RPC_DSAP(TSS_HCONTEXT hContext,		/* in */
3090	 TPM_ENTITY_TYPE entityType,	/* in */
3091	 TCS_KEY_HANDLE keyHandle,	/* in */
3092	 TPM_NONCE *nonceOddDSAP,	/* in */
3093	 UINT32 entityValueSize,	/* in */
3094	 BYTE * entityValue,		/* in */
3095	 TCS_AUTHHANDLE *authHandle,	/* out */
3096	 TPM_NONCE *nonceEven,		/* out */
3097	 TPM_NONCE *nonceEvenDSAP)	/* out */
3098{
3099	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3100	struct host_table_entry *entry = get_table_entry(hContext);
3101
3102	if (entry == NULL)
3103		return TSPERR(TSS_E_NO_CONNECTION);
3104
3105	switch (entry->type) {
3106		case CONNECTION_TYPE_TCP_PERSISTANT:
3107			result = RPC_DSAP_TP(entry, entityType, keyHandle, nonceOddDSAP,
3108					     entityValueSize, entityValue, authHandle, nonceEven,
3109					     nonceEvenDSAP);
3110			break;
3111		default:
3112			break;
3113	}
3114
3115	put_table_entry(entry);
3116
3117	return result;
3118}
3119
3120#endif
3121
3122#ifdef TSS_BUILD_CMK
3123TSS_RESULT
3124RPC_CMK_SetRestrictions(TSS_HCONTEXT hContext,	/* in */
3125			TSS_CMK_DELEGATE restriction,	/* in */
3126			TPM_AUTH *ownerAuth)		/* in, out */
3127{
3128	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3129	struct host_table_entry *entry = get_table_entry(hContext);
3130
3131	if (entry == NULL)
3132		return TSPERR(TSS_E_NO_CONNECTION);
3133
3134	switch (entry->type) {
3135		case CONNECTION_TYPE_TCP_PERSISTANT:
3136			result = RPC_CMK_SetRestrictions_TP(entry, restriction, ownerAuth);
3137			break;
3138		default:
3139			break;
3140	}
3141
3142	put_table_entry(entry);
3143
3144	return result;
3145}
3146
3147TSS_RESULT
3148RPC_CMK_ApproveMA(TSS_HCONTEXT hContext,		/* in */
3149		  TPM_DIGEST migAuthorityDigest,	/* in */
3150		  TPM_AUTH *ownerAuth,			/* in, out */
3151		  TPM_HMAC *migAuthorityApproval)	/* out */
3152{
3153	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3154	struct host_table_entry *entry = get_table_entry(hContext);
3155
3156	if (entry == NULL)
3157		return TSPERR(TSS_E_NO_CONNECTION);
3158
3159	switch (entry->type) {
3160		case CONNECTION_TYPE_TCP_PERSISTANT:
3161			result = RPC_CMK_ApproveMA_TP(entry, migAuthorityDigest, ownerAuth,
3162					migAuthorityApproval);
3163			break;
3164		default:
3165			break;
3166	}
3167
3168	put_table_entry(entry);
3169
3170	return result;
3171}
3172
3173TSS_RESULT
3174RPC_CMK_CreateKey(TSS_HCONTEXT hContext,		/* in */
3175		  TCS_KEY_HANDLE hWrappingKey,		/* in */
3176		  TPM_ENCAUTH *keyUsageAuth,		/* in */
3177		  TPM_HMAC *migAuthorityApproval,	/* in */
3178		  TPM_DIGEST *migAuthorityDigest,	/* in */
3179		  UINT32 *keyDataSize,			/* in, out */
3180		  BYTE **keyData,			/* in, out */
3181		  TPM_AUTH *pAuth)			/* in, out */
3182{
3183	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3184	struct host_table_entry *entry = get_table_entry(hContext);
3185
3186	if (entry == NULL)
3187		return TSPERR(TSS_E_NO_CONNECTION);
3188
3189	switch (entry->type) {
3190		case CONNECTION_TYPE_TCP_PERSISTANT:
3191			result = RPC_CMK_CreateKey_TP(entry, hWrappingKey, keyUsageAuth,
3192					migAuthorityApproval, migAuthorityDigest, keyDataSize,
3193					keyData, pAuth);
3194			break;
3195		default:
3196			break;
3197	}
3198
3199	put_table_entry(entry);
3200
3201	return result;
3202}
3203
3204TSS_RESULT
3205RPC_CMK_CreateTicket(TSS_HCONTEXT hContext,	/* in */
3206		     UINT32 publicVerifyKeySize,	/* in */
3207		     BYTE *publicVerifyKey,		/* in */
3208		     TPM_DIGEST signedData,		/* in */
3209		     UINT32 sigValueSize,		/* in */
3210		     BYTE *sigValue,			/* in */
3211		     TPM_AUTH *ownerAuth,		/* in, out */
3212		     TPM_HMAC *sigTicket)		/* out */
3213{
3214	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3215	struct host_table_entry *entry = get_table_entry(hContext);
3216
3217	if (entry == NULL)
3218		return TSPERR(TSS_E_NO_CONNECTION);
3219
3220	switch (entry->type) {
3221		case CONNECTION_TYPE_TCP_PERSISTANT:
3222			result = RPC_CMK_CreateTicket_TP(entry, publicVerifyKeySize,
3223					publicVerifyKey, signedData, sigValueSize, sigValue,
3224					ownerAuth, sigTicket);
3225			break;
3226		default:
3227			break;
3228	}
3229
3230	put_table_entry(entry);
3231
3232	return result;
3233}
3234
3235TSS_RESULT
3236RPC_CMK_CreateBlob(TSS_HCONTEXT hContext,	/* in */
3237		   TCS_KEY_HANDLE hParentKey,		/* in */
3238		   TSS_MIGRATE_SCHEME migrationType,	/* in */
3239		   UINT32 migKeyAuthSize,		/* in */
3240		   BYTE *migKeyAuth,			/* in */
3241		   TPM_DIGEST pubSourceKeyDigest,	/* in */
3242		   UINT32 msaListSize,			/* in */
3243		   BYTE *msaList,			/* in */
3244		   UINT32 restrictTicketSize,		/* in */
3245		   BYTE *restrictTicket,		/* in */
3246		   UINT32 sigTicketSize,		/* in */
3247		   BYTE *sigTicket,			/* in */
3248		   UINT32 encDataSize,			/* in */
3249		   BYTE *encData,			/* in */
3250		   TPM_AUTH *pAuth,			/* in, out */
3251		   UINT32 *randomSize,			/* out */
3252		   BYTE **random,			/* out */
3253		   UINT32 *outDataSize,			/* out */
3254		   BYTE **outData)			/* out */
3255{
3256	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3257	struct host_table_entry *entry = get_table_entry(hContext);
3258
3259	if (entry == NULL)
3260		return TSPERR(TSS_E_NO_CONNECTION);
3261
3262	switch (entry->type) {
3263		case CONNECTION_TYPE_TCP_PERSISTANT:
3264			result = RPC_CMK_CreateBlob_TP(entry, hParentKey, migrationType,
3265					migKeyAuthSize, migKeyAuth, pubSourceKeyDigest,
3266					msaListSize, msaList, restrictTicketSize, restrictTicket,
3267					sigTicketSize, sigTicket, encDataSize, encData, pAuth,
3268					randomSize, random, outDataSize, outData);
3269			break;
3270		default:
3271			break;
3272	}
3273
3274	put_table_entry(entry);
3275
3276	return result;
3277}
3278
3279TSS_RESULT
3280RPC_CMK_ConvertMigration(TSS_HCONTEXT hContext,	/* in */
3281			 TCS_KEY_HANDLE hParentHandle,	/* in */
3282			 TPM_CMK_AUTH restrictTicket,	/* in */
3283			 TPM_HMAC sigTicket,		/* in */
3284			 UINT32 keyDataSize,		/* in */
3285			 BYTE *keyData,			/* in */
3286			 UINT32 msaListSize,		/* in */
3287			 BYTE *msaList,			/* in */
3288			 UINT32 randomSize,		/* in */
3289			 BYTE *random,			/* in */
3290			 TPM_AUTH *pAuth,		/* in, out */
3291			 UINT32 *outDataSize,		/* out */
3292			 BYTE **outData)		/* out */
3293{
3294	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3295	struct host_table_entry *entry = get_table_entry(hContext);
3296
3297	if (entry == NULL)
3298		return TSPERR(TSS_E_NO_CONNECTION);
3299
3300	switch (entry->type) {
3301		case CONNECTION_TYPE_TCP_PERSISTANT:
3302			result = RPC_CMK_ConvertMigration_TP(entry, hParentHandle, restrictTicket,
3303					sigTicket, keyDataSize, keyData, msaListSize, msaList,
3304					randomSize, random, pAuth, outDataSize, outData);
3305			break;
3306		default:
3307			break;
3308	}
3309
3310	put_table_entry(entry);
3311
3312	return result;
3313}
3314#endif
3315
3316#ifdef TSS_BUILD_TSS12
3317TSS_RESULT
3318RPC_FlushSpecific(TSS_HCONTEXT hContext, /* in */
3319		  TCS_HANDLE hResHandle, /* in */
3320		  TPM_RESOURCE_TYPE resourceType) /* in */
3321{
3322	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3323	struct host_table_entry *entry = get_table_entry(hContext);
3324
3325	if (entry == NULL)
3326		return TSPERR(TSS_E_NO_CONNECTION);
3327
3328	switch (entry->type) {
3329		case CONNECTION_TYPE_TCP_PERSISTANT:
3330			result = RPC_FlushSpecific_TP(entry, hResHandle, resourceType);
3331			break;
3332		default:
3333			break;
3334	}
3335
3336	put_table_entry(entry);
3337
3338	return result;
3339}
3340
3341TSS_RESULT
3342RPC_KeyControlOwner(TCS_CONTEXT_HANDLE hContext,		/* in */
3343		    TCS_KEY_HANDLE     hKey,			/* in */
3344		    UINT32             ulPublicInfoLength,	/* in */
3345		    BYTE*              rgbPublicInfo,		/* in */
3346		    UINT32             attribName,		/* in */
3347		    TSS_BOOL           attribValue,		/* in */
3348		    TPM_AUTH*          pOwnerAuth,		/* in, out */
3349		    TSS_UUID*          pUuidData)		/* out */
3350
3351{
3352	TSS_RESULT result = (TSS_E_INTERNAL_ERROR | TSS_LAYER_TSP);
3353	struct host_table_entry *entry = get_table_entry(hContext);
3354
3355	if (entry == NULL)
3356		return TSPERR(TSS_E_NO_CONNECTION);
3357
3358	switch (entry->type) {
3359		case CONNECTION_TYPE_TCP_PERSISTANT:
3360			result = RPC_KeyControlOwner_TP(entry, hKey,
3361							ulPublicInfoLength,
3362							rgbPublicInfo,
3363							attribName,
3364							attribValue,
3365							pOwnerAuth,
3366							pUuidData);
3367			break;
3368		default:
3369			break;
3370	}
3371
3372	put_table_entry(entry);
3373
3374	return result;
3375}
3376#endif
3377
3378