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

« back to all changes in this revision

Viewing changes to src/tspi/secrets.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, 2005
8
 
 *
9
 
 */
10
 
 
11
 
 
12
 
#include <stdlib.h>
13
 
#include <stdio.h>
14
 
#include <string.h>
15
 
#include <time.h>
16
 
#include <errno.h>
17
 
 
18
 
#include "trousers/tss.h"
19
 
#include "trousers/trousers.h"
20
 
#include "spi_internal_types.h"
21
 
#include "spi_utils.h"
22
 
#include "capabilities.h"
23
 
#include "tsplog.h"
24
 
#include "obj.h"
25
 
 
26
 
/*
27
 
 *  popup_GetSecret()
28
 
 *
29
 
 *    newPIN - non-zero to popup the dialog to enter a new PIN, zero to popup a dialog
30
 
 *      to enter an existing PIN
31
 
 *    hash_mode - flag indicating whether to include null terminating data in the hash
32
 
 *      of the secret (1.2 backport only).
33
 
 *    popup_str - string to appear in the title bar of the popup dialog
34
 
 *    auth_hash - the 20+ byte buffer that receives the SHA1 hash of the auth data
35
 
 *      entered into the dialog box
36
 
 *
37
 
 */
38
 
TSS_RESULT
39
 
popup_GetSecret(UINT32 new_pin, UINT32 hash_mode, BYTE *popup_str, void *auth_hash)
40
 
{
41
 
        BYTE secret[UI_MAX_SECRET_STRING_LENGTH] = { 0 };
42
 
        BYTE *dflt = (BYTE *)"TSS Authentication Dialog";
43
 
        UINT32 secret_len;
44
 
 
45
 
        if (popup_str == NULL)
46
 
                popup_str = dflt;
47
 
 
48
 
        /* pin the area where the secret will be put in memory */
49
 
        if (pin_mem(&secret, UI_MAX_SECRET_STRING_LENGTH)) {
50
 
                LogError("Failed to pin secret in memory.");
51
 
                return TSPERR(TSS_E_INTERNAL_ERROR);
52
 
        }
53
 
 
54
 
        if (new_pin)
55
 
                DisplayNewPINWindow(secret, &secret_len, popup_str);
56
 
        else
57
 
                DisplayPINWindow(secret, &secret_len, popup_str);
58
 
 
59
 
        if (!secret_len) {
60
 
                unpin_mem(&secret, UI_MAX_SECRET_STRING_LENGTH);
61
 
                return TSPERR(TSS_E_POLICY_NO_SECRET);
62
 
        }
63
 
 
64
 
#ifndef TSS_SPEC_COMPLIANCE
65
 
        if (hash_mode == TSS_TSPATTRIB_HASH_MODE_NOT_NULL)
66
 
                secret_len -= sizeof(UNICODE); // Take off the NULL terminator
67
 
#endif
68
 
        LogDebug("Hashing these %u bytes as the secret:", secret_len);
69
 
        LogDebugData(secret_len, secret);
70
 
        Trspi_Hash(TSS_HASH_SHA1, secret_len, secret, auth_hash);
71
 
 
72
 
        /* zero, then unpin the memory */
73
 
        memset(secret, 0, secret_len);
74
 
        unpin_mem(&secret, UI_MAX_SECRET_STRING_LENGTH);
75
 
 
76
 
        return TSS_SUCCESS;
77
 
}
78
 
 
79
 
TSS_RESULT
80
 
secret_PerformAuth_OIAP(TSS_HOBJECT hAuthorizedObject, UINT32 ulPendingFn,
81
 
                        TSS_HPOLICY hPolicy, TCPA_DIGEST *hashDigest,
82
 
                        TPM_AUTH *auth)
83
 
{
84
 
        TSS_RESULT result;
85
 
        TSS_BOOL bExpired;
86
 
        UINT32 mode;
87
 
        TCPA_SECRET secret;
88
 
        TSS_HCONTEXT tspContext;
89
 
 
90
 
        /* This validates that the secret can be used */
91
 
        if ((result = obj_policy_has_expired(hPolicy, &bExpired)))
92
 
                return result;
93
 
 
94
 
        if (bExpired == TRUE)
95
 
                return TSPERR(TSS_E_INVALID_OBJ_ACCESS);
96
 
 
97
 
        if ((result = obj_policy_get_tsp_context(hPolicy, &tspContext)))
98
 
                return result;
99
 
 
100
 
        if ((result = obj_policy_get_mode(hPolicy, &mode)))
101
 
                return result;
102
 
 
103
 
        if ((result = Init_AuthNonce(tspContext, auth)))
104
 
                return result;
105
 
 
106
 
        /* added retry logic */
107
 
        if ((result = TCSP_OIAP(tspContext, &auth->AuthHandle, &auth->NonceEven))) {
108
 
                if (result == TCPA_E_RESOURCES) {
109
 
                        int retry = 0;
110
 
                        do {
111
 
                                /* POSIX sleep time, { secs, nanosecs } */
112
 
                                struct timespec t = { 0, AUTH_RETRY_NANOSECS };
113
 
 
114
 
                                nanosleep(&t, NULL);
115
 
 
116
 
                                result = TCSP_OIAP(tspContext, &auth->AuthHandle, &auth->NonceEven);
117
 
                        } while (result == TCPA_E_RESOURCES && ++retry < AUTH_RETRY_COUNT);
118
 
                }
119
 
 
120
 
                if (result)
121
 
                        return result;
122
 
        }
123
 
 
124
 
        switch (mode) {
125
 
                case TSS_SECRET_MODE_CALLBACK:
126
 
                        result = obj_policy_do_hmac(hPolicy, hAuthorizedObject,
127
 
                                                    TRUE, ulPendingFn,
128
 
                                                    auth->fContinueAuthSession,
129
 
                                                    20,
130
 
                                                    auth->NonceEven.nonce,
131
 
                                                    auth->NonceOdd.nonce,
132
 
                                                    NULL, NULL, 20,
133
 
                                                    hashDigest->digest,
134
 
                                                    (BYTE *)&auth->HMAC);
135
 
                        break;
136
 
                case TSS_SECRET_MODE_SHA1:
137
 
                case TSS_SECRET_MODE_PLAIN:
138
 
                case TSS_SECRET_MODE_POPUP:
139
 
                        if ((result = obj_policy_get_secret(hPolicy, TR_SECRET_CTX_NOT_NEW,
140
 
                                                            &secret)))
141
 
                                break;
142
 
 
143
 
                        HMAC_Auth(secret.authdata, hashDigest->digest, auth);
144
 
                        break;
145
 
                case TSS_SECRET_MODE_NONE:
146
 
                        /* fall through */
147
 
                default:
148
 
                        result = TSPERR(TSS_E_POLICY_NO_SECRET);
149
 
                        break;
150
 
        }
151
 
 
152
 
        if (result) {
153
 
                TCSP_TerminateHandle(tspContext, auth->AuthHandle);
154
 
                return result;
155
 
        }
156
 
 
157
 
        return obj_policy_dec_counter(hPolicy);
158
 
}
159
 
 
160
 
TSS_RESULT
161
 
secret_PerformXOR_OSAP(TSS_HPOLICY hPolicy, TSS_HPOLICY hUsagePolicy,
162
 
                       TSS_HPOLICY hMigrationPolicy, TSS_HOBJECT hOSAPObject,
163
 
                       UINT16 osapType, UINT32 osapData,
164
 
                       TCPA_ENCAUTH * encAuthUsage, TCPA_ENCAUTH * encAuthMig,
165
 
                       BYTE *sharedSecret, TPM_AUTH * auth, TCPA_NONCE * nonceEvenOSAP)
166
 
{
167
 
        TSS_BOOL bExpired;
168
 
        TCPA_SECRET keySecret;
169
 
        TCPA_SECRET usageSecret;
170
 
        TCPA_SECRET migSecret = { { 0, } };
171
 
        UINT32 keyMode, usageMode, migMode = 0;
172
 
        TSS_RESULT result;
173
 
        TSS_HCONTEXT tspContext;
174
 
 
175
 
        if ((result = obj_policy_has_expired(hPolicy, &bExpired)))
176
 
                return result;
177
 
 
178
 
        if (bExpired == TRUE)
179
 
                return TSPERR(TSS_E_INVALID_OBJ_ACCESS);
180
 
 
181
 
        if ((result = obj_policy_has_expired(hUsagePolicy, &bExpired)))
182
 
                return result;
183
 
 
184
 
        if (bExpired == TRUE)
185
 
                return TSPERR(TSS_E_INVALID_OBJ_ACCESS);
186
 
 
187
 
        if (hMigrationPolicy) {
188
 
                if ((result = obj_policy_has_expired(hMigrationPolicy, &bExpired)))
189
 
                        return result;
190
 
 
191
 
                if (bExpired == TRUE)
192
 
                        return TSPERR(TSS_E_INVALID_OBJ_ACCESS);
193
 
 
194
 
                if ((result = obj_policy_get_mode(hMigrationPolicy, &migMode)))
195
 
                        return result;
196
 
        }
197
 
 
198
 
 
199
 
        if ((result = obj_policy_get_tsp_context(hPolicy, &tspContext)))
200
 
                return result;
201
 
 
202
 
        if ((result = obj_policy_get_mode(hPolicy, &keyMode)))
203
 
                return result;
204
 
 
205
 
        if ((result = obj_policy_get_mode(hUsagePolicy, &usageMode)))
206
 
                return result;
207
 
 
208
 
        if (keyMode == TSS_SECRET_MODE_CALLBACK ||
209
 
            usageMode == TSS_SECRET_MODE_CALLBACK ||
210
 
            migMode == TSS_SECRET_MODE_CALLBACK) {
211
 
                if (keyMode != TSS_SECRET_MODE_CALLBACK ||
212
 
                    usageMode != TSS_SECRET_MODE_CALLBACK ||
213
 
                    (hMigrationPolicy && migMode != TSS_SECRET_MODE_CALLBACK))
214
 
                        return TSPERR(TSS_E_BAD_PARAMETER);
215
 
        }
216
 
 
217
 
        if (keyMode != TSS_SECRET_MODE_CALLBACK) {
218
 
                if ((result = obj_policy_get_secret(hPolicy, TR_SECRET_CTX_NOT_NEW, &keySecret)))
219
 
                        return result;
220
 
 
221
 
                if ((result = obj_policy_get_secret(hUsagePolicy, TR_SECRET_CTX_NEW, &usageSecret)))
222
 
                        return result;
223
 
 
224
 
                if (hMigrationPolicy) {
225
 
                        if ((result = obj_policy_get_secret(hMigrationPolicy, TR_SECRET_CTX_NEW,
226
 
                                                            &migSecret)))
227
 
                                return result;
228
 
                }
229
 
 
230
 
                if ((result = OSAP_Calc(tspContext, osapType, osapData,
231
 
                                        keySecret.authdata, usageSecret.authdata,
232
 
                                        migSecret.authdata, encAuthUsage,
233
 
                                        encAuthMig, sharedSecret, auth)))
234
 
                        return result;
235
 
        } else {
236
 
                /* If the secret mode is NONE here, we don't return an error. This is
237
 
                 * because there are commands such as CreateKey, which require an auth
238
 
                 * session even when creating no-auth keys. A secret of all 0's will be
239
 
                 * used in this case. */
240
 
                if ((result = TCSP_OSAP(tspContext, osapType, osapData,
241
 
                                        auth->NonceOdd, &auth->AuthHandle,
242
 
                                        &auth->NonceEven, nonceEvenOSAP)))
243
 
                        return result;
244
 
 
245
 
                if ((result = obj_policy_do_xor(hPolicy, hOSAPObject,
246
 
                                                hPolicy, TRUE, 20,
247
 
                                                auth->NonceEven.nonce, NULL,
248
 
                                                nonceEvenOSAP->nonce,
249
 
                                                auth->NonceOdd.nonce, 20,
250
 
                                                encAuthUsage->authdata,
251
 
                                                encAuthMig->authdata))) {
252
 
                        TCSP_TerminateHandle(tspContext, auth->AuthHandle);
253
 
                        return result;
254
 
                }
255
 
        }
256
 
 
257
 
        return TSS_SUCCESS;
258
 
}
259
 
 
260
 
TSS_RESULT
261
 
secret_PerformAuth_OSAP(TSS_HOBJECT hAuthorizedObject, UINT32 ulPendingFn,
262
 
                        TSS_HPOLICY hPolicy, TSS_HPOLICY hUsagePolicy,
263
 
                        TSS_HPOLICY hMigPolicy, BYTE sharedSecret[20],
264
 
                        TPM_AUTH *auth, BYTE *hashDigest,
265
 
                        TCPA_NONCE *nonceEvenOSAP)
266
 
{
267
 
        TSS_RESULT result;
268
 
        UINT32 keyMode, usageMode, migMode = 0;
269
 
 
270
 
        if ((result = obj_policy_get_mode(hPolicy, &keyMode)))
271
 
                return result;
272
 
 
273
 
        if ((result = obj_policy_get_mode(hUsagePolicy, &usageMode)))
274
 
                return result;
275
 
 
276
 
        if (hMigPolicy) {
277
 
                if ((result = obj_policy_get_mode(hMigPolicy, &migMode)))
278
 
                        return result;
279
 
        }
280
 
 
281
 
        /* ---  If any of them is a callback */
282
 
        if (keyMode == TSS_SECRET_MODE_CALLBACK ||
283
 
            usageMode == TSS_SECRET_MODE_CALLBACK ||
284
 
            (hMigPolicy && migMode == TSS_SECRET_MODE_CALLBACK)) {
285
 
                /* ---  And they're not all callback */
286
 
                if (keyMode != TSS_SECRET_MODE_CALLBACK ||
287
 
                    usageMode != TSS_SECRET_MODE_CALLBACK ||
288
 
                    (hMigPolicy && migMode != TSS_SECRET_MODE_CALLBACK))
289
 
                        return TSPERR(TSS_E_BAD_PARAMETER);
290
 
        }
291
 
 
292
 
        if (keyMode == TSS_SECRET_MODE_CALLBACK) {
293
 
                if ((result = obj_policy_do_hmac(hPolicy, hAuthorizedObject,
294
 
                                                 TRUE, ulPendingFn,
295
 
                                                 auth->fContinueAuthSession,
296
 
                                                 20,
297
 
                                                 auth->NonceEven.nonce,
298
 
                                                 NULL,
299
 
                                                 nonceEvenOSAP->nonce,
300
 
                                                 auth->NonceOdd.nonce, 20,
301
 
                                                 hashDigest,
302
 
                                                 (BYTE *)&auth->HMAC)))
303
 
                        return result;
304
 
        } else {
305
 
                HMAC_Auth(sharedSecret, hashDigest, auth);
306
 
        }
307
 
 
308
 
        if ((result = obj_policy_dec_counter(hPolicy)))
309
 
                return result;
310
 
 
311
 
        if ((result = obj_policy_dec_counter(hUsagePolicy)))
312
 
                return result;
313
 
 
314
 
        if (hMigPolicy) {
315
 
                if ((result = obj_policy_dec_counter(hMigPolicy)))
316
 
                        return result;
317
 
        }
318
 
 
319
 
        return TSS_SUCCESS;
320
 
}
321
 
 
322
 
TSS_RESULT
323
 
secret_ValidateAuth_OSAP(TSS_HOBJECT hAuthorizedObject, UINT32 ulPendingFn,
324
 
                         TSS_HPOLICY hPolicy, TSS_HPOLICY hUsagePolicy,
325
 
                         TSS_HPOLICY hMigPolicy, BYTE sharedSecret[20],
326
 
                         TPM_AUTH *auth, BYTE *hashDigest,
327
 
                         TCPA_NONCE *nonceEvenOSAP)
328
 
{
329
 
        TSS_RESULT result;
330
 
        UINT32 keyMode, usageMode, migMode = 0;
331
 
 
332
 
        if ((result = obj_policy_get_mode(hPolicy, &keyMode)))
333
 
                return result;
334
 
 
335
 
        if ((result = obj_policy_get_mode(hUsagePolicy, &usageMode)))
336
 
                return result;
337
 
 
338
 
        if (hMigPolicy) {
339
 
                if ((result = obj_policy_get_mode(hMigPolicy, &migMode)))
340
 
                        return result;
341
 
        }
342
 
 
343
 
        /* ---  If any of them is a callback */
344
 
        if (keyMode == TSS_SECRET_MODE_CALLBACK ||
345
 
            usageMode == TSS_SECRET_MODE_CALLBACK ||
346
 
            migMode == TSS_SECRET_MODE_CALLBACK) {
347
 
                /* ---  And they're not all callback */
348
 
                if (keyMode != TSS_SECRET_MODE_CALLBACK ||
349
 
                    usageMode != TSS_SECRET_MODE_CALLBACK ||
350
 
                    (hMigPolicy && migMode != TSS_SECRET_MODE_CALLBACK))
351
 
                        return TSPERR(TSS_E_BAD_PARAMETER);
352
 
        }
353
 
 
354
 
        if (keyMode != TSS_SECRET_MODE_CALLBACK) {
355
 
                if (validateReturnAuth(sharedSecret, hashDigest, auth))
356
 
                        return TSPERR(TSS_E_TSP_AUTHFAIL);
357
 
        } else {
358
 
                if ((result = obj_policy_do_hmac(hPolicy, hAuthorizedObject,
359
 
                                                 FALSE, ulPendingFn,
360
 
                                                 auth->fContinueAuthSession,
361
 
                                                 20,
362
 
                                                 auth->NonceEven.nonce,
363
 
                                                 NULL,
364
 
                                                 nonceEvenOSAP->nonce,
365
 
                                                 auth->NonceOdd.nonce, 20,
366
 
                                                 hashDigest,
367
 
                                                 (BYTE *)&auth->HMAC)))
368
 
                        return result;
369
 
        }
370
 
 
371
 
        return TSS_SUCCESS;
372
 
}
373
 
 
374
 
TSS_RESULT
375
 
secret_TakeOwnership(TSS_HKEY hEndorsementPubKey,
376
 
                     TSS_HTPM hTPM,
377
 
                     TSS_HKEY hKeySRK,
378
 
                     TPM_AUTH * auth,
379
 
                     UINT32 * encOwnerAuthLength,
380
 
                     BYTE * encOwnerAuth, UINT32 * encSRKAuthLength, BYTE * encSRKAuth)
381
 
{
382
 
        TSS_RESULT result;
383
 
        UINT32 endorsementKeySize;
384
 
        BYTE *endorsementKey;
385
 
        TCPA_KEY dummyKey;
386
 
        UINT64 offset;
387
 
        TCPA_SECRET ownerSecret;
388
 
        TCPA_SECRET srkSecret;
389
 
        BYTE hashblob[1024];
390
 
        TCPA_DIGEST digest;
391
 
        TSS_HPOLICY hSrkPolicy;
392
 
        TSS_HPOLICY hOwnerPolicy;
393
 
        UINT32 srkKeyBlobLength;
394
 
        BYTE *srkKeyBlob;
395
 
        TSS_HCONTEXT tspContext;
396
 
        UINT32 ownerMode, srkMode;
397
 
 
398
 
        if ((result = obj_tpm_get_tsp_context(hTPM, &tspContext)))
399
 
                return result;
400
 
 
401
 
        /*************************************************
402
 
         *      First, get the policy objects and check them for how
403
 
         *              to handle the secrets.  If they cannot be found
404
 
         *              or there is an error, then we must fail
405
 
         **************************************************/
406
 
 
407
 
        /* First get the Owner Policy */
408
 
        if ((result = Tspi_GetPolicyObject(hTPM, TSS_POLICY_USAGE, &hOwnerPolicy)))
409
 
                return result;
410
 
 
411
 
        /* Now get the SRK Policy */
412
 
 
413
 
        if ((result = Tspi_GetPolicyObject(hKeySRK, TSS_POLICY_USAGE, &hSrkPolicy)))
414
 
                return result;
415
 
 
416
 
        if ((result = obj_policy_get_mode(hOwnerPolicy, &ownerMode)))
417
 
                return result;
418
 
 
419
 
        if ((result = obj_policy_get_mode(hSrkPolicy, &srkMode)))
420
 
                return result;
421
 
 
422
 
        /* If the policy callback's aren't the same, that's an error if one is callback */
423
 
        if (srkMode == TSS_SECRET_MODE_CALLBACK ||
424
 
            ownerMode == TSS_SECRET_MODE_CALLBACK) {
425
 
                if (srkMode != TSS_SECRET_MODE_CALLBACK ||
426
 
                    ownerMode != TSS_SECRET_MODE_CALLBACK) {
427
 
                        LogError("Policy callback modes for SRK policy and "
428
 
                                        "Owner policy differ");
429
 
                        return TSPERR(TSS_E_BAD_PARAMETER);
430
 
                }
431
 
        }
432
 
 
433
 
        if (ownerMode != TSS_SECRET_MODE_CALLBACK) {
434
 
                /* First, get the Endorsement Public Key for Encrypting */
435
 
                if ((result = Tspi_GetAttribData(hEndorsementPubKey,
436
 
                                            TSS_TSPATTRIB_KEY_BLOB,
437
 
                                            TSS_TSPATTRIB_KEYBLOB_BLOB,
438
 
                                            &endorsementKeySize, &endorsementKey)))
439
 
                        return result;
440
 
 
441
 
                /* now stick it in a Key Structure */
442
 
                offset = 0;
443
 
                if ((result = Trspi_UnloadBlob_KEY(&offset, endorsementKey, &dummyKey)))
444
 
                        return result;
445
 
 
446
 
                if ((result = obj_policy_get_secret(hOwnerPolicy, TR_SECRET_CTX_NEW,
447
 
                                                    &ownerSecret))) {
448
 
                        free(dummyKey.pubKey.key);
449
 
                        free(dummyKey.algorithmParms.parms);
450
 
                        return result;
451
 
                }
452
 
 
453
 
                if ((result = obj_policy_get_secret(hSrkPolicy, TR_SECRET_CTX_NEW, &srkSecret))) {
454
 
                        free(dummyKey.pubKey.key);
455
 
                        free(dummyKey.algorithmParms.parms);
456
 
                        return result;
457
 
                }
458
 
 
459
 
                /* Encrypt the Owner, SRK Authorizations */
460
 
                if ((result = Trspi_RSA_Encrypt(ownerSecret.authdata, 20, encOwnerAuth,
461
 
                                                encOwnerAuthLength, dummyKey.pubKey.key,
462
 
                                                dummyKey.pubKey.keyLength))) {
463
 
                        free(dummyKey.pubKey.key);
464
 
                        free(dummyKey.algorithmParms.parms);
465
 
                        return result;
466
 
                }
467
 
 
468
 
                if ((result = Trspi_RSA_Encrypt(srkSecret.authdata, 20, encSRKAuth,
469
 
                                                encSRKAuthLength, dummyKey.pubKey.key,
470
 
                                                dummyKey.pubKey.keyLength))) {
471
 
                        free(dummyKey.pubKey.key);
472
 
                        free(dummyKey.algorithmParms.parms);
473
 
                        return result;
474
 
                }
475
 
 
476
 
                free(dummyKey.pubKey.key);
477
 
                free(dummyKey.algorithmParms.parms);
478
 
        } else {
479
 
                *encOwnerAuthLength = 256;
480
 
                *encSRKAuthLength = 256;
481
 
                if ((result = obj_policy_do_takeowner(hOwnerPolicy, hTPM,
482
 
                                                      hEndorsementPubKey,
483
 
                                                      *encOwnerAuthLength,
484
 
                                                      encOwnerAuth)))
485
 
                        return result;
486
 
        }
487
 
 
488
 
        if ((result = Tspi_GetAttribData(hKeySRK,
489
 
                                         TSS_TSPATTRIB_KEY_BLOB,
490
 
                                         TSS_TSPATTRIB_KEYBLOB_BLOB,
491
 
                                         &srkKeyBlobLength,
492
 
                                         &srkKeyBlob)))
493
 
                return result;
494
 
 
495
 
        /* Authorizatin Digest Calculation */
496
 
        /* Hash first the following: */
497
 
        offset = 0;
498
 
        Trspi_LoadBlob_UINT32(&offset, TPM_ORD_TakeOwnership, hashblob);
499
 
        Trspi_LoadBlob_UINT16(&offset, TCPA_PID_OWNER, hashblob);
500
 
        Trspi_LoadBlob_UINT32(&offset, *encOwnerAuthLength, hashblob);
501
 
        Trspi_LoadBlob(&offset, *encOwnerAuthLength, hashblob, encOwnerAuth);
502
 
        Trspi_LoadBlob_UINT32(&offset, *encSRKAuthLength, hashblob);
503
 
        Trspi_LoadBlob(&offset, *encSRKAuthLength, hashblob, encSRKAuth);
504
 
        Trspi_LoadBlob(&offset, srkKeyBlobLength, hashblob, srkKeyBlob);
505
 
 
506
 
        Trspi_Hash(TSS_HASH_SHA1, offset, hashblob, digest.digest);
507
 
 
508
 
        /* HMAC for the final digest */
509
 
 
510
 
        if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_TakeOwnership,
511
 
                                              hOwnerPolicy, &digest, auth)))
512
 
                return result;
513
 
 
514
 
        return TSS_SUCCESS;
515
 
}