Utility to Import external RSA pem key into TPM
[aaf/sshsm.git] / TPM2-Plugin / lib / include / tpm2_tcti_ldr.h
1 //**********************************************************************;
2 // Copyright (c) 2018, Intel Corporation
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
25 // THE POSSIBILITY OF SUCH DAMAGE.
26 //**********************************************************************;
27
28 #include <tss2/tss2_sys.h>
29
30 #ifndef LIB_TPM2_TCTI_LDR_H_
31 #define LIB_TPM2_TCTI_LDR_H_
32
33 /**
34  * Loads a TCTI from a friendly name, library name, or path.
35  * For example
36  *  friendly:     path = tabrmd
37  *  library name: path = libtss2-tcti-mssim.so
38  *  full path:    path = /home/user/lib/libtss2-tcti-custom.so
39  * @param path
40  *  The path/library to load.
41  * @param opts
42  *  The tcti option configs.
43  * @return
44  *  A tcti context on success or NULL on failure.
45  */
46 TSS2_TCTI_CONTEXT *tpm2_tcti_ldr_load(const char *path, const char *opts);
47
48 /**
49  * Returns the loaded TCTIs information structure,
50  * which contains the initialization routine, description
51  * and help string amongst other things.
52  * @return
53  *  NULL if no TCTI is loaded, else the info structure pointer.
54  */
55 const TSS2_TCTI_INFO *tpm2_tcti_ldr_getinfo(void);
56
57 /**
58  * Given a tcti name, like mssim, tells you if the
59  * library is present using dlopen(3).
60  * @param name
61  *   The friendly name of the tcti.
62  * @return
63  *  True if present, false otherwise.
64  */
65 bool tpm2_tcti_ldr_is_tcti_present(const char *name);
66
67 /**
68  * Unloads the tcti loaded via tpm2_tcti_ldr_load();
69  */
70 void tpm2_tcti_ldr_unload(void);
71
72 #endif /* LIB_TPM2_TCTI_LDR_H_ */