summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/vb2_common_tests.c6
-rw-r--r--tests/vboot_common_tests.c57
-rw-r--r--tests/verify_kernel.c4
3 files changed, 16 insertions, 51 deletions
diff --git a/tests/vb2_common_tests.c b/tests/vb2_common_tests.c
index 13a408ea..4a3025e9 100644
--- a/tests/vb2_common_tests.c
+++ b/tests/vb2_common_tests.c
@@ -80,18 +80,12 @@ static void test_array_size(void)
*/
static void test_struct_packing(void)
{
- /* Test vboot2 versions of vboot1 structs */
TEST_EQ(EXPECTED_VB2_PACKED_KEY_SIZE,
sizeof(struct vb2_packed_key),
"sizeof(vb2_packed_key)");
TEST_EQ(EXPECTED_VB2_GBB_HEADER_SIZE,
sizeof(struct vb2_gbb_header),
"sizeof(vb2_gbb_header)");
-
- /* And make sure they're the same as their vboot1 equivalents */
- TEST_EQ(EXPECTED_VB2_PACKED_KEY_SIZE,
- EXPECTED_VBPUBLICKEY_SIZE,
- "vboot1->2 packed key sizes same");
}
/**
diff --git a/tests/vboot_common_tests.c b/tests/vboot_common_tests.c
index 9bbfba69..6a09d92f 100644
--- a/tests/vboot_common_tests.c
+++ b/tests/vboot_common_tests.c
@@ -21,8 +21,6 @@
*/
static void StructPackingTest(void)
{
- TEST_EQ(EXPECTED_VBPUBLICKEY_SIZE, sizeof(VbPublicKey),
- "sizeof(VbPublicKey)");
TEST_EQ(EXPECTED_VBSIGNATURE_SIZE, sizeof(VbSignature),
"sizeof(VbSignature)");
TEST_EQ(EXPECTED_VBKEYBLOCKHEADER_SIZE, sizeof(VbKeyBlockHeader),
@@ -44,38 +42,6 @@ static void StructPackingTest(void)
static void VerifyHelperFunctions(void)
{
{
- VbPublicKey k = {sizeof(k), 2, 3, 4};
- TEST_EQ((int)vb2_offset_of(&k, GetPublicKeyData(&k)), sizeof(k),
- "GetPublicKeyData() adjacent");
- TEST_EQ((int)vb2_offset_of(&k, GetPublicKeyDataC(&k)), sizeof(k),
- "GetPublicKeyDataC() adjacent");
- }
-
- {
- VbPublicKey k = {123, 2, 3, 4};
- TEST_EQ((int)vb2_offset_of(&k, GetPublicKeyData(&k)), 123,
- "GetPublicKeyData() spaced");
- TEST_EQ((int)vb2_offset_of(&k, GetPublicKeyDataC(&k)), 123,
- "GetPublicKeyDataC() spaced");
- }
-
- {
- VbPublicKey k = {sizeof(k), 128, 0, 0};
- TEST_EQ(VerifyPublicKeyInside(&k, sizeof(k)+128, &k), 0,
- "PublicKeyInside ok 1");
- TEST_EQ(VerifyPublicKeyInside(&k - 1, 2*sizeof(k)+128, &k), 0,
- "PublicKeyInside ok 2");
- TEST_NEQ(VerifyPublicKeyInside(&k, 128, &k), 0,
- "PublicKeyInside key too big");
- }
-
- {
- VbPublicKey k = {100, 4, 0, 0};
- TEST_NEQ(VerifyPublicKeyInside(&k, 99, &k), 0,
- "PublicKeyInside offset too big");
- }
-
- {
VbSignature s = {sizeof(s), 128, 2000};
TEST_EQ(VerifySignatureInside(&s, sizeof(s)+128, &s), 0,
"SignatureInside ok 1");
@@ -95,8 +61,8 @@ static void VerifyHelperFunctions(void)
/* Public key utility functions */
static void PublicKeyTest(void)
{
- VbPublicKey k[3];
- VbPublicKey j[5];
+ struct vb2_packed_key k[3];
+ struct vb2_packed_key j[5];
/* Fill some bits of the public key data */
memset(j, 0, sizeof(j));
@@ -104,9 +70,11 @@ static void PublicKeyTest(void)
k[1].key_size = 12345;
k[2].key_version = 67;
- PublicKeyInit(k, (uint8_t*)(k + 1), 2 * sizeof(VbPublicKey));
- TEST_EQ(k->key_offset, sizeof(VbPublicKey), "PublicKeyInit key_offset");
- TEST_EQ(k->key_size, 2 * sizeof(VbPublicKey), "PublicKeyInit key_size");
+ PublicKeyInit(k, (uint8_t*)(k + 1), 2 * sizeof(struct vb2_packed_key));
+ TEST_EQ(k->key_offset, sizeof(struct vb2_packed_key),
+ "PublicKeyInit key_offset");
+ TEST_EQ(k->key_size, 2 * sizeof(struct vb2_packed_key),
+ "PublicKeyInit key_size");
TEST_EQ(k->algorithm, VB2_ALG_COUNT, "PublicKeyInit algorithm");
TEST_EQ(k->key_version, 0, "PublicKeyInit key_version");
@@ -115,17 +83,20 @@ static void PublicKeyTest(void)
k->key_version = 21;
/* Copying to a smaller destination should fail */
- PublicKeyInit(j, (uint8_t*)(j + 1), 2 * sizeof(VbPublicKey) - 1);
+ PublicKeyInit(j, (uint8_t*)(j + 1),
+ 2 * sizeof(struct vb2_packed_key) - 1);
TEST_NEQ(0, PublicKeyCopy(j, k), "PublicKeyCopy too small");
/* Copying to same or larger size should succeed */
- PublicKeyInit(j, (uint8_t*)(j + 2), 2 * sizeof(VbPublicKey) + 1);
+ PublicKeyInit(j, (uint8_t*)(j + 2),
+ 2 * sizeof(struct vb2_packed_key) + 1);
TEST_EQ(0, PublicKeyCopy(j, k), "PublicKeyCopy same");
/* Offset in destination shouldn't have been modified */
- TEST_EQ(j->key_offset, 2 * sizeof(VbPublicKey),
+ TEST_EQ(j->key_offset, 2 * sizeof(struct vb2_packed_key),
"PublicKeyCopy key_offset");
/* Size should have been reduced to match the source */
- TEST_EQ(k->key_size, 2 * sizeof(VbPublicKey), "PublicKeyCopy key_size");
+ TEST_EQ(k->key_size, 2 * sizeof(struct vb2_packed_key),
+ "PublicKeyCopy key_size");
/* Other fields should have been copied */
TEST_EQ(k->algorithm, j->algorithm, "PublicKeyCopy algorithm");
TEST_EQ(k->key_version, j->key_version, "PublicKeyCopy key_version");
diff --git a/tests/verify_kernel.c b/tests/verify_kernel.c
index 03349562..f326ec7d 100644
--- a/tests/verify_kernel.c
+++ b/tests/verify_kernel.c
@@ -62,7 +62,7 @@ static void print_help(const char *progname)
int main(int argc, char *argv[])
{
- VbPublicKey *kernkey;
+ struct vb2_packed_key *kernkey;
uint64_t disk_bytes = 0;
int rv;
@@ -80,7 +80,7 @@ int main(int argc, char *argv[])
}
/* Read public key */
- kernkey = (VbPublicKey *)vb2_read_packed_key(argv[2]);
+ kernkey = vb2_read_packed_key(argv[2]);
if (!kernkey) {
fprintf(stderr, "Can't read key file %s\n", argv[2]);
return 1;