diff options
author | Philip Tricca <philip.b.tricca@intel.com> | 2019-07-09 16:13:19 -0700 |
---|---|---|
committer | Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> | 2019-07-25 10:48:24 +0200 |
commit | be796453eac88172f93e0c5ce7538e4fff27c869 (patch) | |
tree | 6b07d92523e0d1ff78ba8c7437497f6f9c1e985c /include | |
parent | 0d6e704df13fa07856d7f2d75e0412fd45dc62b5 (diff) | |
download | tpm2-tss-be796453eac88172f93e0c5ce7538e4fff27c869.tar.gz |
tctildr: Add library to automate TCTI lifecycle.
Instantiating a TCTI context takes a bit of work. The default offered
by ESYS is a good start but this still leaves applications that need to
override the default with a lot of extra work. libtss2-tctildr will do
this work for you.
It provides:
- Tss2_TctiLdr_Initialize - Allocate and initialize a TCTI context for
the caller. The 'name' parameter is a string that is either passed to
dlopen, or mapped to an internal table of names to TCTIs linked
directly into the loader.
- Tss2_TctiLdr_Finalize - The dual of 'Initialize'.
'Initialize' returns a TCTI instance that can be used by the existing
SYS & ESYS APIs. When no longer in use it must be freed using the paired
'Finalize' function.
This implementation reuses the esys_tcti_default module to preserve
existing behavior / default TCTI selection logic as much as possible.
The interface however is very different as callers may now search for
TCTIs using the 'name' parameter of Tss2_TctiLdr_Initialize. When this
parameter is NULL the old default selection logic is used to select a
default TCTI. When it is populated the library will attempt to load it.
On a system with 'dlopen' we simply pass the provided name through which
requires the caller provide the full name of the TCTI library (i.e.
libtss2-tcti-device.so.0). For the NO_DL case this commit introduces a
lookup mechanism for common TCTI names that we compare to the provided
'name'.
The ESYS unit tests have been updated and new unit tests added to cover
the dl & nodl, and tctildr modules. The build (both autotools and visual
studio) has been updated to include rules to build this new library and
to update dependencies:
- tss2-esys no longer depnds on the TCTIs directly
- tss2-esys now depends on tss2-tctildr
This includes a page in section 7 for the library itself as well as
individual pages in section 3 for the initialize and finalize functions.
Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/tss2/tss2_common.h | 2 | ||||
-rw-r--r-- | include/tss2/tss2_tctildr.h | 21 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/tss2/tss2_common.h b/include/tss2/tss2_common.h index 6cb5d553..587866d1 100644 --- a/include/tss2/tss2_common.h +++ b/include/tss2/tss2_common.h @@ -134,6 +134,8 @@ typedef uint32_t TSS2_RC; TSS2_BASE_RC_MALFORMED_RESPONSE)) #define TSS2_TCTI_RC_NOT_SUPPORTED ((TSS2_RC)(TSS2_TCTI_RC_LAYER | \ TSS2_BASE_RC_NOT_SUPPORTED)) +#define TSS2_TCTI_RC_MEMORY ((TSS2_RC)(TSS2_TCTI_RC_LAYER | \ + TSS2_BASE_RC_MEMORY)) /* SAPI error codes */ #define TSS2_SYS_RC_GENERAL_FAILURE ((TSS2_RC)(TSS2_SYS_RC_LAYER | \ TSS2_BASE_RC_GENERAL_FAILURE)) diff --git a/include/tss2/tss2_tctildr.h b/include/tss2/tss2_tctildr.h new file mode 100644 index 00000000..32492db8 --- /dev/null +++ b/include/tss2/tss2_tctildr.h @@ -0,0 +1,21 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * Copyright 2018-2019 Intel Corporation + */ +#ifndef TSS2_TCTILDR_H +#define TSS2_TCTILDR_H + +#include <inttypes.h> +#include <stdlib.h> + +#include "tss2_tpm2_types.h" +#include "tss2_tcti.h" + +void +Tss2_TctiLdr_Finalize (TSS2_TCTI_CONTEXT **context); +TSS2_RC +Tss2_TctiLdr_Initialize (const char *name, + const char *conf, + TSS2_TCTI_CONTEXT **context); + +#endif /* TSS2_TCTILDR_H */ |