xref: /netbsd-src/crypto/external/cpl/trousers/dist/src/include/rpc_tcstp_tcs.h (revision 1023804e3833a0bd94414f2545512128f6502c74)
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 #ifndef _RPC_TCSTP_TCS_H_
12 #define _RPC_TCSTP_TCS_H_
13 
14 #include "rpc_tcstp.h"
15 
16 #define DECLARE_TCSTP_FUNC(x) \
17 	TSS_RESULT tcs_wrap_##x(struct tcsd_thread_data *)
18 /* Auth session, context and TPM caps support are always compiled in. TPM caps
19  * are necessary so that the TCSD can know what type of TPM its talking to */
20 DECLARE_TCSTP_FUNC(OpenContext);
21 DECLARE_TCSTP_FUNC(CloseContext);
22 DECLARE_TCSTP_FUNC(OIAP);
23 DECLARE_TCSTP_FUNC(OSAP);
24 DECLARE_TCSTP_FUNC(GetCapability);
25 DECLARE_TCSTP_FUNC(GetCapabilityOwner);
26 DECLARE_TCSTP_FUNC(SetCapability);
27 
28 #ifdef TSS_BUILD_RANDOM
29 DECLARE_TCSTP_FUNC(GetRandom);
30 DECLARE_TCSTP_FUNC(StirRandom);
31 #else
32 #define tcs_wrap_GetRandom	tcs_wrap_Error
33 #define tcs_wrap_StirRandom	tcs_wrap_Error
34 #endif
35 
36 #ifdef TSS_BUILD_EK
37 DECLARE_TCSTP_FUNC(CreateEndorsementKeyPair);
38 DECLARE_TCSTP_FUNC(ReadPubek);
39 DECLARE_TCSTP_FUNC(OwnerReadPubek);
40 DECLARE_TCSTP_FUNC(DisablePubekRead);
41 #ifdef TSS_BUILD_TSS12
42 DECLARE_TCSTP_FUNC(CreateRevocableEndorsementKeyPair);
43 DECLARE_TCSTP_FUNC(RevokeEndorsementKeyPair);
44 #else
45 #define tcs_wrap_CreateRevocableEndorsementKeyPair	tcs_wrap_Error
46 #define tcs_wrap_RevokeEndorsementKeyPair		tcs_wrap_Error
47 #endif
48 #else
49 #define tcs_wrap_CreateEndorsementKeyPair		tcs_wrap_Error
50 #define tcs_wrap_ReadPubek				tcs_wrap_Error
51 #define tcs_wrap_OwnerReadPubek				tcs_wrap_Error
52 #define tcs_wrap_DisablePubekRead			tcs_wrap_Error
53 #define tcs_wrap_CreateRevocableEndorsementKeyPair	tcs_wrap_Error
54 #define tcs_wrap_RevokeEndorsementKeyPair		tcs_wrap_Error
55 #endif
56 
57 #ifdef TSS_BUILD_KEY
58 DECLARE_TCSTP_FUNC(EvictKey);
59 DECLARE_TCSTP_FUNC(GetPubkey);
60 DECLARE_TCSTP_FUNC(TerminateHandle);
61 DECLARE_TCSTP_FUNC(LoadKeyByBlob);
62 DECLARE_TCSTP_FUNC(CreateWrapKey);
63 #ifdef TSS_BUILD_TSS12
64 DECLARE_TCSTP_FUNC(KeyControlOwner);
65 DECLARE_TCSTP_FUNC(OwnerReadInternalPub);
66 #else
67 #define tcs_wrap_KeyControlOwner	tcs_wrap_Error
68 #define tcs_wrap_OwnerReadInternalPub	tcs_wrap_Error
69 #endif
70 #else
71 #define tcs_wrap_EvictKey		tcs_wrap_Error
72 #define tcs_wrap_GetPubkey		tcs_wrap_Error
73 #define tcs_wrap_TerminateHandle	tcs_wrap_Error
74 #define tcs_wrap_LoadKeyByBlob		tcs_wrap_Error
75 #define tcs_wrap_CreateWrapKey		tcs_wrap_Error
76 #define tcs_wrap_KeyControlOwner	tcs_wrap_Error
77 
78 #endif
79 
80 #ifdef TSS_BUILD_PCR_EXTEND
81 DECLARE_TCSTP_FUNC(Extend);
82 DECLARE_TCSTP_FUNC(PcrRead);
83 DECLARE_TCSTP_FUNC(PcrReset);
84 #else
85 #define tcs_wrap_Extend		tcs_wrap_Error
86 #define tcs_wrap_PcrRead	tcs_wrap_Error
87 #define tcs_wrap_PcrReset	tcs_wrap_Error
88 #endif
89 
90 #ifdef TSS_BUILD_CAPS
91 DECLARE_TCSTP_FUNC(TCSGetCapability);
92 #else
93 #define tcs_wrap_TCSGetCapability	tcs_wrap_Error
94 #endif
95 
96 #ifdef TSS_BUILD_OWN
97 DECLARE_TCSTP_FUNC(TakeOwnership);
98 DECLARE_TCSTP_FUNC(OwnerClear);
99 #else
100 #define tcs_wrap_TakeOwnership	tcs_wrap_Error
101 #define tcs_wrap_OwnerClear	tcs_wrap_Error
102 #endif
103 
104 #ifdef TSS_BUILD_PS
105 DECLARE_TCSTP_FUNC(RegisterKey);
106 DECLARE_TCSTP_FUNC(UnregisterKey);
107 DECLARE_TCSTP_FUNC(GetRegisteredKeyBlob);
108 DECLARE_TCSTP_FUNC(LoadKeyByUUID);
109 DECLARE_TCSTP_FUNC(GetRegisteredKeyByPublicInfo);
110 DECLARE_TCSTP_FUNC(EnumRegisteredKeys);
111 DECLARE_TCSTP_FUNC(EnumRegisteredKeys2);
112 #else
113 #define tcs_wrap_RegisterKey			tcs_wrap_Error
114 #define tcs_wrap_UnregisterKey			tcs_wrap_Error
115 #define tcs_wrap_GetRegisteredKeyBlob		tcs_wrap_Error
116 #define tcs_wrap_LoadKeyByUUID			tcs_wrap_Error
117 #define tcs_wrap_GetRegisteredKeyByPublicInfo	tcs_wrap_Error
118 #define tcs_wrap_EnumRegisteredKeys		tcs_wrap_Error
119 #define tcs_wrap_EnumRegisteredKeys2	tcs_wrap_Error
120 #endif
121 
122 #ifdef TSS_BUILD_SIGN
123 DECLARE_TCSTP_FUNC(Sign);
124 #else
125 #define tcs_wrap_Sign	tcs_wrap_Error
126 #endif
127 
128 #ifdef TSS_BUILD_DIR
129 DECLARE_TCSTP_FUNC(DirWriteAuth);
130 DECLARE_TCSTP_FUNC(DirRead);
131 #else
132 #define tcs_wrap_DirWriteAuth	tcs_wrap_Error
133 #define tcs_wrap_DirRead	tcs_wrap_Error
134 #endif
135 
136 #ifdef TSS_BUILD_SEAL
137 DECLARE_TCSTP_FUNC(Seal);
138 DECLARE_TCSTP_FUNC(UnSeal);
139 #else
140 #define tcs_wrap_Seal	tcs_wrap_Error
141 #define tcs_wrap_UnSeal	tcs_wrap_Error
142 #endif
143 
144 #ifdef TSS_BUILD_SEALX
145 DECLARE_TCSTP_FUNC(Sealx);
146 #else
147 #define tcs_wrap_Sealx	tcs_wrap_Error
148 #endif
149 
150 #ifdef TSS_BUILD_BIND
151 DECLARE_TCSTP_FUNC(UnBind);
152 #else
153 #define tcs_wrap_UnBind	tcs_wrap_Error
154 #endif
155 
156 #ifdef TSS_BUILD_CHANGEAUTH
157 DECLARE_TCSTP_FUNC(ChangeAuth);
158 DECLARE_TCSTP_FUNC(ChangeAuthOwner);
159 #else
160 #define tcs_wrap_ChangeAuth		tcs_wrap_Error
161 #define tcs_wrap_ChangeAuthOwner	tcs_wrap_Error
162 #endif
163 
164 #ifdef TSS_BUILD_QUOTE
165 DECLARE_TCSTP_FUNC(Quote);
166 #else
167 #define tcs_wrap_Quote	tcs_wrap_Error
168 #endif
169 
170 #ifdef TSS_BUILD_QUOTE2
171 DECLARE_TCSTP_FUNC(Quote2);
172 #else
173 #define tcs_wrap_Quote2		tcs_wrap_Error
174 #endif
175 
176 #ifdef TSS_BUILD_PCR_EVENTS
177 DECLARE_TCSTP_FUNC(LogPcrEvent);
178 DECLARE_TCSTP_FUNC(GetPcrEvent);
179 DECLARE_TCSTP_FUNC(GetPcrEventsByPcr);
180 DECLARE_TCSTP_FUNC(GetPcrEventLog);
181 #else
182 #define tcs_wrap_LogPcrEvent		tcs_wrap_Error
183 #define tcs_wrap_GetPcrEvent		tcs_wrap_Error
184 #define tcs_wrap_GetPcrEventsByPcr	tcs_wrap_Error
185 #define tcs_wrap_GetPcrEventLog		tcs_wrap_Error
186 #endif
187 
188 #ifdef TSS_BUILD_SELFTEST
189 DECLARE_TCSTP_FUNC(SelfTestFull);
190 DECLARE_TCSTP_FUNC(CertifySelfTest);
191 DECLARE_TCSTP_FUNC(GetTestResult);
192 #else
193 #define tcs_wrap_SelfTestFull		tcs_wrap_Error
194 #define tcs_wrap_CertifySelfTest	tcs_wrap_Error
195 #define tcs_wrap_GetTestResult		tcs_wrap_Error
196 #endif
197 
198 #ifdef TSS_BUILD_ADMIN
199 DECLARE_TCSTP_FUNC(DisableOwnerClear);
200 DECLARE_TCSTP_FUNC(ForceClear);
201 DECLARE_TCSTP_FUNC(DisableForceClear);
202 DECLARE_TCSTP_FUNC(PhysicalEnable);
203 DECLARE_TCSTP_FUNC(PhysicalSetDeactivated);
204 DECLARE_TCSTP_FUNC(SetOwnerInstall);
205 DECLARE_TCSTP_FUNC(OwnerSetDisable);
206 DECLARE_TCSTP_FUNC(PhysicalDisable);
207 DECLARE_TCSTP_FUNC(PhysicalPresence);
208 DECLARE_TCSTP_FUNC(SetTempDeactivated);
209 #ifdef TSS_BUILD_TSS12
210 DECLARE_TCSTP_FUNC(SetTempDeactivated2);
211 DECLARE_TCSTP_FUNC(ResetLockValue);
212 #else
213 #define tcs_wrap_SetTempDeactivated2	tcs_wrap_Error
214 #define tcs_wrap_ResetLockValue		tcs_wrap_Error
215 #endif
216 #else
217 #define tcs_wrap_DisableOwnerClear	tcs_wrap_Error
218 #define tcs_wrap_ForceClear		tcs_wrap_Error
219 #define tcs_wrap_DisableForceClear	tcs_wrap_Error
220 #define tcs_wrap_PhysicalEnable		tcs_wrap_Error
221 #define tcs_wrap_PhysicalSetDeactivated	tcs_wrap_Error
222 #define tcs_wrap_SetOwnerInstall	tcs_wrap_Error
223 #define tcs_wrap_OwnerSetDisable	tcs_wrap_Error
224 #define tcs_wrap_PhysicalDisable	tcs_wrap_Error
225 #define tcs_wrap_PhysicalPresence	tcs_wrap_Error
226 #define tcs_wrap_SetTempDeactivated	tcs_wrap_Error
227 #define tcs_wrap_SetTempDeactivated2	tcs_wrap_Error
228 #define tcs_wrap_ResetLockValue		tcs_wrap_Error
229 #endif
230 
231 #ifdef TSS_BUILD_CERTIFY
232 DECLARE_TCSTP_FUNC(CertifyKey);
233 #else
234 #define tcs_wrap_CertifyKey	tcs_wrap_Error
235 #endif
236 
237 #ifdef TSS_BUILD_AIK
238 DECLARE_TCSTP_FUNC(MakeIdentity);
239 DECLARE_TCSTP_FUNC(ActivateIdentity);
240 #ifdef TSS_BUILD_TSS12
241 DECLARE_TCSTP_FUNC(GetCredential);
242 #else
243 #define tcs_wrap_GetCredential		tcs_wrap_Error
244 #endif
245 #else
246 #define tcs_wrap_MakeIdentity		tcs_wrap_Error
247 #define tcs_wrap_ActivateIdentity	tcs_wrap_Error
248 #define tcs_wrap_GetCredential		tcs_wrap_Error
249 #endif
250 
251 #ifdef TSS_BUILD_MIGRATION
252 DECLARE_TCSTP_FUNC(CreateMigrationBlob);
253 DECLARE_TCSTP_FUNC(ConvertMigrationBlob);
254 DECLARE_TCSTP_FUNC(AuthorizeMigrationKey);
255 #else
256 #define tcs_wrap_CreateMigrationBlob	tcs_wrap_Error
257 #define tcs_wrap_ConvertMigrationBlob	tcs_wrap_Error
258 #define tcs_wrap_AuthorizeMigrationKey	tcs_wrap_Error
259 #endif
260 
261 #ifdef TSS_BUILD_MAINT
262 DECLARE_TCSTP_FUNC(KillMaintenanceFeature);
263 DECLARE_TCSTP_FUNC(CreateMaintenanceArchive);
264 DECLARE_TCSTP_FUNC(LoadMaintenanceArchive);
265 DECLARE_TCSTP_FUNC(LoadManuMaintPub);
266 DECLARE_TCSTP_FUNC(ReadManuMaintPub);
267 #else
268 #define tcs_wrap_KillMaintenanceFeature		tcs_wrap_Error
269 #define tcs_wrap_CreateMaintenanceArchive	tcs_wrap_Error
270 #define tcs_wrap_LoadMaintenanceArchive		tcs_wrap_Error
271 #define tcs_wrap_LoadManuMaintPub		tcs_wrap_Error
272 #define tcs_wrap_ReadManuMaintPub		tcs_wrap_Error
273 #endif
274 
275 #ifdef TSS_BUILD_DAA
276 DECLARE_TCSTP_FUNC(DaaJoin);
277 DECLARE_TCSTP_FUNC(DaaSign);
278 #else
279 #define tcs_wrap_DaaJoin	tcs_wrap_Error
280 #define tcs_wrap_DaaSign	tcs_wrap_Error
281 #endif
282 
283 #ifdef TSS_BUILD_NV
284 DECLARE_TCSTP_FUNC(NV_DefineOrReleaseSpace);
285 DECLARE_TCSTP_FUNC(NV_WriteValue);
286 DECLARE_TCSTP_FUNC(NV_WriteValueAuth);
287 DECLARE_TCSTP_FUNC(NV_ReadValue);
288 DECLARE_TCSTP_FUNC(NV_ReadValueAuth);
289 #else
290 #define tcs_wrap_NV_DefineOrReleaseSpace      tcs_wrap_Error
291 #define tcs_wrap_NV_WriteValue                tcs_wrap_Error
292 #define tcs_wrap_NV_WriteValueAuth            tcs_wrap_Error
293 #define tcs_wrap_NV_ReadValue                 tcs_wrap_Error
294 #define tcs_wrap_NV_ReadValueAuth             tcs_wrap_Error
295 #endif
296 
297 #ifdef TSS_BUILD_COUNTER
298 DECLARE_TCSTP_FUNC(ReadCounter);
299 DECLARE_TCSTP_FUNC(CreateCounter);
300 DECLARE_TCSTP_FUNC(IncrementCounter);
301 DECLARE_TCSTP_FUNC(ReleaseCounter);
302 DECLARE_TCSTP_FUNC(ReleaseCounterOwner);
303 #else
304 #define tcs_wrap_ReadCounter		tcs_wrap_Error
305 #define tcs_wrap_CreateCounter		tcs_wrap_Error
306 #define tcs_wrap_IncrementCounter	tcs_wrap_Error
307 #define tcs_wrap_ReleaseCounter		tcs_wrap_Error
308 #define tcs_wrap_ReleaseCounterOwner	tcs_wrap_Error
309 #endif
310 
311 #ifdef TSS_BUILD_TICK
312 DECLARE_TCSTP_FUNC(ReadCurrentTicks);
313 DECLARE_TCSTP_FUNC(TickStampBlob);
314 #else
315 #define tcs_wrap_ReadCurrentTicks	tcs_wrap_Error
316 #define tcs_wrap_TickStampBlob		tcs_wrap_Error
317 #endif
318 
319 #ifdef TSS_BUILD_TRANSPORT
320 DECLARE_TCSTP_FUNC(EstablishTransport);
321 DECLARE_TCSTP_FUNC(ExecuteTransport);
322 DECLARE_TCSTP_FUNC(ReleaseTransportSigned);
323 #else
324 #define tcs_wrap_EstablishTransport	tcs_wrap_Error
325 #define tcs_wrap_ExecuteTransport	tcs_wrap_Error
326 #define tcs_wrap_ReleaseTransportSigned	tcs_wrap_Error
327 #endif
328 
329 #ifdef TSS_BUILD_AUDIT
330 DECLARE_TCSTP_FUNC(SetOrdinalAuditStatus);
331 DECLARE_TCSTP_FUNC(GetAuditDigest);
332 DECLARE_TCSTP_FUNC(GetAuditDigestSigned);
333 #else
334 #define tcs_wrap_SetOrdinalAuditStatus	tcs_wrap_Error
335 #define tcs_wrap_GetAuditDigest		tcs_wrap_Error
336 #define tcs_wrap_GetAuditDigestSigned	tcs_wrap_Error
337 #endif
338 
339 #ifdef TSS_BUILD_TSS12
340 DECLARE_TCSTP_FUNC(SetOperatorAuth);
341 DECLARE_TCSTP_FUNC(FlushSpecific);
342 #else
343 #define tcs_wrap_SetOperatorAuth	tcs_wrap_Error
344 #define tcs_wrap_FlushSpecific		tcs_wrap_Error
345 #endif
346 
347 #ifdef TSS_BUILD_DELEGATION
348 DECLARE_TCSTP_FUNC(Delegate_Manage);
349 DECLARE_TCSTP_FUNC(Delegate_CreateKeyDelegation);
350 DECLARE_TCSTP_FUNC(Delegate_CreateOwnerDelegation);
351 DECLARE_TCSTP_FUNC(Delegate_LoadOwnerDelegation);
352 DECLARE_TCSTP_FUNC(Delegate_ReadTable);
353 DECLARE_TCSTP_FUNC(Delegate_UpdateVerificationCount);
354 DECLARE_TCSTP_FUNC(Delegate_VerifyDelegation);
355 DECLARE_TCSTP_FUNC(DSAP);
356 #else
357 #define tcs_wrap_Delegate_Manage			tcs_wrap_Error
358 #define tcs_wrap_Delegate_CreateKeyDelegation		tcs_wrap_Error
359 #define tcs_wrap_Delegate_CreateOwnerDelegation		tcs_wrap_Error
360 #define tcs_wrap_Delegate_LoadOwnerDelegation		tcs_wrap_Error
361 #define tcs_wrap_Delegate_ReadTable			tcs_wrap_Error
362 #define tcs_wrap_Delegate_UpdateVerificationCount	tcs_wrap_Error
363 #define tcs_wrap_Delegate_VerifyDelegation		tcs_wrap_Error
364 #define tcs_wrap_DSAP					tcs_wrap_Error
365 #endif
366 
367 #ifdef TSS_BUILD_CMK
368 DECLARE_TCSTP_FUNC(CMK_SetRestrictions);
369 DECLARE_TCSTP_FUNC(CMK_ApproveMA);
370 DECLARE_TCSTP_FUNC(CMK_CreateKey);
371 DECLARE_TCSTP_FUNC(CMK_CreateTicket);
372 DECLARE_TCSTP_FUNC(CMK_CreateBlob);
373 DECLARE_TCSTP_FUNC(CMK_ConvertMigration);
374 #else
375 #define tcs_wrap_CMK_SetRestrictions	tcs_wrap_Error
376 #define tcs_wrap_CMK_ApproveMA		tcs_wrap_Error
377 #define tcs_wrap_CMK_CreateKey		tcs_wrap_Error
378 #define tcs_wrap_CMK_CreateTicket	tcs_wrap_Error
379 #define tcs_wrap_CMK_CreateBlob		tcs_wrap_Error
380 #define tcs_wrap_CMK_ConvertMigration	tcs_wrap_Error
381 #endif
382 
383 DECLARE_TCSTP_FUNC(dispatchCommand);
384 
385 void LoadBlob_Auth_Special(UINT64 *, BYTE *, TPM_AUTH *);
386 void UnloadBlob_Auth_Special(UINT64 *, BYTE *, TPM_AUTH *);
387 void LoadBlob_KM_KEYINFO(UINT64 *, BYTE *, TSS_KM_KEYINFO *);
388 void LoadBlob_KM_KEYINFO2(UINT64 *, BYTE *, TSS_KM_KEYINFO2 *);
389 void UnloadBlob_KM_KEYINFO(UINT64 *, BYTE *, TSS_KM_KEYINFO *);
390 void UnloadBlob_KM_KEYINFO2(UINT64 *, BYTE *, TSS_KM_KEYINFO2 *);
391 void LoadBlob_LOADKEY_INFO(UINT64 *, BYTE *, TCS_LOADKEY_INFO *);
392 void UnloadBlob_LOADKEY_INFO(UINT64 *, BYTE *, TCS_LOADKEY_INFO *);
393 void LoadBlob_PCR_EVENT(UINT64 *, BYTE *, TSS_PCR_EVENT *);
394 TSS_RESULT UnloadBlob_PCR_EVENT(UINT64 *, BYTE *, TSS_PCR_EVENT *);
395 int setData(TCSD_PACKET_TYPE, unsigned int, void *, int, struct tcsd_comm_data *);
396 UINT32 getData(TCSD_PACKET_TYPE, unsigned int, void *, int, struct tcsd_comm_data *);
397 void initData(struct tcsd_comm_data *, int);
398 int recv_from_socket(int, void *, int);
399 int send_to_socket(int, void *, int);
400 TSS_RESULT getTCSDPacket(struct tcsd_thread_data *);
401 
402 MUTEX_DECLARE_EXTERN(tcsp_lock);
403 
404 #endif
405 
406 
407