summaryrefslogtreecommitdiff
path: root/src/libtpmtss
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtpmtss')
-rw-r--r--src/libtpmtss/Makefile.in8
-rw-r--r--src/libtpmtss/plugins/tpm/Makefile.in8
-rw-r--r--src/libtpmtss/tpm_tss_tss2.c94
3 files changed, 92 insertions, 18 deletions
diff --git a/src/libtpmtss/Makefile.in b/src/libtpmtss/Makefile.in
index 405d717d9..90d5e54f5 100644
--- a/src/libtpmtss/Makefile.in
+++ b/src/libtpmtss/Makefile.in
@@ -355,8 +355,6 @@ RANLIB = @RANLIB@
RTLIB = @RTLIB@
RUBY = @RUBY@
RUBYGEMDIR = @RUBYGEMDIR@
-RUBYINCLUDE = @RUBYINCLUDE@
-RUBYLIB = @RUBYLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
@@ -457,6 +455,8 @@ random_device = @random_device@
resolv_conf = @resolv_conf@
routing_table = @routing_table@
routing_table_prio = @routing_table_prio@
+ruby_CFLAGS = @ruby_CFLAGS@
+ruby_LIBS = @ruby_LIBS@
runstatedir = @runstatedir@
s_plugins = @s_plugins@
sbindir = @sbindir@
@@ -485,6 +485,10 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
tss2_CFLAGS = @tss2_CFLAGS@
tss2_LIBS = @tss2_LIBS@
+tss2_socket_CFLAGS = @tss2_socket_CFLAGS@
+tss2_socket_LIBS = @tss2_socket_LIBS@
+tss2_tabrmd_CFLAGS = @tss2_tabrmd_CFLAGS@
+tss2_tabrmd_LIBS = @tss2_tabrmd_LIBS@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
diff --git a/src/libtpmtss/plugins/tpm/Makefile.in b/src/libtpmtss/plugins/tpm/Makefile.in
index eb9489eb4..f80c0f736 100644
--- a/src/libtpmtss/plugins/tpm/Makefile.in
+++ b/src/libtpmtss/plugins/tpm/Makefile.in
@@ -312,8 +312,6 @@ RANLIB = @RANLIB@
RTLIB = @RTLIB@
RUBY = @RUBY@
RUBYGEMDIR = @RUBYGEMDIR@
-RUBYINCLUDE = @RUBYINCLUDE@
-RUBYLIB = @RUBYLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
@@ -414,6 +412,8 @@ random_device = @random_device@
resolv_conf = @resolv_conf@
routing_table = @routing_table@
routing_table_prio = @routing_table_prio@
+ruby_CFLAGS = @ruby_CFLAGS@
+ruby_LIBS = @ruby_LIBS@
runstatedir = @runstatedir@
s_plugins = @s_plugins@
sbindir = @sbindir@
@@ -442,6 +442,10 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
tss2_CFLAGS = @tss2_CFLAGS@
tss2_LIBS = @tss2_LIBS@
+tss2_socket_CFLAGS = @tss2_socket_CFLAGS@
+tss2_socket_LIBS = @tss2_socket_LIBS@
+tss2_tabrmd_CFLAGS = @tss2_tabrmd_CFLAGS@
+tss2_tabrmd_LIBS = @tss2_tabrmd_LIBS@
urandom_device = @urandom_device@
xml_CFLAGS = @xml_CFLAGS@
xml_LIBS = @xml_LIBS@
diff --git a/src/libtpmtss/tpm_tss_tss2.c b/src/libtpmtss/tpm_tss_tss2.c
index 9a4b9a40c..dcba05c43 100644
--- a/src/libtpmtss/tpm_tss_tss2.c
+++ b/src/libtpmtss/tpm_tss_tss2.c
@@ -23,8 +23,18 @@
#include <bio/bio_reader.h>
#include <tpm20.h>
+
+#ifdef TSS2_TCTI_TABRMD
+#include <tcti/tcti-tabrmd.h>
+#endif /* TSS2_TCTI_TABRMD */
+
+#ifdef TSS2_TCTI_SOCKET
#include <tcti_socket.h>
+#define TCTI_SOCKET_DEFAULT_ADDRESS "127.0.0.1"
+#define TCTI_SOCKET_DEFAULT_PORT 2323
+#endif /* TSS2_TCTI_SOCKET */
+
#define LABEL "TPM 2.0 -"
typedef struct private_tpm_tss_tss2_t private_tpm_tss_tss2_t;
@@ -209,23 +219,52 @@ static bool get_algs_capability(private_tpm_tss_tss2_t *this)
}
/**
- * Initialize TSS context
+ * Initialize TSS2 TCTI TABRMD context
*/
-static bool initialize_context(private_tpm_tss_tss2_t *this)
+static bool initialize_tcti_tabrmd_context(private_tpm_tss_tss2_t *this)
{
+#ifdef TSS2_TCTI_TABRMD
size_t tcti_context_size;
- uint32_t sys_context_size;
uint32_t rval;
- TCTI_SOCKET_CONF rm_if_config = { DEFAULT_HOSTNAME,
- DEFAULT_RESMGR_TPM_PORT
- };
+ /* determine size of tcti context */
+ rval = tss2_tcti_tabrmd_init(NULL, &tcti_context_size);
+ if (rval != TSS2_RC_SUCCESS)
+ {
+ DBG1(DBG_PTS, "%s could not get tcti_context size: 0x%06x",
+ LABEL, rval);
+ return FALSE;
+ }
- TSS2_ABI_VERSION abi_version = { TSSWG_INTEROP,
- TSS_SAPI_FIRST_FAMILY,
- TSS_SAPI_FIRST_LEVEL,
- TSS_SAPI_FIRST_VERSION
- };
+ /* allocate memory for tcti context */
+ this->tcti_context = (TSS2_TCTI_CONTEXT*)malloc(tcti_context_size);
+
+ /* initialize tcti context */
+ rval = tss2_tcti_tabrmd_init(this->tcti_context, &tcti_context_size);
+ if (rval != TSS2_RC_SUCCESS)
+ {
+ DBG1(DBG_PTS, "%s could not get tcti_context: 0x%06x "
+ "via tabrmd interface", LABEL, rval);
+ return FALSE;
+ }
+ return TRUE;
+#else /* TSS2_TCTI_TABRMD */
+ return FALSE;
+#endif /* TSS2_TCTI_TABRMD */
+}
+
+/**
+ * Initialize TSS2 TCTI Socket context
+ */
+static bool initialize_tcti_socket_context(private_tpm_tss_tss2_t *this)
+{
+#ifdef TSS2_TCTI_SOCKET
+ size_t tcti_context_size;
+ uint32_t rval;
+
+ TCTI_SOCKET_CONF rm_if_config = { TCTI_SOCKET_DEFAULT_ADDRESS,
+ TCTI_SOCKET_DEFAULT_PORT
+ };
/* determine size of tcti context */
rval = InitSocketTcti(NULL, &tcti_context_size, &rm_if_config, 0);
@@ -244,10 +283,29 @@ static bool initialize_context(private_tpm_tss_tss2_t *this)
&rm_if_config, 0);
if (rval != TSS2_RC_SUCCESS)
{
- DBG1(DBG_PTS, "%s could not get tcti_context: 0x%06x",
- LABEL, rval);
+ DBG1(DBG_PTS, "%s could not get tcti_context: 0x%06x "
+ "via socket interface", LABEL, rval);
return FALSE;
}
+ return TRUE;
+#else /* TSS2_TCTI_SOCKET */
+ return FALSE;
+#endif /* TSS2_TCTI_SOCKET */
+}
+
+/**
+ * Initialize TSS2 Sys context
+ */
+static bool initialize_sys_context(private_tpm_tss_tss2_t *this)
+{
+ uint32_t sys_context_size;
+ uint32_t rval;
+
+ TSS2_ABI_VERSION abi_version = { TSSWG_INTEROP,
+ TSS_SAPI_FIRST_FAMILY,
+ TSS_SAPI_FIRST_LEVEL,
+ TSS_SAPI_FIRST_VERSION
+ };
/* determine size of sys context */
sys_context_size = Tss2_Sys_GetContextSize(0);
@@ -885,7 +943,15 @@ tpm_tss_t *tpm_tss_tss2_create()
},
);
- available = initialize_context(this);
+ available = initialize_tcti_tabrmd_context(this);
+ if (!available)
+ {
+ available = initialize_tcti_socket_context(this);
+ }
+ if (available)
+ {
+ available = initialize_sys_context(this);
+ }
DBG1(DBG_PTS, "TPM 2.0 via TSS2 %savailable", available ? "" : "not ");
if (!available)