1TPMLIB_MainInit(3)                                          TPMLIB_MainInit(3)
2
3
4

NAME

6       TPMLIB_MainInit    - Initialize the TPM
7
8       TPMLIB_Terminate   - Terminate the TPM
9

LIBRARY

11       TPM library (libtpms, -ltpms)
12

SYNOPSIS

14       #include <libtpms/tpm_types.h>
15
16       #include <libtpms/tpm_library.h>
17
18       #include <libtpms/tpm_error.h>
19
20       TPM_RESULT TPMLIB_MainInit(void);
21
22       TPM_RESULT TPMLIB_Terminate(void);
23

DESCRIPTION

25       The TPMLIB_MainInit() and TPMLIB_Terminate() functions are used to
26       initialize and terminate the TPM respectively. The TPMLIB_MainInit()
27       function must be called before the TPM processes any TPM command.  The
28       TPMLIB_Terminate() function is called to free all the internal
29       resources (memory allocations) the TPM has used and must be called
30       after the last TPM command was processed by the TPM. The
31       TPMLIB_MainInit() function can then be called again.
32
33       Use TPMLIB_RegisterCallbacks() to set callback functions for
34       initialization and writing and restoring the internal state in a
35       portable format.
36

ERRORS

38       TPM_SUCCESS
39           The function completed successfully.
40
41       TPM_FAIL
42           General failure.
43
44       For a complete list of TPM error codes please consult the include file
45       libtpms/tpm_error.h
46

EXAMPLE

48        #include <stdio.h>
49
50        #include <libtpms/tpm_types.h>
51        #include <libtpms/tpm_library.h>
52        #include <libtpms/tpm_error.h>
53
54        int main(void) {
55            TPM_RESULT res;
56            unsigned char *respbuffer = NULL;
57            uint32_t resp_size = 0;
58            uint32_t respbufsize = 0;
59            unsigned char *command;
60            uint32_t command_size;
61
62            [...]
63
64            if (TPMLIB_MainInit() != TPM_SUCCESS) {
65                fprintf(stderr, "Could not start the TPM.\n");
66                return 1;
67            }
68
69            [...]
70            /* build TPM command */
71            [...]
72
73            res = TPMLIB_Process(&respbuffer, &resp_size,
74                                 &respbufsize,
75                                 command, command_size);
76            [...]
77
78            TPMLIB_Terminate();
79
80            return 0;
81        }
82

SEE ALSO

84       TPMLIB_Process(3), TPMLIB_RegisterCallbacks(3), TPMLIB_GetVersion(3)
85       TPMLIB_GetTPMProperty(3), TPMLIB_DecodeBlob(3)
86
87
88
89libtpms                           2023-07-20                TPMLIB_MainInit(3)
Impressum