3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2007
16
#include "trousers/tss.h"
17
#include "trousers/trousers.h"
18
#include "trousers_types.h"
20
#include "hosttable.h"
21
#include "tcsd_wrap.h"
22
#include "rpc_tcstp_tsp.h"
26
RPC_SetOrdinalAuditStatus_TP(struct host_table_entry *hte,
27
TPM_AUTH *ownerAuth, /* in/out */
28
UINT32 ulOrdinal, /* in */
29
TSS_BOOL bAuditState) /* in */
33
initData(&hte->comm, 4);
34
hte->comm.hdr.u.ordinal = TCSD_ORD_SETORDINALAUDITSTATUS;
35
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
37
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
38
return TSPERR(TSS_E_INTERNAL_ERROR);
39
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &ulOrdinal, 0, &hte->comm))
40
return TSPERR(TSS_E_INTERNAL_ERROR);
41
if (setData(TCSD_PACKET_TYPE_BOOL, 2, &bAuditState, 0, &hte->comm))
42
return TSPERR(TSS_E_INTERNAL_ERROR);
43
if (setData(TCSD_PACKET_TYPE_AUTH, 3, ownerAuth, 0, &hte->comm))
44
return TSPERR(TSS_E_INTERNAL_ERROR);
46
result = sendTCSDPacket(hte);
48
if (result == TSS_SUCCESS)
49
result = hte->comm.hdr.u.result;
51
if (result == TSS_SUCCESS) {
52
if (getData(TCSD_PACKET_TYPE_AUTH, 0, ownerAuth, 0, &hte->comm))
53
result = TSPERR(TSS_E_INTERNAL_ERROR);
60
RPC_GetAuditDigest_TP(struct host_table_entry *hte,
61
UINT32 startOrdinal, /* in */
62
TPM_DIGEST *auditDigest, /* out */
63
UINT32 *counterValueSize, /* out */
64
BYTE **counterValue, /* out */
65
TSS_BOOL *more, /* out */
66
UINT32 *ordSize, /* out */
67
UINT32 **ordList) /* out */
71
initData(&hte->comm, 2);
72
hte->comm.hdr.u.ordinal = TCSD_ORD_GETAUDITDIGEST;
73
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
75
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
76
return TSPERR(TSS_E_INTERNAL_ERROR);
77
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &startOrdinal, 0, &hte->comm))
78
return TSPERR(TSS_E_INTERNAL_ERROR);
80
result = sendTCSDPacket(hte);
82
if (result == TSS_SUCCESS)
83
result = hte->comm.hdr.u.result;
85
if (result == TSS_SUCCESS) {
86
if (getData(TCSD_PACKET_TYPE_DIGEST, 0, auditDigest, 0, &hte->comm)) {
87
result = TSPERR(TSS_E_INTERNAL_ERROR);
90
if (getData(TCSD_PACKET_TYPE_UINT32, 1, counterValueSize, 0, &hte->comm)) {
91
result = TSPERR(TSS_E_INTERNAL_ERROR);
94
*counterValue = (BYTE *)malloc(*counterValueSize);
95
if (*counterValue == NULL) {
96
LogError("malloc of %u bytes failed.", *counterValueSize);
97
result = TSPERR(TSS_E_OUTOFMEMORY);
100
if (getData(TCSD_PACKET_TYPE_PBYTE, 2, *counterValue, *counterValueSize, &hte->comm)) {
102
result = TSPERR(TSS_E_INTERNAL_ERROR);
105
if (getData(TCSD_PACKET_TYPE_BOOL, 3, more, 0, &hte->comm)) {
107
result = TSPERR(TSS_E_INTERNAL_ERROR);
110
if (getData(TCSD_PACKET_TYPE_UINT32, 4, ordSize, 0, &hte->comm)) {
112
result = TSPERR(TSS_E_INTERNAL_ERROR);
115
*ordList = (UINT32 *)malloc(*ordSize * sizeof(UINT32));
116
if (*ordList == NULL) {
117
LogError("malloc of %u bytes failed.", *ordSize);
119
result = TSPERR(TSS_E_OUTOFMEMORY);
122
if (getData(TCSD_PACKET_TYPE_PBYTE, 5, *ordList, *ordSize * sizeof(UINT32), &hte->comm)) {
125
result = TSPERR(TSS_E_INTERNAL_ERROR);
135
RPC_GetAuditDigestSigned_TP(struct host_table_entry *hte,
136
TCS_KEY_HANDLE keyHandle, /* in */
137
TSS_BOOL closeAudit, /* in */
138
TPM_NONCE *antiReplay, /* in */
139
TPM_AUTH *privAuth, /* in/out */
140
UINT32 *counterValueSize, /* out */
141
BYTE **counterValue, /* out */
142
TPM_DIGEST *auditDigest, /* out */
143
TPM_DIGEST *ordinalDigest, /* out */
144
UINT32 *sigSize, /* out */
145
BYTE **sig) /* out */
147
TSS_RESULT result = TSPERR(TSS_E_INTERNAL_ERROR);
151
initData(&hte->comm, 5);
152
hte->comm.hdr.u.ordinal = TCSD_ORD_GETAUDITDIGESTSIGNED;
153
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
155
memset(&null_auth, 0, sizeof(TPM_AUTH));
157
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
158
return TSPERR(TSS_E_INTERNAL_ERROR);
159
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &keyHandle, 0, &hte->comm))
160
return TSPERR(TSS_E_INTERNAL_ERROR);
161
if (setData(TCSD_PACKET_TYPE_BOOL, 2, &closeAudit, 0, &hte->comm))
162
return TSPERR(TSS_E_INTERNAL_ERROR);
163
if (setData(TCSD_PACKET_TYPE_NONCE, 3, antiReplay, 0, &hte->comm))
164
return TSPERR(TSS_E_INTERNAL_ERROR);
166
if (setData(TCSD_PACKET_TYPE_AUTH, 4, privAuth, 0, &hte->comm))
167
return TSPERR(TSS_E_INTERNAL_ERROR);
170
if (setData(TCSD_PACKET_TYPE_AUTH, 4, &null_auth, 0, &hte->comm))
171
return TSPERR(TSS_E_INTERNAL_ERROR);
174
result = sendTCSDPacket(hte);
176
if (result == TSS_SUCCESS)
177
result = hte->comm.hdr.u.result;
179
if (result == TSS_SUCCESS) {
182
if (getData(TCSD_PACKET_TYPE_AUTH, i++, privAuth, 0, &hte->comm)) {
183
result = TSPERR(TSS_E_INTERNAL_ERROR);
187
if (getData(TCSD_PACKET_TYPE_UINT32, i++, counterValueSize, 0, &hte->comm)) {
188
result = TSPERR(TSS_E_INTERNAL_ERROR);
191
*counterValue = (BYTE *)malloc(*counterValueSize);
192
if (*counterValue == NULL) {
193
LogError("malloc of %u bytes failed.", *counterValueSize);
194
result = TSPERR(TSS_E_OUTOFMEMORY);
197
if (getData(TCSD_PACKET_TYPE_PBYTE, i++, *counterValue, *counterValueSize, &hte->comm)) {
199
result = TSPERR(TSS_E_INTERNAL_ERROR);
202
if (getData(TCSD_PACKET_TYPE_DIGEST, i++, auditDigest, 0, &hte->comm)) {
204
result = TSPERR(TSS_E_INTERNAL_ERROR);
207
if (getData(TCSD_PACKET_TYPE_DIGEST, i++, ordinalDigest, 0, &hte->comm)) {
209
result = TSPERR(TSS_E_INTERNAL_ERROR);
212
if (getData(TCSD_PACKET_TYPE_UINT32, i++, sigSize, 0, &hte->comm)) {
214
result = TSPERR(TSS_E_INTERNAL_ERROR);
217
*sig = (BYTE *)malloc(*sigSize);
219
LogError("malloc of %u bytes failed.", *sigSize);
221
result = TSPERR(TSS_E_OUTOFMEMORY);
224
if (getData(TCSD_PACKET_TYPE_PBYTE, i++, *sig, *sigSize, &hte->comm)) {
227
result = TSPERR(TSS_E_INTERNAL_ERROR);