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

Unified Diff: net/socket/ssl_client_socket.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket.cc
diff --git a/net/socket/ssl_client_socket.cc b/net/socket/ssl_client_socket.cc
index a52e6a3c052c70eba239aa57594c8a390816fc56..2ea403f73c958b8afb51eb4a88e5b9de2c216023 100644
--- a/net/socket/ssl_client_socket.cc
+++ b/net/socket/ssl_client_socket.cc
@@ -11,6 +11,7 @@
#include "net/base/connection_type_histograms.h"
#include "net/base/host_port_pair.h"
#include "net/ssl/channel_id_service.h"
+#include "net/ssl/ssl_cipher_suite_names.h"
#include "net/ssl/ssl_config_service.h"
#include "net/ssl/ssl_connection_status_flags.h"
@@ -234,37 +235,45 @@ bool SSLClientSocket::IsChannelIDEnabled(
}
// static
+bool SSLClientSocket::HasCipherAdequateForHTTP2(
+ const std::vector<uint16>& cipher_suites) {
+ for (uint16 cipher : cipher_suites) {
+ if (IsSecureTLSCipherSuite(cipher))
+ return true;
+ }
+ return false;
+}
+
+// static
+bool SSLClientSocket::IsTLSVersionAdequateForHTTP2(
+ const SSLConfig& ssl_config) {
+ return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2;
+}
+
+// static
std::vector<uint8_t> SSLClientSocket::SerializeNextProtos(
- const std::vector<std::string>& next_protos) {
- // Do a first pass to determine the total length.
- size_t wire_length = 0;
- for (std::vector<std::string>::const_iterator i = next_protos.begin();
- i != next_protos.end(); ++i) {
- if (i->size() > 255) {
- LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << *i;
+ const NextProtoVector& next_protos,
+ bool can_advertise_http2) {
+ std::vector<uint8_t> wire_protos;
+ for (const NextProto next_proto : next_protos) {
+ if (!can_advertise_http2 && kProtoSPDY4MinimumVersion <= next_proto &&
+ next_proto <= kProtoSPDY4MaximumVersion) {
continue;
}
- if (i->size() == 0) {
- LOG(WARNING) << "Ignoring empty NPN/ALPN protocol";
+ const std::string proto = NextProtoToString(next_proto);
+ if (proto.size() > 255) {
+ LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto;
continue;
}
- wire_length += i->size();
- wire_length++;
- }
-
- // Allocate memory for the result and fill it in.
- std::vector<uint8_t> wire_protos;
- wire_protos.reserve(wire_length);
- for (std::vector<std::string>::const_iterator i = next_protos.begin();
- i != next_protos.end(); i++) {
- if (i->size() == 0 || i->size() > 255)
+ if (proto.size() == 0) {
+ LOG(WARNING) << "Ignoring empty NPN/ALPN protocol";
continue;
- wire_protos.push_back(i->size());
- wire_protos.resize(wire_protos.size() + i->size());
- memcpy(&wire_protos[wire_protos.size() - i->size()],
- i->data(), i->size());
+ }
+ wire_protos.push_back(proto.size());
+ for (const char ch : proto) {
+ wire_protos.push_back(static_cast<uint8_t>(ch));
+ }
}
- DCHECK_EQ(wire_protos.size(), wire_length);
return wire_protos;
}
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698