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 #ifndef NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 5 #ifndef NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
6 #define NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 6 #define NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "net/quic/crypto/channel_id.h" | 10 #include "net/quic/crypto/channel_id.h" |
11 #include "net/quic/crypto/proof_verifier.h" | 11 #include "net/quic/crypto/proof_verifier.h" |
12 #include "net/quic/crypto/quic_crypto_client_config.h" | 12 #include "net/quic/crypto/quic_crypto_client_config.h" |
13 #include "net/quic/quic_config.h" | 13 #include "net/quic/quic_config.h" |
14 #include "net/quic/quic_crypto_stream.h" | 14 #include "net/quic/quic_crypto_stream.h" |
15 #include "net/quic/quic_server_id.h" | 15 #include "net/quic/quic_server_id.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class QuicClientSessionBase; | 19 class QuicClientSessionBase; |
20 | 20 |
21 namespace test { | 21 namespace test { |
22 class CryptoTestUtils; | 22 class CryptoTestUtils; |
23 class QuicChromiumClientSessionPeer; | 23 class QuicChromiumClientSessionPeer; |
24 } // namespace test | 24 } // namespace test |
25 | 25 |
26 class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { | 26 class NET_EXPORT_PRIVATE QuicCryptoClientStreamBase : public QuicCryptoStream { |
| 27 public: |
| 28 explicit QuicCryptoClientStreamBase(QuicClientSessionBase* session); |
| 29 |
| 30 ~QuicCryptoClientStreamBase() override{}; |
| 31 |
| 32 // Performs a crypto handshake with the server. |
| 33 virtual void CryptoConnect() = 0; |
| 34 |
| 35 // num_sent_client_hellos returns the number of client hello messages that |
| 36 // have been sent. If the handshake has completed then this is one greater |
| 37 // than the number of round-trips needed for the handshake. |
| 38 virtual int num_sent_client_hellos() const = 0; |
| 39 }; |
| 40 |
| 41 class NET_EXPORT_PRIVATE QuicCryptoClientStream |
| 42 : public QuicCryptoClientStreamBase { |
27 public: | 43 public: |
28 // kMaxClientHellos is the maximum number of times that we'll send a client | 44 // kMaxClientHellos is the maximum number of times that we'll send a client |
29 // hello. The value 3 accounts for: | 45 // hello. The value 3 accounts for: |
30 // * One failure due to an incorrect or missing source-address token. | 46 // * One failure due to an incorrect or missing source-address token. |
31 // * One failure due the server's certificate chain being unavailible and | 47 // * One failure due the server's certificate chain being unavailible and |
32 // the server being unwilling to send it without a valid source-address | 48 // the server being unwilling to send it without a valid source-address |
33 // token. | 49 // token. |
34 static const int kMaxClientHellos = 3; | 50 static const int kMaxClientHellos = 3; |
35 | |
36 QuicCryptoClientStream(const QuicServerId& server_id, | 51 QuicCryptoClientStream(const QuicServerId& server_id, |
37 QuicClientSessionBase* session, | 52 QuicClientSessionBase* session, |
38 ProofVerifyContext* verify_context, | 53 ProofVerifyContext* verify_context, |
39 QuicCryptoClientConfig* crypto_config); | 54 QuicCryptoClientConfig* crypto_config); |
| 55 |
40 ~QuicCryptoClientStream() override; | 56 ~QuicCryptoClientStream() override; |
41 | 57 |
| 58 // From QuicCryptoClientStreamBase |
| 59 void CryptoConnect() override; |
| 60 int num_sent_client_hellos() const override; |
| 61 |
42 // CryptoFramerVisitorInterface implementation | 62 // CryptoFramerVisitorInterface implementation |
43 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override; | 63 void OnHandshakeMessage(const CryptoHandshakeMessage& message) override; |
44 | 64 |
45 // Performs a crypto handshake with the server. | |
46 virtual void CryptoConnect(); | |
47 | |
48 // num_sent_client_hellos returns the number of client hello messages that | |
49 // have been sent. If the handshake has completed then this is one greater | |
50 // than the number of round-trips needed for the handshake. | |
51 int num_sent_client_hellos() const; | |
52 | |
53 // Returns true if a channel ID was sent on this connection. | 65 // Returns true if a channel ID was sent on this connection. |
54 bool WasChannelIDSent() const; | 66 bool WasChannelIDSent() const; |
55 | 67 |
56 // Returns true if our ChannelIDSourceCallback was run, which implies the | 68 // Returns true if our ChannelIDSourceCallback was run, which implies the |
57 // ChannelIDSource operated asynchronously. Intended for testing. | 69 // ChannelIDSource operated asynchronously. Intended for testing. |
58 bool WasChannelIDSourceCallbackRun() const; | 70 bool WasChannelIDSourceCallbackRun() const; |
59 | 71 |
60 private: | 72 private: |
61 // ChannelIDSourceCallbackImpl is passed as the callback method to | 73 // ChannelIDSourceCallbackImpl is passed as the callback method to |
62 // GetChannelIDKey. The ChannelIDSource calls this class with the result of | 74 // GetChannelIDKey. The ChannelIDSource calls this class with the result of |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const CryptoHandshakeMessage& server_config_update); | 133 const CryptoHandshakeMessage& server_config_update); |
122 | 134 |
123 // DoHandshakeLoop performs a step of the handshake state machine. Note that | 135 // DoHandshakeLoop performs a step of the handshake state machine. Note that |
124 // |in| may be nullptr if the call did not result from a received message. | 136 // |in| may be nullptr if the call did not result from a received message. |
125 void DoHandshakeLoop(const CryptoHandshakeMessage* in); | 137 void DoHandshakeLoop(const CryptoHandshakeMessage* in); |
126 | 138 |
127 // Start the handshake process. | 139 // Start the handshake process. |
128 void DoInitialize(QuicCryptoClientConfig::CachedState* cached); | 140 void DoInitialize(QuicCryptoClientConfig::CachedState* cached); |
129 | 141 |
130 // Send either InchoateClientHello or ClientHello message to the server. | 142 // Send either InchoateClientHello or ClientHello message to the server. |
131 void DoSendCHLO(const CryptoHandshakeMessage* in, | 143 void DoSendCHLO(QuicCryptoClientConfig::CachedState* cached); |
132 QuicCryptoClientConfig::CachedState* cached); | |
133 | 144 |
134 // Process REJ message from the server. | 145 // Process REJ message from the server. |
135 void DoReceiveREJ(const CryptoHandshakeMessage* in, | 146 void DoReceiveREJ(const CryptoHandshakeMessage* in, |
136 QuicCryptoClientConfig::CachedState* cached); | 147 QuicCryptoClientConfig::CachedState* cached); |
137 | 148 |
138 // Start the proof verification process. Returns the QuicAsyncStatus returned | 149 // Start the proof verification process. Returns the QuicAsyncStatus returned |
139 // by the ProofVerifier's VerifyProof. | 150 // by the ProofVerifier's VerifyProof. |
140 QuicAsyncStatus DoVerifyProof(QuicCryptoClientConfig::CachedState* cached); | 151 QuicAsyncStatus DoVerifyProof(QuicCryptoClientConfig::CachedState* cached); |
141 | 152 |
142 // If proof is valid then it sets the proof as valid (which persists the | 153 // If proof is valid then it sets the proof as valid (which persists the |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 // reject. Used for book-keeping between the STATE_RECV_REJ, | 232 // reject. Used for book-keeping between the STATE_RECV_REJ, |
222 // STATE_VERIFY_PROOF*, and subsequent STATE_SEND_CHLO state. | 233 // STATE_VERIFY_PROOF*, and subsequent STATE_SEND_CHLO state. |
223 bool stateless_reject_received_; | 234 bool stateless_reject_received_; |
224 | 235 |
225 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); | 236 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); |
226 }; | 237 }; |
227 | 238 |
228 } // namespace net | 239 } // namespace net |
229 | 240 |
230 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 241 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
OLD | NEW |