summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-01-25 13:56:55 -0800
committerChromeBot <chrome-bot@google.com>2013-01-25 17:24:58 -0800
commit3b806ea95117dbed57787f0e397a7e2a47d3b8e3 (patch)
tree20e54c9ee19d291584ead9539f9108da16f2b644
parent8fd1aaf66e2b4796d3d0b117ac3aa7860c8de5fd (diff)
downloadvboot-3b806ea95117dbed57787f0e397a7e2a47d3b8e3.tar.gz
Add more vboot common tests
BUG=chromium-os:38139 BRANCH=none TEST=make runtests Change-Id: Iad795956c1bb7f6444d6cce0bb618687e26d6025 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/42052 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
-rw-r--r--tests/vboot_common2_tests.c5
-rw-r--r--tests/vboot_common3_tests.c12
-rw-r--r--tests/vboot_common_tests.c12
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/vboot_common2_tests.c b/tests/vboot_common2_tests.c
index f2ed5260..b154e50b 100644
--- a/tests/vboot_common2_tests.c
+++ b/tests/vboot_common2_tests.c
@@ -96,6 +96,9 @@ static void VerifyDigestTest(const VbPublicKey *public_key,
GetSignatureData(sig)[0] ^= 0x5A;
TEST_EQ(VerifyDigest(digest, sig, rsa), 1, "VerifyDigest() wrong sig");
+ sig->sig_size = 1;
+ TEST_EQ(VerifyDigest(digest, sig, rsa), 1, "VerifyDigest() sig size");
+
RSAPublicKeyFree(rsa);
free(sig);
free(digest);
@@ -135,6 +138,8 @@ static void VerifyKernelPreambleTest(const VbPublicKey *public_key,
"VerifyKernelPreamble() ok using key");
TEST_NEQ(VerifyKernelPreamble(hdr, hsize - 1, rsa), 0,
"VerifyKernelPreamble() size--");
+ TEST_NEQ(VerifyKernelPreamble(hdr, 4, rsa), 0,
+ "VerifyKernelPreamble() size tiny");
TEST_EQ(VerifyKernelPreamble(hdr, hsize + 1, rsa), 0,
"VerifyKernelPreamble() size++");
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,
diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c
index f36ec76d..73cbeb55 100644
--- a/tests/vboot_common_tests.c
+++ b/tests/vboot_common_tests.c
@@ -100,6 +100,15 @@ static void VerifyHelperFunctions(void)
"MemberInside data before parent");
TEST_EQ(VerifyMemberInside(p, 20, p, 4, 4, 17), 1,
"MemberInside data too big");
+ TEST_EQ(VerifyMemberInside(p, (uint64_t)-1,
+ p+(uint64_t)-10, 12, 5, 0), 1,
+ "MemberInside wraparound 1");
+ TEST_EQ(VerifyMemberInside(p, (uint64_t)-1,
+ p+(uint64_t)-10, 5, 12, 0), 1,
+ "MemberInside wraparound 2");
+ TEST_EQ(VerifyMemberInside(p, (uint64_t)-1,
+ p+(uint64_t)-10, 5, 0, 12), 1,
+ "MemberInside wraparound 3");
}
{
@@ -214,6 +223,9 @@ static void VbSharedDataTest(void)
TEST_EQ(d->lk_call_count, 0, "VbSharedDataInit lk_call_count");
TEST_EQ(d->kernel_version_lowest, 0,
"VbSharedDataInit kernel_version_lowest");
+
+ TEST_NEQ(VBOOT_SUCCESS, VbSharedDataSetKernelKey(NULL, NULL),
+ "VbSharedDataSetKernelKey null");
}
/* disable MSVC warnings on unused arguments */