Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: net/socket/ssl_client_socket_impl.cc

Issue 2510633003: Add an escape hatch for the ECDSA CBC cipher removal. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/socket/ssl_client_socket_impl.h" 5 #include "net/socket/ssl_client_socket_impl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback_helpers.h" 13 #include "base/callback_helpers.h"
14 #include "base/feature_list.h"
14 #include "base/lazy_instance.h" 15 #include "base/lazy_instance.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/singleton.h" 17 #include "base/memory/singleton.h"
17 #include "base/metrics/field_trial.h" 18 #include "base/metrics/field_trial.h"
18 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/sparse_histogram.h" 20 #include "base/metrics/sparse_histogram.h"
20 #include "base/profiler/scoped_tracker.h" 21 #include "base/profiler/scoped_tracker.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_piece.h" 23 #include "base/strings/string_piece.h"
23 #include "base/synchronization/lock.h" 24 #include "base/synchronization/lock.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (base::StringToInt(base::FieldTrialList::FindFullName(field_trial), 210 if (base::StringToInt(base::FieldTrialList::FindFullName(field_trial),
210 &override_buffer_size)) { 211 &override_buffer_size)) {
211 buffer_size = override_buffer_size; 212 buffer_size = override_buffer_size;
212 buffer_size = std::max(buffer_size, 1000); 213 buffer_size = std::max(buffer_size, 1000);
213 buffer_size = std::min(buffer_size, 2 * kDefaultOpenSSLBufferSize); 214 buffer_size = std::min(buffer_size, 2 * kDefaultOpenSSLBufferSize);
214 } 215 }
215 #endif // !defined(OS_NACL) 216 #endif // !defined(OS_NACL)
216 return buffer_size; 217 return buffer_size;
217 } 218 }
218 219
220 #if defined(OS_NACL)
221 bool AreLegacyECDSACiphersEnabled() {
222 return false;
223 }
224 #else
225 // TODO(davidben): Remove this after the ECDSA CBC removal sticks.
Ryan Sleevi 2016/11/17 04:06:28 File a crbug? :) Also: In addition to not working
davidben 2016/11/17 05:15:58 Done.
226 const base::Feature kLegacyECDSACiphersFeature{
227 "SSLLegacyECDSACiphers", base::FEATURE_DISABLED_BY_DEFAULT};
228
229 bool AreLegacyECDSACiphersEnabled() {
230 return base::FeatureList::IsEnabled(kLegacyECDSACiphersFeature);
231 }
232 #endif
233
219 } // namespace 234 } // namespace
220 235
221 class SSLClientSocketImpl::SSLContext { 236 class SSLClientSocketImpl::SSLContext {
222 public: 237 public:
223 static SSLContext* GetInstance() { 238 static SSLContext* GetInstance() {
224 return base::Singleton<SSLContext>::get(); 239 return base::Singleton<SSLContext>::get();
225 } 240 }
226 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); } 241 SSL_CTX* ssl_ctx() { return ssl_ctx_.get(); }
227 SSLClientSessionCache* session_cache() { return &session_cache_; } 242 SSLClientSessionCache* session_cache() { return &session_cache_; }
228 243
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 "CECPQ1-RSA-CHACHA20-POLY1305-SHA256:" 951 "CECPQ1-RSA-CHACHA20-POLY1305-SHA256:"
937 "CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256:"); 952 "CECPQ1-ECDSA-CHACHA20-POLY1305-SHA256:");
938 if (!EVP_has_aes_hardware()) { 953 if (!EVP_has_aes_hardware()) {
939 command.append( 954 command.append(
940 "CECPQ1-RSA-AES256-GCM-SHA384:" 955 "CECPQ1-RSA-AES256-GCM-SHA384:"
941 "CECPQ1-ECDSA-AES256-GCM-SHA384:"); 956 "CECPQ1-ECDSA-AES256-GCM-SHA384:");
942 } 957 }
943 } 958 }
944 959
945 // Use BoringSSL defaults, but disable HMAC-SHA256 and HMAC-SHA384 ciphers 960 // Use BoringSSL defaults, but disable HMAC-SHA256 and HMAC-SHA384 ciphers
946 // (note that SHA256 and SHA384 only select legacy CBC ciphers). Additionally 961 // (note that SHA256 and SHA384 only select legacy CBC ciphers). Also disable
947 // disable HMAC-SHA1 ciphers in ECDSA. Also disable
948 // DHE_RSA_WITH_AES_256_GCM_SHA384. Historically, AES_256_GCM was not 962 // DHE_RSA_WITH_AES_256_GCM_SHA384. Historically, AES_256_GCM was not
949 // supported. As DHE is being deprecated, don't add a cipher only to remove it 963 // supported. As DHE is being deprecated, don't add a cipher only to remove
950 // immediately. 964 // it immediately.
951 // 965 //
952 // TODO(davidben): Remove the DHE_RSA_WITH_AES_256_GCM_SHA384 exclusion when 966 // TODO(davidben): Remove the DHE_RSA_WITH_AES_256_GCM_SHA384 exclusion when
953 // the DHEEnabled administrative policy expires. 967 // the DHEEnabled administrative policy expires.
954 command.append( 968 command.append("ALL:!SHA256:!SHA384:!DHE-RSA-AES256-GCM-SHA384:!aPSK:!RC4");
955 "ALL:!SHA256:!SHA384:!ECDSA+SHA1:!DHE-RSA-AES256-GCM-SHA384:!aPSK:!RC4");
956 969
957 if (ssl_config_.require_ecdhe) 970 if (ssl_config_.require_ecdhe)
958 command.append(":!kRSA:!kDHE"); 971 command.append(":!kRSA:!kDHE");
959 972
960 if (!ssl_config_.deprecated_cipher_suites_enabled) { 973 if (!ssl_config_.deprecated_cipher_suites_enabled) {
961 // Only offer DHE on the second handshake. https://crbug.com/538690 974 // Only offer DHE on the second handshake. https://crbug.com/538690
962 command.append(":!kDHE"); 975 command.append(":!kDHE");
963 } 976 }
964 977
978 // Additionally disable HMAC-SHA1 ciphers in ECDSA. These are the remaining
979 // CBC-mode ECDSA ciphers.
980 if (!AreLegacyECDSACiphersEnabled())
981 command.append("!ECDSA+SHA1");
982
965 // Remove any disabled ciphers. 983 // Remove any disabled ciphers.
966 for (uint16_t id : ssl_config_.disabled_cipher_suites) { 984 for (uint16_t id : ssl_config_.disabled_cipher_suites) {
967 const SSL_CIPHER* cipher = SSL_get_cipher_by_value(id); 985 const SSL_CIPHER* cipher = SSL_get_cipher_by_value(id);
968 if (cipher) { 986 if (cipher) {
969 command.append(":!"); 987 command.append(":!");
970 command.append(SSL_CIPHER_get_name(cipher)); 988 command.append(SSL_CIPHER_get_name(cipher));
971 } 989 }
972 } 990 }
973 991
974 int rv = SSL_set_cipher_list(ssl_.get(), command.c_str()); 992 int rv = SSL_set_cipher_list(ssl_.get(), command.c_str());
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED && 2018 if (ERR_GET_REASON(info->error_code) == SSL_R_TLSV1_ALERT_ACCESS_DENIED &&
2001 !certificate_requested_) { 2019 !certificate_requested_) {
2002 net_error = ERR_SSL_PROTOCOL_ERROR; 2020 net_error = ERR_SSL_PROTOCOL_ERROR;
2003 } 2021 }
2004 } 2022 }
2005 2023
2006 return net_error; 2024 return net_error;
2007 } 2025 }
2008 2026
2009 } // namespace net 2027 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698