aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-03-16 19:37:38 -0500
committerTao Bao2017-03-17 16:07:12 -0500
commit5e535014dd7961fbf812abeaa27f3339775031f1 (patch)
tree5b0df6618eb06633342242f917a2fcd020e8e78f /verifier.h
parentdd553d280f3dabf8b2bd01d63111206d4ccb098c (diff)
downloadplatform-bootable-recovery-5e535014dd7961fbf812abeaa27f3339775031f1.tar.gz
platform-bootable-recovery-5e535014dd7961fbf812abeaa27f3339775031f1.tar.xz
platform-bootable-recovery-5e535014dd7961fbf812abeaa27f3339775031f1.zip
Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for posting the verification progress, which requires the users of libverifier to provide a UI instance. This CL adds an optional argument to verify_file() so that it can post the progress through the provided callback function. As a result, we can drop the MockUI class in verifier_test.cpp. Test: recovery_component_test passes. Test: verify_file() posts progress update when installing an OTA. Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
Diffstat (limited to 'verifier.h')
-rw-r--r--verifier.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/verifier.h b/verifier.h
index 58083fe1..067dab55 100644
--- a/verifier.h
+++ b/verifier.h
@@ -17,6 +17,7 @@
17#ifndef _RECOVERY_VERIFIER_H 17#ifndef _RECOVERY_VERIFIER_H
18#define _RECOVERY_VERIFIER_H 18#define _RECOVERY_VERIFIER_H
19 19
20#include <functional>
20#include <memory> 21#include <memory>
21#include <vector> 22#include <vector>
22 23
@@ -58,13 +59,14 @@ struct Certificate {
58 std::unique_ptr<EC_KEY, ECKEYDeleter> ec; 59 std::unique_ptr<EC_KEY, ECKEYDeleter> ec;
59}; 60};
60 61
61/* addr and length define a an update package file that has been 62/*
62 * loaded (or mmap'ed, or whatever) into memory. Verify that the file 63 * 'addr' and 'length' define an update package file that has been loaded (or mmap'ed, or
63 * is signed and the signature matches one of the given keys. Return 64 * whatever) into memory. Verifies that the file is signed and the signature matches one of the
64 * one of the constants below. 65 * given keys. It optionally accepts a callback function for posting the progress to. Returns one
66 * of the constants of VERIFY_SUCCESS and VERIFY_FAILURE.
65 */ 67 */
66int verify_file(unsigned char* addr, size_t length, 68int verify_file(unsigned char* addr, size_t length, const std::vector<Certificate>& keys,
67 const std::vector<Certificate>& keys); 69 const std::function<void(float)>& set_progress = nullptr);
68 70
69bool load_keys(const char* filename, std::vector<Certificate>& certs); 71bool load_keys(const char* filename, std::vector<Certificate>& certs);
70 72