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_GetRandom_TP(struct host_table_entry *hte,
30
UINT32 bytesRequested, /* in */
31
BYTE ** randomBytes) /* out */
35
initData(&hte->comm, 2);
36
hte->comm.hdr.u.ordinal = TCSD_ORD_GETRANDOM;
37
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
39
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
40
return TSPERR(TSS_E_INTERNAL_ERROR);
41
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &bytesRequested, 0, &hte->comm))
42
return TSPERR(TSS_E_INTERNAL_ERROR);
44
result = sendTCSDPacket(hte);
46
if (result == TSS_SUCCESS)
47
result = hte->comm.hdr.u.result;
49
if (result == TSS_SUCCESS) {
50
if (getData(TCSD_PACKET_TYPE_UINT32, 0, &bytesRequested, 0, &hte->comm)) {
51
result = TSPERR(TSS_E_INTERNAL_ERROR);
54
*randomBytes = (BYTE *) malloc(bytesRequested);
55
if (*randomBytes == NULL) {
56
LogError("malloc of %u bytes failed.", bytesRequested);
57
result = TSPERR(TSS_E_OUTOFMEMORY);
60
if (getData(TCSD_PACKET_TYPE_PBYTE, 1, *randomBytes, bytesRequested, &hte->comm)) {
62
result = TSPERR(TSS_E_INTERNAL_ERROR);
71
RPC_StirRandom_TP(struct host_table_entry *hte,
72
UINT32 inDataSize, /* in */
73
BYTE * inData) /* in */
77
initData(&hte->comm, 3);
78
hte->comm.hdr.u.ordinal = TCSD_ORD_STIRRANDOM;
79
LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
81
if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
82
return TSPERR(TSS_E_INTERNAL_ERROR);
83
if (setData(TCSD_PACKET_TYPE_UINT32, 1, &inDataSize, 0, &hte->comm))
84
return TSPERR(TSS_E_INTERNAL_ERROR);
85
if (setData(TCSD_PACKET_TYPE_PBYTE, 2, inData, inDataSize, &hte->comm))
86
return TSPERR(TSS_E_INTERNAL_ERROR);
88
result = sendTCSDPacket(hte);
90
if (result == TSS_SUCCESS)
91
result = hte->comm.hdr.u.result;