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