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 "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "net/quic/crypto/crypto_protocol.h" | 8 #include "net/quic/crypto/crypto_protocol.h" |
9 #include "net/quic/crypto/crypto_utils.h" | 9 #include "net/quic/crypto/crypto_utils.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
11 #include "net/quic/quic_client_session_base.h" | 11 #include "net/quic/quic_client_session_base.h" |
12 #include "net/quic/quic_flags.h" | 12 #include "net/quic/quic_flags.h" |
13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
14 #include "net/quic/quic_session.h" | 14 #include "net/quic/quic_session.h" |
15 | 15 |
16 using std::string; | 16 using std::string; |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
| 20 QuicCryptoClientStreamBase::QuicCryptoClientStreamBase( |
| 21 QuicClientSessionBase* session) |
| 22 : QuicCryptoStream(session) {} |
| 23 |
20 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: | 24 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: |
21 ChannelIDSourceCallbackImpl(QuicCryptoClientStream* stream) | 25 ChannelIDSourceCallbackImpl(QuicCryptoClientStream* stream) |
22 : stream_(stream) {} | 26 : stream_(stream) {} |
23 | 27 |
24 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: | 28 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: |
25 ~ChannelIDSourceCallbackImpl() {} | 29 ~ChannelIDSourceCallbackImpl() {} |
26 | 30 |
27 void QuicCryptoClientStream::ChannelIDSourceCallbackImpl::Run( | 31 void QuicCryptoClientStream::ChannelIDSourceCallbackImpl::Run( |
28 scoped_ptr<ChannelIDKey>* channel_id_key) { | 32 scoped_ptr<ChannelIDKey>* channel_id_key) { |
29 if (stream_ == nullptr) { | 33 if (stream_ == nullptr) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 74 |
71 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() { | 75 void QuicCryptoClientStream::ProofVerifierCallbackImpl::Cancel() { |
72 stream_ = nullptr; | 76 stream_ = nullptr; |
73 } | 77 } |
74 | 78 |
75 QuicCryptoClientStream::QuicCryptoClientStream( | 79 QuicCryptoClientStream::QuicCryptoClientStream( |
76 const QuicServerId& server_id, | 80 const QuicServerId& server_id, |
77 QuicClientSessionBase* session, | 81 QuicClientSessionBase* session, |
78 ProofVerifyContext* verify_context, | 82 ProofVerifyContext* verify_context, |
79 QuicCryptoClientConfig* crypto_config) | 83 QuicCryptoClientConfig* crypto_config) |
80 : QuicCryptoStream(session), | 84 : QuicCryptoClientStreamBase(session), |
81 next_state_(STATE_IDLE), | 85 next_state_(STATE_IDLE), |
82 num_client_hellos_(0), | 86 num_client_hellos_(0), |
83 crypto_config_(crypto_config), | 87 crypto_config_(crypto_config), |
84 server_id_(server_id), | 88 server_id_(server_id), |
85 generation_counter_(0), | 89 generation_counter_(0), |
86 channel_id_sent_(false), | 90 channel_id_sent_(false), |
87 channel_id_source_callback_run_(false), | 91 channel_id_source_callback_run_(false), |
88 channel_id_source_callback_(nullptr), | 92 channel_id_source_callback_(nullptr), |
89 verify_context_(verify_context), | 93 verify_context_(verify_context), |
90 proof_verify_callback_(nullptr), | 94 proof_verify_callback_(nullptr), |
91 stateless_reject_received_(false) { | 95 stateless_reject_received_(false) { |
92 DCHECK_EQ(Perspective::IS_CLIENT, session->connection()->perspective()); | 96 DCHECK_EQ(Perspective::IS_CLIENT, session->connection()->perspective()); |
93 } | 97 } |
94 | 98 |
95 QuicCryptoClientStream::~QuicCryptoClientStream() { | 99 QuicCryptoClientStream::~QuicCryptoClientStream() { |
96 if (channel_id_source_callback_) { | 100 if (channel_id_source_callback_) { |
97 channel_id_source_callback_->Cancel(); | 101 channel_id_source_callback_->Cancel(); |
98 } | 102 } |
99 if (proof_verify_callback_) { | 103 if (proof_verify_callback_) { |
100 proof_verify_callback_->Cancel(); | 104 proof_verify_callback_->Cancel(); |
101 } | 105 } |
102 } | 106 } |
103 | 107 |
104 void QuicCryptoClientStream::OnHandshakeMessage( | 108 void QuicCryptoClientStream::OnHandshakeMessage( |
105 const CryptoHandshakeMessage& message) { | 109 const CryptoHandshakeMessage& message) { |
106 QuicCryptoStream::OnHandshakeMessage(message); | 110 QuicCryptoClientStreamBase::OnHandshakeMessage(message); |
107 | 111 |
108 if (message.tag() == kSCUP) { | 112 if (message.tag() == kSCUP) { |
109 if (!handshake_confirmed()) { | 113 if (!handshake_confirmed()) { |
110 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE); | 114 CloseConnection(QUIC_CRYPTO_UPDATE_BEFORE_HANDSHAKE_COMPLETE); |
111 return; | 115 return; |
112 } | 116 } |
113 | 117 |
114 // |message| is an update from the server, so we treat it differently from a | 118 // |message| is an update from the server, so we treat it differently from a |
115 // handshake message. | 119 // handshake message. |
116 HandleServerConfigUpdateMessage(message); | 120 HandleServerConfigUpdateMessage(message); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 do { | 184 do { |
181 CHECK_NE(STATE_NONE, next_state_); | 185 CHECK_NE(STATE_NONE, next_state_); |
182 const State state = next_state_; | 186 const State state = next_state_; |
183 next_state_ = STATE_IDLE; | 187 next_state_ = STATE_IDLE; |
184 rv = QUIC_SUCCESS; | 188 rv = QUIC_SUCCESS; |
185 switch (state) { | 189 switch (state) { |
186 case STATE_INITIALIZE: | 190 case STATE_INITIALIZE: |
187 DoInitialize(cached); | 191 DoInitialize(cached); |
188 break; | 192 break; |
189 case STATE_SEND_CHLO: | 193 case STATE_SEND_CHLO: |
190 DoSendCHLO(in, cached); | 194 DoSendCHLO(cached); |
191 return; // return waiting to hear from server. | 195 return; // return waiting to hear from server. |
192 case STATE_RECV_REJ: | 196 case STATE_RECV_REJ: |
193 DoReceiveREJ(in, cached); | 197 DoReceiveREJ(in, cached); |
194 break; | 198 break; |
195 case STATE_VERIFY_PROOF: | 199 case STATE_VERIFY_PROOF: |
196 rv = DoVerifyProof(cached); | 200 rv = DoVerifyProof(cached); |
197 break; | 201 break; |
198 case STATE_VERIFY_PROOF_COMPLETE: | 202 case STATE_VERIFY_PROOF_COMPLETE: |
199 DoVerifyProofComplete(cached); | 203 DoVerifyProofComplete(cached); |
200 break; | 204 break; |
(...skipping 29 matching lines...) Expand all Loading... |
230 // the proof. | 234 // the proof. |
231 DCHECK(crypto_config_->proof_verifier()); | 235 DCHECK(crypto_config_->proof_verifier()); |
232 // If the cached state needs to be verified, do it now. | 236 // If the cached state needs to be verified, do it now. |
233 next_state_ = STATE_VERIFY_PROOF; | 237 next_state_ = STATE_VERIFY_PROOF; |
234 } else { | 238 } else { |
235 next_state_ = STATE_GET_CHANNEL_ID; | 239 next_state_ = STATE_GET_CHANNEL_ID; |
236 } | 240 } |
237 } | 241 } |
238 | 242 |
239 void QuicCryptoClientStream::DoSendCHLO( | 243 void QuicCryptoClientStream::DoSendCHLO( |
240 const CryptoHandshakeMessage* in, | |
241 QuicCryptoClientConfig::CachedState* cached) { | 244 QuicCryptoClientConfig::CachedState* cached) { |
242 if (stateless_reject_received_) { | 245 if (stateless_reject_received_) { |
243 // If we've gotten to this point, we've sent at least one hello | 246 // If we've gotten to this point, we've sent at least one hello |
244 // and received a stateless reject in response. We cannot | 247 // and received a stateless reject in response. We cannot |
245 // continue to send hellos because the server has abandoned state | 248 // continue to send hellos because the server has abandoned state |
246 // for this connection. Abandon further handshakes. | 249 // for this connection. Abandon further handshakes. |
247 next_state_ = STATE_NONE; | 250 next_state_ = STATE_NONE; |
248 if (session()->connection()->connected()) { | 251 if (session()->connection()->connected()) { |
249 session()->connection()->CloseConnection( | 252 session()->connection()->CloseConnection( |
250 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, false); | 253 QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, false); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 615 } |
613 } | 616 } |
614 return false; | 617 return false; |
615 } | 618 } |
616 | 619 |
617 QuicClientSessionBase* QuicCryptoClientStream::client_session() { | 620 QuicClientSessionBase* QuicCryptoClientStream::client_session() { |
618 return reinterpret_cast<QuicClientSessionBase*>(session()); | 621 return reinterpret_cast<QuicClientSessionBase*>(session()); |
619 } | 622 } |
620 | 623 |
621 } // namespace net | 624 } // namespace net |
OLD | NEW |