diff options
author | Mattias Nissler <mnissler@chromium.org> | 2017-07-10 13:46:20 +0200 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-07-18 00:32:48 -0700 |
commit | 2a7e9b84ac69c374112a13fd16fbf7cb996b78bf (patch) | |
tree | 3a3ddc06183f57bc31262fbc2456142f66cd4dae /tests/tlcl_tests.c | |
parent | 68466c6d0a6cf629b77972773f523118b9cbb7be (diff) | |
download | vboot-2a7e9b84ac69c374112a13fd16fbf7cb996b78bf.tar.gz |
Implement tpmc getversion command.stabilize-9756.B
This command exposes the vendor and TPM firmware version.
BRANCH=none
BUG=chromium:728130
TEST=Builds and tpmc getversion prints plausible results.
Change-Id: Iec556a298e025e10bda00121b40a25d8dc3839d1
Reviewed-on: https://chromium-review.googlesource.com/565287
Commit-Ready: Mattias Nissler <mnissler@chromium.org>
Tested-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'tests/tlcl_tests.c')
-rw-r--r-- | tests/tlcl_tests.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/tlcl_tests.c b/tests/tlcl_tests.c index 50371615..f06947b9 100644 --- a/tests/tlcl_tests.c +++ b/tests/tlcl_tests.c @@ -335,6 +335,47 @@ static void RandomTest(void) TEST_EQ(size, 0, " size 0"); } +/** + * Test GetVersion + */ +static void GetVersionTest(void) +{ + uint8_t response[] = { + 0x00, 0xc4, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x30, + 0x01, 0x02, 0x04, 0x20, 0x00, 0x02, 0x03, 0x49, + 0x46, 0x58, 0x00, 0x00, 0x0d, 0x04, 0x20, 0x03, + 0x6f, 0x00, 0x74, 0x70, 0x6d, 0x33, 0x38, 0xff, + 0xff, 0xff + }; + + uint32_t vendor; + uint64_t firmware_version; + + ResetMocks(); + calls[0].rsp = response; + calls[0].rsp_size = sizeof(response); + TEST_EQ(TlclGetVersion(&vendor, &firmware_version), 0, "GetVersion"); + TEST_EQ(calls[0].req_cmd, TPM_ORD_GetCapability, " cmd"); + TEST_EQ(vendor, 0x49465800, " vendor"); + TEST_EQ(firmware_version, 0x420, " firmware_version"); + + ResetMocks(); + SetResponse(0, TPM_E_IOERROR, 0); + TEST_EQ(TlclGetVersion(&vendor, &firmware_version), TPM_E_IOERROR, + "GetVersion - error"); + TEST_EQ(calls[0].req_cmd, TPM_ORD_GetCapability, " cmd"); + + /* Adjust response to indicate a 1 byte too short payload size. */ + ToTpmUint32(response + kTpmResponseHeaderLength, 14); + ResetMocks(); + calls[0].rsp = response; + calls[0].rsp_size = sizeof(response); + TEST_EQ(TlclGetVersion(&vendor, &firmware_version), TPM_E_IOERROR, + "GetVersion -- short"); + TEST_EQ(calls[0].req_cmd, TPM_ORD_GetCapability, " cmd"); +} + int main(void) { TlclTest(); @@ -343,6 +384,7 @@ int main(void) PcrTest(); FlagsTest(); RandomTest(); + GetVersionTest(); return gTestSuccess ? 0 : 255; } |