From 36bc59140c9d3d4110b3d1c4b7c6b0b84875e81e Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 4 Mar 2015 16:13:45 -0800 Subject: vb21: Rename struct vb2_guid to struct vb2_id Since the ID structure isn't a true GUID anymore, let's call it something else. BUG=none BRANCH=none TEST=make runtests Change-Id: I96f511bd5587a94d2cc20764e26d7ef0096de04c Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/256182 Reviewed-by: Randall Spangler --- tests/vb21_api_tests.c | 22 +++++++++++----------- tests/vb21_common_tests.c | 8 ++++---- tests/vb21_host_key_tests.c | 22 +++++++++++----------- tests/vb21_host_sig_tests.c | 8 ++++---- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'tests') diff --git a/tests/vb21_api_tests.c b/tests/vb21_api_tests.c index dbc4750d..91631f69 100644 --- a/tests/vb21_api_tests.c +++ b/tests/vb21_api_tests.c @@ -33,7 +33,7 @@ static const int mock_body_size = sizeof(mock_body); static const int mock_hash_alg = VB2_HASH_SHA256; static int mock_sig_size; -static const struct vb2_guid test_guid[4] = { +static const struct vb2_id test_id[4] = { {.raw = {0x11}}, {.raw = {0x22}}, {.raw = {0x33}}, @@ -104,7 +104,7 @@ static void reset_common_data(enum reset_type t) for (i = 0; i < 3; i++) { vb2_sign_data(&sig, mock_body, mock_body_size - 16 * i, hash_key, NULL); - memcpy(&sig->guid, test_guid + i, sizeof(sig->guid)); + memcpy(&sig->id, test_id + i, sizeof(sig->id)); memcpy((uint8_t *)pre + sig_offset, sig, sig->c.total_size); sig_offset += sig->c.total_size; mock_sig_size = sig->c.total_size; @@ -116,7 +116,7 @@ static void reset_common_data(enum reset_type t) + sd->workbuf_preamble_size; if (t == FOR_EXTEND_HASH || t == FOR_CHECK_HASH) - vb2api_init_hash2(&ctx, test_guid, NULL); + vb2api_init_hash2(&ctx, test_id, NULL); if (t == FOR_CHECK_HASH) vb2api_extend_hash(&ctx, mock_body, mock_body_size); @@ -208,7 +208,7 @@ static void init_hash_tests(void) sig = (struct vb2_signature *)((uint8_t *)pre + pre->hash_offset); wb_used_before = ctx.workbuf_used; - TEST_SUCC(vb2api_init_hash2(&ctx, test_guid, &size), + TEST_SUCC(vb2api_init_hash2(&ctx, test_id, &size), "init hash good"); TEST_EQ(sd->workbuf_hash_offset, (wb_used_before + (VB2_WORKBUF_ALIGN - 1)) & @@ -225,7 +225,7 @@ static void init_hash_tests(void) TEST_EQ(sd->hash_remaining_size, mock_body_size, "hash remaining"); wb_used_before = ctx.workbuf_used; - TEST_SUCC(vb2api_init_hash2(&ctx, test_guid + 2, NULL), + TEST_SUCC(vb2api_init_hash2(&ctx, test_id + 2, NULL), "init hash again"); TEST_EQ(ctx.workbuf_used, wb_used_before, "init hash reuses context"); TEST_EQ(sd->hash_tag, @@ -234,29 +234,29 @@ static void init_hash_tests(void) "hash signature offset 2"); reset_common_data(FOR_MISC); - TEST_EQ(vb2api_init_hash2(&ctx, test_guid + 3, &size), - VB2_ERROR_API_INIT_HASH_GUID, "init hash invalid guid"); + TEST_EQ(vb2api_init_hash2(&ctx, test_id + 3, &size), + VB2_ERROR_API_INIT_HASH_ID, "init hash invalid id"); reset_common_data(FOR_MISC); sd->workbuf_preamble_size = 0; - TEST_EQ(vb2api_init_hash2(&ctx, test_guid, &size), + TEST_EQ(vb2api_init_hash2(&ctx, test_id, &size), VB2_ERROR_API_INIT_HASH_PREAMBLE, "init hash preamble"); reset_common_data(FOR_MISC); ctx.workbuf_used = ctx.workbuf_size - sizeof(struct vb2_digest_context) + 8; - TEST_EQ(vb2api_init_hash2(&ctx, test_guid, &size), + TEST_EQ(vb2api_init_hash2(&ctx, test_id, &size), VB2_ERROR_API_INIT_HASH_WORKBUF, "init hash workbuf"); reset_common_data(FOR_MISC); sig->hash_alg = VB2_HASH_INVALID; - TEST_EQ(vb2api_init_hash2(&ctx, test_guid, &size), + TEST_EQ(vb2api_init_hash2(&ctx, test_id, &size), VB2_ERROR_SHA_INIT_ALGORITHM, "init hash algorithm"); if (hwcrypto_state == HWCRYPTO_ENABLED) { reset_common_data(FOR_MISC); retval_hwcrypto = VB2_ERROR_MOCK; - TEST_EQ(vb2api_init_hash2(&ctx, test_guid, &size), + TEST_EQ(vb2api_init_hash2(&ctx, test_id, &size), VB2_ERROR_MOCK, "init hash use hwcrypto"); } } diff --git a/tests/vb21_common_tests.c b/tests/vb21_common_tests.c index d2ac0edf..eb943bc1 100644 --- a/tests/vb21_common_tests.c +++ b/tests/vb21_common_tests.c @@ -27,9 +27,9 @@ static const uint8_t test_data3[] = "Even more test data"; static void test_struct_packing(void) { /* Test new struct sizes */ - TEST_EQ(EXPECTED_GUID_SIZE, - sizeof(struct vb2_guid), - "sizeof(vb2_guid)"); + TEST_EQ(EXPECTED_ID_SIZE, + sizeof(struct vb2_id), + "sizeof(vb2_id)"); TEST_EQ(EXPECTED_VB2_STRUCT_COMMON_SIZE, sizeof(struct vb2_struct_common), "sizeof(vb2_struct_common)"); @@ -298,7 +298,7 @@ static void test_verify_keyblock(void) memcpy(buf, buf2, buf_size); TEST_EQ(vb2_verify_keyblock(kbuf, buf_size, &pubk3, &wb), - VB2_ERROR_KEYBLOCK_SIG_GUID, + VB2_ERROR_KEYBLOCK_SIG_ID, "vb2_verify_keyblock() key not present"); memcpy(buf, buf2, buf_size); diff --git a/tests/vb21_host_key_tests.c b/tests/vb21_host_key_tests.c index 6a01d724..e6730133 100644 --- a/tests/vb21_host_key_tests.c +++ b/tests/vb21_host_key_tests.c @@ -39,7 +39,7 @@ static void private_key_tests(const struct alg_combo *combo, const char *testfile = "test.vbprik2"; const char *notapem = "not_a_pem"; const char *testdesc = "test desc"; - const struct vb2_guid test_guid = {.raw = {0xaa}}; + const struct vb2_id test_id = {.raw = {0xaa}}; uint8_t *buf, *buf2; uint32_t bufsize; @@ -72,7 +72,7 @@ static void private_key_tests(const struct alg_combo *combo, TEST_SUCC(vb2_private_key_set_desc(key, testdesc), "Set desc"); key->hash_alg = combo->hash_alg; key->sig_alg = combo->sig_alg; - key->guid = test_guid; + key->id = test_id; unlink(testfile); @@ -86,7 +86,7 @@ static void private_key_tests(const struct alg_combo *combo, TEST_PTR_NEQ(k2, NULL, " key_ptr"); TEST_EQ(k2->sig_alg, key->sig_alg, " sig alg"); TEST_EQ(k2->hash_alg, key->hash_alg, " hash alg"); - TEST_EQ(memcmp(&k2->guid, &key->guid, sizeof(k2->guid)), 0, " guid"); + TEST_EQ(memcmp(&k2->id, &key->id, sizeof(k2->id)), 0, " id"); TEST_EQ(strcmp(k2->desc, testdesc), 0, " desc"); vb2_private_key_free(k2); @@ -157,8 +157,8 @@ static void private_key_tests(const struct alg_combo *combo, TEST_PTR_NEQ(ckey, NULL, " key_ptr"); TEST_EQ(ckey->hash_alg, combo->hash_alg, " hash_alg"); TEST_EQ(ckey->sig_alg, VB2_SIG_NONE, " sig_alg"); - TEST_EQ(memcmp(&ckey->guid, vb2_hash_guid(combo->hash_alg), - sizeof(ckey->guid)), 0, " guid"); + TEST_EQ(memcmp(&ckey->id, vb2_hash_id(combo->hash_alg), + sizeof(ckey->id)), 0, " id"); TEST_SUCC(vb2_private_key_write(ckey, testfile), "Write hash key"); TEST_SUCC(vb2_private_key_read(&key, testfile), "Read hash key"); @@ -172,7 +172,7 @@ static void public_key_tests(const struct alg_combo *combo, struct vb2_packed_key *pkey; const char *testfile = "test.vbpubk2"; const char *testdesc = "test desc"; - const struct vb2_guid test_guid = {.raw = {0xbb}}; + const struct vb2_id test_id = {.raw = {0xbb}}; const uint32_t test_version = 0xcc01; uint8_t *buf; uint32_t bufsize; @@ -214,7 +214,7 @@ static void public_key_tests(const struct alg_combo *combo, TEST_SUCC(vb2_public_key_read_keyb(&key, keybfile), "Read keyb 3"); TEST_SUCC(vb2_public_key_set_desc(key, testdesc), "Set desc"); key->hash_alg = combo->hash_alg; - key->guid = &test_guid; + key->id = &test_id; key->version = test_version; TEST_SUCC(vb2_public_key_pack(&pkey, key), "Pack public key"); @@ -222,8 +222,8 @@ static void public_key_tests(const struct alg_combo *combo, TEST_EQ(pkey->hash_alg, key->hash_alg, " hash_alg"); TEST_EQ(pkey->sig_alg, key->sig_alg, " sig_alg"); TEST_EQ(pkey->key_version, key->version, " version"); - TEST_EQ(memcmp(&pkey->guid, key->guid, sizeof(pkey->guid)), 0, - " guid"); + TEST_EQ(memcmp(&pkey->id, key->id, sizeof(pkey->id)), 0, + " id"); TEST_EQ(strcmp(vb2_common_desc(pkey), key->desc), 0, " desc"); TEST_SUCC(vb2_unpack_key(&k2, (uint8_t *)pkey, pkey->c.total_size), "Unpack public key"); @@ -266,8 +266,8 @@ static void public_key_tests(const struct alg_combo *combo, TEST_SUCC(vb2_public_key_hash(&k2, combo->hash_alg), "Hash key"); TEST_EQ(k2.hash_alg, combo->hash_alg, " hash_alg"); TEST_EQ(k2.sig_alg, VB2_SIG_NONE, " sig_alg"); - TEST_EQ(memcmp(k2.guid, vb2_hash_guid(combo->hash_alg), - sizeof(*k2.guid)), 0, " guid"); + TEST_EQ(memcmp(k2.id, vb2_hash_id(combo->hash_alg), + sizeof(*k2.id)), 0, " id"); TEST_SUCC(vb2_public_key_pack(&pkey, &k2), "Pack public hash key"); TEST_PTR_NEQ(pkey, NULL, " key_ptr"); diff --git a/tests/vb21_host_sig_tests.c b/tests/vb21_host_sig_tests.c index 4a1943ab..37894a56 100644 --- a/tests/vb21_host_sig_tests.c +++ b/tests/vb21_host_sig_tests.c @@ -30,7 +30,7 @@ static const struct alg_combo test_algs[] = { {"RSA8192/SHA-512", VB2_SIG_RSA8192, VB2_HASH_SHA512}, }; -const struct vb2_guid test_guid = {.raw = {0xaa}}; +const struct vb2_id test_id = {.raw = {0xaa}}; const char *test_desc = "The test key"; const char *test_sig_desc = "The test signature"; const uint8_t test_data[] = "Some test data"; @@ -60,13 +60,13 @@ static void sig_tests(const struct alg_combo *combo, /* Create test keys */ /* TODO: should read these from .vbprik2, .vbpubk2 files */ TEST_SUCC(vb2_private_key_read_pem(&prik, pemfile), "Read private key"); - prik->guid = test_guid; + prik->id = test_id; prik->hash_alg = combo->hash_alg; prik->sig_alg = combo->sig_alg; vb2_private_key_set_desc(prik, test_desc); TEST_SUCC(vb2_public_key_read_keyb(&pubk, keybfile), "Read pub key"); - pubk->guid = &test_guid; + pubk->id = &test_id; pubk->hash_alg = combo->hash_alg; vb2_public_key_set_desc(pubk, test_desc); @@ -83,7 +83,7 @@ static void sig_tests(const struct alg_combo *combo, "Sign good"); TEST_PTR_NEQ(sig, NULL, " sig_ptr"); TEST_EQ(0, strcmp(vb2_common_desc(sig), test_desc), " desc"); - TEST_EQ(0, memcmp(&sig->guid, &test_guid, sizeof(test_guid)), " guid"); + TEST_EQ(0, memcmp(&sig->id, &test_id, sizeof(test_id)), " id"); TEST_EQ(sig->data_size, test_size, " data_size"); TEST_SUCC(vb2_sig_size_for_key(&size, prik, NULL), "Sig size"); TEST_EQ(size, sig->c.total_size, " size"); -- cgit v1.2.1