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_Sign(struct tcsd_thread_data *data)
33
TCS_CONTEXT_HANDLE hContext;
35
UINT32 areaToSignSize;
47
if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
48
return TCSERR(TSS_E_INTERNAL_ERROR);
50
LogDebugFn("thread %zd context %x", THREAD_ID, hContext);
52
if (getData(TCSD_PACKET_TYPE_UINT32, 1, &hKey, 0, &data->comm))
53
return TCSERR(TSS_E_INTERNAL_ERROR);
54
if (getData(TCSD_PACKET_TYPE_UINT32, 2, &areaToSignSize, 0, &data->comm))
55
return TCSERR(TSS_E_INTERNAL_ERROR);
57
areaToSign = calloc(1, areaToSignSize);
58
if (areaToSign == NULL) {
59
LogError("malloc of %d bytes failed.", areaToSignSize);
60
return TCSERR(TSS_E_OUTOFMEMORY);
62
if (getData(TCSD_PACKET_TYPE_PBYTE, 3, areaToSign, areaToSignSize, &data->comm)) {
64
return TCSERR(TSS_E_INTERNAL_ERROR);
66
result = getData(TCSD_PACKET_TYPE_AUTH, 4, &auth, 0, &data->comm);
67
if (result == TSS_TCP_RPC_BAD_PACKET_TYPE)
75
MUTEX_LOCK(tcsp_lock);
77
result = TCSP_Sign_Internal(hContext, hKey, areaToSignSize, areaToSign, pAuth, &sigSize,
80
MUTEX_UNLOCK(tcsp_lock);
83
if (result == TSS_SUCCESS) {
85
initData(&data->comm, 3);
87
if (setData(TCSD_PACKET_TYPE_AUTH, i++, &auth, 0, &data->comm)) {
89
return TCSERR(TSS_E_INTERNAL_ERROR);
92
if (setData(TCSD_PACKET_TYPE_UINT32, i++, &sigSize, 0, &data->comm)) {
94
return TCSERR(TSS_E_INTERNAL_ERROR);
96
if (setData(TCSD_PACKET_TYPE_PBYTE, i++, sig, sigSize, &data->comm)) {
98
return TCSERR(TSS_E_INTERNAL_ERROR);
102
initData(&data->comm, 0);
104
data->comm.hdr.u.result = result;