aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/component/verifier_test.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp
index e520f502..2ef3828a 100644
--- a/tests/component/verifier_test.cpp
+++ b/tests/component/verifier_test.cpp
@@ -117,21 +117,6 @@ TEST(VerifierTest, load_keys_invalid_keys) {
117 ASSERT_FALSE(load_keys(key_file5.path, certs)); 117 ASSERT_FALSE(load_keys(key_file5.path, certs));
118} 118}
119 119
120TEST(VerifierTest, BadPackage_SignatureStartOutOfBounds) {
121 std::string testkey_v3;
122 ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3));
123
124 TemporaryFile key_file;
125 ASSERT_TRUE(android::base::WriteStringToFile(testkey_v3, key_file.path));
126 std::vector<Certificate> certs;
127 ASSERT_TRUE(load_keys(key_file.path, certs));
128
129 // Signature start is 65535 (0xffff) while comment size is 0 (Bug: 31914369).
130 std::string package = "\x50\x4b\x05\x06"s + std::string(12, '\0') + "\xff\xff\xff\xff\x00\x00"s;
131 ASSERT_EQ(VERIFY_FAILURE, verify_file(reinterpret_cast<const unsigned char*>(package.data()),
132 package.size(), certs));
133}
134
135TEST(VerifierTest, BadPackage_AlteredFooter) { 120TEST(VerifierTest, BadPackage_AlteredFooter) {
136 std::string testkey_v3; 121 std::string testkey_v3;
137 ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3)); 122 ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3));
@@ -177,6 +162,21 @@ TEST(VerifierTest, BadPackage_AlteredContent) {
177 certs)); 162 certs));
178} 163}
179 164
165TEST(VerifierTest, BadPackage_SignatureStartOutOfBounds) {
166 std::string testkey_v3;
167 ASSERT_TRUE(android::base::ReadFileToString(from_testdata_base("testkey_v3.txt"), &testkey_v3));
168
169 TemporaryFile key_file;
170 ASSERT_TRUE(android::base::WriteStringToFile(testkey_v3, key_file.path));
171 std::vector<Certificate> certs;
172 ASSERT_TRUE(load_keys(key_file.path, certs));
173
174 // Signature start is 65535 (0xffff) while comment size is 0 (Bug: 31914369).
175 std::string package = "\x50\x4b\x05\x06"s + std::string(12, '\0') + "\xff\xff\xff\xff\x00\x00"s;
176 ASSERT_EQ(VERIFY_FAILURE, verify_file(reinterpret_cast<const unsigned char*>(package.data()),
177 package.size(), certs));
178}
179
180TEST_P(VerifierSuccessTest, VerifySucceed) { 180TEST_P(VerifierSuccessTest, VerifySucceed) {
181 ASSERT_EQ(verify_file(memmap.addr, memmap.length, certs, nullptr), VERIFY_SUCCESS); 181 ASSERT_EQ(verify_file(memmap.addr, memmap.length, certs, nullptr), VERIFY_SUCCESS);
182} 182}