From 825669802315fe11508f0e962490b77cfdfc6184 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Wed, 10 Oct 2018 15:44:17 -0700 Subject: Add function to load the key from x509.pem file We used to convert a pem certificate file to some intermediate plain text format; and parse that format under recovery mode. This is uncessary since the x509.pem can be directly parsed with openssl functions. Add the function to load the public key from one x509.pem file and corresponding unit tests. And we will add more cls to extract the pem files from otacert.zip later. Bug: 116655889 Test: verify package with 5 supported certficate versions Change-Id: Ibc6c696c534567f005db75143cc4ef8d4bdea6a0 --- verifier.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'verifier.h') diff --git a/verifier.h b/verifier.h index 6fa8f2b0a..b13424126 100644 --- a/verifier.h +++ b/verifier.h @@ -17,6 +17,8 @@ #ifndef _RECOVERY_VERIFIER_H #define _RECOVERY_VERIFIER_H +#include + #include #include #include @@ -70,6 +72,10 @@ int verify_file(const unsigned char* addr, size_t length, const std::vector& certs); +// Parses a PEM-encoded x509 certificate from the given buffer and saves it into |cert|. Returns +// false if there is a parsing failure or the signature's encryption algorithm is not supported. +bool LoadCertificateFromBuffer(const std::vector& pem_content, Certificate* cert); + #define VERIFY_SUCCESS 0 #define VERIFY_FAILURE 1 -- cgit v1.2.3