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

Side by Side Diff: net/quic/crypto/quic_crypto_client_config.cc

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 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 | « net/quic/crypto/proof_test.cc ('k') | net/quic/crypto/quic_crypto_server_config.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/quic/crypto/quic_crypto_client_config.h" 5 #include "net/quic/crypto/quic_crypto_client_config.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( 766 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello(
767 const CryptoHandshakeMessage& server_hello, 767 const CryptoHandshakeMessage& server_hello,
768 QuicConnectionId connection_id, 768 QuicConnectionId connection_id,
769 QuicVersion version, 769 QuicVersion version,
770 const QuicVersionVector& negotiated_versions, 770 const QuicVersionVector& negotiated_versions,
771 CachedState* cached, 771 CachedState* cached,
772 QuicCryptoNegotiatedParameters* out_params, 772 QuicCryptoNegotiatedParameters* out_params,
773 string* error_details) { 773 string* error_details) {
774 DCHECK(error_details != nullptr); 774 DCHECK(error_details != nullptr);
775 775
776 if (server_hello.tag() != kSHLO) { 776 QuicErrorCode valid = CryptoUtils::ValidateServerHello(
777 *error_details = "Bad tag"; 777 server_hello, negotiated_versions, error_details);
778 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; 778 if (valid != QUIC_NO_ERROR) {
779 } 779 return valid;
780
781 const QuicTag* supported_version_tags;
782 size_t num_supported_versions;
783
784 if (server_hello.GetTaglist(kVER, &supported_version_tags,
785 &num_supported_versions) != QUIC_NO_ERROR) {
786 *error_details = "server hello missing version list";
787 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
788 }
789 if (!negotiated_versions.empty()) {
790 bool mismatch = num_supported_versions != negotiated_versions.size();
791 for (size_t i = 0; i < num_supported_versions && !mismatch; ++i) {
792 mismatch = QuicTagToQuicVersion(supported_version_tags[i]) !=
793 negotiated_versions[i];
794 }
795 // The server sent a list of supported versions, and the connection
796 // reports that there was a version negotiation during the handshake.
797 // Ensure that these two lists are identical.
798 if (mismatch) {
799 *error_details = "Downgrade attack detected";
800 return QUIC_VERSION_NEGOTIATION_MISMATCH;
801 }
802 } 780 }
803 781
804 // Learn about updated source address tokens. 782 // Learn about updated source address tokens.
805 StringPiece token; 783 StringPiece token;
806 if (server_hello.GetStringPiece(kSourceAddressTokenTag, &token)) { 784 if (server_hello.GetStringPiece(kSourceAddressTokenTag, &token)) {
807 cached->set_source_address_token(token); 785 cached->set_source_address_token(token);
808 } 786 }
809 787
810 StringPiece shlo_nonce; 788 StringPiece shlo_nonce;
811 if (version > QUIC_VERSION_26 && 789 if (version > QUIC_VERSION_26 &&
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 } 920 }
943 921
944 // Update canonical version to point at the "most recent" entry. 922 // Update canonical version to point at the "most recent" entry.
945 canonical_server_map_[suffix_server_id] = server_id; 923 canonical_server_map_[suffix_server_id] = server_id;
946 924
947 server_state->InitializeFrom(*canonical_state); 925 server_state->InitializeFrom(*canonical_state);
948 return true; 926 return true;
949 } 927 }
950 928
951 } // namespace net 929 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/proof_test.cc ('k') | net/quic/crypto/quic_crypto_server_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698