diff options
author | Andrey Pronin <apronin@chromium.org> | 2018-03-26 10:22:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-27 14:58:11 -0700 |
commit | a872e9b49e2690da00baf183e216931ba1ef0e6b (patch) | |
tree | cf31d54abd7cb04e6637d8fabd00357924a53c8e | |
parent | 3ee5c7d8adf5d78d6864c73bf4f33b95f04a7979 (diff) | |
download | vboot-a872e9b49e2690da00baf183e216931ba1ef0e6b.tar.gz |
firmware: tpm2_lite: fix command/response code type
Responses and commands share the same header structure. The
tpm_code field corresponds to TPM_CC in one case and TPM_RC
in the other. Make it uint32_t (instead of TPM_CC) in the
structure to avoid confusion when dealing with responses.
BUG=chromium:825894
BRANCH=none
TEST=build
Change-Id: I07821f35b0f539a863ee97c0a08c141d0533a4de
Signed-off-by: Andrey Pronin <apronin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/981111
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r-- | firmware/include/tpm2_tss_constants.h | 2 | ||||
-rw-r--r-- | firmware/lib/tpm2_lite/marshaling.c | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/firmware/include/tpm2_tss_constants.h b/firmware/include/tpm2_tss_constants.h index 498cc954..92b53a0e 100644 --- a/firmware/include/tpm2_tss_constants.h +++ b/firmware/include/tpm2_tss_constants.h @@ -196,7 +196,7 @@ struct tpm2_shutdown_cmd { struct tpm_header { uint16_t tpm_tag; uint32_t tpm_size; - TPM_CC tpm_code; + uint32_t tpm_code; } __attribute__((packed)); struct nv_read_response { diff --git a/firmware/lib/tpm2_lite/marshaling.c b/firmware/lib/tpm2_lite/marshaling.c index b5d45bfc..ab374951 100644 --- a/firmware/lib/tpm2_lite/marshaling.c +++ b/firmware/lib/tpm2_lite/marshaling.c @@ -322,7 +322,6 @@ static void marshal_u32(void **buffer, uint32_t value, int *buffer_space) *buffer_space -= sizeof(value); } -#define unmarshal_TPM_CC(a, b) unmarshal_u32(a, b) #define marshal_TPM_HANDLE(a, b, c) marshal_u32(a, b, c) #define marshal_TPM_SU(a, b, c) marshal_u16(a, b, c) #define marshal_ALG_ID(a, b, c) marshal_u16(a, b, c) @@ -727,7 +726,7 @@ int tpm_unmarshal_response(TPM_CC command, response->hdr.tpm_tag = unmarshal_u16(&response_body, &cr_size); response->hdr.tpm_size = unmarshal_u32(&response_body, &cr_size); - response->hdr.tpm_code = unmarshal_TPM_CC(&response_body, &cr_size); + response->hdr.tpm_code = unmarshal_u32(&response_body, &cr_size); if (!cr_size) { if (response->hdr.tpm_size != sizeof(response->hdr)) |