OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ |
| 6 #define COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "net/cert/cert_status_flags.h" |
| 10 #include "net/cert/sct_status_flags.h" |
| 11 #include "net/cert/x509_certificate.h" |
| 12 |
| 13 namespace security_state { |
| 14 |
| 15 class SecurityStateModelDelegate; |
| 16 |
| 17 // SecurityStateModel provides high-level security information about a |
| 18 // page or request. The SecurityStateModel takes as input a basic set of |
| 19 // information about the SSL properties of the page or request, and |
| 20 // produces as ouptut a SecurityInfo object describing the security |
| 21 // state with policies such as crypto deprecations, mixed content, |
| 22 // etc. applied. |
| 23 // |
| 24 // SecurityInfo is the main data structure computed |
| 25 // by a SecurityStateModel. SecurityInfo contains a SecurityLevel (which |
| 26 // is a single value describing the overall security state) along with |
| 27 // information that a consumer might want to display in UI to explain or |
| 28 // elaborate on the SecurityLevel. |
| 29 |
| 30 // Describes the overall security state of the page. |
| 31 // |
| 32 // If you reorder, add, or delete values from this enum, you must also |
| 33 // update the UI icons in ToolbarModelImpl::GetIconForSecurityLevel. |
| 34 // |
| 35 // A Java counterpart will be generated for this enum. |
| 36 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.security_state |
| 37 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConnectionSecurityLevel |
| 38 enum SecurityLevel { |
| 39 // HTTP/no URL/HTTPS but with insecure passive content on the page |
| 40 NONE, |
| 41 |
| 42 // HTTPS with valid EV cert |
| 43 EV_SECURE, |
| 44 |
| 45 // HTTPS (non-EV) with valid cert |
| 46 SECURE, |
| 47 |
| 48 // HTTPS, but unable to check certificate revocation status or with |
| 49 // errors |
| 50 SECURITY_WARNING, |
| 51 |
| 52 // HTTPS, but the certificate verification chain is anchored on a |
| 53 // certificate that was installed by the system administrator |
| 54 SECURITY_POLICY_WARNING, |
| 55 |
| 56 // Attempted HTTPS and failed, page not authenticated, or HTTPS with |
| 57 // insecure active content on the page |
| 58 SECURITY_ERROR, |
| 59 }; |
| 60 |
| 61 // Describes how the SHA1 deprecation policy applies to an HTTPS |
| 62 // connection. |
| 63 enum SHA1DeprecationStatus { |
| 64 // No SHA1 deprecation policy applies. |
| 65 NO_DEPRECATED_SHA1, |
| 66 // The connection used a certificate with a SHA1 signature in the |
| 67 // chain, and policy says that the connection should be treated with a |
| 68 // warning. |
| 69 DEPRECATED_SHA1_MINOR, |
| 70 // The connection used a certificate with a SHA1 signature in the |
| 71 // chain, and policy says that the connection should be treated as |
| 72 // broken HTTPS. |
| 73 DEPRECATED_SHA1_MAJOR, |
| 74 }; |
| 75 |
| 76 // Describes the type of mixed content (if any) that a site |
| 77 // displayed/ran. |
| 78 enum MixedContentStatus { |
| 79 NO_MIXED_CONTENT, |
| 80 // The site displayed insecure resources (passive mixed content). |
| 81 DISPLAYED_MIXED_CONTENT, |
| 82 // The site ran insecure code (active mixed content). |
| 83 RAN_MIXED_CONTENT, |
| 84 // The site both ran and displayed insecure resources. |
| 85 RAN_AND_DISPLAYED_MIXED_CONTENT, |
| 86 }; |
| 87 |
| 88 // Describes the security status of a page or request. This is the |
| 89 // main data structure provided by SecurityStateModel. |
| 90 struct SecurityInfo { |
| 91 SecurityInfo(); |
| 92 ~SecurityInfo(); |
| 93 SecurityLevel security_level; |
| 94 SHA1DeprecationStatus sha1_deprecation_status; |
| 95 MixedContentStatus mixed_content_status; |
| 96 // The verification statuses of the signed certificate timestamps |
| 97 // for the connection. |
| 98 std::vector<net::ct::SCTVerifyStatus> sct_verify_statuses; |
| 99 bool scheme_is_cryptographic; |
| 100 net::CertStatus cert_status; |
| 101 int cert_id; |
| 102 // The security strength, in bits, of the SSL cipher suite. In late |
| 103 // 2015, 128 is considered the minimum. |
| 104 // 0 means the connection is not encrypted. |
| 105 // -1 means the security strength is unknown. |
| 106 int security_bits; |
| 107 // Information about the SSL connection, such as protocol and |
| 108 // ciphersuite. See ssl_connection_flags.h in net. |
| 109 int connection_status; |
| 110 // True if the protocol version and ciphersuite for the connection |
| 111 // are considered secure. |
| 112 bool is_secure_protocol_and_ciphersuite; |
| 113 }; |
| 114 |
| 115 class SecurityStateModel { |
| 116 public: |
| 117 SecurityStateModel(); |
| 118 virtual ~SecurityStateModel(); |
| 119 |
| 120 void SetDelegate(SecurityStateModelDelegate* delegate); |
| 121 |
| 122 // These security levels describe the treatment given to pages that |
| 123 // display and run mixed content. They are used to coordinate the |
| 124 // treatment of mixed content with other security UI elements. |
| 125 static const SecurityLevel kDisplayedInsecureContentLevel; |
| 126 static const SecurityLevel kRanInsecureContentLevel; |
| 127 |
| 128 // Returns a SecurityInfo describing the current page or |
| 129 // request. Results are cached so that computation is only done when |
| 130 // relevant state has changed. |
| 131 const SecurityInfo& GetSecurityInfo() const; |
| 132 |
| 133 private: |
| 134 SecurityStateModelDelegate* delegate_; |
| 135 |
| 136 // Caches the SecurityInfo for the page or request. Marked mutable so |
| 137 // that the const accessor GetSecurityInfo() can update the cached |
| 138 // value. |
| 139 mutable SecurityInfo security_info_; |
| 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(SecurityStateModel); |
| 142 }; |
| 143 |
| 144 } // namespace security_state |
| 145 |
| 146 #endif // COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ |
OLD | NEW |