Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: net/cert/ct_log_verifier_openssl.cc

Issue 1100003006: Certificate Transparency: Fetching of Signed Tree Heads (DRAFT) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revised design, addressed some comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/cert/ct_log_verifier_openssl.cc
diff --git a/net/cert/ct_log_verifier_openssl.cc b/net/cert/ct_log_verifier_openssl.cc
index af875a58738be475c4ace28018723e57c1fa82ed..ab25da491ed84ab6d6182c055fae12ba4f8229ab 100644
--- a/net/cert/ct_log_verifier_openssl.cc
+++ b/net/cert/ct_log_verifier_openssl.cc
@@ -47,6 +47,27 @@ CTLogVerifier::~CTLogVerifier() {
EVP_PKEY_free(public_key_);
}
+CTLogVerifier::CTLogVerifier(const CTLogVerifier& other)
+ : key_id_(other.key_id_),
+ description_(other.description_),
+ url_(url),
+ hash_algorithm_(other.hash_algorithm_),
+ signature_algorithm_(other.signature_algorithm_),
+ public_key_(NULL) {
+ // No direct function for copying EVP_PKEY: Serialize to PEM
+ // and de-serialize.
+ BIO* tbio = BIO_new(BIO_s_mem());
+
+ if (PEM_write_bio_PUBKEY(tbio, other.public_key) == 1) {
+ if (PEM_read_bio_PUBKEY(tbio, &public_key_, 0, 0) == 0) {
+ // Will fail VerifySignature later.
+ public_key_ = NULL;
+ }
+ }
+
+ BIO_free(tbio);
+}
+
bool CTLogVerifier::Init(const base::StringPiece& public_key) {
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
@@ -88,6 +109,9 @@ bool CTLogVerifier::Init(const base::StringPiece& public_key) {
bool CTLogVerifier::VerifySignature(const base::StringPiece& data_to_sign,
const base::StringPiece& signature) {
crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
+ if (public_key_ == NULL) {
Ryan Sleevi 2015/06/29 11:58:13 if (!public_key_)
+ return false;
+ }
const EVP_MD* hash_alg = GetEvpAlg(hash_algorithm_);
if (hash_alg == NULL)

Powered by Google App Engine
This is Rietveld 408576698