summaryrefslogtreecommitdiffstats
path: root/verifier.h
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-02-03 18:43:28 +0100
committerandroid-build-merger <android-build-merger@google.com>2016-02-03 18:43:28 +0100
commitb177ead3d747d0565dd3e87bb2afa765ec7e54fc (patch)
tree706c122f98334cc3d316888708c0f9086a2b3b5d /verifier.h
parentMerge "uncrypt: generate map file by renaming tmp file." (diff)
parentMerge "recovery: Refactor verifier and verifier_test." (diff)
downloadandroid_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar.gz
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar.bz2
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar.lz
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar.xz
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.tar.zst
android_bootable_recovery-b177ead3d747d0565dd3e87bb2afa765ec7e54fc.zip
Diffstat (limited to 'verifier.h')
-rw-r--r--verifier.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/verifier.h b/verifier.h
index 15f8d98e4..4eafc7565 100644
--- a/verifier.h
+++ b/verifier.h
@@ -17,6 +17,9 @@
#ifndef _RECOVERY_VERIFIER_H
#define _RECOVERY_VERIFIER_H
+#include <memory>
+#include <vector>
+
#include "mincrypt/p256.h"
#include "mincrypt/rsa.h"
@@ -25,17 +28,25 @@ typedef struct {
p256_int y;
} ECPublicKey;
-typedef struct {
+struct Certificate {
typedef enum {
RSA,
EC,
} KeyType;
+ Certificate(int hash_len_, KeyType key_type_,
+ std::unique_ptr<RSAPublicKey>&& rsa_,
+ std::unique_ptr<ECPublicKey>&& ec_) :
+ hash_len(hash_len_),
+ key_type(key_type_),
+ rsa(std::move(rsa_)),
+ ec(std::move(ec_)) { }
+
int hash_len; // SHA_DIGEST_SIZE (SHA-1) or SHA256_DIGEST_SIZE (SHA-256)
KeyType key_type;
- RSAPublicKey* rsa;
- ECPublicKey* ec;
-} Certificate;
+ std::unique_ptr<RSAPublicKey> rsa;
+ std::unique_ptr<ECPublicKey> ec;
+};
/* addr and length define a an update package file that has been
* loaded (or mmap'ed, or whatever) into memory. Verify that the file
@@ -43,9 +54,9 @@ typedef struct {
* one of the constants below.
*/
int verify_file(unsigned char* addr, size_t length,
- const Certificate *pKeys, unsigned int numKeys);
+ const std::vector<Certificate>& keys);
-Certificate* load_keys(const char* filename, int* numKeys);
+bool load_keys(const char* filename, std::vector<Certificate>& certs);
#define VERIFY_SUCCESS 0
#define VERIFY_FAILURE 1