tpm: Store the length of the tpm_buf data separately.
authorJarkko Sakkinen <jarkko@kernel.org>
Mon, 29 Apr 2024 20:27:54 +0000 (16:27 -0400)
committerJarkko Sakkinen <jarkko@kernel.org>
Thu, 9 May 2024 19:30:51 +0000 (22:30 +0300)
commite1b72e1b11109bd81577950538a17bc0428e647f
tree71735a798386429af0e0e358bfbc866c0597b459
parent37e2ee16d67d17926085cbd0500dd78ca747e59c
tpm: Store the length of the tpm_buf data separately.

TPM2B buffers, or sized buffers, have a two byte header, which contains the
length of the payload as a 16-bit big-endian number, without counting in
the space taken by the header. This differs from encoding in the TPM header
where the length includes also the bytes taken by the header.

Unbound the length of a tpm_buf from the value stored to the TPM command
header. A separate encoding and decoding step so that different buffer
types can be supported, with variant header format and length encoding.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Tested-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm-buf.c
drivers/char/tpm/tpm-interface.c
include/keys/trusted_tpm.h
include/linux/tpm.h
security/keys/trusted-keys/trusted_tpm1.c