3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2004-2006
17
#include "trousers/tss.h"
18
#include "trousers_types.h"
20
#include "tcs_utils.h"
21
#include "tcs_int_literals.h"
22
#include "capabilities.h"
24
#include "tcsd_wrap.h"
26
#include "tcs_utils.h"
27
#include "rpc_tcstp_tcs.h"
31
tcs_wrap_Quote(struct tcsd_thread_data *data)
33
TCS_CONTEXT_HANDLE hContext;
35
TCPA_NONCE antiReplay;
42
UINT32 pcrDataSizeOut;
50
if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
51
return TCSERR(TSS_E_INTERNAL_ERROR);
53
LogDebugFn("thread %zd context %x", THREAD_ID, hContext);
55
if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
56
return TCSERR(TSS_E_INTERNAL_ERROR);
57
if (getData(TCSD_PACKET_TYPE_NONCE, 2, &antiReplay, 0, &data->comm))
58
return TCSERR(TSS_E_INTERNAL_ERROR);
59
if (getData(TCSD_PACKET_TYPE_UINT32, 3, &pcrDataSizeIn, 0, &data->comm))
60
return TCSERR(TSS_E_INTERNAL_ERROR);
61
pcrDataIn = (BYTE *)calloc(1, pcrDataSizeIn);
62
if (pcrDataIn == NULL) {
63
LogError("malloc of %d bytes failed.", pcrDataSizeIn);
64
return TCSERR(TSS_E_OUTOFMEMORY);
66
if (getData(TCSD_PACKET_TYPE_PBYTE, 4, pcrDataIn, pcrDataSizeIn, &data->comm)) {
68
return TCSERR(TSS_E_INTERNAL_ERROR);
71
result = getData(TCSD_PACKET_TYPE_AUTH, 5, &privAuth, 0, &data->comm);
72
if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
78
pPrivAuth = &privAuth;
80
MUTEX_LOCK(tcsp_lock);
82
result = TCSP_Quote_Internal(hContext, hKey, antiReplay, pcrDataSizeIn, pcrDataIn,
83
pPrivAuth, &pcrDataSizeOut, &pcrDataOut, &sigSize, &sig);
85
MUTEX_UNLOCK(tcsp_lock);
88
if (result == TSS_SUCCESS) {
90
initData(&data->comm, 5);
91
if (pPrivAuth != NULL) {
92
if (setData(TCSD_PACKET_TYPE_AUTH, i++, pPrivAuth, 0, &data->comm)) {
95
return TCSERR(TSS_E_INTERNAL_ERROR);
98
if (setData(TCSD_PACKET_TYPE_UINT32, i++, &pcrDataSizeOut, 0, &data->comm)) {
101
return TCSERR(TSS_E_INTERNAL_ERROR);
103
if (setData(TCSD_PACKET_TYPE_PBYTE, i++, pcrDataOut, pcrDataSizeOut, &data->comm)) {
106
return TCSERR(TSS_E_INTERNAL_ERROR);
108
if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
111
return TCSERR(TSS_E_INTERNAL_ERROR);
113
if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
116
return TCSERR(TSS_E_INTERNAL_ERROR);
122
initData(&data->comm, 0);
124
data->comm.hdr.u.result = result;