summaryrefslogtreecommitdiff
path: root/tests/vboot_common3_tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/vboot_common3_tests.c')
-rw-r--r--tests/vboot_common3_tests.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/vboot_common3_tests.c b/tests/vboot_common3_tests.c
index ce818a4c..69c54a80 100644
--- a/tests/vboot_common3_tests.c
+++ b/tests/vboot_common3_tests.c
@@ -113,6 +113,12 @@ static void KeyBlockVerifyTest(const VbPublicKey* public_key,
TEST_NEQ(KeyBlockVerify(h, hsize, public_key, 0), 0,
"KeyBlockVerify() sig mismatch");
+ Memcpy(h, hdr, hsize);
+ //ReChecksumKeyBlock(h);
+ h->key_block_checksum.data_size = h->key_block_size + 1;
+ TEST_NEQ(KeyBlockVerify(h, hsize, public_key, 1), 0,
+ "KeyBlockVerify() checksum data past end of block");
+
/* Check that we signed header and data key */
Memcpy(h, hdr, hsize);
h->key_block_checksum.data_size = 4;
@@ -128,6 +134,10 @@ static void KeyBlockVerifyTest(const VbPublicKey* public_key,
TEST_NEQ(KeyBlockVerify(h, hsize, NULL, 1), 0,
"KeyBlockVerify() data key off end");
+ /* Corner cases for error checking */
+ TEST_NEQ(KeyBlockVerify(NULL, 4, NULL, 1), 0,
+ "KeyBlockVerify size too small");
+
/* TODO: verify parser can support a bigger header (i.e., one where
* data_key.key_offset is bigger than expected). */
@@ -169,6 +179,8 @@ static void VerifyFirmwarePreambleTest(const VbPublicKey* public_key,
TEST_EQ(VerifyFirmwarePreamble(hdr, hsize, rsa), 0,
"VerifyFirmwarePreamble() ok using key");
+ TEST_NEQ(VerifyFirmwarePreamble(hdr, 4, rsa), 0,
+ "VerifyFirmwarePreamble() size tiny");
TEST_NEQ(VerifyFirmwarePreamble(hdr, hsize - 1, rsa), 0,
"VerifyFirmwarePreamble() size--");
TEST_EQ(VerifyFirmwarePreamble(hdr, hsize + 1, rsa), 0,