diff options
author | NingSun <ning.sun@intel.com> | 2018-03-27 10:42:51 -0700 |
---|---|---|
committer | NingSun <ning.sun@intel.com> | 2018-03-28 16:03:21 -0700 |
commit | 8a5b33a9ba846d785d244e29bc29a46f7be34928 (patch) | |
tree | a5b6ad7d3950a57fefd60dd1200c4ce52dd959b5 /TPM2-Plugin/lib/tpm2_tcti_ldr.c | |
parent | da00ff6db5e68773996ec79d711c45fb3444c580 (diff) |
Add more codes in tpm2-plugin
Implement tpm2_plugin_load_key() and tpm2_plugin_rsa_sign() APIs
Issue-ID: AAF-94
Change-Id: I5f4329fdf973e52264d9e0e8aabc864c5fbdeebf
Signed-off-by: NingSun <ning.sun@intel.com>
Diffstat (limited to 'TPM2-Plugin/lib/tpm2_tcti_ldr.c')
-rw-r--r-- | TPM2-Plugin/lib/tpm2_tcti_ldr.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/TPM2-Plugin/lib/tpm2_tcti_ldr.c b/TPM2-Plugin/lib/tpm2_tcti_ldr.c index 9f25188..5b827a9 100644 --- a/TPM2-Plugin/lib/tpm2_tcti_ldr.c +++ b/TPM2-Plugin/lib/tpm2_tcti_ldr.c @@ -30,7 +30,7 @@ #include <stdio.h> #include <dlfcn.h> -#include <sapi/tpm20.h> +#include <tss2/tss2_sys.h> #include "log.h" #include "tpm2_tcti_ldr.h" @@ -52,6 +52,19 @@ const TSS2_TCTI_INFO *tpm2_tcti_ldr_getinfo(void) { return info; } +bool tpm2_tcti_ldr_is_tcti_present(const char *name) { + + char path[PATH_MAX]; + snprintf(path, sizeof(path), "libtss2-tcti-%s.so", name); + + void *handle = dlopen (path, RTLD_LAZY); + if (handle) { + dlclose(handle); + } + + return handle != NULL; +} + TSS2_TCTI_CONTEXT *tpm2_tcti_ldr_load(const char *path, const char *opts) { TSS2_TCTI_CONTEXT *tcti_ctx = NULL; @@ -63,13 +76,13 @@ TSS2_TCTI_CONTEXT *tpm2_tcti_ldr_load(const char *path, const char *opts) { /* * Try what they gave us, if it doesn't load up, try - * libtcti-xxx.so replacing xxx with what they gave us. + * libtss2-tcti-xxx.so replacing xxx with what they gave us. */ handle = dlopen (path, RTLD_LAZY); if (!handle) { char buf[PATH_MAX]; - size_t size = snprintf(buf, sizeof(buf), "libtcti-%s.so", path); + size_t size = snprintf(buf, sizeof(buf), "libtss2-tcti-%s.so", path); if (size >= sizeof(buf)) { LOG_ERR("Truncated friendly name conversion, got: \"%s\", made: \"%s\"", path, buf); |