3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2004-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"
22
#include "hosttable.h"
23
#include "tcsd_wrap.h"
25
#include "rpc_tcstp_tsp.h"
29
RPC_Quote2_TP(struct host_table_entry *hte,
30
TCS_KEY_HANDLE keyHandle, /* in */
31
TCPA_NONCE *antiReplay, /* in */
32
UINT32 pcrDataSizeIn, /* in */
33
BYTE * pcrDataIn, /* in */
34
TSS_BOOL addVersion, /* in */
35
TPM_AUTH * privAuth, /* in, out */
36
UINT32 * pcrDataSizeOut, /* out */
37
BYTE ** pcrDataOut, /* out */
38
UINT32* versionInfoSize, /* out */
39
BYTE** versionInfo, /* out */
40
UINT32 * sigSize, /* out */
41
BYTE ** sig) /* out */
46
initData(&hte->comm, 7);
48
hte->comm.hdr.u.ordinal = TCSD_ORD_QUOTE2;
49
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
52
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
53
return TSPERR(TSS_E_INTERNAL_ERROR);
54
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &keyHandle, 0, &hte->comm))
55
return TSPERR(TSS_E_INTERNAL_ERROR);
56
if (setData(TCSD_PACKET_TYPE_NONCE, 2, antiReplay, 0, &hte->comm))
57
return TSPERR(TSS_E_INTERNAL_ERROR);
58
if (setData(TCSD_PACKET_TYPE_UINT32, 3, &pcrDataSizeIn, 0, &hte->comm))
59
return TSPERR(TSS_E_INTERNAL_ERROR);
60
if (setData(TCSD_PACKET_TYPE_PBYTE, 4, pcrDataIn, pcrDataSizeIn, &hte->comm))
61
return TSPERR(TSS_E_INTERNAL_ERROR);
62
if (setData(TCSD_PACKET_TYPE_BOOL, 5, &addVersion, 0, &hte->comm))
63
return TSPERR(TSS_E_INTERNAL_ERROR);
65
if (setData(TCSD_PACKET_TYPE_AUTH, 6, privAuth, 0, &hte->comm))
66
return TSPERR(TSS_E_INTERNAL_ERROR);
69
result = sendTCSDPacket(hte);
71
if (result == TSS_SUCCESS)
72
result = hte->comm.hdr.u.result;
74
/* Takes and sets the output data */
75
if (result == TSS_SUCCESS) {
78
if (getData(TCSD_PACKET_TYPE_AUTH, i++, privAuth, 0, &hte->comm)) {
79
result = TSPERR(TSS_E_INTERNAL_ERROR);
83
if (getData(TCSD_PACKET_TYPE_UINT32, i++, pcrDataSizeOut, 0, &hte->comm)) {
84
result = TSPERR(TSS_E_INTERNAL_ERROR);
88
*pcrDataOut = (BYTE *) malloc(*pcrDataSizeOut);
89
if (*pcrDataOut == NULL) {
90
LogError("malloc of %u bytes failed.", *pcrDataSizeOut);
91
result = TSPERR(TSS_E_OUTOFMEMORY);
94
if (getData(TCSD_PACKET_TYPE_PBYTE, i++, *pcrDataOut, *pcrDataSizeOut, &hte->comm)) {
96
result = TSPERR(TSS_E_INTERNAL_ERROR);
99
/* Retrieves the versionInfo Parameters */
100
if (getData(TCSD_PACKET_TYPE_UINT32, i++, versionInfoSize, 0, &hte->comm)) {
102
result = TSPERR(TSS_E_INTERNAL_ERROR);
105
if (*versionInfoSize >0){
106
*versionInfo = (BYTE *) malloc(*versionInfoSize);
107
if (*versionInfo == NULL) {
108
LogError("malloc of %u bytes failed.", *versionInfoSize);
110
result = TSPERR(TSS_E_OUTOFMEMORY);
113
if (getData(TCSD_PACKET_TYPE_PBYTE, i++, *versionInfo, *versionInfoSize,
117
result = TSPERR(TSS_E_INTERNAL_ERROR);
122
if (getData(TCSD_PACKET_TYPE_UINT32, i++, sigSize, 0, &hte->comm)) {
126
result = TSPERR(TSS_E_INTERNAL_ERROR);
129
*sig = (BYTE *) malloc(*sigSize);
131
LogError("malloc of %u bytes failed.", *sigSize);
135
result = TSPERR(TSS_E_OUTOFMEMORY);
138
if (getData(TCSD_PACKET_TYPE_PBYTE, i++, *sig, *sigSize, &hte->comm)) {
143
result = TSPERR(TSS_E_INTERNAL_ERROR);