1TPMLIB_Process(3) TPMLIB_Process(3)
2
3
4
6 TPMLIB_Process - process a TPM command
7
9 TPM library (libtpms, -ltpms)
10
12 #include <libtpms/tpm_library.h>
13
14 #include <libtpms/tpm_error.h>
15
16 TPM_RESULT TPMLIB_Process(unsigned char **respbuffer,
17 uint32_t *resp_size,
18 uint32_t *respbufsize,
19 unsigned char *command,
20 uint32_t command_size);
21
23 The TPMLIB_Process() function is used to send TPM commands to the TPM
24 and receive the results.
25
26 The command parameter provides the buffer for the TPM command and the
27 command_size the number of valid TPM command bytes within that buffer.
28
29 The respbuffer is a pointer to a buffer where the TPM will return its
30 result. If no buffer is given (respbuffer is NULL), the TPM will
31 allocate a buffer. The parameter resp_size returns the number of valid
32 TPM response bytes in the buffer. The number of valid bytes in the
33 response is guaranteed to not exceed the maximum I/O buffer size. Use
34 the TPMLIB_GetTPMProperty() API and parameter TPMPROP_TPM_BUFFER_MAX
35 for getting the maximum size. The user must indicate the size of a
36 provided buffer with the respbufsize parameter. If the buffer is not
37 big enough for the response, the TPM will free the provided buffer and
38 allocate one of sufficient size and adapt respbufsize. The returned
39 buffer is only subject to size restrictions as explained for
40 TPM_Malloc().
41
43 TPM_SUCCESS
44 The function completed successfully.
45
46 TPM_FAIL
47 General failure.
48
49 For a complete list of TPM error codes please consult the include file
50 libtpms/tpm_error.h
51
53 #include <stdio.h>
54
55 #include <libtpms/tpm_types.h>
56 #include <libtpms/tpm_library.h>
57 #include <libtpms/tpm_error.h>
58
59 static unsigned char TPM_Startup_ST_CLEAR[] = {
60 0x00, 0xC1, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x99,
61 0x00, TPM_ST_CLEAR
62 };
63
64 int main(void) {
65 TPM_RESULT res;
66 unsigned char *respbuffer = NULL;
67 uint32_t resp_size = 0;
68 uint32_t respbufsize = 0;
69 unsigned char *command;
70 uint32_t command_size;
71
72 [...]
73
74 if (TPMLIB_MainInit() != TPM_SUCCESS) {
75 fprintf(stderr, "Could not start the TPM.\n");
76 return 1;
77 }
78
79 [...]
80 /* build TPM command */
81 command = TPM_Startup_ST_CLEAR;
82 command_size = sizeof(TPM_Startup_ST_CLEAR);
83 [...]
84
85 res = TPMLIB_Process(&respbuffer, &resp_size,
86 &respbufsize,
87 command, command_size);
88 [...]
89
90 TPMLIB_Terminate();
91
92 return 0;
93 }
94
96 TPMLIB_MainInit(3), TPMLIB_Terminate(3), TPMLIB_RegisterCallbacks(3)
97 TPMLIB_GetTPMProperty(3), TPMLIB_Malloc(3), TPMLIB_Realloc(3)
98
99
100
101libtpms 2022-07-21 TPMLIB_Process(3)