summaryrefslogtreecommitdiff
path: root/src/tspi/tspi_oper.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/tspi_oper.c
downloadtrousers-upstream/0.3.9.tar.gz
Imported Upstream version 0.3.9upstream/0.3.9upstream
Diffstat (limited to 'src/tspi/tspi_oper.c')
-rw-r--r--src/tspi/tspi_oper.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tspi/tspi_oper.c b/src/tspi/tspi_oper.c
new file mode 100644
index 0000000..01db9ff
--- /dev/null
+++ b/src/tspi/tspi_oper.c
@@ -0,0 +1,52 @@
+
+/*
+ * 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 "trousers/tss.h"
+#include "trousers/trousers.h"
+#include "trousers_types.h"
+#include "spi_utils.h"
+#include "obj.h"
+#include "tsplog.h"
+
+
+TSS_RESULT
+Tspi_TPM_SetOperatorAuth(TSS_HTPM hTpm, /* in */
+ TSS_HPOLICY hOperatorPolicy) /* in */
+{
+ TSS_HCONTEXT tspContext;
+ UINT32 type;
+ TCPA_SECRET operatorAuth;
+ TSS_RESULT result = TSS_SUCCESS;
+
+ if ((result = obj_tpm_get_tsp_context(hTpm, &tspContext)))
+ return result;
+
+ if ((result = obj_policy_get_type(hOperatorPolicy, &type)))
+ return result;
+
+ if (type != TSS_POLICY_OPERATOR)
+ return TSPERR(TSS_E_BAD_PARAMETER);
+
+ if ((result = obj_policy_get_secret(hOperatorPolicy, TR_SECRET_CTX_NEW, &operatorAuth)))
+ return result;
+
+ if ((result = TCS_API(tspContext)->SetOperatorAuth(tspContext, &operatorAuth)))
+ return result;
+
+ if ((result = obj_tpm_set_policy(hTpm, hOperatorPolicy)))
+ return result;
+
+ return result;
+}