// SPDX-License-Identifier: GPL-2.0 /* * Handling of TPM command and other buffers. */ #include <linux/tpm_command.h> #include <linux/module.h> #include <linux/tpm.h> /** * tpm_buf_init() - Allocate and initialize a TPM command * @buf: A &tpm_buf * @tag: TPM_TAG_RQU_COMMAND, TPM2_ST_NO_SESSIONS or TPM2_ST_SESSIONS * @ordinal: A command ordinal * * Return: 0 or -ENOMEM */ int tpm_buf_init(struct tpm_buf *buf, u16 tag, u32 ordinal) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_reset() - Initialize a TPM command * @buf: A &tpm_buf * @tag: TPM_TAG_RQU_COMMAND, TPM2_ST_NO_SESSIONS or TPM2_ST_SESSIONS * @ordinal: A command ordinal */ void tpm_buf_reset(struct tpm_buf *buf, u16 tag, u32 ordinal) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_init_sized() - Allocate and initialize a sized (TPM2B) buffer * @buf: A @tpm_buf * * Return: 0 or -ENOMEM */ int tpm_buf_init_sized(struct tpm_buf *buf) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_reset_sized() - Initialize a sized buffer * @buf: A &tpm_buf */ void tpm_buf_reset_sized(struct tpm_buf *buf) { … } EXPORT_SYMBOL_GPL(…); void tpm_buf_destroy(struct tpm_buf *buf) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_length() - Return the number of bytes consumed by the data * @buf: A &tpm_buf * * Return: The number of bytes consumed by the buffer */ u32 tpm_buf_length(struct tpm_buf *buf) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_append() - Append data to an initialized buffer * @buf: A &tpm_buf * @new_data: A data blob * @new_length: Size of the appended data */ void tpm_buf_append(struct tpm_buf *buf, const u8 *new_data, u16 new_length) { … } EXPORT_SYMBOL_GPL(…); void tpm_buf_append_u8(struct tpm_buf *buf, const u8 value) { … } EXPORT_SYMBOL_GPL(…); void tpm_buf_append_u16(struct tpm_buf *buf, const u16 value) { … } EXPORT_SYMBOL_GPL(…); void tpm_buf_append_u32(struct tpm_buf *buf, const u32 value) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_read() - Read from a TPM buffer * @buf: &tpm_buf instance * @offset: offset within the buffer * @count: the number of bytes to read * @output: the output buffer */ static void tpm_buf_read(struct tpm_buf *buf, off_t *offset, size_t count, void *output) { … } /** * tpm_buf_read_u8() - Read 8-bit word from a TPM buffer * @buf: &tpm_buf instance * @offset: offset within the buffer * * Return: next 8-bit word */ u8 tpm_buf_read_u8(struct tpm_buf *buf, off_t *offset) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_read_u16() - Read 16-bit word from a TPM buffer * @buf: &tpm_buf instance * @offset: offset within the buffer * * Return: next 16-bit word */ u16 tpm_buf_read_u16(struct tpm_buf *buf, off_t *offset) { … } EXPORT_SYMBOL_GPL(…); /** * tpm_buf_read_u32() - Read 32-bit word from a TPM buffer * @buf: &tpm_buf instance * @offset: offset within the buffer * * Return: next 32-bit word */ u32 tpm_buf_read_u32(struct tpm_buf *buf, off_t *offset) { … } EXPORT_SYMBOL_GPL(…);