2 * Copyright 2016 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
6 #ifndef __SRC_LIB_TPM2_MARSHALING_H
7 #define __SRC_LIB_TPM2_MARSHALING_H
9 #include "tss_constants.h"
11 /* The below functions are used to serialize/deserialize TPM2 commands. */
16 * Given a structure containing a TPM2 command, serialize the structure for
17 * sending it to the TPM.
19 * @command: code of the TPM2 command to marshal
20 * @tpm_command_body: a pointer to the command specific structure
21 * @buffer: buffer where command is marshaled to
22 * @buffer_size: size of the buffer
24 * Returns number of bytes placed in the buffer, or -1 on error.
27 int tpm_marshal_command(TPM_CC command, void *tpm_command_body,
28 void *buffer, int buffer_size);
31 * tpm_unmarshal_response
33 * Given a buffer received from the TPM in response to a certain command,
34 * deserialize the buffer into the expeced response structure.
36 * struct tpm2_response is a union of all possible responses.
38 * @command: code of the TPM2 command for which a response is unmarshaled
39 * @response_body: buffer containing the serialized response.
40 * @response_size: number of bytes in the buffer containing response
42 * Returns a pointer to the deserialized response or NULL in case of
43 * unmarshaling problems.
45 struct tpm2_response *tpm_unmarshal_response(TPM_CC command,
49 #endif // __SRC_LIB_TPM2_MARSHALING_H