Chromium Code Reviews| 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 "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
| 8 #include "net/quic/crypto/crypto_utils.h" | 8 #include "net/quic/crypto/crypto_utils.h" |
| 9 #include "net/quic/crypto/null_encrypter.h" | 9 #include "net/quic/crypto/null_encrypter.h" |
| 10 #include "net/quic/quic_client_session_base.h" | 10 #include "net/quic/quic_client_session_base.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 const QuicServerId& server_id, | 71 const QuicServerId& server_id, |
| 72 QuicClientSessionBase* session, | 72 QuicClientSessionBase* session, |
| 73 ProofVerifyContext* verify_context, | 73 ProofVerifyContext* verify_context, |
| 74 QuicCryptoClientConfig* crypto_config) | 74 QuicCryptoClientConfig* crypto_config) |
| 75 : QuicCryptoStream(session), | 75 : QuicCryptoStream(session), |
| 76 next_state_(STATE_IDLE), | 76 next_state_(STATE_IDLE), |
| 77 num_client_hellos_(0), | 77 num_client_hellos_(0), |
| 78 crypto_config_(crypto_config), | 78 crypto_config_(crypto_config), |
| 79 server_id_(server_id), | 79 server_id_(server_id), |
| 80 generation_counter_(0), | 80 generation_counter_(0), |
| 81 channel_id_sent_(false), | |
| 81 channel_id_source_callback_(NULL), | 82 channel_id_source_callback_(NULL), |
| 82 verify_context_(verify_context), | 83 verify_context_(verify_context), |
| 83 proof_verify_callback_(NULL) { | 84 proof_verify_callback_(NULL) { |
| 84 } | 85 } |
| 85 | 86 |
| 86 QuicCryptoClientStream::~QuicCryptoClientStream() { | 87 QuicCryptoClientStream::~QuicCryptoClientStream() { |
| 87 if (channel_id_source_callback_) { | 88 if (channel_id_source_callback_) { |
| 88 channel_id_source_callback_->Cancel(); | 89 channel_id_source_callback_->Cancel(); |
| 89 } | 90 } |
| 90 if (proof_verify_callback_) { | 91 if (proof_verify_callback_) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 103 next_state_ = STATE_INITIALIZE; | 104 next_state_ = STATE_INITIALIZE; |
| 104 DoHandshakeLoop(NULL); | 105 DoHandshakeLoop(NULL); |
| 105 return true; | 106 return true; |
| 106 } | 107 } |
| 107 | 108 |
| 108 int QuicCryptoClientStream::num_sent_client_hellos() const { | 109 int QuicCryptoClientStream::num_sent_client_hellos() const { |
| 109 return num_client_hellos_; | 110 return num_client_hellos_; |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool QuicCryptoClientStream::WasChannelIDSent() const { | 113 bool QuicCryptoClientStream::WasChannelIDSent() const { |
| 113 // TODO(rch): we should replace this with a boolean member so we | 114 return channel_id_sent_; |
| 114 // can free the memory associated with the key after we're finished with it. | |
| 115 return channel_id_key_.get() != NULL; | |
| 116 } | 115 } |
| 117 | 116 |
| 118 // kMaxClientHellos is the maximum number of times that we'll send a client | 117 // kMaxClientHellos is the maximum number of times that we'll send a client |
| 119 // hello. The value 3 accounts for: | 118 // hello. The value 3 accounts for: |
| 120 // * One failure due to an incorrect or missing source-address token. | 119 // * One failure due to an incorrect or missing source-address token. |
| 121 // * One failure due the server's certificate chain being unavailible and the | 120 // * One failure due the server's certificate chain being unavailible and the |
| 122 // server being unwilling to send it without a valid source-address token. | 121 // server being unwilling to send it without a valid source-address token. |
| 123 static const int kMaxClientHellos = 3; | 122 static const int kMaxClientHellos = 3; |
| 124 | 123 |
| 125 void QuicCryptoClientStream::DoHandshakeLoop( | 124 void QuicCryptoClientStream::DoHandshakeLoop( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 return; | 184 return; |
| 186 } | 185 } |
| 187 session()->config()->ToHandshakeMessage(&out); | 186 session()->config()->ToHandshakeMessage(&out); |
| 188 error = crypto_config_->FillClientHello( | 187 error = crypto_config_->FillClientHello( |
| 189 server_id_, | 188 server_id_, |
| 190 session()->connection()->connection_id(), | 189 session()->connection()->connection_id(), |
| 191 session()->connection()->supported_versions().front(), | 190 session()->connection()->supported_versions().front(), |
| 192 cached, | 191 cached, |
| 193 session()->connection()->clock()->WallNow(), | 192 session()->connection()->clock()->WallNow(), |
| 194 session()->connection()->random_generator(), | 193 session()->connection()->random_generator(), |
| 195 channel_id_key_.get(), | 194 channel_id_key_.get(), |
|
wtc
2014/07/16 02:01:27
If channel_id_key_.get() is not null, crypto_confi
| |
| 196 &crypto_negotiated_params_, | 195 &crypto_negotiated_params_, |
| 197 &out, | 196 &out, |
| 198 &error_details); | 197 &error_details); |
| 199 if (error != QUIC_NO_ERROR) { | 198 if (error != QUIC_NO_ERROR) { |
| 200 // Flush the cached config so that, if it's bad, the server has a | 199 // Flush the cached config so that, if it's bad, the server has a |
| 201 // chance to send us another in the future. | 200 // chance to send us another in the future. |
| 202 cached->InvalidateServerConfig(); | 201 cached->InvalidateServerConfig(); |
| 203 CloseConnectionWithDetails(error, error_details); | 202 CloseConnectionWithDetails(error, error_details); |
| 204 return; | 203 return; |
| 205 } | 204 } |
| 205 channel_id_sent_ = (channel_id_key_.get() != NULL); | |
| 206 if (cached->proof_verify_details()) { | 206 if (cached->proof_verify_details()) { |
| 207 client_session()->OnProofVerifyDetailsAvailable( | 207 client_session()->OnProofVerifyDetailsAvailable( |
| 208 *cached->proof_verify_details()); | 208 *cached->proof_verify_details()); |
| 209 } | 209 } |
| 210 next_state_ = STATE_RECV_SHLO; | 210 next_state_ = STATE_RECV_SHLO; |
| 211 DVLOG(1) << "Client: Sending " << out.DebugString(); | 211 DVLOG(1) << "Client: Sending " << out.DebugString(); |
| 212 SendHandshakeMessage(out); | 212 SendHandshakeMessage(out); |
| 213 // Be prepared to decrypt with the new server write key. | 213 // Be prepared to decrypt with the new server write key. |
| 214 session()->connection()->SetAlternativeDecrypter( | 214 session()->connection()->SetAlternativeDecrypter( |
| 215 crypto_negotiated_params_.initial_crypters.decrypter.release(), | 215 crypto_negotiated_params_.initial_crypters.decrypter.release(), |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 return false; | 458 return false; |
| 459 } | 459 } |
| 460 | 460 |
| 461 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 461 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
| 462 return reinterpret_cast<QuicClientSessionBase*>(session()); | 462 return reinterpret_cast<QuicClientSessionBase*>(session()); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace net | 465 } // namespace net |
| OLD | NEW |