1
2 /*
3 * Licensed Materials - Property of IBM
4 *
5 * trousers - An open source TCG Software Stack
6 *
7 * (C) Copyright International Business Machines Corp. 2004-2006
8 *
9 */
10
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <assert.h>
15
16 #include "trousers/tss.h"
17 #include "trousers/trousers.h"
18 #include "trousers_types.h"
19 #include "spi_utils.h"
20 #include "capabilities.h"
21 #include "tsplog.h"
22 #include "hosttable.h"
23 #include "tcsd_wrap.h"
24 #include "obj.h"
25 #include "rpc_tcstp_tsp.h"
26
27
28 TSS_RESULT
RPC_Extend_TP(struct host_table_entry * hte,TCPA_PCRINDEX pcrNum,TCPA_DIGEST inDigest,TCPA_PCRVALUE * outDigest)29 RPC_Extend_TP(struct host_table_entry *hte,
30 TCPA_PCRINDEX pcrNum, /* in */
31 TCPA_DIGEST inDigest, /* in */
32 TCPA_PCRVALUE * outDigest /* out */
33 ) {
34 TSS_RESULT result;
35
36 initData(&hte->comm, 3);
37 hte->comm.hdr.u.ordinal = TCSD_ORD_EXTEND;
38 LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
39
40 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
41 return TSPERR(TSS_E_INTERNAL_ERROR);
42 if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrNum, 0, &hte->comm))
43 return TSPERR(TSS_E_INTERNAL_ERROR);
44 if (setData(TCSD_PACKET_TYPE_DIGEST, 2, &inDigest, 0, &hte->comm))
45 return TSPERR(TSS_E_INTERNAL_ERROR);
46
47 result = sendTCSDPacket(hte);
48
49 if (result == TSS_SUCCESS)
50 result = hte->comm.hdr.u.result;
51
52 if (result == TSS_SUCCESS) {
53 if (getData(TCSD_PACKET_TYPE_DIGEST, 0, outDigest, 0, &hte->comm))
54 result = TSPERR(TSS_E_INTERNAL_ERROR);
55 }
56
57 return result;
58 }
59
60 TSS_RESULT
RPC_PcrRead_TP(struct host_table_entry * hte,TCPA_PCRINDEX pcrNum,TCPA_PCRVALUE * outDigest)61 RPC_PcrRead_TP(struct host_table_entry *hte,
62 TCPA_PCRINDEX pcrNum, /* in */
63 TCPA_PCRVALUE * outDigest /* out */
64 ) {
65 TSS_RESULT result;
66
67 initData(&hte->comm, 2);
68 hte->comm.hdr.u.ordinal = TCSD_ORD_PCRREAD;
69 LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
70
71 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
72 return TSPERR(TSS_E_INTERNAL_ERROR);
73 if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrNum, 0, &hte->comm))
74 return TSPERR(TSS_E_INTERNAL_ERROR);
75
76 result = sendTCSDPacket(hte);
77
78 if (result == TSS_SUCCESS)
79 result = hte->comm.hdr.u.result;
80
81 if (result == TSS_SUCCESS) {
82 if (getData(TCSD_PACKET_TYPE_DIGEST, 0, outDigest, 0, &hte->comm))
83 result = TSPERR(TSS_E_INTERNAL_ERROR);
84 }
85
86 return result;
87 }
88
89 TSS_RESULT
RPC_PcrReset_TP(struct host_table_entry * hte,UINT32 pcrDataSizeIn,BYTE * pcrDataIn)90 RPC_PcrReset_TP(struct host_table_entry *hte,
91 UINT32 pcrDataSizeIn, /* in */
92 BYTE * pcrDataIn) /* in */
93 {
94 TSS_RESULT result;
95
96 initData(&hte->comm, 3);
97 hte->comm.hdr.u.ordinal = TCSD_ORD_PCRRESET;
98 LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
99
100 if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
101 return TSPERR(TSS_E_INTERNAL_ERROR);
102 if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrDataSizeIn, 0, &hte->comm))
103 return TSPERR(TSS_E_INTERNAL_ERROR);
104 if (setData(TCSD_PACKET_TYPE_PBYTE, 2, pcrDataIn, pcrDataSizeIn, &hte->comm))
105 return TSPERR(TSS_E_INTERNAL_ERROR);
106
107 result = sendTCSDPacket(hte);
108
109 if (result == TSS_SUCCESS)
110 result = hte->comm.hdr.u.result;
111
112 return result;
113 }
114