OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/content/content_utils.h" | 5 #include "components/security_state/content/content_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "components/security_state/core/security_state.h" | 9 #include "components/security_state/core/security_state.h" |
10 #include "components/security_state/core/switches.h" | 10 #include "components/security_state/core/switches.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 &security_info.connection_status); | 174 &security_info.connection_status); |
175 net::SSLConnectionStatusSetVersion(net::SSL_CONNECTION_VERSION_TLS1_2, | 175 net::SSLConnectionStatusSetVersion(net::SSL_CONNECTION_VERSION_TLS1_2, |
176 &security_info.connection_status); | 176 &security_info.connection_status); |
177 security_info.key_exchange_group = 29; // X25519 | 177 security_info.key_exchange_group = 29; // X25519 |
178 | 178 |
179 { | 179 { |
180 content::SecurityStyleExplanations explanations; | 180 content::SecurityStyleExplanations explanations; |
181 GetSecurityStyle(security_info, &explanations); | 181 GetSecurityStyle(security_info, &explanations); |
182 content::SecurityStyleExplanation explanation; | 182 content::SecurityStyleExplanation explanation; |
183 ASSERT_TRUE(FindSecurityStyleExplanation( | 183 ASSERT_TRUE(FindSecurityStyleExplanation( |
184 explanations.secure_explanations, "Secure Connection", &explanation)); | 184 explanations.secure_explanations, "Secure connection", &explanation)); |
185 EXPECT_EQ( | 185 EXPECT_EQ( |
186 "The connection to this site is encrypted and authenticated using a " | 186 "The connection to this site is encrypted and authenticated using a " |
187 "strong protocol (TLS 1.2), a strong key exchange (ECDHE_RSA with " | 187 "strong protocol (TLS 1.2), a strong key exchange (ECDHE_RSA with " |
188 "X25519), and a strong cipher (CHACHA20_POLY1305).", | 188 "X25519), and a strong cipher (CHACHA20_POLY1305).", |
189 explanation.description); | 189 explanation.description); |
190 } | 190 } |
191 | 191 |
192 // Some older cache entries may be missing the key exchange group, despite | 192 // Some older cache entries may be missing the key exchange group, despite |
193 // having a cipher which should supply one. | 193 // having a cipher which should supply one. |
194 security_info.key_exchange_group = 0; | 194 security_info.key_exchange_group = 0; |
195 { | 195 { |
196 content::SecurityStyleExplanations explanations; | 196 content::SecurityStyleExplanations explanations; |
197 GetSecurityStyle(security_info, &explanations); | 197 GetSecurityStyle(security_info, &explanations); |
198 content::SecurityStyleExplanation explanation; | 198 content::SecurityStyleExplanation explanation; |
199 ASSERT_TRUE(FindSecurityStyleExplanation( | 199 ASSERT_TRUE(FindSecurityStyleExplanation( |
200 explanations.secure_explanations, "Secure Connection", &explanation)); | 200 explanations.secure_explanations, "Secure connection", &explanation)); |
201 EXPECT_EQ( | 201 EXPECT_EQ( |
202 "The connection to this site is encrypted and authenticated using a " | 202 "The connection to this site is encrypted and authenticated using a " |
203 "strong protocol (TLS 1.2), a strong key exchange (ECDHE_RSA), and a " | 203 "strong protocol (TLS 1.2), a strong key exchange (ECDHE_RSA), and a " |
204 "strong cipher (CHACHA20_POLY1305).", | 204 "strong cipher (CHACHA20_POLY1305).", |
205 explanation.description); | 205 explanation.description); |
206 } | 206 } |
207 | 207 |
208 // TLS 1.3 ciphers use the key exchange group exclusively. | 208 // TLS 1.3 ciphers use the key exchange group exclusively. |
209 net::SSLConnectionStatusSetCipherSuite(0x1301 /* TLS_AES_128_GCM_SHA256 */, | 209 net::SSLConnectionStatusSetCipherSuite(0x1301 /* TLS_AES_128_GCM_SHA256 */, |
210 &security_info.connection_status); | 210 &security_info.connection_status); |
211 net::SSLConnectionStatusSetVersion(net::SSL_CONNECTION_VERSION_TLS1_3, | 211 net::SSLConnectionStatusSetVersion(net::SSL_CONNECTION_VERSION_TLS1_3, |
212 &security_info.connection_status); | 212 &security_info.connection_status); |
213 security_info.key_exchange_group = 29; // X25519 | 213 security_info.key_exchange_group = 29; // X25519 |
214 { | 214 { |
215 content::SecurityStyleExplanations explanations; | 215 content::SecurityStyleExplanations explanations; |
216 GetSecurityStyle(security_info, &explanations); | 216 GetSecurityStyle(security_info, &explanations); |
217 content::SecurityStyleExplanation explanation; | 217 content::SecurityStyleExplanation explanation; |
218 ASSERT_TRUE(FindSecurityStyleExplanation( | 218 ASSERT_TRUE(FindSecurityStyleExplanation( |
219 explanations.secure_explanations, "Secure Connection", &explanation)); | 219 explanations.secure_explanations, "Secure connection", &explanation)); |
220 EXPECT_EQ( | 220 EXPECT_EQ( |
221 "The connection to this site is encrypted and authenticated using a " | 221 "The connection to this site is encrypted and authenticated using a " |
222 "strong protocol (TLS 1.3), a strong key exchange (X25519), and a " | 222 "strong protocol (TLS 1.3), a strong key exchange (X25519), and a " |
223 "strong cipher (AES_128_GCM).", | 223 "strong cipher (AES_128_GCM).", |
224 explanation.description); | 224 explanation.description); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 // Tests that a security level of HTTP_SHOW_WARNING produces | 228 // Tests that a security level of HTTP_SHOW_WARNING produces |
229 // blink::WebSecurityStyleNeutral and an explanation if appropriate. | 229 // blink::WebSecurityStyleNeutral and an explanation if appropriate. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 EXPECT_EQ(1u, explanations.insecure_explanations.size()); | 273 EXPECT_EQ(1u, explanations.insecure_explanations.size()); |
274 | 274 |
275 explanations.insecure_explanations.clear(); | 275 explanations.insecure_explanations.clear(); |
276 security_info.cert_missing_subject_alt_name = false; | 276 security_info.cert_missing_subject_alt_name = false; |
277 GetSecurityStyle(security_info, &explanations); | 277 GetSecurityStyle(security_info, &explanations); |
278 // Verify that no explanation is shown if the subjectAltName is present. | 278 // Verify that no explanation is shown if the subjectAltName is present. |
279 EXPECT_EQ(0u, explanations.insecure_explanations.size()); | 279 EXPECT_EQ(0u, explanations.insecure_explanations.size()); |
280 } | 280 } |
281 | 281 |
282 } // namespace | 282 } // namespace |
OLD | NEW |