| 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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "net/quic/core/crypto/crypto_protocol.h" | 12 #include "net/quic/core/crypto/crypto_protocol.h" |
| 13 #include "net/quic/core/crypto/crypto_utils.h" | 13 #include "net/quic/core/crypto/crypto_utils.h" |
| 14 #include "net/quic/core/crypto/null_encrypter.h" | 14 #include "net/quic/core/crypto/null_encrypter.h" |
| 15 #include "net/quic/core/quic_flags.h" | 15 #include "net/quic/core/quic_flags.h" |
| 16 #include "net/quic/core/quic_packets.h" | 16 #include "net/quic/core/quic_packets.h" |
| 17 #include "net/quic/core/quic_session.h" | 17 #include "net/quic/core/quic_session.h" |
| 18 #include "net/quic/core/quic_utils.h" | 18 #include "net/quic/core/quic_utils.h" |
| 19 #include "net/quic/platform/api/quic_logging.h" |
| 19 #include "net/quic/platform/api/quic_str_cat.h" | 20 #include "net/quic/platform/api/quic_str_cat.h" |
| 20 | 21 |
| 21 using std::string; | 22 using std::string; |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| 25 const int QuicCryptoClientStream::kMaxClientHellos; | 26 const int QuicCryptoClientStream::kMaxClientHellos; |
| 26 | 27 |
| 27 QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) | 28 QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) |
| 28 : QuicCryptoStream(session) {} | 29 : QuicCryptoStream(session) {} |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { | 299 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { |
| 299 crypto_config_->FillInchoateClientHello( | 300 crypto_config_->FillInchoateClientHello( |
| 300 server_id_, session()->connection()->supported_versions().front(), | 301 server_id_, session()->connection()->supported_versions().front(), |
| 301 cached, session()->connection()->random_generator(), | 302 cached, session()->connection()->random_generator(), |
| 302 /* demand_x509_proof= */ true, crypto_negotiated_params_, &out); | 303 /* demand_x509_proof= */ true, crypto_negotiated_params_, &out); |
| 303 // Pad the inchoate client hello to fill up a packet. | 304 // Pad the inchoate client hello to fill up a packet. |
| 304 const QuicByteCount kFramingOverhead = 50; // A rough estimate. | 305 const QuicByteCount kFramingOverhead = 50; // A rough estimate. |
| 305 const QuicByteCount max_packet_size = | 306 const QuicByteCount max_packet_size = |
| 306 session()->connection()->max_packet_length(); | 307 session()->connection()->max_packet_length(); |
| 307 if (max_packet_size <= kFramingOverhead) { | 308 if (max_packet_size <= kFramingOverhead) { |
| 308 DLOG(DFATAL) << "max_packet_length (" << max_packet_size | 309 QUIC_DLOG(DFATAL) << "max_packet_length (" << max_packet_size |
| 309 << ") has no room for framing overhead."; | 310 << ") has no room for framing overhead."; |
| 310 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, | 311 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, |
| 311 "max_packet_size too smalll"); | 312 "max_packet_size too smalll"); |
| 312 return; | 313 return; |
| 313 } | 314 } |
| 314 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { | 315 if (kClientHelloMinimumSize > max_packet_size - kFramingOverhead) { |
| 315 DLOG(DFATAL) << "Client hello won't fit in a single packet."; | 316 QUIC_DLOG(DFATAL) << "Client hello won't fit in a single packet."; |
| 316 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, "CHLO too large"); | 317 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, "CHLO too large"); |
| 317 return; | 318 return; |
| 318 } | 319 } |
| 319 // TODO(rch): Remove this when we remove: | 320 // TODO(rch): Remove this when we remove: |
| 320 // FLAGS_quic_use_chlo_packet_size | 321 // FLAGS_quic_use_chlo_packet_size |
| 321 out.set_minimum_size( | 322 out.set_minimum_size( |
| 322 static_cast<size_t>(max_packet_size - kFramingOverhead)); | 323 static_cast<size_t>(max_packet_size - kFramingOverhead)); |
| 323 next_state_ = STATE_RECV_REJ; | 324 next_state_ = STATE_RECV_REJ; |
| 324 CryptoUtils::HashHandshakeMessage(out, &chlo_hash_); | 325 CryptoUtils::HashHandshakeMessage(out, &chlo_hash_); |
| 325 SendHandshakeMessage(out); | 326 SendHandshakeMessage(out); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 QuicAsyncStatus status = verifier->VerifyProof( | 459 QuicAsyncStatus status = verifier->VerifyProof( |
| 459 server_id_.host(), server_id_.port(), cached->server_config(), | 460 server_id_.host(), server_id_.port(), cached->server_config(), |
| 460 session()->connection()->version(), chlo_hash_, cached->certs(), | 461 session()->connection()->version(), chlo_hash_, cached->certs(), |
| 461 cached->cert_sct(), cached->signature(), verify_context_.get(), | 462 cached->cert_sct(), cached->signature(), verify_context_.get(), |
| 462 &verify_error_details_, &verify_details_, | 463 &verify_error_details_, &verify_details_, |
| 463 std::unique_ptr<ProofVerifierCallback>(proof_verify_callback)); | 464 std::unique_ptr<ProofVerifierCallback>(proof_verify_callback)); |
| 464 | 465 |
| 465 switch (status) { | 466 switch (status) { |
| 466 case QUIC_PENDING: | 467 case QUIC_PENDING: |
| 467 proof_verify_callback_ = proof_verify_callback; | 468 proof_verify_callback_ = proof_verify_callback; |
| 468 DVLOG(1) << "Doing VerifyProof"; | 469 QUIC_DVLOG(1) << "Doing VerifyProof"; |
| 469 break; | 470 break; |
| 470 case QUIC_FAILURE: | 471 case QUIC_FAILURE: |
| 471 break; | 472 break; |
| 472 case QUIC_SUCCESS: | 473 case QUIC_SUCCESS: |
| 473 verify_ok_ = true; | 474 verify_ok_ = true; |
| 474 break; | 475 break; |
| 475 } | 476 } |
| 476 return status; | 477 return status; |
| 477 } | 478 } |
| 478 | 479 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } | 526 } |
| 526 | 527 |
| 527 ChannelIDSourceCallbackImpl* channel_id_source_callback = | 528 ChannelIDSourceCallbackImpl* channel_id_source_callback = |
| 528 new ChannelIDSourceCallbackImpl(this); | 529 new ChannelIDSourceCallbackImpl(this); |
| 529 QuicAsyncStatus status = crypto_config_->channel_id_source()->GetChannelIDKey( | 530 QuicAsyncStatus status = crypto_config_->channel_id_source()->GetChannelIDKey( |
| 530 server_id_.host(), &channel_id_key_, channel_id_source_callback); | 531 server_id_.host(), &channel_id_key_, channel_id_source_callback); |
| 531 | 532 |
| 532 switch (status) { | 533 switch (status) { |
| 533 case QUIC_PENDING: | 534 case QUIC_PENDING: |
| 534 channel_id_source_callback_ = channel_id_source_callback; | 535 channel_id_source_callback_ = channel_id_source_callback; |
| 535 DVLOG(1) << "Looking up channel ID"; | 536 QUIC_DVLOG(1) << "Looking up channel ID"; |
| 536 break; | 537 break; |
| 537 case QUIC_FAILURE: | 538 case QUIC_FAILURE: |
| 538 next_state_ = STATE_NONE; | 539 next_state_ = STATE_NONE; |
| 539 delete channel_id_source_callback; | 540 delete channel_id_source_callback; |
| 540 CloseConnectionWithDetails(QUIC_INVALID_CHANNEL_ID_SIGNATURE, | 541 CloseConnectionWithDetails(QUIC_INVALID_CHANNEL_ID_SIGNATURE, |
| 541 "Channel ID lookup failed"); | 542 "Channel ID lookup failed"); |
| 542 break; | 543 break; |
| 543 case QUIC_SUCCESS: | 544 case QUIC_SUCCESS: |
| 544 delete channel_id_source_callback; | 545 delete channel_id_source_callback; |
| 545 break; | 546 break; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 670 } |
| 670 for (size_t i = 0; i < num_their_proof_demands; i++) { | 671 for (size_t i = 0; i < num_their_proof_demands; i++) { |
| 671 if (their_proof_demands[i] == kCHID) { | 672 if (their_proof_demands[i] == kCHID) { |
| 672 return true; | 673 return true; |
| 673 } | 674 } |
| 674 } | 675 } |
| 675 return false; | 676 return false; |
| 676 } | 677 } |
| 677 | 678 |
| 678 } // namespace net | 679 } // namespace net |
| OLD | NEW |