diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp index b5d70327..2a78173d 100644 --- a/tests/component/verifier_test.cpp +++ b/tests/component/verifier_test.cpp @@ -99,30 +99,14 @@ class VerifierTest : public testing::TestWithParam> { android::base::StringPrintf("%s%s%s%s", DATA_PATH, NATIVE_TEST_PATH, TESTDATA_PATH, args[0].c_str()); if (sysMapFile(package.c_str(), &memmap) != 0) { - FAIL() << "Failed to mmap " << package << ": " << strerror(errno) - << "\n"; + FAIL() << "Failed to mmap " << package << ": " << strerror(errno) << "\n"; } for (auto it = ++(args.cbegin()); it != args.cend(); ++it) { - if (it->substr(it->length() - 3, it->length()) == "256") { - if (certs.empty()) { - FAIL() << "May only specify -sha256 after key type\n"; - } - certs.back().hash_len = SHA256_DIGEST_LENGTH; - } else { - std::string public_key_file = android::base::StringPrintf( - "%s%s%stest_key_%s.txt", DATA_PATH, NATIVE_TEST_PATH, - TESTDATA_PATH, it->c_str()); - ASSERT_TRUE(load_keys(public_key_file.c_str(), certs)); - certs.back().hash_len = SHA_DIGEST_LENGTH; - } - } - if (certs.empty()) { std::string public_key_file = android::base::StringPrintf( - "%s%s%stest_key_e3.txt", DATA_PATH, NATIVE_TEST_PATH, - TESTDATA_PATH); + "%s%s%stestkey_%s.txt", DATA_PATH, NATIVE_TEST_PATH, + TESTDATA_PATH, it->c_str()); ASSERT_TRUE(load_keys(public_key_file.c_str(), certs)); - certs.back().hash_len = SHA_DIGEST_LENGTH; } } @@ -147,37 +131,38 @@ TEST_P(VerifierFailureTest, VerifyFailure) { INSTANTIATE_TEST_CASE_P(SingleKeySuccess, VerifierSuccessTest, ::testing::Values( - std::vector({"otasigned.zip", "e3"}), - std::vector({"otasigned_f4.zip", "f4"}), - std::vector({"otasigned_sha256.zip", "e3", "sha256"}), - std::vector({"otasigned_f4_sha256.zip", "f4", "sha256"}), - std::vector({"otasigned_ecdsa_sha256.zip", "ec", "sha256"}))); + std::vector({"otasigned_v1.zip", "v1"}), + std::vector({"otasigned_v2.zip", "v2"}), + std::vector({"otasigned_v3.zip", "v3"}), + std::vector({"otasigned_v4.zip", "v4"}), + std::vector({"otasigned_v5.zip", "v5"}))); INSTANTIATE_TEST_CASE_P(MultiKeySuccess, VerifierSuccessTest, ::testing::Values( - std::vector({"otasigned.zip", "f4", "e3"}), - std::vector({"otasigned_f4.zip", "ec", "f4"}), - std::vector({"otasigned_sha256.zip", "ec", "e3", "e3", "sha256"}), - std::vector({"otasigned_f4_sha256.zip", "ec", "sha256", "e3", "f4", "sha256"}), - std::vector({"otasigned_ecdsa_sha256.zip", "f4", "sha256", "e3", "ec", "sha256"}))); + std::vector({"otasigned_v1.zip", "v1", "v2"}), + std::vector({"otasigned_v2.zip", "v5", "v2"}), + std::vector({"otasigned_v3.zip", "v5", "v1", "v3"}), + std::vector({"otasigned_v4.zip", "v5", "v1", "v4"}), + std::vector({"otasigned_v5.zip", "v4", "v1", "v5"}))); INSTANTIATE_TEST_CASE_P(WrongKey, VerifierFailureTest, ::testing::Values( - std::vector({"otasigned.zip", "f4"}), - std::vector({"otasigned_f4.zip", "e3"}), - std::vector({"otasigned_ecdsa_sha256.zip", "e3", "sha256"}))); + std::vector({"otasigned_v1.zip", "v2"}), + std::vector({"otasigned_v2.zip", "v1"}), + std::vector({"otasigned_v3.zip", "v5"}), + std::vector({"otasigned_v4.zip", "v5"}), + std::vector({"otasigned_v5.zip", "v3"}))); INSTANTIATE_TEST_CASE_P(WrongHash, VerifierFailureTest, ::testing::Values( - std::vector({"otasigned.zip", "e3", "sha256"}), - std::vector({"otasigned_f4.zip", "f4", "sha256"}), - std::vector({"otasigned_sha256.zip"}), - std::vector({"otasigned_f4_sha256.zip", "f4"}), - std::vector({"otasigned_ecdsa_sha256.zip"}))); + std::vector({"otasigned_v1.zip", "v3"}), + std::vector({"otasigned_v2.zip", "v4"}), + std::vector({"otasigned_v3.zip", "v1"}), + std::vector({"otasigned_v4.zip", "v2"}))); INSTANTIATE_TEST_CASE_P(BadPackage, VerifierFailureTest, ::testing::Values( - std::vector({"random.zip"}), - std::vector({"fake-eocd.zip"}), - std::vector({"alter-metadata.zip"}), - std::vector({"alter-footer.zip"}))); + std::vector({"random.zip", "v1"}), + std::vector({"fake-eocd.zip", "v1"}), + std::vector({"alter-metadata.zip", "v1"}), + std::vector({"alter-footer.zip", "v1"}))); diff --git a/tests/testdata/otasigned.zip b/tests/testdata/otasigned_v1.zip similarity index 100% rename from tests/testdata/otasigned.zip rename to tests/testdata/otasigned_v1.zip diff --git a/tests/testdata/otasigned_f4.zip b/tests/testdata/otasigned_v2.zip similarity index 100% rename from tests/testdata/otasigned_f4.zip rename to tests/testdata/otasigned_v2.zip diff --git a/tests/testdata/otasigned_sha256.zip b/tests/testdata/otasigned_v3.zip similarity index 100% rename from tests/testdata/otasigned_sha256.zip rename to tests/testdata/otasigned_v3.zip diff --git a/tests/testdata/otasigned_f4_sha256.zip b/tests/testdata/otasigned_v4.zip similarity index 100% rename from tests/testdata/otasigned_f4_sha256.zip rename to tests/testdata/otasigned_v4.zip diff --git a/tests/testdata/otasigned_ecdsa_sha256.zip b/tests/testdata/otasigned_v5.zip similarity index 100% rename from tests/testdata/otasigned_ecdsa_sha256.zip rename to tests/testdata/otasigned_v5.zip diff --git a/tests/testdata/testkey.pk8 b/tests/testdata/testkey_v1.pk8 similarity index 100% rename from tests/testdata/testkey.pk8 rename to tests/testdata/testkey_v1.pk8 diff --git a/tests/testdata/test_key_e3.txt b/tests/testdata/testkey_v1.txt similarity index 100% rename from tests/testdata/test_key_e3.txt rename to tests/testdata/testkey_v1.txt diff --git a/tests/testdata/testkey.x509.pem b/tests/testdata/testkey_v1.x509.pem similarity index 100% rename from tests/testdata/testkey.x509.pem rename to tests/testdata/testkey_v1.x509.pem diff --git a/tests/testdata/test_f4.pk8 b/tests/testdata/testkey_v2.pk8 similarity index 100% rename from tests/testdata/test_f4.pk8 rename to tests/testdata/testkey_v2.pk8 diff --git a/tests/testdata/test_key_f4.txt b/tests/testdata/testkey_v2.txt similarity index 100% rename from tests/testdata/test_key_f4.txt rename to tests/testdata/testkey_v2.txt diff --git a/tests/testdata/test_f4.x509.pem b/tests/testdata/testkey_v2.x509.pem similarity index 100% rename from tests/testdata/test_f4.x509.pem rename to tests/testdata/testkey_v2.x509.pem diff --git a/tests/testdata/testkey_v3.pk8 b/tests/testdata/testkey_v3.pk8 new file mode 120000 index 00000000..18ecf981 --- /dev/null +++ b/tests/testdata/testkey_v3.pk8 @@ -0,0 +1 @@ +testkey_v1.pk8 \ No newline at end of file diff --git a/tests/testdata/testkey_v3.txt b/tests/testdata/testkey_v3.txt new file mode 100644 index 00000000..3208571a --- /dev/null +++ b/tests/testdata/testkey_v3.txt @@ -0,0 +1 @@ +v3 {64,0xc926ad21,{1795090719,2141396315,950055447,2581568430,4268923165,1920809988,546586521,3498997798,1776797858,3740060814,1805317999,1429410244,129622599,1422441418,1783893377,1222374759,2563319927,323993566,28517732,609753416,1826472888,215237850,4261642700,4049082591,3228462402,774857746,154822455,2497198897,2758199418,3019015328,2794777644,87251430,2534927978,120774784,571297800,3695899472,2479925187,3811625450,3401832990,2394869647,3267246207,950095497,555058928,414729973,1136544882,3044590084,465547824,4058146728,2731796054,1689838846,3890756939,1048029507,895090649,247140249,178744550,3547885223,3165179243,109881576,3944604415,1044303212,3772373029,2985150306,3737520932,3599964420},{3437017481,3784475129,2800224972,3086222688,251333580,2131931323,512774938,325948880,2657486437,2102694287,3820568226,792812816,1026422502,2053275343,2800889200,3113586810,165549746,4273519969,4065247892,1902789247,772932719,3941848426,3652744109,216871947,3164400649,1942378755,3996765851,1055777370,964047799,629391717,2232744317,3910558992,191868569,2758883837,3682816752,2997714732,2702529250,3570700455,3776873832,3924067546,3555689545,2758825434,1323144535,61311905,1997411085,376844204,213777604,4077323584,9135381,1625809335,2804742137,2952293945,1117190829,4237312782,1825108855,3013147971,1111251351,2568837572,1684324211,2520978805,367251975,810756730,2353784344,1175080310}} diff --git a/tests/testdata/testkey_sha256.x509.pem b/tests/testdata/testkey_v3.x509.pem similarity index 100% rename from tests/testdata/testkey_sha256.x509.pem rename to tests/testdata/testkey_v3.x509.pem diff --git a/tests/testdata/testkey_v4.pk8 b/tests/testdata/testkey_v4.pk8 new file mode 120000 index 00000000..683b9a3f --- /dev/null +++ b/tests/testdata/testkey_v4.pk8 @@ -0,0 +1 @@ +testkey_v2.pk8 \ No newline at end of file diff --git a/tests/testdata/testkey_v4.txt b/tests/testdata/testkey_v4.txt new file mode 100644 index 00000000..532cbd51 --- /dev/null +++ b/tests/testdata/testkey_v4.txt @@ -0,0 +1 @@ +v4 {64,0xc9bd1f21,{293133087,3210546773,865313125,250921607,3158780490,943703457,1242806226,2986289859,2942743769,2457906415,2719374299,1783459420,149579627,3081531591,3440738617,2788543742,2758457512,1146764939,3699497403,2446203424,1744968926,1159130537,2370028300,3978231572,3392699980,1487782451,1180150567,2841334302,3753960204,961373345,3333628321,748825784,2978557276,1566596926,1613056060,2600292737,1847226629,50398611,1890374404,2878700735,2286201787,1401186359,619285059,731930817,2340993166,1156490245,2992241729,151498140,318782170,3480838990,2100383433,4223552555,3628927011,4247846280,1759029513,4215632601,2719154626,3490334597,1751299340,3487864726,3668753795,4217506054,3748782284,3150295088},{1772626313,445326068,3477676155,1758201194,2986784722,491035581,3922936562,702212696,2979856666,3324974564,2488428922,3056318590,1626954946,664714029,398585816,3964097931,3356701905,2298377729,2040082097,3025491477,539143308,3348777868,2995302452,3602465520,212480763,2691021393,1307177300,704008044,2031136606,1054106474,3838318865,2441343869,1477566916,700949900,2534790355,3353533667,336163563,4106790558,2701448228,1571536379,1103842411,3623110423,1635278839,1577828979,910322800,715583630,138128831,1017877531,2289162787,447994798,1897243165,4121561445,4150719842,2131821093,2262395396,3305771534,980753571,3256525190,3128121808,1072869975,3507939515,4229109952,118381341,2209831334}} diff --git a/tests/testdata/test_f4_sha256.x509.pem b/tests/testdata/testkey_v4.x509.pem similarity index 100% rename from tests/testdata/test_f4_sha256.x509.pem rename to tests/testdata/testkey_v4.x509.pem diff --git a/tests/testdata/testkey_ecdsa.pk8 b/tests/testdata/testkey_v5.pk8 similarity index 100% rename from tests/testdata/testkey_ecdsa.pk8 rename to tests/testdata/testkey_v5.pk8 diff --git a/tests/testdata/test_key_ec.txt b/tests/testdata/testkey_v5.txt similarity index 100% rename from tests/testdata/test_key_ec.txt rename to tests/testdata/testkey_v5.txt diff --git a/tests/testdata/testkey_ecdsa.x509.pem b/tests/testdata/testkey_v5.x509.pem similarity index 100% rename from tests/testdata/testkey_ecdsa.x509.pem rename to tests/testdata/testkey_v5.x509.pem