diff options
author | Tao Bao <tbao@google.com> | 2017-03-18 15:16:14 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-03-18 15:16:16 +0100 |
commit | 90d3f20c993671ec7fa90119ce5d214cc370f83d (patch) | |
tree | bbc97b3f9d49d4c05260677a2d4f9ffb561684cb /install.cpp | |
parent | Merge "Revert "Revert "Print SHA-1 in hex for corrupted blocks""" (diff) | |
parent | Drop the dependency on 'ui' in verify_file(). (diff) | |
download | android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar.gz android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar.bz2 android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar.lz android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar.xz android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.tar.zst android_bootable_recovery-90d3f20c993671ec7fa90119ce5d214cc370f83d.zip |
Diffstat (limited to 'install.cpp')
-rw-r--r-- | install.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/install.cpp b/install.cpp index ce89e0dc0..9123fc276 100644 --- a/install.cpp +++ b/install.cpp @@ -27,6 +27,7 @@ #include <unistd.h> #include <chrono> +#include <functional> #include <limits> #include <map> #include <string> @@ -578,23 +579,24 @@ install_package(const char* path, bool* wipe_cache, const char* install_file, } bool verify_package(const unsigned char* package_data, size_t package_size) { - std::vector<Certificate> loadedKeys; - if (!load_keys(PUBLIC_KEYS_FILE, loadedKeys)) { - LOG(ERROR) << "Failed to load keys"; - return false; - } - LOG(INFO) << loadedKeys.size() << " key(s) loaded from " << PUBLIC_KEYS_FILE; - - // Verify package. - ui->Print("Verifying update package...\n"); - auto t0 = std::chrono::system_clock::now(); - int err = verify_file(const_cast<unsigned char*>(package_data), package_size, loadedKeys); - std::chrono::duration<double> duration = std::chrono::system_clock::now() - t0; - ui->Print("Update package verification took %.1f s (result %d).\n", duration.count(), err); - if (err != VERIFY_SUCCESS) { - LOG(ERROR) << "Signature verification failed"; - LOG(ERROR) << "error: " << kZipVerificationFailure; - return false; - } - return true; + std::vector<Certificate> loadedKeys; + if (!load_keys(PUBLIC_KEYS_FILE, loadedKeys)) { + LOG(ERROR) << "Failed to load keys"; + return false; + } + LOG(INFO) << loadedKeys.size() << " key(s) loaded from " << PUBLIC_KEYS_FILE; + + // Verify package. + ui->Print("Verifying update package...\n"); + auto t0 = std::chrono::system_clock::now(); + int err = verify_file(const_cast<unsigned char*>(package_data), package_size, loadedKeys, + std::bind(&RecoveryUI::SetProgress, ui, std::placeholders::_1)); + std::chrono::duration<double> duration = std::chrono::system_clock::now() - t0; + ui->Print("Update package verification took %.1f s (result %d).\n", duration.count(), err); + if (err != VERIFY_SUCCESS) { + LOG(ERROR) << "Signature verification failed"; + LOG(ERROR) << "error: " << kZipVerificationFailure; + return false; + } + return true; } |