| OLD | NEW |
| 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/core/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 it->second->Clear(); | 413 it->second->Clear(); |
| 414 } | 414 } |
| 415 } | 415 } |
| 416 | 416 |
| 417 void QuicCryptoClientConfig::FillInchoateClientHello( | 417 void QuicCryptoClientConfig::FillInchoateClientHello( |
| 418 const QuicServerId& server_id, | 418 const QuicServerId& server_id, |
| 419 const QuicVersion preferred_version, | 419 const QuicVersion preferred_version, |
| 420 const CachedState* cached, | 420 const CachedState* cached, |
| 421 QuicRandom* rand, | 421 QuicRandom* rand, |
| 422 bool demand_x509_proof, | 422 bool demand_x509_proof, |
| 423 QuicCryptoNegotiatedParameters* out_params, | 423 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
| 424 CryptoHandshakeMessage* out) const { | 424 CryptoHandshakeMessage* out) const { |
| 425 out->set_tag(kCHLO); | 425 out->set_tag(kCHLO); |
| 426 // TODO(rch): Remove this when we remove: | 426 // TODO(rch): Remove this when we remove: |
| 427 // FLAGS_quic_use_chlo_packet_size | 427 // FLAGS_quic_use_chlo_packet_size |
| 428 out->set_minimum_size(kClientHelloMinimumSize); | 428 out->set_minimum_size(kClientHelloMinimumSize); |
| 429 | 429 |
| 430 // Server name indication. We only send SNI if it's a valid domain name, as | 430 // Server name indication. We only send SNI if it's a valid domain name, as |
| 431 // per the spec. | 431 // per the spec. |
| 432 if (CryptoUtils::IsValidSNI(server_id.host())) { | 432 if (CryptoUtils::IsValidSNI(server_id.host())) { |
| 433 out->SetStringPiece(kSNI, server_id.host()); | 433 out->SetStringPiece(kSNI, server_id.host()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 487 |
| 488 QuicErrorCode QuicCryptoClientConfig::FillClientHello( | 488 QuicErrorCode QuicCryptoClientConfig::FillClientHello( |
| 489 const QuicServerId& server_id, | 489 const QuicServerId& server_id, |
| 490 QuicConnectionId connection_id, | 490 QuicConnectionId connection_id, |
| 491 const QuicVersion actual_version, | 491 const QuicVersion actual_version, |
| 492 const QuicVersion preferred_version, | 492 const QuicVersion preferred_version, |
| 493 const CachedState* cached, | 493 const CachedState* cached, |
| 494 QuicWallTime now, | 494 QuicWallTime now, |
| 495 QuicRandom* rand, | 495 QuicRandom* rand, |
| 496 const ChannelIDKey* channel_id_key, | 496 const ChannelIDKey* channel_id_key, |
| 497 QuicCryptoNegotiatedParameters* out_params, | 497 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
| 498 CryptoHandshakeMessage* out, | 498 CryptoHandshakeMessage* out, |
| 499 string* error_details) const { | 499 string* error_details) const { |
| 500 DCHECK(error_details != nullptr); | 500 DCHECK(error_details != nullptr); |
| 501 | 501 |
| 502 FillInchoateClientHello(server_id, preferred_version, cached, rand, | 502 FillInchoateClientHello(server_id, preferred_version, cached, rand, |
| 503 /* demand_x509_proof= */ true, out_params, out); | 503 /* demand_x509_proof= */ true, out_params, out); |
| 504 | 504 |
| 505 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); | 505 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); |
| 506 if (!scfg) { | 506 if (!scfg) { |
| 507 // This should never happen as our caller should have checked | 507 // This should never happen as our caller should have checked |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 | 790 |
| 791 return QUIC_NO_ERROR; | 791 return QUIC_NO_ERROR; |
| 792 } | 792 } |
| 793 | 793 |
| 794 QuicErrorCode QuicCryptoClientConfig::ProcessRejection( | 794 QuicErrorCode QuicCryptoClientConfig::ProcessRejection( |
| 795 const CryptoHandshakeMessage& rej, | 795 const CryptoHandshakeMessage& rej, |
| 796 QuicWallTime now, | 796 QuicWallTime now, |
| 797 const QuicVersion version, | 797 const QuicVersion version, |
| 798 StringPiece chlo_hash, | 798 StringPiece chlo_hash, |
| 799 CachedState* cached, | 799 CachedState* cached, |
| 800 QuicCryptoNegotiatedParameters* out_params, | 800 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
| 801 string* error_details) { | 801 string* error_details) { |
| 802 DCHECK(error_details != nullptr); | 802 DCHECK(error_details != nullptr); |
| 803 | 803 |
| 804 if ((rej.tag() != kREJ) && (rej.tag() != kSREJ)) { | 804 if ((rej.tag() != kREJ) && (rej.tag() != kSREJ)) { |
| 805 *error_details = "Message is not REJ or SREJ"; | 805 *error_details = "Message is not REJ or SREJ"; |
| 806 return QUIC_CRYPTO_INTERNAL_ERROR; | 806 return QUIC_CRYPTO_INTERNAL_ERROR; |
| 807 } | 807 } |
| 808 | 808 |
| 809 QuicErrorCode error = | 809 QuicErrorCode error = |
| 810 CacheNewServerConfig(rej, now, version, chlo_hash, | 810 CacheNewServerConfig(rej, now, version, chlo_hash, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 833 | 833 |
| 834 return QUIC_NO_ERROR; | 834 return QUIC_NO_ERROR; |
| 835 } | 835 } |
| 836 | 836 |
| 837 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( | 837 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( |
| 838 const CryptoHandshakeMessage& server_hello, | 838 const CryptoHandshakeMessage& server_hello, |
| 839 QuicConnectionId connection_id, | 839 QuicConnectionId connection_id, |
| 840 QuicVersion version, | 840 QuicVersion version, |
| 841 const QuicVersionVector& negotiated_versions, | 841 const QuicVersionVector& negotiated_versions, |
| 842 CachedState* cached, | 842 CachedState* cached, |
| 843 QuicCryptoNegotiatedParameters* out_params, | 843 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
| 844 string* error_details) { | 844 string* error_details) { |
| 845 DCHECK(error_details != nullptr); | 845 DCHECK(error_details != nullptr); |
| 846 | 846 |
| 847 QuicErrorCode valid = CryptoUtils::ValidateServerHello( | 847 QuicErrorCode valid = CryptoUtils::ValidateServerHello( |
| 848 server_hello, negotiated_versions, error_details); | 848 server_hello, negotiated_versions, error_details); |
| 849 if (valid != QUIC_NO_ERROR) { | 849 if (valid != QUIC_NO_ERROR) { |
| 850 return valid; | 850 return valid; |
| 851 } | 851 } |
| 852 | 852 |
| 853 // Learn about updated source address tokens. | 853 // Learn about updated source address tokens. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 | 896 |
| 897 return QUIC_NO_ERROR; | 897 return QUIC_NO_ERROR; |
| 898 } | 898 } |
| 899 | 899 |
| 900 QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate( | 900 QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate( |
| 901 const CryptoHandshakeMessage& server_config_update, | 901 const CryptoHandshakeMessage& server_config_update, |
| 902 QuicWallTime now, | 902 QuicWallTime now, |
| 903 const QuicVersion version, | 903 const QuicVersion version, |
| 904 StringPiece chlo_hash, | 904 StringPiece chlo_hash, |
| 905 CachedState* cached, | 905 CachedState* cached, |
| 906 QuicCryptoNegotiatedParameters* out_params, | 906 scoped_refptr<QuicCryptoNegotiatedParameters> out_params, |
| 907 string* error_details) { | 907 string* error_details) { |
| 908 DCHECK(error_details != nullptr); | 908 DCHECK(error_details != nullptr); |
| 909 | 909 |
| 910 if (server_config_update.tag() != kSCUP) { | 910 if (server_config_update.tag() != kSCUP) { |
| 911 *error_details = "ServerConfigUpdate must have kSCUP tag."; | 911 *error_details = "ServerConfigUpdate must have kSCUP tag."; |
| 912 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; | 912 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; |
| 913 } | 913 } |
| 914 return CacheNewServerConfig(server_config_update, now, version, chlo_hash, | 914 return CacheNewServerConfig(server_config_update, now, version, chlo_hash, |
| 915 out_params->cached_certs, cached, error_details); | 915 out_params->cached_certs, cached, error_details); |
| 916 } | 916 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 } | 988 } |
| 989 | 989 |
| 990 // Update canonical version to point at the "most recent" entry. | 990 // Update canonical version to point at the "most recent" entry. |
| 991 canonical_server_map_[suffix_server_id] = server_id; | 991 canonical_server_map_[suffix_server_id] = server_id; |
| 992 | 992 |
| 993 server_state->InitializeFrom(*canonical_state); | 993 server_state->InitializeFrom(*canonical_state); |
| 994 return true; | 994 return true; |
| 995 } | 995 } |
| 996 | 996 |
| 997 } // namespace net | 997 } // namespace net |
| OLD | NEW |