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

Side by Side Diff: net/cert/ct_log_verifier_openssl.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/cert/ct_known_logs_static.h ('k') | net/cert/ct_log_verifier_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cert/ct_log_verifier.h" 5 #include "net/cert/ct_log_verifier.h"
6 6
7 #include <openssl/evp.h> 7 #include <openssl/evp.h>
8 #include <openssl/x509.h> 8 #include <openssl/x509.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 CTLogVerifier::CTLogVerifier() 50 CTLogVerifier::CTLogVerifier()
51 : hash_algorithm_(ct::DigitallySigned::HASH_ALGO_NONE), 51 : hash_algorithm_(ct::DigitallySigned::HASH_ALGO_NONE),
52 signature_algorithm_(ct::DigitallySigned::SIG_ALGO_ANONYMOUS), 52 signature_algorithm_(ct::DigitallySigned::SIG_ALGO_ANONYMOUS),
53 public_key_(NULL) {} 53 public_key_(NULL) {}
54 54
55 bool CTLogVerifier::Init(const base::StringPiece& public_key, 55 bool CTLogVerifier::Init(const base::StringPiece& public_key,
56 const base::StringPiece& description) { 56 const base::StringPiece& description) {
57 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); 57 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE);
58 58
59 crypto::ScopedBIO bio( 59 const uint8_t* ptr = reinterpret_cast<const uint8_t*>(public_key.data());
60 BIO_new_mem_buf(const_cast<char*>(public_key.data()), public_key.size())); 60 const uint8_t* end = ptr + public_key.size();
61 if (!bio.get()) 61 public_key_ = d2i_PUBKEY(nullptr, &ptr, public_key.size());
62 return false; 62 if (!public_key_ || ptr != end)
63
64 public_key_ = d2i_PUBKEY_bio(bio.get(), NULL);
65 if (!public_key_)
66 return false; 63 return false;
67 64
68 key_id_ = crypto::SHA256HashString(public_key); 65 key_id_ = crypto::SHA256HashString(public_key);
69 description_ = description.as_string(); 66 description_ = description.as_string();
70 67
71 // Right now, only RSASSA-PKCS1v15 with SHA-256 and ECDSA with SHA-256 are 68 // Right now, only RSASSA-PKCS1v15 with SHA-256 and ECDSA with SHA-256 are
72 // supported. 69 // supported.
73 switch (EVP_PKEY_type(public_key_->type)) { 70 switch (EVP_PKEY_type(public_key_->type)) {
74 case EVP_PKEY_RSA: 71 case EVP_PKEY_RSA:
75 hash_algorithm_ = ct::DigitallySigned::HASH_ALGO_SHA256; 72 hash_algorithm_ = ct::DigitallySigned::HASH_ALGO_SHA256;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 1 == EVP_DigestVerifyFinal( 110 1 == EVP_DigestVerifyFinal(
114 &ctx, 111 &ctx,
115 reinterpret_cast<const uint8_t*>(signature.data()), 112 reinterpret_cast<const uint8_t*>(signature.data()),
116 signature.size())); 113 signature.size()));
117 114
118 EVP_MD_CTX_cleanup(&ctx); 115 EVP_MD_CTX_cleanup(&ctx);
119 return ok; 116 return ok;
120 } 117 }
121 118
122 } // namespace net 119 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/ct_known_logs_static.h ('k') | net/cert/ct_log_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698