~ubuntu-branches/ubuntu/hardy/trousers/hardy-proposed

« back to all changes in this revision

Viewing changes to src/tcsd_api/calltcsapi.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-01-23 22:03:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080123220300-fhtqja3c0oq0gp6z
Tags: 0.3.1-4
* Added patch from Aaron M. Ucko <ucko@debian.org> to allow trousers to
  build successfully on amd64, and presumably also other 64-bit
  architectures (Closes: #457400).
* Including udev rule for /dev/tpm from William Lima
  <wlima.amadeus@gmail.com> as suggested by David Smith <dds@google.com>
  (Closes: #459682).
* Added lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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-2006
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 "spi_internal_types.h"
19
 
#include "spi_utils.h"
20
 
#include "hosttable.h"
21
 
#include "tsplog.h"
22
 
#include "trpctp.h"
23
 
#include "obj.h"
24
 
#include "tcsd.h"
25
 
 
26
 
 
27
 
TSS_RESULT
28
 
TCS_OpenContext_RPC(TSS_HCONTEXT tspContext, BYTE *host, int type)
29
 
{
30
 
        TSS_RESULT result;
31
 
        TCS_CONTEXT_HANDLE tcsContext;
32
 
        struct host_table_entry *entry;
33
 
 
34
 
        /* add_table_entry() will make sure an entry doesn't already exist for this tsp context */
35
 
        if ((result = add_table_entry(tspContext, host, type, &entry)))
36
 
                return result;
37
 
 
38
 
        switch (type) {
39
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
40
 
                        if ((result = TCS_OpenContext_RPC_TP(entry, &tcsContext)) == TSS_SUCCESS)
41
 
                                entry->tcsContext = tcsContext;
42
 
                        else
43
 
                                remove_table_entry(tspContext);
44
 
 
45
 
                        return result;
46
 
                default:
47
 
                        break;
48
 
        }
49
 
 
50
 
        return TSPERR(TSS_E_INTERNAL_ERROR);
51
 
}
52
 
 
53
 
TSS_RESULT TCSP_GetRegisteredKeyByPublicInfo(TSS_HCONTEXT hContext,
54
 
                                             TCPA_ALGORITHM_ID algID, /* in */
55
 
                                             UINT32 ulPublicInfoLength, /* in */
56
 
                                             BYTE * rgbPublicInfo, /* in */
57
 
                                             UINT32 * keySize, BYTE ** keyBlob)
58
 
{
59
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
60
 
        struct host_table_entry *entry = get_table_entry(hContext);
61
 
 
62
 
        if (entry == NULL)
63
 
                return TSPERR(TSS_E_NO_CONNECTION);
64
 
 
65
 
        switch (entry->type) {
66
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
67
 
                        result = TCSP_GetRegisteredKeyByPublicInfo_TP(entry, algID,
68
 
                                                                      ulPublicInfoLength,
69
 
                                                                      rgbPublicInfo, keySize,
70
 
                                                                      keyBlob);
71
 
                        break;
72
 
                default:
73
 
                        break;
74
 
        }
75
 
 
76
 
        put_table_entry(entry);
77
 
 
78
 
        return result;
79
 
}
80
 
 
81
 
TSS_RESULT TCS_CloseContext(TSS_HCONTEXT hContext)      /* in */
82
 
{
83
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
84
 
        struct host_table_entry *entry = get_table_entry(hContext);
85
 
 
86
 
        if (entry == NULL)
87
 
                return TSPERR(TSS_E_NO_CONNECTION);
88
 
 
89
 
        switch (entry->type) {
90
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
91
 
                        if ((result = TCS_CloseContext_TP(entry, hContext)) == TSS_SUCCESS) {
92
 
                                close(entry->socket);
93
 
                                remove_table_entry(hContext);
94
 
                        }
95
 
                        break;
96
 
                default:
97
 
                        break;
98
 
        }
99
 
 
100
 
        if (result != TSS_SUCCESS)
101
 
                put_table_entry(entry);
102
 
 
103
 
        return result;
104
 
}
105
 
 
106
 
TSS_RESULT TCS_FreeMemory(TSS_HCONTEXT hContext,        /* in */
107
 
                          BYTE * pMemory)       /* in */
108
 
{
109
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
110
 
        struct host_table_entry *entry = get_table_entry(hContext);
111
 
 
112
 
        if (entry == NULL)
113
 
                return TSPERR(TSS_E_NO_CONNECTION);
114
 
 
115
 
        switch (entry->type) {
116
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
117
 
                        result = TCS_FreeMemory_TP(entry, pMemory);
118
 
                        break;
119
 
                default:
120
 
                        break;
121
 
        }
122
 
 
123
 
        put_table_entry(entry);
124
 
 
125
 
        return result;
126
 
}
127
 
 
128
 
TSS_RESULT TCS_LogPcrEvent(TSS_HCONTEXT hContext,       /* in */
129
 
                           TSS_PCR_EVENT Event, /* in */
130
 
                           UINT32 * pNumber)    /* out */
131
 
{
132
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
133
 
        struct host_table_entry *entry = get_table_entry(hContext);
134
 
 
135
 
        if (entry == NULL)
136
 
                return TSPERR(TSS_E_NO_CONNECTION);
137
 
 
138
 
        switch (entry->type) {
139
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
140
 
                        result = TCS_LogPcrEvent_TP(entry, Event, pNumber);
141
 
                        break;
142
 
                default:
143
 
                        break;
144
 
        }
145
 
 
146
 
        put_table_entry(entry);
147
 
 
148
 
        return result;
149
 
}
150
 
 
151
 
TSS_RESULT TCS_GetPcrEvent(TSS_HCONTEXT hContext,       /* in */
152
 
                           UINT32 PcrIndex,     /* in */
153
 
                           UINT32 * pNumber,    /* in, out */
154
 
                           TSS_PCR_EVENT ** ppEvent)    /* out */
155
 
{
156
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
157
 
        struct host_table_entry *entry = get_table_entry(hContext);
158
 
 
159
 
        if (entry == NULL)
160
 
                return TSPERR(TSS_E_NO_CONNECTION);
161
 
 
162
 
        switch (entry->type) {
163
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
164
 
                result =
165
 
                        TCS_GetPcrEvent_TP(entry, PcrIndex, pNumber, ppEvent);
166
 
                        break;
167
 
                default:
168
 
                        break;
169
 
        }
170
 
 
171
 
        put_table_entry(entry);
172
 
 
173
 
        return result;
174
 
}
175
 
 
176
 
TSS_RESULT TCS_GetPcrEventsByPcr(TSS_HCONTEXT hContext, /* in */
177
 
                                 UINT32 PcrIndex,       /* in */
178
 
                                 UINT32 FirstEvent,     /* in */
179
 
                                 UINT32 * pEventCount,  /* in,out */
180
 
                                 TSS_PCR_EVENT ** ppEvents)     /* out */
181
 
{
182
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
183
 
        struct host_table_entry *entry = get_table_entry(hContext);
184
 
 
185
 
        if (entry == NULL)
186
 
                return TSPERR(TSS_E_NO_CONNECTION);
187
 
 
188
 
        switch (entry->type) {
189
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
190
 
                        result = TCS_GetPcrEventsByPcr_TP(entry, PcrIndex, FirstEvent,
191
 
                                                          pEventCount, ppEvents);
192
 
                        break;
193
 
                default:
194
 
                        break;
195
 
        }
196
 
 
197
 
        put_table_entry(entry);
198
 
 
199
 
        return result;
200
 
}
201
 
 
202
 
TSS_RESULT TCS_GetPcrEventLog(TSS_HCONTEXT hContext,    /* in */
203
 
                              UINT32 * pEventCount,     /* out */
204
 
                              TSS_PCR_EVENT ** ppEvents)        /* out */
205
 
{
206
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
207
 
        struct host_table_entry *entry = get_table_entry(hContext);
208
 
 
209
 
        if (entry == NULL)
210
 
                return TSPERR(TSS_E_NO_CONNECTION);
211
 
 
212
 
        switch (entry->type) {
213
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
214
 
                        result = TCS_GetPcrEventLog_TP(entry, pEventCount, ppEvents);
215
 
                        break;
216
 
                default:
217
 
                        break;
218
 
        }
219
 
 
220
 
        put_table_entry(entry);
221
 
 
222
 
        return result;
223
 
}
224
 
 
225
 
TSS_RESULT TCS_RegisterKey(TSS_HCONTEXT hContext,       /* in */
226
 
                           TSS_UUID WrappingKeyUUID,    /* in */
227
 
                           TSS_UUID KeyUUID,    /* in */
228
 
                           UINT32 cKeySize,     /* in */
229
 
                           BYTE * rgbKey,       /* in */
230
 
                           UINT32 cVendorData,  /* in */
231
 
                           BYTE * gbVendorData) /* in */
232
 
{
233
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
234
 
        struct host_table_entry *entry = get_table_entry(hContext);
235
 
 
236
 
        if (entry == NULL)
237
 
                return TSPERR(TSS_E_NO_CONNECTION);
238
 
 
239
 
        switch (entry->type) {
240
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
241
 
                        result = TCS_RegisterKey_TP(entry, WrappingKeyUUID, KeyUUID,
242
 
                                                    cKeySize, rgbKey, cVendorData, gbVendorData);
243
 
                        break;
244
 
                default:
245
 
                        break;
246
 
        }
247
 
 
248
 
        put_table_entry(entry);
249
 
 
250
 
        return result;
251
 
}
252
 
 
253
 
TSS_RESULT TCSP_UnregisterKey(TSS_HCONTEXT hContext,    /* in */
254
 
                              TSS_UUID KeyUUID) /* in */
255
 
{
256
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
257
 
        struct host_table_entry *entry = get_table_entry(hContext);
258
 
 
259
 
        if (entry == NULL)
260
 
                return TSPERR(TSS_E_NO_CONNECTION);
261
 
 
262
 
        switch (entry->type) {
263
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
264
 
                        result = TCSP_UnregisterKey_TP(entry, KeyUUID);
265
 
                        break;
266
 
                default:
267
 
                        break;
268
 
        }
269
 
 
270
 
        put_table_entry(entry);
271
 
 
272
 
        return result;
273
 
}
274
 
 
275
 
TSS_RESULT TCS_EnumRegisteredKeys(TSS_HCONTEXT hContext,        /* in */
276
 
                                  TSS_UUID * pKeyUUID,  /* in */
277
 
                                  UINT32 * pcKeyHierarchySize,  /* out */
278
 
                                  TSS_KM_KEYINFO ** ppKeyHierarchy)     /* out */
279
 
{
280
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
281
 
        struct host_table_entry *entry = get_table_entry(hContext);
282
 
 
283
 
        if (entry == NULL)
284
 
                return TSPERR(TSS_E_NO_CONNECTION);
285
 
 
286
 
        switch (entry->type) {
287
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
288
 
                        result = TCS_EnumRegisteredKeys_TP(entry, pKeyUUID,
289
 
                                                           pcKeyHierarchySize, ppKeyHierarchy);
290
 
                        break;
291
 
                default:
292
 
                        break;
293
 
        }
294
 
 
295
 
        put_table_entry(entry);
296
 
 
297
 
        return result;
298
 
}
299
 
 
300
 
TSS_RESULT TCS_GetRegisteredKey(TSS_HCONTEXT hContext,  /* in */
301
 
                                TSS_UUID KeyUUID,       /* in */
302
 
                                TSS_KM_KEYINFO ** ppKeyInfo)    /* out */
303
 
{
304
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
305
 
        struct host_table_entry *entry = get_table_entry(hContext);
306
 
 
307
 
        if (entry == NULL)
308
 
                return TSPERR(TSS_E_NO_CONNECTION);
309
 
 
310
 
        switch (entry->type) {
311
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
312
 
                        result = TCS_GetRegisteredKey_TP(entry, KeyUUID, ppKeyInfo);
313
 
                        break;
314
 
                default:
315
 
                        break;
316
 
        }
317
 
 
318
 
        put_table_entry(entry);
319
 
 
320
 
        return result;
321
 
}
322
 
 
323
 
TSS_RESULT TCS_GetRegisteredKeyBlob(TSS_HCONTEXT hContext,      /* in */
324
 
                                    TSS_UUID KeyUUID,   /* in */
325
 
                                    UINT32 * pcKeySize, /* out */
326
 
                                    BYTE ** prgbKey)    /* out */
327
 
{
328
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
329
 
        struct host_table_entry *entry = get_table_entry(hContext);
330
 
 
331
 
        if (entry == NULL)
332
 
                return TSPERR(TSS_E_NO_CONNECTION);
333
 
 
334
 
        switch (entry->type) {
335
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
336
 
                        result = TCS_GetRegisteredKeyBlob_TP(entry, KeyUUID, pcKeySize,
337
 
                                                             prgbKey);
338
 
                        break;
339
 
                default:
340
 
                        break;
341
 
        }
342
 
 
343
 
        put_table_entry(entry);
344
 
 
345
 
        return result;
346
 
}
347
 
 
348
 
TSS_RESULT TCSP_LoadKeyByBlob(TSS_HCONTEXT hContext,    /* in */
349
 
                              TCS_KEY_HANDLE hUnwrappingKey,    /* in */
350
 
                              UINT32 cWrappedKeyBlobSize,       /* in */
351
 
                              BYTE * rgbWrappedKeyBlob, /* in */
352
 
                              TPM_AUTH * pAuth, /* in, out */
353
 
                              TCS_KEY_HANDLE * phKeyTCSI,       /* out */
354
 
                              TCS_KEY_HANDLE * phKeyHMAC)       /* out */
355
 
{
356
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
357
 
        struct host_table_entry *entry = get_table_entry(hContext);
358
 
 
359
 
        if (entry == NULL)
360
 
                return TSPERR(TSS_E_NO_CONNECTION);
361
 
 
362
 
        switch (entry->type) {
363
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
364
 
                        result = TCSP_LoadKeyByBlob_TP(entry, hUnwrappingKey,
365
 
                                                       cWrappedKeyBlobSize, rgbWrappedKeyBlob,
366
 
                                                       pAuth, phKeyTCSI, phKeyHMAC);
367
 
                        break;
368
 
                default:
369
 
                        break;
370
 
        }
371
 
 
372
 
        put_table_entry(entry);
373
 
 
374
 
        return result;
375
 
}
376
 
 
377
 
TSS_RESULT TCSP_LoadKeyByUUID(TSS_HCONTEXT hContext,    /* in */
378
 
                              TSS_UUID KeyUUID, /* in */
379
 
                              TCS_LOADKEY_INFO * pLoadKeyInfo,  /* in, out */
380
 
                              TCS_KEY_HANDLE * phKeyTCSI)       /* out */
381
 
{
382
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
383
 
        struct host_table_entry *entry = get_table_entry(hContext);
384
 
 
385
 
        if (entry == NULL)
386
 
                return TSPERR(TSS_E_NO_CONNECTION);
387
 
 
388
 
        switch (entry->type) {
389
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
390
 
                        result = TCSP_LoadKeyByUUID_TP(entry, KeyUUID, pLoadKeyInfo,
391
 
                                                       phKeyTCSI);
392
 
                        break;
393
 
                default:
394
 
                        break;
395
 
        }
396
 
 
397
 
        put_table_entry(entry);
398
 
 
399
 
        return result;
400
 
}
401
 
 
402
 
TSS_RESULT TCSP_EvictKey(TSS_HCONTEXT hContext, /* in */
403
 
                         TCS_KEY_HANDLE hKey)   /* in */
404
 
{
405
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
406
 
        struct host_table_entry *entry = get_table_entry(hContext);
407
 
 
408
 
        if (entry == NULL)
409
 
                return TSPERR(TSS_E_NO_CONNECTION);
410
 
 
411
 
        switch (entry->type) {
412
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
413
 
                        result = TCSP_EvictKey_TP(entry, hKey);
414
 
                        break;
415
 
                default:
416
 
                        break;
417
 
        }
418
 
 
419
 
        put_table_entry(entry);
420
 
 
421
 
        return result;
422
 
}
423
 
 
424
 
TSS_RESULT TCSP_CreateWrapKey(TSS_HCONTEXT hContext,    /* in */
425
 
                              TCS_KEY_HANDLE hWrappingKey,      /* in */
426
 
                              TCPA_ENCAUTH KeyUsageAuth,        /* in */
427
 
                              TCPA_ENCAUTH KeyMigrationAuth,    /* in */
428
 
                              UINT32 keyInfoSize,       /* in */
429
 
                              BYTE * keyInfo,   /* in */
430
 
                              UINT32 * keyDataSize,     /* out */
431
 
                              BYTE ** keyData,  /* out */
432
 
                              TPM_AUTH * pAuth) /* in, out */
433
 
{
434
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
435
 
        struct host_table_entry *entry = get_table_entry(hContext);
436
 
 
437
 
        if (entry == NULL)
438
 
                return TSPERR(TSS_E_NO_CONNECTION);
439
 
 
440
 
        switch (entry->type) {
441
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
442
 
                        result = TCSP_CreateWrapKey_TP(entry, hWrappingKey, KeyUsageAuth,
443
 
                                                       KeyMigrationAuth, keyInfoSize, keyInfo,
444
 
                                                       keyDataSize, keyData, pAuth);
445
 
                        break;
446
 
                default:
447
 
                        break;
448
 
        }
449
 
 
450
 
        put_table_entry(entry);
451
 
 
452
 
        return result;
453
 
}
454
 
 
455
 
TSS_RESULT TCSP_GetPubKey(TSS_HCONTEXT hContext,        /* in */
456
 
                           TCS_KEY_HANDLE hKey, /* in */
457
 
                           TPM_AUTH * pAuth,    /* in, out */
458
 
                           UINT32 * pcPubKeySize,       /* out */
459
 
                           BYTE ** prgbPubKey)  /* out */
460
 
{
461
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
462
 
        struct host_table_entry *entry = get_table_entry(hContext);
463
 
 
464
 
        if (entry == NULL)
465
 
                return TSPERR(TSS_E_NO_CONNECTION);
466
 
 
467
 
        switch (entry->type) {
468
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
469
 
                        result = TCSP_GetPubKey_TP(entry, hKey, pAuth, pcPubKeySize,
470
 
                                                   prgbPubKey);
471
 
                        break;
472
 
                default:
473
 
                        break;
474
 
        }
475
 
 
476
 
        put_table_entry(entry);
477
 
 
478
 
        return result;
479
 
}
480
 
 
481
 
TSS_RESULT TCSP_MakeIdentity(TSS_HCONTEXT hContext,     /* in */
482
 
                             TCPA_ENCAUTH identityAuth, /* in */
483
 
                             TCPA_CHOSENID_HASH IDLabel_PrivCAHash,     /* in */
484
 
                             UINT32 idKeyInfoSize,      /* in */
485
 
                             BYTE * idKeyInfo,  /* in */
486
 
                             TPM_AUTH * pSrkAuth,       /* in, out */
487
 
                             TPM_AUTH * pOwnerAuth,     /* in, out */
488
 
                             UINT32 * idKeySize,        /* out */
489
 
                             BYTE ** idKey,     /* out */
490
 
                             UINT32 * pcIdentityBindingSize,    /* out */
491
 
                             BYTE ** prgbIdentityBinding,       /* out */
492
 
                             UINT32 * pcEndorsementCredentialSize,      /* out */
493
 
                             BYTE ** prgbEndorsementCredential, /* out */
494
 
                             UINT32 * pcPlatformCredentialSize, /* out */
495
 
                             BYTE ** prgbPlatformCredential,    /* out */
496
 
                             UINT32 * pcConformanceCredentialSize,      /* out */
497
 
                             BYTE ** prgbConformanceCredential) /* out */
498
 
{
499
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
500
 
        struct host_table_entry *entry = get_table_entry(hContext);
501
 
 
502
 
        if (entry == NULL)
503
 
                return TSPERR(TSS_E_NO_CONNECTION);
504
 
 
505
 
        switch (entry->type) {
506
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
507
 
                        result = TCSP_MakeIdentity_TP(entry, identityAuth,
508
 
                                                      IDLabel_PrivCAHash, idKeyInfoSize, idKeyInfo,
509
 
                                                      pSrkAuth, pOwnerAuth, idKeySize, idKey,
510
 
                                                      pcIdentityBindingSize, prgbIdentityBinding,
511
 
                                                      pcEndorsementCredentialSize,
512
 
                                                      prgbEndorsementCredential,
513
 
                                                      pcPlatformCredentialSize,
514
 
                                                      prgbPlatformCredential,
515
 
                                                      pcConformanceCredentialSize,
516
 
                                                      prgbConformanceCredential);
517
 
                        break;
518
 
                default:
519
 
                        break;
520
 
        }
521
 
 
522
 
        put_table_entry(entry);
523
 
 
524
 
        return result;
525
 
}
526
 
 
527
 
TSS_RESULT TCSP_SetOwnerInstall(TSS_HCONTEXT hContext,  /* in */
528
 
                                TSS_BOOL state) /* in */
529
 
{
530
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
531
 
        struct host_table_entry *entry = get_table_entry(hContext);
532
 
 
533
 
        if (entry == NULL)
534
 
                return TSPERR(TSS_E_NO_CONNECTION);
535
 
 
536
 
        switch (entry->type) {
537
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
538
 
                        result = TCSP_SetOwnerInstall_TP(entry, state);
539
 
                        break;
540
 
                default:
541
 
                        break;
542
 
        }
543
 
 
544
 
        put_table_entry(entry);
545
 
 
546
 
        return result;
547
 
}
548
 
 
549
 
TSS_RESULT TCSP_TakeOwnership(TSS_HCONTEXT hContext,    /* in */
550
 
                              UINT16 protocolID,        /* in */
551
 
                              UINT32 encOwnerAuthSize,  /* in */
552
 
                              BYTE * encOwnerAuth,      /* in */
553
 
                              UINT32 encSrkAuthSize,    /* in */
554
 
                              BYTE * encSrkAuth,        /* in */
555
 
                              UINT32 srkInfoSize,       /* in */
556
 
                              BYTE * srkInfo,   /* in */
557
 
                              TPM_AUTH * ownerAuth,     /* in, out */
558
 
                              UINT32 * srkKeySize,
559
 
                              BYTE ** srkKey)
560
 
{
561
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
562
 
        struct host_table_entry *entry = get_table_entry(hContext);
563
 
 
564
 
        if (entry == NULL)
565
 
                return TSPERR(TSS_E_NO_CONNECTION);
566
 
 
567
 
        switch (entry->type) {
568
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
569
 
                        result = TCSP_TakeOwnership_TP(entry, protocolID,
570
 
                                                       encOwnerAuthSize, encOwnerAuth,
571
 
                                                       encSrkAuthSize, encSrkAuth, srkInfoSize,
572
 
                                                       srkInfo, ownerAuth, srkKeySize, srkKey);
573
 
                        break;
574
 
                default:
575
 
                        break;
576
 
        }
577
 
 
578
 
        put_table_entry(entry);
579
 
 
580
 
        return result;
581
 
}
582
 
 
583
 
TSS_RESULT TCSP_OIAP(TSS_HCONTEXT hContext,     /* in */
584
 
                     TCS_AUTHHANDLE * authHandle,       /* out */
585
 
                     TCPA_NONCE * nonce0)       /* out */
586
 
{
587
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
588
 
        struct host_table_entry *entry = get_table_entry(hContext);
589
 
 
590
 
        if (entry == NULL)
591
 
                return TSPERR(TSS_E_NO_CONNECTION);
592
 
 
593
 
        switch (entry->type) {
594
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
595
 
                        result = TCSP_OIAP_TP(entry, authHandle, nonce0);
596
 
                        break;
597
 
                default:
598
 
                        break;
599
 
        }
600
 
 
601
 
        put_table_entry(entry);
602
 
 
603
 
        return result;
604
 
}
605
 
 
606
 
TSS_RESULT TCSP_OSAP(TSS_HCONTEXT hContext,     /* in */
607
 
                     TCPA_ENTITY_TYPE entityType,       /* in */
608
 
                     UINT32 entityValue,        /* in */
609
 
                     TCPA_NONCE nonceOddOSAP,   /* in */
610
 
                     TCS_AUTHHANDLE * authHandle,       /* out */
611
 
                     TCPA_NONCE * nonceEven,    /* out */
612
 
                     TCPA_NONCE * nonceEvenOSAP)        /* out */
613
 
{
614
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
615
 
        struct host_table_entry *entry = get_table_entry(hContext);
616
 
 
617
 
        if (entry == NULL)
618
 
                return TSPERR(TSS_E_NO_CONNECTION);
619
 
 
620
 
        switch (entry->type) {
621
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
622
 
                        result = TCSP_OSAP_TP(entry, entityType, entityValue,
623
 
                                              nonceOddOSAP, authHandle, nonceEven, nonceEvenOSAP);
624
 
                        break;
625
 
                default:
626
 
                        break;
627
 
        }
628
 
 
629
 
        put_table_entry(entry);
630
 
 
631
 
        return result;
632
 
}
633
 
 
634
 
TSS_RESULT TCSP_ChangeAuth(TSS_HCONTEXT hContext,       /* in */
635
 
                           TCS_KEY_HANDLE parentHandle, /* in */
636
 
                           TCPA_PROTOCOL_ID protocolID, /* in */
637
 
                           TCPA_ENCAUTH newAuth,        /* in */
638
 
                           TCPA_ENTITY_TYPE entityType, /* in */
639
 
                           UINT32 encDataSize,  /* in */
640
 
                           BYTE * encData,      /* in */
641
 
                           TPM_AUTH * ownerAuth,        /* in, out */
642
 
                           TPM_AUTH * entityAuth,       /* in, out */
643
 
                           UINT32 * outDataSize,        /* out */
644
 
                           BYTE ** outData)     /* out */
645
 
{
646
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
647
 
        struct host_table_entry *entry = get_table_entry(hContext);
648
 
 
649
 
        if (entry == NULL)
650
 
                return TSPERR(TSS_E_NO_CONNECTION);
651
 
 
652
 
        switch (entry->type) {
653
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
654
 
                        result = TCSP_ChangeAuth_TP(entry, parentHandle, protocolID, newAuth,
655
 
                                                    entityType, encDataSize, encData, ownerAuth,
656
 
                                                    entityAuth, outDataSize, outData);
657
 
                        break;
658
 
                default:
659
 
                        break;
660
 
        }
661
 
 
662
 
        put_table_entry(entry);
663
 
 
664
 
        return result;
665
 
}
666
 
 
667
 
TSS_RESULT TCSP_ChangeAuthOwner(TSS_HCONTEXT hContext,  /* in */
668
 
                                TCPA_PROTOCOL_ID protocolID,    /* in */
669
 
                                TCPA_ENCAUTH newAuth,   /* in */
670
 
                                TCPA_ENTITY_TYPE entityType,    /* in */
671
 
                                TPM_AUTH * ownerAuth)   /* in, out */
672
 
{
673
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
674
 
        struct host_table_entry *entry = get_table_entry(hContext);
675
 
 
676
 
        if (entry == NULL)
677
 
                return TSPERR(TSS_E_NO_CONNECTION);
678
 
 
679
 
        switch (entry->type) {
680
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
681
 
                        result = TCSP_ChangeAuthOwner_TP(entry, protocolID, newAuth,
682
 
                                                         entityType, ownerAuth);
683
 
                        break;
684
 
                default:
685
 
                        break;
686
 
        }
687
 
 
688
 
        put_table_entry(entry);
689
 
 
690
 
        return result;
691
 
}
692
 
 
693
 
TSS_RESULT TCSP_ChangeAuthAsymStart(TSS_HCONTEXT hContext,      /* in */
694
 
                                    TCS_KEY_HANDLE idHandle,    /* in */
695
 
                                    TCPA_NONCE antiReplay,      /* in */
696
 
                                    UINT32 KeySizeIn,   /* in */
697
 
                                    BYTE * KeyDataIn,   /* in */
698
 
                                    TPM_AUTH * pAuth,   /* in, out */
699
 
                                    UINT32 * KeySizeOut,        /* out */
700
 
                                    BYTE ** KeyDataOut, /* out */
701
 
                                    UINT32 * CertifyInfoSize,   /* out */
702
 
                                    BYTE ** CertifyInfo,        /* out */
703
 
                                    UINT32 * sigSize,   /* out */
704
 
                                    BYTE ** sig,        /* out */
705
 
                                    TCS_KEY_HANDLE * ephHandle) /* out */
706
 
{
707
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
708
 
        struct host_table_entry *entry = get_table_entry(hContext);
709
 
 
710
 
        if (entry == NULL)
711
 
                return TSPERR(TSS_E_NO_CONNECTION);
712
 
 
713
 
        switch (entry->type) {
714
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
715
 
                        result = TCSP_ChangeAuthAsymStart_TP(entry, idHandle, antiReplay,
716
 
                                                             KeySizeIn, KeyDataIn, pAuth,
717
 
                                                             KeySizeOut, KeyDataOut,
718
 
                                                             CertifyInfoSize, CertifyInfo, sigSize,
719
 
                                                             sig, ephHandle);
720
 
                        break;
721
 
                default:
722
 
                        break;
723
 
        }
724
 
 
725
 
        put_table_entry(entry);
726
 
 
727
 
        return result;
728
 
}
729
 
 
730
 
TSS_RESULT TCSP_ChangeAuthAsymFinish(TSS_HCONTEXT hContext,     /* in */
731
 
                                     TCS_KEY_HANDLE parentHandle,       /* in */
732
 
                                     TCS_KEY_HANDLE ephHandle,  /* in */
733
 
                                     TCPA_ENTITY_TYPE entityType,       /* in */
734
 
                                     TCPA_HMAC newAuthLink,     /* in */
735
 
                                     UINT32 newAuthSize,        /* in */
736
 
                                     BYTE * encNewAuth, /* in */
737
 
                                     UINT32 encDataSizeIn,      /* in */
738
 
                                     BYTE * encDataIn,  /* in */
739
 
                                     TPM_AUTH * ownerAuth,      /* in, out */
740
 
                                     UINT32 * encDataSizeOut,   /* out */
741
 
                                     BYTE ** encDataOut,        /* out */
742
 
                                     TCPA_SALT_NONCE * saltNonce,       /* out */
743
 
                                     TCPA_DIGEST * changeProof) /* out */
744
 
{
745
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
746
 
        struct host_table_entry *entry = get_table_entry(hContext);
747
 
 
748
 
        if (entry == NULL)
749
 
                return TSPERR(TSS_E_NO_CONNECTION);
750
 
 
751
 
        switch (entry->type) {
752
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
753
 
                        result = TCSP_ChangeAuthAsymFinish_TP(entry, parentHandle,
754
 
                                                              ephHandle, entityType, newAuthLink,
755
 
                                                              newAuthSize, encNewAuth,
756
 
                                                              encDataSizeIn, encDataIn, ownerAuth,
757
 
                                                              encDataSizeOut, encDataOut, saltNonce,
758
 
                                                              changeProof);
759
 
                        break;
760
 
                default:
761
 
                        break;
762
 
        }
763
 
 
764
 
        put_table_entry(entry);
765
 
 
766
 
        return result;
767
 
}
768
 
 
769
 
TSS_RESULT TCSP_TerminateHandle(TSS_HCONTEXT hContext,  /* in */
770
 
                                TCS_AUTHHANDLE handle)  /* in */
771
 
{
772
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
773
 
        struct host_table_entry *entry = get_table_entry(hContext);
774
 
 
775
 
        if (entry == NULL)
776
 
                return TSPERR(TSS_E_NO_CONNECTION);
777
 
 
778
 
        switch (entry->type) {
779
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
780
 
                        result = TCSP_TerminateHandle_TP(entry, handle);
781
 
                        break;
782
 
                default:
783
 
                        break;
784
 
        }
785
 
 
786
 
        put_table_entry(entry);
787
 
 
788
 
        return result;
789
 
}
790
 
 
791
 
TSS_RESULT TCSP_ActivateTPMIdentity(TSS_HCONTEXT hContext,      /* in */
792
 
                                    TCS_KEY_HANDLE idKey,       /* in */
793
 
                                    UINT32 blobSize,    /* in */
794
 
                                    BYTE * blob,        /* in */
795
 
                                    TPM_AUTH * idKeyAuth,       /* in, out */
796
 
                                    TPM_AUTH * ownerAuth,       /* in, out */
797
 
                                    UINT32 * SymmetricKeySize,  /* out */
798
 
                                    BYTE ** SymmetricKey)       /* out */
799
 
{
800
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
801
 
        struct host_table_entry *entry = get_table_entry(hContext);
802
 
 
803
 
        if (entry == NULL)
804
 
                return TSPERR(TSS_E_NO_CONNECTION);
805
 
 
806
 
        switch (entry->type) {
807
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
808
 
                        result = TCSP_ActivateTPMIdentity_TP(entry, idKey, blobSize, blob,
809
 
                                                             idKeyAuth, ownerAuth, SymmetricKeySize,
810
 
                                                             SymmetricKey);
811
 
                        break;
812
 
                default:
813
 
                        break;
814
 
        }
815
 
 
816
 
        put_table_entry(entry);
817
 
 
818
 
        return result;
819
 
}
820
 
 
821
 
TSS_RESULT TCSP_Extend(TSS_HCONTEXT hContext,   /* in */
822
 
                        TCPA_PCRINDEX pcrNum,   /* in */
823
 
                        TCPA_DIGEST inDigest,   /* in */
824
 
                        TCPA_PCRVALUE * outDigest)      /* out */
825
 
{
826
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
827
 
        struct host_table_entry *entry = get_table_entry(hContext);
828
 
 
829
 
        if (entry == NULL)
830
 
                return TSPERR(TSS_E_NO_CONNECTION);
831
 
 
832
 
        switch (entry->type) {
833
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
834
 
                        result = TCSP_Extend_TP(entry, pcrNum, inDigest, outDigest);
835
 
                        break;
836
 
                default:
837
 
                        break;
838
 
        }
839
 
 
840
 
        put_table_entry(entry);
841
 
 
842
 
        return result;
843
 
}
844
 
 
845
 
TSS_RESULT TCSP_PcrRead(TSS_HCONTEXT hContext,  /* in */
846
 
                        TCPA_PCRINDEX pcrNum,   /* in */
847
 
                        TCPA_PCRVALUE * outDigest)      /* out */
848
 
{
849
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
850
 
        struct host_table_entry *entry = get_table_entry(hContext);
851
 
 
852
 
        if (entry == NULL)
853
 
                return TSPERR(TSS_E_NO_CONNECTION);
854
 
 
855
 
        switch (entry->type) {
856
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
857
 
                        result = TCSP_PcrRead_TP(entry, pcrNum, outDigest);
858
 
                        break;
859
 
                default:
860
 
                        break;
861
 
        }
862
 
 
863
 
        put_table_entry(entry);
864
 
 
865
 
        return result;
866
 
}
867
 
 
868
 
TSS_RESULT TCSP_Quote(TSS_HCONTEXT hContext,    /* in */
869
 
                      TCS_KEY_HANDLE keyHandle, /* in */
870
 
                      TCPA_NONCE antiReplay,    /* in */
871
 
                      UINT32 pcrDataSizeIn,     /* in */
872
 
                      BYTE * pcrDataIn, /* in */
873
 
                      TPM_AUTH * privAuth,      /* in, out */
874
 
                      UINT32 * pcrDataSizeOut,  /* out */
875
 
                      BYTE ** pcrDataOut,       /* out */
876
 
                      UINT32 * sigSize, /* out */
877
 
                      BYTE ** sig)      /* out */
878
 
{
879
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
880
 
        struct host_table_entry *entry = get_table_entry(hContext);
881
 
 
882
 
        if (entry == NULL)
883
 
                return TSPERR(TSS_E_NO_CONNECTION);
884
 
 
885
 
        switch (entry->type) {
886
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
887
 
                        result = TCSP_Quote_TP(entry, keyHandle, antiReplay,
888
 
                                               pcrDataSizeIn, pcrDataIn, privAuth, pcrDataSizeOut,
889
 
                                               pcrDataOut, sigSize, sig);
890
 
                        break;
891
 
                default:
892
 
                        break;
893
 
        }
894
 
 
895
 
        put_table_entry(entry);
896
 
 
897
 
        return result;
898
 
}
899
 
 
900
 
TSS_RESULT TCSP_DirWriteAuth(TSS_HCONTEXT hContext,     /* in */
901
 
                             TCPA_DIRINDEX dirIndex,    /* in */
902
 
                             TCPA_DIRVALUE newContents, /* in */
903
 
                             TPM_AUTH * ownerAuth)      /* in, out */
904
 
{
905
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
906
 
        struct host_table_entry *entry = get_table_entry(hContext);
907
 
 
908
 
        if (entry == NULL)
909
 
                return TSPERR(TSS_E_NO_CONNECTION);
910
 
 
911
 
        switch (entry->type) {
912
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
913
 
                        result = TCSP_DirWriteAuth_TP(entry, dirIndex, newContents,
914
 
                                                      ownerAuth);
915
 
                        break;
916
 
                default:
917
 
                        break;
918
 
        }
919
 
 
920
 
        put_table_entry(entry);
921
 
 
922
 
        return result;
923
 
}
924
 
 
925
 
TSS_RESULT TCSP_DirRead(TSS_HCONTEXT hContext,  /* in */
926
 
                         TCPA_DIRINDEX dirIndex,        /* in */
927
 
                         TCPA_DIRVALUE * dirValue)      /* out */
928
 
{
929
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
930
 
        struct host_table_entry *entry = get_table_entry(hContext);
931
 
 
932
 
        if (entry == NULL)
933
 
                return TSPERR(TSS_E_NO_CONNECTION);
934
 
 
935
 
        switch (entry->type) {
936
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
937
 
                        result = TCSP_DirRead_TP(entry, dirIndex, dirValue);
938
 
                        break;
939
 
                default:
940
 
                        break;
941
 
        }
942
 
 
943
 
        put_table_entry(entry);
944
 
 
945
 
        return result;
946
 
}
947
 
 
948
 
TSS_RESULT TCSP_Seal(TSS_HCONTEXT hContext,     /* in */
949
 
                     TCS_KEY_HANDLE keyHandle,  /* in */
950
 
                     TCPA_ENCAUTH encAuth,      /* in */
951
 
                     UINT32 pcrInfoSize,        /* in */
952
 
                     BYTE * PcrInfo,    /* in */
953
 
                     UINT32 inDataSize, /* in */
954
 
                     BYTE * inData,     /* in */
955
 
                     TPM_AUTH * pubAuth,        /* in, out */
956
 
                     UINT32 * SealedDataSize,   /* out */
957
 
                     BYTE ** SealedData)        /* out */
958
 
{
959
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
960
 
        struct host_table_entry *entry = get_table_entry(hContext);
961
 
 
962
 
        if (entry == NULL)
963
 
                return TSPERR(TSS_E_NO_CONNECTION);
964
 
 
965
 
        switch (entry->type) {
966
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
967
 
                        result = TCSP_Seal_TP(entry, keyHandle, encAuth, pcrInfoSize,
968
 
                                              PcrInfo, inDataSize, inData, pubAuth, SealedDataSize,
969
 
                                              SealedData);
970
 
                        break;
971
 
                default:
972
 
                        break;
973
 
        }
974
 
 
975
 
        put_table_entry(entry);
976
 
 
977
 
        return result;
978
 
}
979
 
 
980
 
TSS_RESULT TCSP_Unseal(TSS_HCONTEXT hContext,   /* in */
981
 
                       TCS_KEY_HANDLE parentHandle,     /* in */
982
 
                       UINT32 SealedDataSize,   /* in */
983
 
                       BYTE * SealedData,       /* in */
984
 
                       TPM_AUTH * parentAuth,   /* in, out */
985
 
                       TPM_AUTH * dataAuth,     /* in, out */
986
 
                       UINT32 * DataSize,       /* out */
987
 
                       BYTE ** Data)    /* out */
988
 
{
989
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
990
 
        struct host_table_entry *entry = get_table_entry(hContext);
991
 
 
992
 
        if (entry == NULL)
993
 
                return TSPERR(TSS_E_NO_CONNECTION);
994
 
 
995
 
        switch (entry->type) {
996
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
997
 
                        result = TCSP_Unseal_TP(entry, parentHandle, SealedDataSize,
998
 
                                                SealedData, parentAuth, dataAuth, DataSize, Data);
999
 
                        break;
1000
 
                default:
1001
 
                        break;
1002
 
        }
1003
 
 
1004
 
        put_table_entry(entry);
1005
 
 
1006
 
        return result;
1007
 
}
1008
 
 
1009
 
TSS_RESULT TCSP_UnBind(TSS_HCONTEXT hContext,   /* in */
1010
 
                       TCS_KEY_HANDLE keyHandle,        /* in */
1011
 
                       UINT32 inDataSize,       /* in */
1012
 
                       BYTE * inData,   /* in */
1013
 
                       TPM_AUTH * privAuth,     /* in, out */
1014
 
                       UINT32 * outDataSize,    /* out */
1015
 
                       BYTE ** outData) /* out */
1016
 
{
1017
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1018
 
        struct host_table_entry *entry = get_table_entry(hContext);
1019
 
 
1020
 
        if (entry == NULL)
1021
 
                return TSPERR(TSS_E_NO_CONNECTION);
1022
 
 
1023
 
        switch (entry->type) {
1024
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1025
 
                        result = TCSP_UnBind_TP(entry, keyHandle, inDataSize, inData,
1026
 
                                                privAuth, outDataSize,
1027
 
                                   outData);
1028
 
                        break;
1029
 
                default:
1030
 
                        break;
1031
 
        }
1032
 
 
1033
 
        put_table_entry(entry);
1034
 
 
1035
 
        return result;
1036
 
}
1037
 
 
1038
 
TSS_RESULT TCSP_CreateMigrationBlob(TSS_HCONTEXT hContext,      /* in */
1039
 
                                    TCS_KEY_HANDLE parentHandle,        /* in */
1040
 
                                    TCPA_MIGRATE_SCHEME migrationType,  /* in */
1041
 
                                    UINT32 MigrationKeyAuthSize,        /* in */
1042
 
                                    BYTE * MigrationKeyAuth,    /* in */
1043
 
                                    UINT32 encDataSize, /* in */
1044
 
                                    BYTE * encData,     /* in */
1045
 
                                    TPM_AUTH * parentAuth,      /* in, out */
1046
 
                                    TPM_AUTH * entityAuth,      /* in, out */
1047
 
                                    UINT32 * randomSize,        /* out */
1048
 
                                    BYTE ** random,     /* out */
1049
 
                                    UINT32 * outDataSize,       /* out */
1050
 
                                    BYTE ** outData)    /* out */
1051
 
{
1052
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1053
 
        struct host_table_entry *entry = get_table_entry(hContext);
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 = TCSP_CreateMigrationBlob_TP(entry, parentHandle,
1061
 
                                                             migrationType, MigrationKeyAuthSize,
1062
 
                                                             MigrationKeyAuth, encDataSize, encData,
1063
 
                                                             parentAuth, entityAuth, randomSize,
1064
 
                                                             random, outDataSize, outData);
1065
 
                        break;
1066
 
                default:
1067
 
                        break;
1068
 
        }
1069
 
 
1070
 
        put_table_entry(entry);
1071
 
 
1072
 
        return result;
1073
 
}
1074
 
 
1075
 
TSS_RESULT TCSP_ConvertMigrationBlob(TSS_HCONTEXT hContext,     /* in */
1076
 
                                     TCS_KEY_HANDLE parentHandle,       /* in */
1077
 
                                     UINT32 inDataSize, /* in */
1078
 
                                     BYTE * inData,     /* in */
1079
 
                                     UINT32 randomSize, /* in */
1080
 
                                     BYTE * random,     /* in */
1081
 
                                     TPM_AUTH * parentAuth,     /* in, out */
1082
 
                                     UINT32 * outDataSize,      /* out */
1083
 
                                     BYTE ** outData)   /* out */
1084
 
{
1085
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1086
 
        struct host_table_entry *entry = get_table_entry(hContext);
1087
 
 
1088
 
        if (entry == NULL)
1089
 
                return TSPERR(TSS_E_NO_CONNECTION);
1090
 
 
1091
 
        switch (entry->type) {
1092
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1093
 
                        result = TCSP_ConvertMigrationBlob_TP(entry, parentHandle,
1094
 
                                                              inDataSize, inData, randomSize,
1095
 
                                                              random, parentAuth, outDataSize,
1096
 
                                                              outData);
1097
 
                        break;
1098
 
                default:
1099
 
                        break;
1100
 
        }
1101
 
 
1102
 
        put_table_entry(entry);
1103
 
 
1104
 
        return result;
1105
 
}
1106
 
 
1107
 
TSS_RESULT TCSP_AuthorizeMigrationKey(TSS_HCONTEXT hContext,    /* in */
1108
 
                                      TCPA_MIGRATE_SCHEME migrateScheme,        /* in */
1109
 
                                      UINT32 MigrationKeySize,  /* in */
1110
 
                                      BYTE * MigrationKey,      /* in */
1111
 
                                      TPM_AUTH * ownerAuth,     /* in, out */
1112
 
                                      UINT32 * MigrationKeyAuthSize,    /* out */
1113
 
                                      BYTE ** MigrationKeyAuth) /* out */
1114
 
{
1115
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1116
 
        struct host_table_entry *entry = get_table_entry(hContext);
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 = TCSP_AuthorizeMigrationKey_TP(entry, migrateScheme,
1124
 
                                                               MigrationKeySize, MigrationKey,
1125
 
                                                               ownerAuth, MigrationKeyAuthSize,
1126
 
                                                               MigrationKeyAuth);
1127
 
                        break;
1128
 
                default:
1129
 
                        break;
1130
 
        }
1131
 
 
1132
 
        put_table_entry(entry);
1133
 
 
1134
 
        return result;
1135
 
}
1136
 
 
1137
 
TSS_RESULT TCSP_CertifyKey(TSS_HCONTEXT hContext,       /* in */
1138
 
                           TCS_KEY_HANDLE certHandle,   /* in */
1139
 
                           TCS_KEY_HANDLE keyHandle,    /* in */
1140
 
                           TCPA_NONCE antiReplay,       /* in */
1141
 
                           TPM_AUTH * certAuth, /* in, out */
1142
 
                           TPM_AUTH * keyAuth,  /* in, out */
1143
 
                           UINT32 * CertifyInfoSize,    /* out */
1144
 
                           BYTE ** CertifyInfo, /* out */
1145
 
                           UINT32 * outDataSize,        /* out */
1146
 
                           BYTE ** outData)     /* out */
1147
 
{
1148
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1149
 
        struct host_table_entry *entry = get_table_entry(hContext);
1150
 
 
1151
 
        if (entry == NULL)
1152
 
                return TSPERR(TSS_E_NO_CONNECTION);
1153
 
 
1154
 
        switch (entry->type) {
1155
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1156
 
                        result = TCSP_CertifyKey_TP(entry, certHandle, keyHandle,
1157
 
                                                    antiReplay, certAuth, keyAuth, CertifyInfoSize,
1158
 
                                                    CertifyInfo, outDataSize, outData);
1159
 
                        break;
1160
 
                default:
1161
 
                        break;
1162
 
        }
1163
 
 
1164
 
        put_table_entry(entry);
1165
 
 
1166
 
        return result;
1167
 
}
1168
 
 
1169
 
TSS_RESULT TCSP_Sign(TSS_HCONTEXT hContext,     /* in */
1170
 
                     TCS_KEY_HANDLE keyHandle,  /* in */
1171
 
                     UINT32 areaToSignSize,     /* in */
1172
 
                     BYTE * areaToSign, /* in */
1173
 
                     TPM_AUTH * privAuth,       /* in, out */
1174
 
                     UINT32 * sigSize,  /* out */
1175
 
                     BYTE ** sig)       /* out */
1176
 
{
1177
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1178
 
        struct host_table_entry *entry = get_table_entry(hContext);
1179
 
 
1180
 
        if (entry == NULL)
1181
 
                return TSPERR(TSS_E_NO_CONNECTION);
1182
 
 
1183
 
        switch (entry->type) {
1184
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1185
 
                        result = TCSP_Sign_TP(entry, keyHandle, areaToSignSize,
1186
 
                                              areaToSign, privAuth, sigSize, sig);
1187
 
                        break;
1188
 
                default:
1189
 
                        break;
1190
 
        }
1191
 
 
1192
 
        put_table_entry(entry);
1193
 
 
1194
 
        return result;
1195
 
}
1196
 
 
1197
 
TSS_RESULT TCSP_GetRandom(TSS_HCONTEXT hContext,        /* in */
1198
 
                          UINT32 bytesRequested,        /* in */
1199
 
                          BYTE ** randomBytes)  /* out */
1200
 
{
1201
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1202
 
        struct host_table_entry *entry = get_table_entry(hContext);
1203
 
 
1204
 
        if (entry == NULL)
1205
 
                return TSPERR(TSS_E_NO_CONNECTION);
1206
 
 
1207
 
        switch (entry->type) {
1208
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1209
 
                        result = TCSP_GetRandom_TP(entry, bytesRequested, randomBytes);
1210
 
                        break;
1211
 
                default:
1212
 
                        break;
1213
 
        }
1214
 
 
1215
 
        put_table_entry(entry);
1216
 
 
1217
 
        return result;
1218
 
}
1219
 
 
1220
 
TSS_RESULT TCSP_StirRandom(TSS_HCONTEXT hContext,       /* in */
1221
 
                           UINT32 inDataSize,   /* in */
1222
 
                           BYTE * inData)       /* in */
1223
 
{
1224
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1225
 
        struct host_table_entry *entry = get_table_entry(hContext);
1226
 
 
1227
 
        if (entry == NULL)
1228
 
                return TSPERR(TSS_E_NO_CONNECTION);
1229
 
 
1230
 
        switch (entry->type) {
1231
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1232
 
                        result = TCSP_StirRandom_TP(entry, inDataSize, inData);
1233
 
                        break;
1234
 
                default:
1235
 
                        break;
1236
 
        }
1237
 
 
1238
 
        put_table_entry(entry);
1239
 
 
1240
 
        return result;
1241
 
}
1242
 
 
1243
 
TSS_RESULT TCS_GetCapability(TSS_HCONTEXT hContext,     /* in */
1244
 
                             TCPA_CAPABILITY_AREA capArea,      /* in */
1245
 
                             UINT32 subCapSize, /* in */
1246
 
                             BYTE * subCap,     /* in */
1247
 
                             UINT32 * respSize, /* out */
1248
 
                             BYTE ** resp)      /* out */
1249
 
{
1250
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1251
 
        struct host_table_entry *entry = get_table_entry(hContext);
1252
 
 
1253
 
        if (entry == NULL)
1254
 
                return TSPERR(TSS_E_NO_CONNECTION);
1255
 
 
1256
 
        switch (entry->type) {
1257
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1258
 
                        result = TCS_GetCapability_TP(entry, capArea, subCapSize, subCap,
1259
 
                                                      respSize, resp);
1260
 
                        break;
1261
 
                default:
1262
 
                        break;
1263
 
        }
1264
 
 
1265
 
        put_table_entry(entry);
1266
 
 
1267
 
        return result;
1268
 
}
1269
 
 
1270
 
TSS_RESULT TCSP_GetCapability(TSS_HCONTEXT hContext,    /* in */
1271
 
                              TCPA_CAPABILITY_AREA capArea,     /* in */
1272
 
                              UINT32 subCapSize,        /* in */
1273
 
                              BYTE * subCap,    /* in */
1274
 
                              UINT32 * respSize,        /* out */
1275
 
                              BYTE ** resp)     /* out */
1276
 
{
1277
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1278
 
        struct host_table_entry *entry = get_table_entry(hContext);
1279
 
 
1280
 
        if (entry == NULL)
1281
 
                return TSPERR(TSS_E_NO_CONNECTION);
1282
 
 
1283
 
        switch (entry->type) {
1284
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1285
 
                        result = TCSP_GetCapability_TP(entry, capArea, subCapSize, subCap,
1286
 
                                                       respSize, resp);
1287
 
                        break;
1288
 
                default:
1289
 
                        break;
1290
 
        }
1291
 
 
1292
 
        put_table_entry(entry);
1293
 
 
1294
 
        return result;
1295
 
}
1296
 
 
1297
 
TSS_RESULT TCSP_GetCapabilitySigned(TSS_HCONTEXT hContext,      /* in */
1298
 
                                    TCS_KEY_HANDLE keyHandle,   /* in */
1299
 
                                    TCPA_NONCE antiReplay,      /* in */
1300
 
                                    TCPA_CAPABILITY_AREA capArea,       /* in */
1301
 
                                    UINT32 subCapSize,  /* in */
1302
 
                                    BYTE * subCap,      /* in */
1303
 
                                    TPM_AUTH * privAuth,        /* in, out */
1304
 
                                    TCPA_VERSION * Version,     /* out */
1305
 
                                    UINT32 * respSize,  /* out */
1306
 
                                    BYTE ** resp,       /* out */
1307
 
                                    UINT32 * sigSize,   /* out */
1308
 
                                    BYTE ** sig)        /* out */
1309
 
{
1310
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1311
 
        struct host_table_entry *entry = get_table_entry(hContext);
1312
 
 
1313
 
        if (entry == NULL)
1314
 
                return TSPERR(TSS_E_NO_CONNECTION);
1315
 
 
1316
 
        switch (entry->type) {
1317
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1318
 
                        result = TCSP_GetCapabilitySigned_TP(entry, keyHandle, antiReplay,
1319
 
                                                             capArea, subCapSize, subCap, privAuth,
1320
 
                                                             Version, respSize, resp, sigSize, sig);
1321
 
                        break;
1322
 
                default:
1323
 
                        break;
1324
 
        }
1325
 
 
1326
 
        put_table_entry(entry);
1327
 
 
1328
 
        return result;
1329
 
}
1330
 
 
1331
 
TSS_RESULT TCSP_GetCapabilityOwner(TSS_HCONTEXT hContext,       /* in */
1332
 
                                    TPM_AUTH * pOwnerAuth,      /* out */
1333
 
                                    TCPA_VERSION * pVersion,    /* out */
1334
 
                                    UINT32 * pNonVolatileFlags, /* out */
1335
 
                                    UINT32 * pVolatileFlags)    /* out */
1336
 
{
1337
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1338
 
        struct host_table_entry *entry = get_table_entry(hContext);
1339
 
 
1340
 
        if (entry == NULL)
1341
 
                return TSPERR(TSS_E_NO_CONNECTION);
1342
 
 
1343
 
        switch (entry->type) {
1344
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1345
 
                        result = TCSP_GetCapabilityOwner_TP(entry, pOwnerAuth, pVersion,
1346
 
                                                            pNonVolatileFlags, pVolatileFlags);
1347
 
                        break;
1348
 
                default:
1349
 
                        break;
1350
 
        }
1351
 
 
1352
 
        put_table_entry(entry);
1353
 
 
1354
 
        return result;
1355
 
}
1356
 
 
1357
 
TSS_RESULT TCSP_CreateEndorsementKeyPair(TSS_HCONTEXT hContext, /* in */
1358
 
                                         TCPA_NONCE antiReplay, /* in */
1359
 
                                         UINT32 endorsementKeyInfoSize, /* in */
1360
 
                                         BYTE * endorsementKeyInfo,     /* in */
1361
 
                                         UINT32 * endorsementKeySize,   /* out */
1362
 
                                         BYTE ** endorsementKey,        /* out */
1363
 
                                         TCPA_DIGEST * checksum)        /* out */
1364
 
{
1365
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1366
 
        struct host_table_entry *entry = get_table_entry(hContext);
1367
 
 
1368
 
        if (entry == NULL)
1369
 
                return TSPERR(TSS_E_NO_CONNECTION);
1370
 
 
1371
 
        switch (entry->type) {
1372
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1373
 
                        result = TCSP_CreateEndorsementKeyPair_TP(entry, antiReplay,
1374
 
                                                                  endorsementKeyInfoSize,
1375
 
                                                                  endorsementKeyInfo,
1376
 
                                                                  endorsementKeySize,
1377
 
                                                                  endorsementKey, checksum);
1378
 
                        break;
1379
 
                default:
1380
 
                        break;
1381
 
        }
1382
 
 
1383
 
        put_table_entry(entry);
1384
 
 
1385
 
        return result;
1386
 
}
1387
 
 
1388
 
TSS_RESULT TCSP_ReadPubek(TSS_HCONTEXT hContext,        /* in */
1389
 
                          TCPA_NONCE antiReplay,        /* in */
1390
 
                          UINT32 * pubEndorsementKeySize,       /* out */
1391
 
                          BYTE ** pubEndorsementKey,    /* out */
1392
 
                          TCPA_DIGEST * checksum)       /* out */
1393
 
{
1394
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1395
 
        struct host_table_entry *entry = get_table_entry(hContext);
1396
 
 
1397
 
        if (entry == NULL)
1398
 
                return TSPERR(TSS_E_NO_CONNECTION);
1399
 
 
1400
 
        switch (entry->type) {
1401
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1402
 
                        result = TCSP_ReadPubek_TP(entry, antiReplay,
1403
 
                                                   pubEndorsementKeySize, pubEndorsementKey,
1404
 
                                                   checksum);
1405
 
                        break;
1406
 
                default:
1407
 
                        break;
1408
 
        }
1409
 
 
1410
 
        put_table_entry(entry);
1411
 
 
1412
 
        return result;
1413
 
}
1414
 
 
1415
 
TSS_RESULT TCSP_DisablePubekRead(TSS_HCONTEXT hContext, /* in */
1416
 
                                 TPM_AUTH * ownerAuth)  /* in, out */
1417
 
{
1418
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1419
 
        struct host_table_entry *entry = get_table_entry(hContext);
1420
 
 
1421
 
        if (entry == NULL)
1422
 
                return TSPERR(TSS_E_NO_CONNECTION);
1423
 
 
1424
 
        switch (entry->type) {
1425
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1426
 
                        result = TCSP_DisablePubekRead_TP(entry, ownerAuth);
1427
 
                        break;
1428
 
                default:
1429
 
                        break;
1430
 
        }
1431
 
 
1432
 
        put_table_entry(entry);
1433
 
 
1434
 
        return result;
1435
 
}
1436
 
 
1437
 
TSS_RESULT TCSP_OwnerReadPubek(TSS_HCONTEXT hContext,   /* in */
1438
 
                               TPM_AUTH * ownerAuth,    /* in, out */
1439
 
                               UINT32 * pubEndorsementKeySize,  /* out */
1440
 
                               BYTE ** pubEndorsementKey)       /* out */
1441
 
{
1442
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1443
 
        struct host_table_entry *entry = get_table_entry(hContext);
1444
 
 
1445
 
        if (entry == NULL)
1446
 
                return TSPERR(TSS_E_NO_CONNECTION);
1447
 
 
1448
 
        switch (entry->type) {
1449
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1450
 
                        result = TCSP_OwnerReadPubek_TP(entry, ownerAuth,
1451
 
                                                        pubEndorsementKeySize, pubEndorsementKey);
1452
 
                        break;
1453
 
                default:
1454
 
                        break;
1455
 
        }
1456
 
 
1457
 
        put_table_entry(entry);
1458
 
 
1459
 
        return result;
1460
 
}
1461
 
 
1462
 
TSS_RESULT TCSP_SelfTestFull(TSS_HCONTEXT hContext)     /* in */
1463
 
{
1464
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1465
 
        struct host_table_entry *entry = get_table_entry(hContext);
1466
 
 
1467
 
        if (entry == NULL)
1468
 
                return TSPERR(TSS_E_NO_CONNECTION);
1469
 
 
1470
 
        switch (entry->type) {
1471
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1472
 
                        result = TCSP_SelfTestFull_TP(entry, hContext);
1473
 
                        break;
1474
 
                default:
1475
 
                        break;
1476
 
        }
1477
 
 
1478
 
        put_table_entry(entry);
1479
 
 
1480
 
        return result;
1481
 
}
1482
 
 
1483
 
TSS_RESULT TCSP_CertifySelfTest(TSS_HCONTEXT hContext,  /* in */
1484
 
                                TCS_KEY_HANDLE keyHandle,       /* in */
1485
 
                                TCPA_NONCE antiReplay,  /* in */
1486
 
                                TPM_AUTH * privAuth,    /* in, out */
1487
 
                                UINT32 * sigSize,       /* out */
1488
 
                                BYTE ** sig)    /* out */
1489
 
{
1490
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1491
 
        struct host_table_entry *entry = get_table_entry(hContext);
1492
 
 
1493
 
        if (entry == NULL)
1494
 
                return TSPERR(TSS_E_NO_CONNECTION);
1495
 
 
1496
 
        switch (entry->type) {
1497
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1498
 
                        result = TCSP_CertifySelfTest_TP(entry, keyHandle, antiReplay,
1499
 
                                                         privAuth, sigSize, sig);
1500
 
                        break;
1501
 
                default:
1502
 
                        break;
1503
 
        }
1504
 
 
1505
 
        put_table_entry(entry);
1506
 
 
1507
 
        return result;
1508
 
}
1509
 
 
1510
 
TSS_RESULT TCSP_GetTestResult(TSS_HCONTEXT hContext,    /* in */
1511
 
                              UINT32 * outDataSize,     /* out */
1512
 
                              BYTE ** outData)  /* out */
1513
 
{
1514
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1515
 
        struct host_table_entry *entry = get_table_entry(hContext);
1516
 
 
1517
 
        if (entry == NULL)
1518
 
                return TSPERR(TSS_E_NO_CONNECTION);
1519
 
 
1520
 
        switch (entry->type) {
1521
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1522
 
                        result = TCSP_GetTestResult_TP(entry, outDataSize, outData);
1523
 
                        break;
1524
 
                default:
1525
 
                        break;
1526
 
        }
1527
 
 
1528
 
        put_table_entry(entry);
1529
 
 
1530
 
        return result;
1531
 
}
1532
 
 
1533
 
TSS_RESULT TCSP_OwnerSetDisable(TSS_HCONTEXT hContext,  /* in */
1534
 
                                TSS_BOOL disableState,  /* in */
1535
 
                                TPM_AUTH * ownerAuth)   /* in, out */
1536
 
{
1537
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1538
 
        struct host_table_entry *entry = get_table_entry(hContext);
1539
 
 
1540
 
        if (entry == NULL)
1541
 
                return TSPERR(TSS_E_NO_CONNECTION);
1542
 
 
1543
 
        switch (entry->type) {
1544
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1545
 
                        result = TCSP_OwnerSetDisable_TP(entry, disableState, ownerAuth);
1546
 
                        break;
1547
 
                default:
1548
 
                        break;
1549
 
        }
1550
 
 
1551
 
        put_table_entry(entry);
1552
 
 
1553
 
        return result;
1554
 
}
1555
 
 
1556
 
TSS_RESULT TCSP_OwnerClear(TSS_HCONTEXT hContext,       /* in */
1557
 
                           TPM_AUTH * ownerAuth)        /* in, out */
1558
 
{
1559
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1560
 
        struct host_table_entry *entry = get_table_entry(hContext);
1561
 
 
1562
 
        if (entry == NULL)
1563
 
                return TSPERR(TSS_E_NO_CONNECTION);
1564
 
 
1565
 
        switch (entry->type) {
1566
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1567
 
                        result = TCSP_OwnerClear_TP(entry, ownerAuth);
1568
 
                        break;
1569
 
                default:
1570
 
                        break;
1571
 
        }
1572
 
 
1573
 
        put_table_entry(entry);
1574
 
 
1575
 
        return result;
1576
 
}
1577
 
 
1578
 
TSS_RESULT TCSP_DisableOwnerClear(TSS_HCONTEXT hContext,        /* in */
1579
 
                                  TPM_AUTH * ownerAuth) /* in, out */
1580
 
{
1581
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1582
 
        struct host_table_entry *entry = get_table_entry(hContext);
1583
 
 
1584
 
        if (entry == NULL)
1585
 
                return TSPERR(TSS_E_NO_CONNECTION);
1586
 
 
1587
 
        switch (entry->type) {
1588
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1589
 
                        result = TCSP_DisableOwnerClear_TP(entry, ownerAuth);
1590
 
                        break;
1591
 
                default:
1592
 
                        break;
1593
 
        }
1594
 
 
1595
 
        put_table_entry(entry);
1596
 
 
1597
 
        return result;
1598
 
}
1599
 
 
1600
 
TSS_RESULT TCSP_ForceClear(TSS_HCONTEXT hContext)       /* in */
1601
 
{
1602
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1603
 
        struct host_table_entry *entry = get_table_entry(hContext);
1604
 
 
1605
 
        if (entry == NULL)
1606
 
                return TSPERR(TSS_E_NO_CONNECTION);
1607
 
 
1608
 
        switch (entry->type) {
1609
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1610
 
                        result = TCSP_ForceClear_TP(entry, hContext);
1611
 
                        break;
1612
 
                default:
1613
 
                        break;
1614
 
        }
1615
 
 
1616
 
        put_table_entry(entry);
1617
 
 
1618
 
        return result;
1619
 
}
1620
 
 
1621
 
TSS_RESULT TCSP_DisableForceClear(TSS_HCONTEXT hContext)        /* in */
1622
 
{
1623
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1624
 
        struct host_table_entry *entry = get_table_entry(hContext);
1625
 
 
1626
 
        if (entry == NULL)
1627
 
                return TSPERR(TSS_E_NO_CONNECTION);
1628
 
 
1629
 
        switch (entry->type) {
1630
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1631
 
                        result = TCSP_DisableForceClear_TP(entry, hContext);
1632
 
                        break;
1633
 
                default:
1634
 
                        break;
1635
 
        }
1636
 
 
1637
 
        put_table_entry(entry);
1638
 
 
1639
 
        return result;
1640
 
}
1641
 
 
1642
 
TSS_RESULT TCSP_PhysicalDisable(TSS_HCONTEXT hContext)  /* in */
1643
 
{
1644
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1645
 
        struct host_table_entry *entry = get_table_entry(hContext);
1646
 
 
1647
 
        if (entry == NULL)
1648
 
                return TSPERR(TSS_E_NO_CONNECTION);
1649
 
 
1650
 
        switch (entry->type) {
1651
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1652
 
                        result = TCSP_PhysicalDisable_TP(entry, hContext);
1653
 
                        break;
1654
 
                default:
1655
 
                        break;
1656
 
        }
1657
 
 
1658
 
        put_table_entry(entry);
1659
 
 
1660
 
        return result;
1661
 
}
1662
 
 
1663
 
TSS_RESULT TCSP_PhysicalEnable(TSS_HCONTEXT hContext)   /* in */
1664
 
{
1665
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1666
 
        struct host_table_entry *entry = get_table_entry(hContext);
1667
 
 
1668
 
        if (entry == NULL)
1669
 
                return TSPERR(TSS_E_NO_CONNECTION);
1670
 
 
1671
 
        switch (entry->type) {
1672
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1673
 
                        result = TCSP_PhysicalEnable_TP(entry, hContext);
1674
 
                        break;
1675
 
                default:
1676
 
                        break;
1677
 
        }
1678
 
 
1679
 
        put_table_entry(entry);
1680
 
 
1681
 
        return result;
1682
 
}
1683
 
 
1684
 
TSS_RESULT TCSP_PhysicalSetDeactivated(TSS_HCONTEXT hContext,   /* in */
1685
 
                                       TSS_BOOL state)  /* in */
1686
 
{
1687
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1688
 
        struct host_table_entry *entry = get_table_entry(hContext);
1689
 
 
1690
 
        if (entry == NULL)
1691
 
                return TSPERR(TSS_E_NO_CONNECTION);
1692
 
 
1693
 
        switch (entry->type) {
1694
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1695
 
                        result = TCSP_PhysicalSetDeactivated_TP(entry, state);
1696
 
                        break;
1697
 
                default:
1698
 
                        break;
1699
 
        }
1700
 
 
1701
 
        put_table_entry(entry);
1702
 
 
1703
 
        return result;
1704
 
}
1705
 
 
1706
 
TSS_RESULT TCSP_PhysicalPresence(TSS_HCONTEXT hContext, /* in */
1707
 
                                 TCPA_PHYSICAL_PRESENCE fPhysicalPresence)      /* in */
1708
 
{
1709
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1710
 
        struct host_table_entry *entry = get_table_entry(hContext);
1711
 
 
1712
 
        if (entry == NULL)
1713
 
                return TSPERR(TSS_E_NO_CONNECTION);
1714
 
 
1715
 
        switch (entry->type) {
1716
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1717
 
                        result = TCSP_PhysicalPresence_TP(entry, fPhysicalPresence);
1718
 
                        break;
1719
 
                default:
1720
 
                        break;
1721
 
        }
1722
 
 
1723
 
        put_table_entry(entry);
1724
 
 
1725
 
        return result;
1726
 
}
1727
 
 
1728
 
TSS_RESULT TCSP_SetTempDeactivated(TSS_HCONTEXT hContext)       /* in */
1729
 
{
1730
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1731
 
        struct host_table_entry *entry = get_table_entry(hContext);
1732
 
 
1733
 
        if (entry == NULL)
1734
 
                return TSPERR(TSS_E_NO_CONNECTION);
1735
 
 
1736
 
        switch (entry->type) {
1737
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1738
 
                        result = TCSP_SetTempDeactivated_TP(entry, hContext);
1739
 
                        break;
1740
 
                default:
1741
 
                        break;
1742
 
        }
1743
 
 
1744
 
        put_table_entry(entry);
1745
 
 
1746
 
        return result;
1747
 
}
1748
 
 
1749
 
TSS_RESULT TCSP_FieldUpgrade(TSS_HCONTEXT hContext,     /* in */
1750
 
                              UINT32 dataInSize,        /* in */
1751
 
                              BYTE * dataIn,    /* in */
1752
 
                              UINT32 * dataOutSize,     /* out */
1753
 
                              BYTE ** dataOut,  /* out */
1754
 
                              TPM_AUTH * ownerAuth)     /* in, out */
1755
 
{
1756
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1757
 
        struct host_table_entry *entry = get_table_entry(hContext);
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 = (UINT32) TSPERR(TSS_E_INTERNAL_ERROR);
1765
 
                        break;
1766
 
                default:
1767
 
                        break;
1768
 
        }
1769
 
 
1770
 
        put_table_entry(entry);
1771
 
 
1772
 
        return result;
1773
 
}
1774
 
 
1775
 
TSS_RESULT TCSP_SetRedirection(TSS_HCONTEXT hContext,   /* in */
1776
 
                                TCS_KEY_HANDLE keyHandle,       /* in */
1777
 
                                UINT32 c1,      /* in */
1778
 
                                UINT32 c2,      /* in */
1779
 
                                TPM_AUTH * privAuth)    /* in, out */
1780
 
{
1781
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1782
 
        struct host_table_entry *entry = get_table_entry(hContext);
1783
 
 
1784
 
        if (entry == NULL)
1785
 
                return TSPERR(TSS_E_NO_CONNECTION);
1786
 
 
1787
 
        switch (entry->type) {
1788
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1789
 
                        result = (UINT32) TSPERR(TSS_E_INTERNAL_ERROR);
1790
 
                        break;
1791
 
                default:
1792
 
                        break;
1793
 
        }
1794
 
 
1795
 
        put_table_entry(entry);
1796
 
 
1797
 
        return result;
1798
 
}
1799
 
 
1800
 
TSS_RESULT TCSP_CreateMaintenanceArchive(TSS_HCONTEXT hContext, /* in */
1801
 
                                          TSS_BOOL generateRandom,      /* in */
1802
 
                                          TPM_AUTH * ownerAuth, /* in, out */
1803
 
                                          UINT32 * randomSize,  /* out */
1804
 
                                          BYTE ** random,       /* out */
1805
 
                                          UINT32 * archiveSize, /* out */
1806
 
                                          BYTE ** archive)      /* out */
1807
 
{
1808
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1809
 
        struct host_table_entry *entry = get_table_entry(hContext);
1810
 
 
1811
 
        if (entry == NULL)
1812
 
                return TSPERR(TSS_E_NO_CONNECTION);
1813
 
 
1814
 
        switch (entry->type) {
1815
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1816
 
                        result = TCSP_CreateMaintenanceArchive_TP(entry, generateRandom,
1817
 
                                                                  ownerAuth, randomSize, random,
1818
 
                                                                  archiveSize, archive);
1819
 
                        break;
1820
 
                default:
1821
 
                        break;
1822
 
        }
1823
 
 
1824
 
        put_table_entry(entry);
1825
 
 
1826
 
        return result;
1827
 
}
1828
 
 
1829
 
TSS_RESULT TCSP_LoadMaintenanceArchive(TSS_HCONTEXT hContext,   /* in */
1830
 
                                        UINT32 dataInSize,      /* in */
1831
 
                                        BYTE * dataIn, /* in */
1832
 
                                        TPM_AUTH * ownerAuth,   /* in, out */
1833
 
                                        UINT32 * dataOutSize,   /* out */
1834
 
                                        BYTE ** dataOut)        /* out */
1835
 
{
1836
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1837
 
        struct host_table_entry *entry = get_table_entry(hContext);
1838
 
 
1839
 
        if (entry == NULL)
1840
 
                return TSPERR(TSS_E_NO_CONNECTION);
1841
 
 
1842
 
        switch (entry->type) {
1843
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1844
 
                        result = TCSP_LoadMaintenanceArchive_TP(entry, dataInSize, dataIn,
1845
 
                                                                ownerAuth, dataOutSize, dataOut);
1846
 
                        break;
1847
 
                default:
1848
 
                        break;
1849
 
        }
1850
 
 
1851
 
        put_table_entry(entry);
1852
 
 
1853
 
        return result;
1854
 
}
1855
 
 
1856
 
TSS_RESULT TCSP_KillMaintenanceFeature(TSS_HCONTEXT hContext,   /* in */
1857
 
                                        TPM_AUTH * ownerAuth)   /* in, out */
1858
 
{
1859
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1860
 
        struct host_table_entry *entry = get_table_entry(hContext);
1861
 
 
1862
 
        if (entry == NULL)
1863
 
                return TSPERR(TSS_E_NO_CONNECTION);
1864
 
 
1865
 
        switch (entry->type) {
1866
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1867
 
                        result = TCSP_KillMaintenanceFeature_TP(entry, ownerAuth);
1868
 
                        break;
1869
 
                default:
1870
 
                        break;
1871
 
        }
1872
 
 
1873
 
        put_table_entry(entry);
1874
 
 
1875
 
        return result;
1876
 
}
1877
 
 
1878
 
TSS_RESULT TCSP_LoadManuMaintPub(TSS_HCONTEXT hContext, /* in */
1879
 
                                  TCPA_NONCE antiReplay,        /* in */
1880
 
                                  UINT32 PubKeySize,    /* in */
1881
 
                                  BYTE * PubKey,        /* in */
1882
 
                                  TCPA_DIGEST * checksum)       /* out */
1883
 
{
1884
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1885
 
        struct host_table_entry *entry = get_table_entry(hContext);
1886
 
 
1887
 
        if (entry == NULL)
1888
 
                return TSPERR(TSS_E_NO_CONNECTION);
1889
 
 
1890
 
        switch (entry->type) {
1891
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1892
 
                        result = TCSP_LoadManuMaintPub_TP(entry, antiReplay, PubKeySize,
1893
 
                                                          PubKey, checksum);
1894
 
                        break;
1895
 
                default:
1896
 
                        break;
1897
 
        }
1898
 
 
1899
 
        put_table_entry(entry);
1900
 
 
1901
 
        return result;
1902
 
}
1903
 
 
1904
 
TSS_RESULT TCSP_ReadManuMaintPub(TSS_HCONTEXT hContext, /* in */
1905
 
                                  TCPA_NONCE antiReplay,        /* in */
1906
 
                                  TCPA_DIGEST * checksum)       /* out */
1907
 
{
1908
 
        TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
1909
 
        struct host_table_entry *entry = get_table_entry(hContext);
1910
 
 
1911
 
        if (entry == NULL)
1912
 
                return TSPERR(TSS_E_NO_CONNECTION);
1913
 
 
1914
 
        switch (entry->type) {
1915
 
                case CONNECTION_TYPE_TCP_PERSISTANT:
1916
 
                        result = TCSP_ReadManuMaintPub_TP(entry, antiReplay, checksum);
1917
 
                        break;
1918
 
                default:
1919
 
                        break;
1920
 
        }
1921
 
 
1922
 
        put_table_entry(entry);
1923
 
 
1924
 
        return result;
1925
 
}