| OLD | NEW |
| 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/quic/core/quic_crypto_client_stream.h" | 5 #include "net/quic/core/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 // perform a handshake, or we sent a full hello that the server | 384 // perform a handshake, or we sent a full hello that the server |
| 385 // rejected. Here we hope to have a REJ that contains the information | 385 // rejected. Here we hope to have a REJ that contains the information |
| 386 // that we need. | 386 // that we need. |
| 387 if ((in->tag() != kREJ) && (in->tag() != kSREJ)) { | 387 if ((in->tag() != kREJ) && (in->tag() != kSREJ)) { |
| 388 next_state_ = STATE_NONE; | 388 next_state_ = STATE_NONE; |
| 389 CloseConnectionWithDetails(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, | 389 CloseConnectionWithDetails(QUIC_INVALID_CRYPTO_MESSAGE_TYPE, |
| 390 "Expected REJ"); | 390 "Expected REJ"); |
| 391 return; | 391 return; |
| 392 } | 392 } |
| 393 | 393 |
| 394 const uint32_t* reject_reasons; | 394 QuicTagVector reject_reasons; |
| 395 size_t num_reject_reasons; | |
| 396 static_assert(sizeof(QuicTag) == sizeof(uint32_t), "header out of sync"); | 395 static_assert(sizeof(QuicTag) == sizeof(uint32_t), "header out of sync"); |
| 397 if (in->GetTaglist(kRREJ, &reject_reasons, &num_reject_reasons) == | 396 if (in->GetTaglist(kRREJ, &reject_reasons) == QUIC_NO_ERROR) { |
| 398 QUIC_NO_ERROR) { | |
| 399 uint32_t packed_error = 0; | 397 uint32_t packed_error = 0; |
| 400 for (size_t i = 0; i < num_reject_reasons; ++i) { | 398 for (size_t i = 0; i < reject_reasons.size(); ++i) { |
| 401 // HANDSHAKE_OK is 0 and don't report that as error. | 399 // HANDSHAKE_OK is 0 and don't report that as error. |
| 402 if (reject_reasons[i] == HANDSHAKE_OK || reject_reasons[i] >= 32) { | 400 if (reject_reasons[i] == HANDSHAKE_OK || reject_reasons[i] >= 32) { |
| 403 continue; | 401 continue; |
| 404 } | 402 } |
| 405 HandshakeFailureReason reason = | 403 HandshakeFailureReason reason = |
| 406 static_cast<HandshakeFailureReason>(reject_reasons[i]); | 404 static_cast<HandshakeFailureReason>(reject_reasons[i]); |
| 407 packed_error |= 1 << (reason - 1); | 405 packed_error |= 1 << (reason - 1); |
| 408 } | 406 } |
| 409 DVLOG(1) << "Reasons for rejection: " << packed_error; | 407 DVLOG(1) << "Reasons for rejection: " << packed_error; |
| 410 if (num_client_hellos_ == kMaxClientHellos) { | 408 if (num_client_hellos_ == kMaxClientHellos) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 bool QuicCryptoClientStream::RequiresChannelID( | 654 bool QuicCryptoClientStream::RequiresChannelID( |
| 657 QuicCryptoClientConfig::CachedState* cached) { | 655 QuicCryptoClientConfig::CachedState* cached) { |
| 658 if (server_id_.privacy_mode() == PRIVACY_MODE_ENABLED || | 656 if (server_id_.privacy_mode() == PRIVACY_MODE_ENABLED || |
| 659 !crypto_config_->channel_id_source()) { | 657 !crypto_config_->channel_id_source()) { |
| 660 return false; | 658 return false; |
| 661 } | 659 } |
| 662 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); | 660 const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); |
| 663 if (!scfg) { // scfg may be null then we send an inchoate CHLO. | 661 if (!scfg) { // scfg may be null then we send an inchoate CHLO. |
| 664 return false; | 662 return false; |
| 665 } | 663 } |
| 666 const QuicTag* their_proof_demands; | 664 QuicTagVector their_proof_demands; |
| 667 size_t num_their_proof_demands; | 665 if (scfg->GetTaglist(kPDMD, &their_proof_demands) != QUIC_NO_ERROR) { |
| 668 if (scfg->GetTaglist(kPDMD, &their_proof_demands, &num_their_proof_demands) != | |
| 669 QUIC_NO_ERROR) { | |
| 670 return false; | 666 return false; |
| 671 } | 667 } |
| 672 for (size_t i = 0; i < num_their_proof_demands; i++) { | 668 for (const QuicTag tag : their_proof_demands) { |
| 673 if (their_proof_demands[i] == kCHID) { | 669 if (tag == kCHID) { |
| 674 return true; | 670 return true; |
| 675 } | 671 } |
| 676 } | 672 } |
| 677 return false; | 673 return false; |
| 678 } | 674 } |
| 679 | 675 |
| 680 } // namespace net | 676 } // namespace net |
| OLD | NEW |