|
From: | Stefan Berger |
Subject: | Re: [PATCH v19 21/33] tss2: Add TPM2 Software Stack (TSS2) support |
Date: | Tue, 17 Sep 2024 23:14:33 -0400 |
User-agent: | Mozilla Thunderbird |
On 9/6/24 5:11 AM, Gary Lin wrote:
A Trusted Platform Module (TPM) Software Stack (TSS) provides logic to compose and submit TPM commands and parse reponses.
+static TPM_RC_t +tpm2_submit_command_real (const TPMI_ST_COMMAND_TAG_t tag, + const TPM_CC_t commandCode, + TPM_RC_t *responseCode, + const struct grub_tpm2_buffer *in, + struct grub_tpm2_buffer *out) +{ + grub_err_t err; + struct grub_tpm2_buffer buf; + TPMI_ST_COMMAND_TAG_t tag_out; + grub_uint32_t command_size; + grub_size_t max_output_size; + + /* Marshal */ + grub_tpm2_buffer_init (&buf); + grub_tpm2_buffer_pack_u16 (&buf, tag); + grub_tpm2_buffer_pack_u32 (&buf, 0); + grub_tpm2_buffer_pack_u32 (&buf, commandCode); + grub_tpm2_buffer_pack (&buf, in->data, in->size); + + if (buf.error != 0) + return TPM_RC_FAILURE; + + command_size = grub_swap_bytes32 (buf.size); + grub_memcpy (&buf.data[sizeof (grub_uint16_t)], &command_size, + sizeof (command_size));
This is odd. So UEFI requires that the command size is in little endian while the TPM commands are typically all in big endian format? If so, could you push this into the grub_tcg2_submit_command? Other firmware doesn't need this odd endianess switch and could just leave the size as-is and just pass the TPM command to the device without switching endianess again.
I am working on changes for ppc64 to also support this. So, indeed, there are some parts that are EFI-specific at the moment.
Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |