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"
25
#ifdef TSS_BUILD_TRANSPORT
27
Transport_Quote(TSS_HCONTEXT tspContext, /* in */
28
TCS_KEY_HANDLE keyHandle, /* in */
29
TCPA_NONCE *antiReplay, /* in */
30
UINT32 pcrDataSizeIn, /* in */
31
BYTE * pcrDataIn, /* in */
32
TPM_AUTH * privAuth, /* in, out */
33
UINT32 * pcrDataSizeOut, /* out */
34
BYTE ** pcrDataOut, /* out */
35
UINT32 * sigSize, /* out */
36
BYTE ** sig) /* out */
39
UINT32 handlesLen, dataLen, decLen;
40
TCS_HANDLE *handles, handle;
42
TPM_DIGEST pubKeyHash;
43
Trspi_HashCtx hashCtx;
48
if ((result = obj_context_transport_init(tspContext)))
51
LogDebugFn("Executing in a transport session");
53
if ((result = obj_tcskey_get_pubkeyhash(keyHandle, pubKeyHash.digest)))
56
result = Trspi_HashInit(&hashCtx, TSS_HASH_SHA1);
57
result |= Trspi_Hash_DIGEST(&hashCtx, pubKeyHash.digest);
58
if ((result |= Trspi_HashFinal(&hashCtx, pubKeyHash.digest)))
65
dataLen = sizeof(TCPA_NONCE) + pcrDataSizeIn;
66
if ((data = malloc(dataLen)) == NULL) {
67
LogError("malloc of %u bytes failed", dataLen);
68
return TSPERR(TSS_E_OUTOFMEMORY);
72
Trspi_LoadBlob_NONCE(&offset, data, antiReplay);
73
Trspi_LoadBlob(&offset, pcrDataSizeIn, data, pcrDataIn);
75
if ((result = obj_context_transport_execute(tspContext, TPM_ORD_Quote, dataLen, data,
76
&pubKeyHash, &handlesLen, &handles,
77
privAuth, NULL, &decLen, &dec))) {
84
Trspi_UnloadBlob_PCR_COMPOSITE(&offset, dec, NULL);
85
*pcrDataSizeOut = offset;
87
if ((*pcrDataOut = malloc(*pcrDataSizeOut)) == NULL) {
89
LogError("malloc of %u bytes failed", *pcrDataSizeOut);
91
return TSPERR(TSS_E_OUTOFMEMORY);
95
Trspi_UnloadBlob(&offset, *pcrDataSizeOut, dec, *pcrDataOut);
96
Trspi_UnloadBlob_UINT32(&offset, sigSize, dec);
98
if ((*sig = malloc(*sigSize)) == NULL) {
103
LogError("malloc of %u bytes failed", *sigSize);
105
return TSPERR(TSS_E_OUTOFMEMORY);
107
Trspi_UnloadBlob(&offset, *sigSize, dec, *sig);