3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2004-2007
16
#include "trousers/tss.h"
17
#include "trousers/trousers.h"
18
#include "trousers_types.h"
19
#include "spi_utils.h"
20
#include "capabilities.h"
26
owner_get_pubek(TSS_HCONTEXT tspContext, TSS_HTPM hTPM, TSS_HKEY *hPubEk)
29
UINT32 tpmVersion, pubEKSize;
31
Trspi_HashCtx hashCtx;
38
if ((result = obj_context_get_tpm_version(tspContext, &tpmVersion)))
41
if ((result = obj_tpm_get_policy(hTPM, TSS_POLICY_USAGE, &hPolicy)))
46
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
47
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_OwnerReadInternalPub);
48
result |= Trspi_Hash_UINT32(&hashCtx, TPM_KH_EK);
49
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
52
if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_OwnerReadInternalPub,
53
hPolicy, FALSE, &digest, &ownerAuth)))
56
if ((result = TCS_API(tspContext)->OwnerReadInternalPub(tspContext, TPM_KH_EK,
57
&ownerAuth, &pubEKSize,
61
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
62
result |= Trspi_Hash_UINT32(&hashCtx, TPM_SUCCESS);
63
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_OwnerReadInternalPub);
64
result |= Trspi_HashUpdate(&hashCtx, pubEKSize, pubEK);
65
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
68
if ((result = obj_policy_validate_auth_oiap(hPolicy, &digest, &ownerAuth)))
72
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
73
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_OwnerReadPubek);
74
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
77
if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_OwnerReadPubek, hPolicy, FALSE,
78
&digest, &ownerAuth)))
81
if ((result = TCS_API(tspContext)->OwnerReadPubek(tspContext, &ownerAuth,
85
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
86
result |= Trspi_Hash_UINT32(&hashCtx, TPM_SUCCESS);
87
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_OwnerReadPubek);
88
result |= Trspi_HashUpdate(&hashCtx, pubEKSize, pubEK);
89
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
92
if ((result = obj_policy_validate_auth_oiap(hPolicy, &digest, &ownerAuth)))
98
if ((result = obj_rsakey_add(tspContext, TSS_KEY_SIZE_2048|TSS_KEY_TYPE_LEGACY, &hRetKey)))
101
if ((result = obj_rsakey_set_pubkey(hRetKey, TRUE, pubEK)))