summaryrefslogtreecommitdiff
path: root/src/tcs/tcsi_quote2.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/tcs/tcsi_quote2.c
downloadtrousers-c3649a2def02c41d837ae1f79dda729ccb91e677.tar.gz
Imported Upstream version 0.3.9upstream/0.3.9upstream
Diffstat (limited to 'src/tcs/tcsi_quote2.c')
-rw-r--r--src/tcs/tcsi_quote2.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/tcs/tcsi_quote2.c b/src/tcs/tcsi_quote2.c
new file mode 100644
index 0000000..0ced27f
--- /dev/null
+++ b/src/tcs/tcsi_quote2.c
@@ -0,0 +1,86 @@
+
+/*
+ * Licensed Materials - Property of IBM
+ *
+ * trousers - An open source TCG Software Stack
+ *
+ * (C) Copyright International Business Machines Corp. 2007
+ *
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+
+#include "trousers/tss.h"
+#include "trousers_types.h"
+#include "tcs_tsp.h"
+#include "tcsps.h"
+#include "tcs_utils.h"
+#include "tcs_int_literals.h"
+#include "capabilities.h"
+#include "tcslog.h"
+#include "req_mgr.h"
+#include "tcsd_wrap.h"
+#include "tcsd.h"
+
+
+TSS_RESULT
+TCSP_Quote2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
+ TCS_KEY_HANDLE keyHandle, /* in */
+ TCPA_NONCE antiReplay, /* in */
+ UINT32 pcrDataSizeIn, /* in */
+ BYTE * pcrDataIn, /* in */
+ TSS_BOOL addVersion, /* in */
+ TPM_AUTH * privAuth, /* in, out */
+ UINT32 * pcrDataSizeOut, /* out */
+ BYTE ** pcrDataOut, /* out */
+ UINT32 * versionInfoSize, /* out */
+ BYTE ** versionInfo, /* out */
+ UINT32 * sigSize, /* out */
+ BYTE ** sig) /* out */
+{
+ UINT64 offset = 0;
+ UINT32 paramSize;
+ TSS_RESULT result;
+ UINT32 keySlot;
+
+ /* Command packet to be sent to the TPM */
+ BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
+
+ LogDebug("Entering quote2");
+
+ if ((result = ctx_verify_context(hContext)))
+ goto done;
+
+ if (privAuth != NULL) {
+ LogDebug("Auth Used");
+ if ((result = auth_mgr_check(hContext, &privAuth->AuthHandle)))
+ goto done;
+ } else {
+ LogDebug("No Auth");
+ }
+ if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
+ goto done;
+
+ if ((result = tpm_rqu_build(TPM_ORD_Quote2, &offset, txBlob, keySlot, antiReplay.nonce,
+ pcrDataSizeIn, pcrDataIn, &addVersion, privAuth)))
+ goto done;
+
+ if ((result = req_mgr_submit_req(txBlob)))
+ goto done;
+
+ result = UnloadBlob_Header(txBlob, &paramSize);
+ if (!result) {
+ result = tpm_rsp_parse(TPM_ORD_Quote2, txBlob, paramSize, pcrDataSizeOut,
+ pcrDataOut, &addVersion, versionInfoSize, versionInfo,
+ sigSize, sig, privAuth);
+ }
+ LogResult("Quote2", result);
+done:
+ auth_mgr_release_auth(privAuth, NULL, hContext);
+ return result;
+}
+