summaryrefslogtreecommitdiff
path: root/src/tspi/rpc/tcstp/rpc_pcr_extend.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2012-11-25 14:36:20 +0000
committerIgor Pashev <pashev.igor@gmail.com>2012-11-25 14:36:20 +0000
commitc3649a2def02c41d837ae1f79dda729ccb91e677 (patch)
treebea46dff212fdef977fe9094a70a939e8cc21885 /src/tspi/rpc/tcstp/rpc_pcr_extend.c
downloadtrousers-upstream.tar.gz
Imported Upstream version 0.3.9upstream/0.3.9upstream
Diffstat (limited to 'src/tspi/rpc/tcstp/rpc_pcr_extend.c')
-rw-r--r--src/tspi/rpc/tcstp/rpc_pcr_extend.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/src/tspi/rpc/tcstp/rpc_pcr_extend.c b/src/tspi/rpc/tcstp/rpc_pcr_extend.c
new file mode 100644
index 0000000..3e97ad1
--- /dev/null
+++ b/src/tspi/rpc/tcstp/rpc_pcr_extend.c
@@ -0,0 +1,113 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2004-2006
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+#include "trousers/tss.h"
+#include "trousers/trousers.h"
+#include "trousers_types.h"
+#include "spi_utils.h"
+#include "capabilities.h"
+#include "tsplog.h"
+#include "hosttable.h"
+#include "tcsd_wrap.h"
+#include "obj.h"
+#include "rpc_tcstp_tsp.h"
+
+
+TSS_RESULT
+RPC_Extend_TP(struct host_table_entry *hte,
+ TCPA_PCRINDEX pcrNum, /* in */
+ TCPA_DIGEST inDigest, /* in */
+ TCPA_PCRVALUE * outDigest /* out */
+ ) {
+ TSS_RESULT result;
+
+ initData(&hte->comm, 3);
+ hte->comm.hdr.u.ordinal = TCSD_ORD_EXTEND;
+ LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrNum, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_DIGEST, 2, &inDigest, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+
+ result = sendTCSDPacket(hte);
+
+ if (result == TSS_SUCCESS)
+ result = hte->comm.hdr.u.result;
+
+ if (result == TSS_SUCCESS) {
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 0, outDigest, 0, &hte->comm))
+ result = TSPERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return result;
+}
+
+TSS_RESULT
+RPC_PcrRead_TP(struct host_table_entry *hte,
+ TCPA_PCRINDEX pcrNum, /* in */
+ TCPA_PCRVALUE * outDigest /* out */
+ ) {
+ TSS_RESULT result;
+
+ initData(&hte->comm, 2);
+ hte->comm.hdr.u.ordinal = TCSD_ORD_PCRREAD;
+ LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrNum, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+
+ result = sendTCSDPacket(hte);
+
+ if (result == TSS_SUCCESS)
+ result = hte->comm.hdr.u.result;
+
+ if (result == TSS_SUCCESS) {
+ if (getData(TCSD_PACKET_TYPE_DIGEST, 0, outDigest, 0, &hte->comm))
+ result = TSPERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return result;
+}
+
+TSS_RESULT
+RPC_PcrReset_TP(struct host_table_entry *hte,
+ UINT32 pcrDataSizeIn, /* in */
+ BYTE * pcrDataIn) /* in */
+{
+ TSS_RESULT result;
+
+ initData(&hte->comm, 3);
+ hte->comm.hdr.u.ordinal = TCSD_ORD_PCRRESET;
+ LogDebugFn("TCS Context: 0x%x", hte->tcsContext);
+
+ if (setData(TCSD_PACKET_TYPE_UINT32, 0, &hte->tcsContext, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_UINT32, 1, &pcrDataSizeIn, 0, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+ if (setData(TCSD_PACKET_TYPE_PBYTE, 2, pcrDataIn, pcrDataSizeIn, &hte->comm))
+ return TSPERR(TSS_E_INTERNAL_ERROR);
+
+ result = sendTCSDPacket(hte);
+
+ if (result == TSS_SUCCESS)
+ result = hte->comm.hdr.u.result;
+
+ return result;
+}