Add unittest for load cache manifest success path
Add a unittest that generates a valid manifest, signed with unittest
keys. Then assert that download action can load the cached manifest
correctly.
Since the unittest keys are RSA keys, we add support for RSA keys to
payload_verifier
Test: treehugger
Change-Id: Iebf4bd740ad2c18f4e71527eeee4c12e3f8e7dea
diff --git a/payload_consumer/payload_verifier.cc b/payload_consumer/payload_verifier.cc
index 85902c8..8a3ea65 100644
--- a/payload_consumer/payload_verifier.cc
+++ b/payload_consumer/payload_verifier.cc
@@ -172,9 +172,7 @@
if (padded_hash_data == sig_hash_data) {
return true;
}
- }
-
- if (key_type == EVP_PKEY_EC) {
+ } else if (key_type == EVP_PKEY_EC) {
EC_KEY* ec_key = EVP_PKEY_get0_EC_KEY(public_key.get());
TEST_AND_RETURN_FALSE(ec_key != nullptr);
if (ECDSA_verify(0,
@@ -185,10 +183,10 @@
ec_key) == 1) {
return true;
}
+ } else {
+ LOG(ERROR) << "Unsupported key type " << key_type;
+ return false;
}
-
- LOG(ERROR) << "Unsupported key type " << key_type;
- return false;
}
LOG(INFO) << "Failed to verify the signature with " << public_keys_.size()
<< " keys.";