| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/security_state/core/security_state.h" | 5 #include "components/security_state/core/security_state.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return level; | 84 return level; |
| 85 } | 85 } |
| 86 | 86 |
| 87 SHA1DeprecationStatus GetSHA1DeprecationStatus( | 87 SHA1DeprecationStatus GetSHA1DeprecationStatus( |
| 88 const VisibleSecurityState& visible_security_state) { | 88 const VisibleSecurityState& visible_security_state) { |
| 89 if (!visible_security_state.certificate || | 89 if (!visible_security_state.certificate || |
| 90 !(visible_security_state.cert_status & | 90 !(visible_security_state.cert_status & |
| 91 net::CERT_STATUS_SHA1_SIGNATURE_PRESENT)) | 91 net::CERT_STATUS_SHA1_SIGNATURE_PRESENT)) |
| 92 return NO_DEPRECATED_SHA1; | 92 return NO_DEPRECATED_SHA1; |
| 93 | 93 |
| 94 // The internal representation of the dates for UI treatment of SHA-1. | 94 return DEPRECATED_SHA1; |
| 95 // See http://crbug.com/401365 for details. | |
| 96 static const int64_t kJanuary2017 = INT64_C(13127702400000000); | |
| 97 if (visible_security_state.certificate->valid_expiry() >= | |
| 98 base::Time::FromInternalValue(kJanuary2017)) | |
| 99 return DEPRECATED_SHA1_MAJOR; | |
| 100 static const int64_t kJanuary2016 = INT64_C(13096080000000000); | |
| 101 if (visible_security_state.certificate->valid_expiry() >= | |
| 102 base::Time::FromInternalValue(kJanuary2016)) | |
| 103 return DEPRECATED_SHA1_MINOR; | |
| 104 | |
| 105 return NO_DEPRECATED_SHA1; | |
| 106 } | 95 } |
| 107 | 96 |
| 108 ContentStatus GetContentStatus(bool displayed, bool ran) { | 97 ContentStatus GetContentStatus(bool displayed, bool ran) { |
| 109 if (ran && displayed) | 98 if (ran && displayed) |
| 110 return CONTENT_STATUS_DISPLAYED_AND_RAN; | 99 return CONTENT_STATUS_DISPLAYED_AND_RAN; |
| 111 if (ran) | 100 if (ran) |
| 112 return CONTENT_STATUS_RAN; | 101 return CONTENT_STATUS_RAN; |
| 113 if (displayed) | 102 if (displayed) |
| 114 return CONTENT_STATUS_DISPLAYED; | 103 return CONTENT_STATUS_DISPLAYED; |
| 115 return CONTENT_STATUS_NONE; | 104 return CONTENT_STATUS_NONE; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 154 |
| 166 // Report if there is a policy cert first, before reporting any other | 155 // Report if there is a policy cert first, before reporting any other |
| 167 // authenticated-but-with-errors cases. A policy cert is a strong | 156 // authenticated-but-with-errors cases. A policy cert is a strong |
| 168 // indicator of a MITM being present (the enterprise), while the | 157 // indicator of a MITM being present (the enterprise), while the |
| 169 // other authenticated-but-with-errors indicate something may | 158 // other authenticated-but-with-errors indicate something may |
| 170 // be wrong, or may be wrong in the future, but is unclear now. | 159 // be wrong, or may be wrong in the future, but is unclear now. |
| 171 if (used_policy_installed_certificate) | 160 if (used_policy_installed_certificate) |
| 172 return SECURE_WITH_POLICY_INSTALLED_CERT; | 161 return SECURE_WITH_POLICY_INSTALLED_CERT; |
| 173 | 162 |
| 174 // In most cases, SHA1 use is treated as a certificate error, in which case | 163 // In most cases, SHA1 use is treated as a certificate error, in which case |
| 175 // DANGEROUS will have been returned above. If SHA1 is permitted, we downgrade | 164 // DANGEROUS will have been returned above. If SHA1 was permitted by policy, |
| 176 // the security level to Neutral or Dangerous depending on policy. | 165 // downgrade the security level to Neutral. |
| 177 if (sha1_status == DEPRECATED_SHA1_MAJOR || | 166 if (sha1_status == DEPRECATED_SHA1) |
| 178 sha1_status == DEPRECATED_SHA1_MINOR) { | 167 return NONE; |
| 179 return (visible_security_state.display_sha1_from_local_anchors_as_neutral) | |
| 180 ? NONE | |
| 181 : DANGEROUS; | |
| 182 } | |
| 183 | 168 |
| 184 // Active mixed content is handled above. | 169 // Active mixed content is handled above. |
| 185 DCHECK_NE(CONTENT_STATUS_RAN, mixed_content_status); | 170 DCHECK_NE(CONTENT_STATUS_RAN, mixed_content_status); |
| 186 DCHECK_NE(CONTENT_STATUS_DISPLAYED_AND_RAN, mixed_content_status); | 171 DCHECK_NE(CONTENT_STATUS_DISPLAYED_AND_RAN, mixed_content_status); |
| 187 | 172 |
| 188 if (mixed_content_status == CONTENT_STATUS_DISPLAYED || | 173 if (mixed_content_status == CONTENT_STATUS_DISPLAYED || |
| 189 content_with_cert_errors_status == CONTENT_STATUS_DISPLAYED) { | 174 content_with_cert_errors_status == CONTENT_STATUS_DISPLAYED) { |
| 190 return kDisplayedInsecureContentLevel; | 175 return kDisplayedInsecureContentLevel; |
| 191 } | 176 } |
| 192 | 177 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 cert_status(0), | 285 cert_status(0), |
| 301 connection_status(0), | 286 connection_status(0), |
| 302 key_exchange_group(0), | 287 key_exchange_group(0), |
| 303 security_bits(-1), | 288 security_bits(-1), |
| 304 displayed_mixed_content(false), | 289 displayed_mixed_content(false), |
| 305 ran_mixed_content(false), | 290 ran_mixed_content(false), |
| 306 displayed_content_with_cert_errors(false), | 291 displayed_content_with_cert_errors(false), |
| 307 ran_content_with_cert_errors(false), | 292 ran_content_with_cert_errors(false), |
| 308 pkp_bypassed(false), | 293 pkp_bypassed(false), |
| 309 displayed_password_field_on_http(false), | 294 displayed_password_field_on_http(false), |
| 310 displayed_credit_card_field_on_http(false), | 295 displayed_credit_card_field_on_http(false) {} |
| 311 display_sha1_from_local_anchors_as_neutral(false) {} | |
| 312 | 296 |
| 313 VisibleSecurityState::~VisibleSecurityState() {} | 297 VisibleSecurityState::~VisibleSecurityState() {} |
| 314 | 298 |
| 315 bool VisibleSecurityState::operator==(const VisibleSecurityState& other) const { | 299 bool VisibleSecurityState::operator==(const VisibleSecurityState& other) const { |
| 316 return (url == other.url && | 300 return (url == other.url && |
| 317 malicious_content_status == other.malicious_content_status && | 301 malicious_content_status == other.malicious_content_status && |
| 318 !!certificate == !!other.certificate && | 302 !!certificate == !!other.certificate && |
| 319 (certificate ? certificate->Equals(other.certificate.get()) : true) && | 303 (certificate ? certificate->Equals(other.certificate.get()) : true) && |
| 320 connection_status == other.connection_status && | 304 connection_status == other.connection_status && |
| 321 key_exchange_group == other.key_exchange_group && | 305 key_exchange_group == other.key_exchange_group && |
| 322 security_bits == other.security_bits && | 306 security_bits == other.security_bits && |
| 323 sct_verify_statuses == other.sct_verify_statuses && | 307 sct_verify_statuses == other.sct_verify_statuses && |
| 324 displayed_mixed_content == other.displayed_mixed_content && | 308 displayed_mixed_content == other.displayed_mixed_content && |
| 325 ran_mixed_content == other.ran_mixed_content && | 309 ran_mixed_content == other.ran_mixed_content && |
| 326 displayed_content_with_cert_errors == | 310 displayed_content_with_cert_errors == |
| 327 other.displayed_content_with_cert_errors && | 311 other.displayed_content_with_cert_errors && |
| 328 ran_content_with_cert_errors == other.ran_content_with_cert_errors && | 312 ran_content_with_cert_errors == other.ran_content_with_cert_errors && |
| 329 pkp_bypassed == other.pkp_bypassed && | 313 pkp_bypassed == other.pkp_bypassed && |
| 330 displayed_password_field_on_http == | 314 displayed_password_field_on_http == |
| 331 other.displayed_password_field_on_http && | 315 other.displayed_password_field_on_http && |
| 332 displayed_credit_card_field_on_http == | 316 displayed_credit_card_field_on_http == |
| 333 other.displayed_credit_card_field_on_http && | 317 other.displayed_credit_card_field_on_http); |
| 334 display_sha1_from_local_anchors_as_neutral == | |
| 335 other.display_sha1_from_local_anchors_as_neutral); | |
| 336 } | 318 } |
| 337 | 319 |
| 338 } // namespace security_state | 320 } // namespace security_state |
| OLD | NEW |