| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert_verifier.h" | 5 #include "net/cert/cert_verifier.h" |
| 6 | 6 |
| 7 #include <algorithm> |
| 7 #include <memory> | 8 #include <memory> |
| 8 | 9 |
| 9 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/sha1.h" |
| 10 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 11 #include "net/cert/cert_verify_proc.h" | 13 #include "net/cert/cert_verify_proc.h" |
| 12 | 14 |
| 13 #if defined(OS_NACL) | 15 #if defined(OS_NACL) |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #else | 17 #else |
| 16 #include "net/cert/multi_threaded_cert_verifier.h" | 18 #include "net/cert/multi_threaded_cert_verifier.h" |
| 17 #endif | 19 #endif |
| 18 | 20 |
| 19 namespace net { | 21 namespace net { |
| 20 | 22 |
| 23 CertVerifier::RequestParams::RequestParams( |
| 24 X509Certificate* certificate, |
| 25 const std::string& hostname, |
| 26 int flags, |
| 27 const std::string& ocsp_response, |
| 28 const CertificateList& additional_trust_anchors) |
| 29 : hostname_(hostname), flags_(flags) { |
| 30 // Rather than store all of the original data, create a fingerprint based |
| 31 // on the hash of the request data. |
| 32 SHA1HashValue ocsp_hash; |
| 33 base::SHA1HashBytes( |
| 34 reinterpret_cast<const unsigned char*>(ocsp_response.data()), |
| 35 ocsp_response.size(), ocsp_hash.data); |
| 36 |
| 37 request_data_.reserve(additional_trust_anchors.size() + 3); |
| 38 request_data_.push_back(ocsp_hash); |
| 39 request_data_.push_back(certificate->fingerprint()); |
| 40 request_data_.push_back(certificate->ca_fingerprint()); |
| 41 for (const auto& trust_anchor : additional_trust_anchors) |
| 42 request_data_.push_back(trust_anchor->fingerprint()); |
| 43 } |
| 44 |
| 45 CertVerifier::RequestParams::RequestParams(const RequestParams& other) = |
| 46 default; |
| 47 CertVerifier::RequestParams::~RequestParams() {} |
| 48 |
| 49 bool CertVerifier::RequestParams::operator<( |
| 50 const CertVerifier::RequestParams& other) const { |
| 51 if (flags_ != other.flags_) |
| 52 return flags_ < other.flags_; |
| 53 if (hostname_ != other.hostname_) |
| 54 return hostname_ < other.hostname_; |
| 55 return std::lexicographical_compare( |
| 56 request_data_.begin(), request_data_.end(), other.request_data_.begin(), |
| 57 other.request_data_.end(), SHA1HashValueLessThan()); |
| 58 } |
| 59 |
| 21 bool CertVerifier::SupportsOCSPStapling() { | 60 bool CertVerifier::SupportsOCSPStapling() { |
| 22 return false; | 61 return false; |
| 23 } | 62 } |
| 24 | 63 |
| 25 std::unique_ptr<CertVerifier> CertVerifier::CreateDefault() { | 64 std::unique_ptr<CertVerifier> CertVerifier::CreateDefault() { |
| 26 #if defined(OS_NACL) | 65 #if defined(OS_NACL) |
| 27 NOTIMPLEMENTED(); | 66 NOTIMPLEMENTED(); |
| 28 return std::unique_ptr<CertVerifier>(); | 67 return std::unique_ptr<CertVerifier>(); |
| 29 #else | 68 #else |
| 30 return base::WrapUnique( | 69 return base::WrapUnique( |
| 31 new MultiThreadedCertVerifier(CertVerifyProc::CreateDefault())); | 70 new MultiThreadedCertVerifier(CertVerifyProc::CreateDefault())); |
| 32 #endif | 71 #endif |
| 33 } | 72 } |
| 34 | 73 |
| 35 } // namespace net | 74 } // namespace net |
| OLD | NEW |