| 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/http/transport_security_state.h" | 5 #include "net/http/transport_security_state.h" |
| 6 | 6 |
| 7 #if defined(USE_OPENSSL) | 7 #if defined(USE_OPENSSL) |
| 8 #include <openssl/ecdsa.h> | 8 #include <openssl/ecdsa.h> |
| 9 #include <openssl/ssl.h> | 9 #include <openssl/ssl.h> |
| 10 #else // !defined(USE_OPENSSL) | 10 #else // !defined(USE_OPENSSL) |
| 11 #include <cryptohi.h> | 11 #include <cryptohi.h> |
| 12 #include <hasht.h> | 12 #include <hasht.h> |
| 13 #include <keyhi.h> | 13 #include <keyhi.h> |
| 14 #include <nspr.h> | 14 #include <nspr.h> |
| 15 #include <pk11pub.h> | 15 #include <pk11pub.h> |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 #include <algorithm> | 18 #include <algorithm> |
| 19 | 19 |
| 20 #include "base/base64.h" | 20 #include "base/base64.h" |
| 21 #include "base/build_time.h" | 21 #include "base/build_time.h" |
| 22 #include "base/logging.h" | 22 #include "base/logging.h" |
| 23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/metrics/histogram.h" | 24 #include "base/metrics/histogram.h" |
| 25 #include "base/metrics/sparse_histogram.h" |
| 25 #include "base/sha1.h" | 26 #include "base/sha1.h" |
| 26 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/string_util.h" | 28 #include "base/strings/string_util.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/time/time.h" | 30 #include "base/time/time.h" |
| 30 #include "base/values.h" | 31 #include "base/values.h" |
| 31 #include "crypto/sha2.h" | 32 #include "crypto/sha2.h" |
| 32 #include "net/base/dns_util.h" | 33 #include "net/base/dns_util.h" |
| 33 #include "net/cert/x509_cert_types.h" | 34 #include "net/cert/x509_cert_types.h" |
| 34 #include "net/cert/x509_certificate.h" | 35 #include "net/cert/x509_certificate.h" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 // static | 717 // static |
| 717 void TransportSecurityState::ReportUMAOnPinFailure(const std::string& host) { | 718 void TransportSecurityState::ReportUMAOnPinFailure(const std::string& host) { |
| 718 PreloadResult result; | 719 PreloadResult result; |
| 719 if (!DecodeHSTSPreload(host, &result) || | 720 if (!DecodeHSTSPreload(host, &result) || |
| 720 !result.has_pins) { | 721 !result.has_pins) { |
| 721 return; | 722 return; |
| 722 } | 723 } |
| 723 | 724 |
| 724 DCHECK(result.domain_id != DOMAIN_NOT_PINNED); | 725 DCHECK(result.domain_id != DOMAIN_NOT_PINNED); |
| 725 | 726 |
| 726 UMA_HISTOGRAM_ENUMERATION( | 727 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 727 "Net.PublicKeyPinFailureDomain", result.domain_id, DOMAIN_NUM_EVENTS); | 728 "Net.PublicKeyPinFailureDomain", result.domain_id); |
| 728 } | 729 } |
| 729 | 730 |
| 730 // static | 731 // static |
| 731 bool TransportSecurityState::IsBuildTimely() { | 732 bool TransportSecurityState::IsBuildTimely() { |
| 732 // If the build metadata aren't embedded in the binary then we can't use the | 733 // If the build metadata aren't embedded in the binary then we can't use the |
| 733 // build time to determine if the build is timely, return true by default. If | 734 // build time to determine if the build is timely, return true by default. If |
| 734 // we're building an official build then keep using the build time, even if | 735 // we're building an official build then keep using the build time, even if |
| 735 // it's invalid it'd be a date in the past and this function will return | 736 // it's invalid it'd be a date in the past and this function will return |
| 736 // false. | 737 // false. |
| 737 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) | 738 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 return pkp.spki_hashes.size() > 0 || pkp.bad_spki_hashes.size() > 0; | 917 return pkp.spki_hashes.size() > 0 || pkp.bad_spki_hashes.size() > 0; |
| 917 } | 918 } |
| 918 | 919 |
| 919 TransportSecurityState::DomainState::PKPState::PKPState() { | 920 TransportSecurityState::DomainState::PKPState::PKPState() { |
| 920 } | 921 } |
| 921 | 922 |
| 922 TransportSecurityState::DomainState::PKPState::~PKPState() { | 923 TransportSecurityState::DomainState::PKPState::~PKPState() { |
| 923 } | 924 } |
| 924 | 925 |
| 925 } // namespace | 926 } // namespace |
| OLD | NEW |