VirtualBox

source: vbox/trunk/src/libs/libtpms-0.9.6/include/libtpms/tpm_library.h.in@ 101094

Last change on this file since 101094 was 91612, checked in by vboxsync, 3 years ago

src/libs: Export libtpms-0.9.0, bugref:10078

File size: 6.3 KB
Line 
1/********************************************************************************/
2/* */
3/* LibTPM interface functions */
4/* Written by Stefan Berger */
5/* IBM Thomas J. Watson Research Center */
6/* $Id: tpm_library.h 4623 2011-09-28 15:15:09Z kgoldman $ */
7/* */
8/* (c) Copyright IBM Corporation 2010. */
9/* */
10/* All rights reserved. */
11/* */
12/* Redistribution and use in source and binary forms, with or without */
13/* modification, are permitted provided that the following conditions are */
14/* met: */
15/* */
16/* Redistributions of source code must retain the above copyright notice, */
17/* this list of conditions and the following disclaimer. */
18/* */
19/* Redistributions in binary form must reproduce the above copyright */
20/* notice, this list of conditions and the following disclaimer in the */
21/* documentation and/or other materials provided with the distribution. */
22/* */
23/* Neither the names of the IBM Corporation nor the names of its */
24/* contributors may be used to endorse or promote products derived from */
25/* this software without specific prior written permission. */
26/* */
27/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
28/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
29/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR */
30/* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
31/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
32/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
33/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
34/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY */
35/* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
36/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE */
37/* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
38/********************************************************************************/
39#ifndef TPM_LIBRARY_H
40#define TPM_LIBRARY_H
41
42#include <stdint.h>
43#include <sys/types.h>
44
45#include "tpm_types.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51#define TPM_LIBRARY_VER_MAJOR @LIBTPMS_VER_MAJOR@
52#define TPM_LIBRARY_VER_MINOR @LIBTPMS_VER_MINOR@
53#define TPM_LIBRARY_VER_MICRO @LIBTPMS_VER_MICRO@
54
55#define TPM_LIBRARY_VERSION_GEN(MAJ, MIN, MICRO) \
56 (( MAJ << 16 ) | ( MIN << 8 ) | ( MICRO ))
57
58#define TPM_LIBRARY_VERSION \
59 TPM_LIBRARY_VERSION_GEN(TPM_LIBRARY_VER_MAJOR, \
60 TPM_LIBRARY_VER_MINOR, \
61 TPM_LIBRARY_VER_MICRO)
62
63
64uint32_t TPMLIB_GetVersion(void);
65
66/* TPM implementation version to choose */
67typedef enum TPMLIB_TPMVersion {
68 TPMLIB_TPM_VERSION_1_2,
69 TPMLIB_TPM_VERSION_2,
70} TPMLIB_TPMVersion;
71
72TPM_RESULT TPMLIB_ChooseTPMVersion(TPMLIB_TPMVersion ver);
73TPM_RESULT TPMLIB_MainInit(void);
74
75void TPMLIB_Terminate(void);
76
77TPM_RESULT TPMLIB_Process(unsigned char **respbuffer, uint32_t *resp_size,
78 uint32_t *respbufsize,
79 unsigned char *command, uint32_t command_size);
80
81TPM_RESULT TPMLIB_VolatileAll_Store(unsigned char **buffer, uint32_t *buflen);
82
83TPM_RESULT TPMLIB_CancelCommand(void);
84
85enum TPMLIB_TPMProperty {
86 TPMPROP_TPM_RSA_KEY_LENGTH_MAX = 1,
87 TPMPROP_TPM_BUFFER_MAX,
88 TPMPROP_TPM_KEY_HANDLES,
89 TPMPROP_TPM_OWNER_EVICT_KEY_HANDLES,
90 TPMPROP_TPM_MIN_AUTH_SESSIONS,
91 TPMPROP_TPM_MIN_TRANS_SESSIONS,
92 TPMPROP_TPM_MIN_DAA_SESSIONS,
93 TPMPROP_TPM_MIN_SESSION_LIST,
94 TPMPROP_TPM_MIN_COUNTERS,
95 TPMPROP_TPM_NUM_FAMILY_TABLE_ENTRY_MIN,
96 TPMPROP_TPM_NUM_DELEGATE_TABLE_ENTRY_MIN,
97 TPMPROP_TPM_SPACE_SAFETY_MARGIN,
98 TPMPROP_TPM_MAX_NV_SPACE,
99 TPMPROP_TPM_MAX_SAVESTATE_SPACE,
100 TPMPROP_TPM_MAX_VOLATILESTATE_SPACE,
101};
102
103TPM_RESULT TPMLIB_GetTPMProperty(enum TPMLIB_TPMProperty prop, int *result);
104
105enum TPMLIB_InfoFlags {
106 TPMLIB_INFO_TPMSPECIFICATION = 1,
107 TPMLIB_INFO_TPMATTRIBUTES = 2,
108 TPMLIB_INFO_TPMFEATURES = 4,
109};
110
111char *TPMLIB_GetInfo(enum TPMLIB_InfoFlags flags);
112
113struct libtpms_callbacks {
114 int sizeOfStruct;
115 TPM_RESULT (*tpm_nvram_init)(void);
116 TPM_RESULT (*tpm_nvram_loaddata)(unsigned char **data,
117 uint32_t *length,
118 uint32_t tpm_number,
119 const char *name);
120 TPM_RESULT (*tpm_nvram_storedata)(const unsigned char *data,
121 uint32_t length,
122 uint32_t tpm_number,
123 const char *name);
124 TPM_RESULT (*tpm_nvram_deletename)(uint32_t tpm_number,
125 const char *name,
126 TPM_BOOL mustExist);
127 TPM_RESULT (*tpm_io_init)(void);
128 TPM_RESULT (*tpm_io_getlocality)(TPM_MODIFIER_INDICATOR *localityModifer,
129 uint32_t tpm_number);
130 TPM_RESULT (*tpm_io_getphysicalpresence)(TPM_BOOL *physicalPresence,
131 uint32_t tpm_number);
132};
133
134TPM_RESULT TPMLIB_RegisterCallbacks(struct libtpms_callbacks *);
135
136enum TPMLIB_BlobType {
137 TPMLIB_BLOB_TYPE_INITSTATE,
138
139 TPMLIB_BLOB_TYPE_LAST,
140};
141
142#define TPMLIB_INITSTATE_START_TAG "-----BEGIN INITSTATE-----"
143#define TPMLIB_INITSTATE_END_TAG "-----END INITSTATE-----"
144
145TPM_RESULT TPMLIB_DecodeBlob(const char *data, enum TPMLIB_BlobType type,
146 unsigned char **result, size_t *result_len);
147
148void TPMLIB_SetDebugFD(int fd);
149void TPMLIB_SetDebugLevel(unsigned int level);
150TPM_RESULT TPMLIB_SetDebugPrefix(const char *prefix);
151
152uint32_t TPMLIB_SetBufferSize(uint32_t wanted_size,
153 uint32_t *min_size,
154 uint32_t *max_size);
155
156enum TPMLIB_StateType {
157 TPMLIB_STATE_PERMANENT = (1 << 0),
158 TPMLIB_STATE_VOLATILE = (1 << 1),
159 TPMLIB_STATE_SAVE_STATE = (1 << 2),
160};
161
162TPM_RESULT TPMLIB_ValidateState(enum TPMLIB_StateType st,
163 unsigned int flags);
164TPM_RESULT TPMLIB_SetState(enum TPMLIB_StateType st,
165 const unsigned char *buffer, uint32_t buflen);
166TPM_RESULT TPMLIB_GetState(enum TPMLIB_StateType st,
167 unsigned char **buffer, uint32_t *buflen);
168
169#ifdef __cplusplus
170}
171#endif
172
173#endif /* TPM_LIBRARY_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette