Chromium Code Reviews| 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) |