Debian Codegraph @

3rdparty/vboot/firmware/include/tpm2_marshaling.h

raw symbols SCIP
1 /* Copyright 2016 The ChromiumOS Authors
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 #ifndef VBOOT_REFERENCE_TPM2_MARSHALING_H_
7 #define VBOOT_REFERENCE_TPM2_MARSHALING_H_
8
9 #include "tss_constants.h"
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif /* __cplusplus */
14
15 /* The below functions are used to serialize/deserialize TPM2 commands. */
16
17 /**
18 * tpm_marshal_command
19 *
20 * Given a structure containing a TPM2 command, serialize the structure for
21 * sending it to the TPM.
22 *
23 * @command: code of the TPM2 command to marshal
24 * @tpm_command_body: a pointer to the command specific structure
25 * @buffer: buffer where command is marshaled to
26 * @buffer_size: size of the buffer
27 *
28 * Returns number of bytes placed in the buffer, or -1 on error.
29 *
30 */
31 int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
32 void *buffer, int buffer_size);
33
34 /**
35 * tpm_unmarshal_response
36 *
37 * Given a buffer received from the TPM in response to a certain command,
38 * deserialize the buffer into the expeced response structure.
39 *
40 * @command: code of the TPM2 command for which a response is unmarshaled
41 * @response_body: buffer containing the serialized response.
42 * @response_size: number of bytes in the buffer containing response
43 * @response: structure to be filled with deserialized response,
44 * struct tpm2_response is a union of all possible responses.
45 *
46 * Returns 0 on success, or -1 on error.
47 */
48 int tpm_unmarshal_response(TPM_CC command,
49 void *response_body,
50 int response_size,
51 struct tpm2_response *response);
52
53 /**
54 * tpm_get_packet_size
55 *
56 * @packet: pointer to the start of the command or response packet.
57 *
58 * Returns the size of the tpm packet.
59 */
60 uint32_t tpm_get_packet_size(const uint8_t *packet);
61
62 /**
63 * tpm_get_packet_response_code
64 *
65 * @packet: pointer to the start of the response packet.
66 *
67 * Returns the response code.
68 */
69 uint32_t tpm_get_packet_response_code(const uint8_t *packet);
70
71 /**
72 * tpm_set_ph_disabled
73 *
74 * Sets the flag that indicates if platform hierarchy is disabled.
75 * Certain commands, like NV_Read, may need to use different
76 * authorization if platform hierarchy is disabled.
77 *
78 * @flag: 1 if platform hierarchy is disabled, 0 otherwise
79 */
80 void tpm_set_ph_disabled(int flag);
81
82 /**
83 * tpm_is_ph_disabled
84 *
85 * Gets the flag that indicates if platform hierarchy is disabled.
86 * Certain commands, like NV_Read, may need to use different
87 * authorization if platform hierarchy is disabled.
88 *
89 * Returns 1 if platform hierarchy is disabled, 0 otherwise
90 */
91 int tpm_is_ph_disabled(void);
92
93 #ifdef __cplusplus
94 }
95 #endif /* __cplusplus */
96
97 #endif /* VBOOT_REFERENCE_TPM2_MARSHALING_H_ */