| 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/quic_crypto_client_stream.h" | 5 #include "net/quic/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" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 AppendFixed(&out); | 314 AppendFixed(&out); |
| 315 | 315 |
| 316 // Send a local timestamp to the server. | 316 // Send a local timestamp to the server. |
| 317 out.SetValue(kCTIM, | 317 out.SetValue(kCTIM, |
| 318 session()->connection()->clock()->WallNow().ToUNIXSeconds()); | 318 session()->connection()->clock()->WallNow().ToUNIXSeconds()); |
| 319 | 319 |
| 320 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { | 320 if (!cached->IsComplete(session()->connection()->clock()->WallNow())) { |
| 321 crypto_config_->FillInchoateClientHello( | 321 crypto_config_->FillInchoateClientHello( |
| 322 server_id_, session()->connection()->supported_versions().front(), | 322 server_id_, session()->connection()->supported_versions().front(), |
| 323 cached, session()->connection()->random_generator(), | 323 cached, session()->connection()->random_generator(), |
| 324 &crypto_negotiated_params_, &out); | 324 /* demand_x509_proof= */ true, &crypto_negotiated_params_, &out); |
| 325 // Pad the inchoate client hello to fill up a packet. | 325 // Pad the inchoate client hello to fill up a packet. |
| 326 const QuicByteCount kFramingOverhead = 50; // A rough estimate. | 326 const QuicByteCount kFramingOverhead = 50; // A rough estimate. |
| 327 const QuicByteCount max_packet_size = | 327 const QuicByteCount max_packet_size = |
| 328 session()->connection()->max_packet_length(); | 328 session()->connection()->max_packet_length(); |
| 329 if (max_packet_size <= kFramingOverhead) { | 329 if (max_packet_size <= kFramingOverhead) { |
| 330 DLOG(DFATAL) << "max_packet_length (" << max_packet_size | 330 DLOG(DFATAL) << "max_packet_length (" << max_packet_size |
| 331 << ") has no room for framing overhead."; | 331 << ") has no room for framing overhead."; |
| 332 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, | 332 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, |
| 333 "max_packet_size too smalll"); | 333 "max_packet_size too smalll"); |
| 334 return; | 334 return; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 ENCRYPTION_INITIAL, | 383 ENCRYPTION_INITIAL, |
| 384 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 384 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
| 385 true /* latch once used */); | 385 true /* latch once used */); |
| 386 // Send subsequent packets under encryption on the assumption that the | 386 // Send subsequent packets under encryption on the assumption that the |
| 387 // server will accept the handshake. | 387 // server will accept the handshake. |
| 388 session()->connection()->SetEncrypter( | 388 session()->connection()->SetEncrypter( |
| 389 ENCRYPTION_INITIAL, | 389 ENCRYPTION_INITIAL, |
| 390 crypto_negotiated_params_.initial_crypters.encrypter.release()); | 390 crypto_negotiated_params_.initial_crypters.encrypter.release()); |
| 391 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); | 391 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); |
| 392 | 392 |
| 393 if (FLAGS_quic_reply_to_rej) { | 393 // TODO(ianswett): Merge ENCRYPTION_REESTABLISHED and |
| 394 // TODO(ianswett): Merge ENCRYPTION_REESTABLISHED and | 394 // ENCRYPTION_FIRST_ESTABLSIHED |
| 395 // ENCRYPTION_FIRST_ESTABLSIHED. | 395 encryption_established_ = true; |
| 396 encryption_established_ = true; | 396 session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_REESTABLISHED); |
| 397 session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_REESTABLISHED); | |
| 398 } else { | |
| 399 if (!encryption_established_) { | |
| 400 encryption_established_ = true; | |
| 401 session()->OnCryptoHandshakeEvent( | |
| 402 QuicSession::ENCRYPTION_FIRST_ESTABLISHED); | |
| 403 } else { | |
| 404 session()->OnCryptoHandshakeEvent(QuicSession::ENCRYPTION_REESTABLISHED); | |
| 405 } | |
| 406 } | |
| 407 } | 397 } |
| 408 | 398 |
| 409 void QuicCryptoClientStream::DoReceiveREJ( | 399 void QuicCryptoClientStream::DoReceiveREJ( |
| 410 const CryptoHandshakeMessage* in, | 400 const CryptoHandshakeMessage* in, |
| 411 QuicCryptoClientConfig::CachedState* cached) { | 401 QuicCryptoClientConfig::CachedState* cached) { |
| 412 // We sent a dummy CHLO because we didn't have enough information to | 402 // We sent a dummy CHLO because we didn't have enough information to |
| 413 // perform a handshake, or we sent a full hello that the server | 403 // perform a handshake, or we sent a full hello that the server |
| 414 // rejected. Here we hope to have a REJ that contains the information | 404 // rejected. Here we hope to have a REJ that contains the information |
| 415 // that we need. | 405 // that we need. |
| 416 if ((in->tag() != kREJ) && (in->tag() != kSREJ)) { | 406 if ((in->tag() != kREJ) && (in->tag() != kSREJ)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 469 |
| 480 ProofVerifierCallbackImpl* proof_verify_callback = | 470 ProofVerifierCallbackImpl* proof_verify_callback = |
| 481 new ProofVerifierCallbackImpl(this); | 471 new ProofVerifierCallbackImpl(this); |
| 482 | 472 |
| 483 verify_ok_ = false; | 473 verify_ok_ = false; |
| 484 | 474 |
| 485 QuicAsyncStatus status = verifier->VerifyProof( | 475 QuicAsyncStatus status = verifier->VerifyProof( |
| 486 server_id_.host(), server_id_.port(), cached->server_config(), | 476 server_id_.host(), server_id_.port(), cached->server_config(), |
| 487 session()->connection()->version(), chlo_hash_, cached->certs(), | 477 session()->connection()->version(), chlo_hash_, cached->certs(), |
| 488 cached->cert_sct(), cached->signature(), verify_context_.get(), | 478 cached->cert_sct(), cached->signature(), verify_context_.get(), |
| 489 &verify_error_details_, &verify_details_, proof_verify_callback); | 479 &verify_error_details_, &verify_details_, |
| 480 std::unique_ptr<ProofVerifierCallback>(proof_verify_callback)); |
| 490 | 481 |
| 491 switch (status) { | 482 switch (status) { |
| 492 case QUIC_PENDING: | 483 case QUIC_PENDING: |
| 493 proof_verify_callback_ = proof_verify_callback; | 484 proof_verify_callback_ = proof_verify_callback; |
| 494 DVLOG(1) << "Doing VerifyProof"; | 485 DVLOG(1) << "Doing VerifyProof"; |
| 495 break; | 486 break; |
| 496 case QUIC_FAILURE: | 487 case QUIC_FAILURE: |
| 497 delete proof_verify_callback; | |
| 498 break; | 488 break; |
| 499 case QUIC_SUCCESS: | 489 case QUIC_SUCCESS: |
| 500 delete proof_verify_callback; | |
| 501 verify_ok_ = true; | 490 verify_ok_ = true; |
| 502 break; | 491 break; |
| 503 } | 492 } |
| 504 return status; | 493 return status; |
| 505 } | 494 } |
| 506 | 495 |
| 507 void QuicCryptoClientStream::DoVerifyProofComplete( | 496 void QuicCryptoClientStream::DoVerifyProofComplete( |
| 508 QuicCryptoClientConfig::CachedState* cached) { | 497 QuicCryptoClientConfig::CachedState* cached) { |
| 509 if (!proof_verify_start_time_.is_null()) { | 498 if (!proof_verify_start_time_.is_null()) { |
| 510 UMA_HISTOGRAM_TIMES("Net.QuicSession.VerifyProofTime.CachedServerConfig", | 499 UMA_HISTOGRAM_TIMES("Net.QuicSession.VerifyProofTime.CachedServerConfig", |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 } | 685 } |
| 697 for (size_t i = 0; i < num_their_proof_demands; i++) { | 686 for (size_t i = 0; i < num_their_proof_demands; i++) { |
| 698 if (their_proof_demands[i] == kCHID) { | 687 if (their_proof_demands[i] == kCHID) { |
| 699 return true; | 688 return true; |
| 700 } | 689 } |
| 701 } | 690 } |
| 702 return false; | 691 return false; |
| 703 } | 692 } |
| 704 | 693 |
| 705 } // namespace net | 694 } // namespace net |
| OLD | NEW |