3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2006
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
* This function provides a funnel through which all the TCSP_SetCapability requests can be
27
* sent. This will keep the owner auth code from being duplicated around the TSP.
30
TSP_SetCapability(TSS_HCONTEXT tspContext,
32
TSS_HPOLICY hTPMPolicy,
33
TPM_CAPABILITY_AREA tcsCapArea,
38
Trspi_HashCtx hashCtx;
42
subCap = endian32(subCap);
44
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
45
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_SetCapability);
46
result |= Trspi_Hash_UINT32(&hashCtx, tcsCapArea);
47
result |= Trspi_Hash_UINT32(&hashCtx, (UINT32)sizeof(UINT32));
48
result |= Trspi_HashUpdate(&hashCtx, (UINT32)sizeof(UINT32), (BYTE *)&subCap);
49
result |= Trspi_Hash_UINT32(&hashCtx, (UINT32)sizeof(TSS_BOOL));
50
result |= Trspi_Hash_BOOL(&hashCtx, value);
51
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
54
if ((result = secret_PerformAuth_OIAP(hTPM, TPM_ORD_SetCapability, hTPMPolicy, FALSE,
58
if ((result = TCS_API(tspContext)->SetCapability(tspContext, tcsCapArea, sizeof(UINT32),
59
(BYTE *)&subCap, sizeof(TSS_BOOL),
60
(BYTE *)&value, &auth)))
63
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
64
result |= Trspi_Hash_UINT32(&hashCtx, result);
65
result |= Trspi_Hash_UINT32(&hashCtx, TPM_ORD_SetCapability);
66
if ((result |= Trspi_HashFinal(&hashCtx, digest.digest)))
69
return obj_policy_validate_auth_oiap(hTPMPolicy, &digest, &auth);
72
#ifdef TSS_BUILD_TRANSPORT
74
Transport_GetTPMCapability(TSS_HCONTEXT tspContext, /* in */
75
TPM_CAPABILITY_AREA capArea, /* in */
76
UINT32 subCapLen, /* in */
77
BYTE* subCap, /* in */
78
UINT32* respLen, /* out */
79
BYTE** resp) /* out */
82
UINT32 decLen = 0, dataLen;
85
TCS_HANDLE handlesLen = 0;
88
if ((result = obj_context_transport_init(tspContext)))
91
LogDebugFn("Executing in a transport session");
93
dataLen = (2 * sizeof(UINT32)) + subCapLen;
94
if ((data = malloc(dataLen)) == NULL) {
95
LogError("malloc of %u bytes failed", dataLen);
96
return TSPERR(TSS_E_OUTOFMEMORY);
100
Trspi_LoadBlob_UINT32(&offset, capArea, data);
101
Trspi_LoadBlob_UINT32(&offset, subCapLen, data);
102
Trspi_LoadBlob(&offset, subCapLen, data, subCap);
104
if ((result = obj_context_transport_execute(tspContext, TPM_ORD_GetCapability, dataLen,
105
data, NULL, &handlesLen, NULL, NULL, NULL,
113
Trspi_UnloadBlob_UINT32(&offset, respLen, dec);
115
if ((*resp = malloc(*respLen)) == NULL) {
117
LogError("malloc of %u bytes failed", *respLen);
118
return TSPERR(TSS_E_OUTOFMEMORY);
121
Trspi_UnloadBlob(&offset, *respLen, dec, *resp);
129
Transport_SetCapability(TSS_HCONTEXT tspContext, /* in */
130
TCPA_CAPABILITY_AREA capArea, /* in */
131
UINT32 subCapSize, /* in */
132
BYTE * subCap, /* in */
133
UINT32 valueSize, /* in */
134
BYTE * value, /* in */
135
TPM_AUTH *ownerAuth) /* in, out */
140
TCS_HANDLE handlesLen = 0;
143
if ((result = obj_context_transport_init(tspContext)))
146
LogDebugFn("Executing in a transport session");
148
dataLen = (3 * sizeof(UINT32)) + subCapSize + valueSize;
149
if ((data = malloc(dataLen)) == NULL) {
150
LogError("malloc of %u bytes failed", dataLen);
151
return TSPERR(TSS_E_OUTOFMEMORY);
155
Trspi_LoadBlob_UINT32(&offset, capArea, data);
156
Trspi_LoadBlob_UINT32(&offset, subCapSize, data);
157
Trspi_LoadBlob(&offset, subCapSize, data, subCap);
158
Trspi_LoadBlob_UINT32(&offset, valueSize, data);
159
Trspi_LoadBlob(&offset, valueSize, data, value);
161
result = obj_context_transport_execute(tspContext, TPM_ORD_SetCapability, dataLen, data,
162
NULL, &handlesLen, NULL, NULL, NULL, NULL, NULL);