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/proof_verifier.h" | 11 #include "net/quic/crypto/proof_verifier.h" |
11 #include "net/quic/crypto/quic_crypto_client_config.h" | 12 #include "net/quic/crypto/quic_crypto_client_config.h" |
12 #include "net/quic/quic_config.h" | 13 #include "net/quic/quic_config.h" |
13 #include "net/quic/quic_crypto_stream.h" | 14 #include "net/quic/quic_crypto_stream.h" |
14 #include "net/quic/quic_server_id.h" | 15 #include "net/quic/quic_server_id.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 class QuicClientSessionBase; | 19 class QuicClientSessionBase; |
19 | 20 |
(...skipping 17 matching lines...) Expand all Loading... | |
37 // handshake is started successfully. | 38 // handshake is started successfully. |
38 // TODO(agl): this should probably return void. | 39 // TODO(agl): this should probably return void. |
39 virtual bool CryptoConnect(); | 40 virtual bool CryptoConnect(); |
40 | 41 |
41 // num_sent_client_hellos returns the number of client hello messages that | 42 // num_sent_client_hellos returns the number of client hello messages that |
42 // have been sent. If the handshake has completed then this is one greater | 43 // have been sent. If the handshake has completed then this is one greater |
43 // than the number of round-trips needed for the handshake. | 44 // than the number of round-trips needed for the handshake. |
44 int num_sent_client_hellos() const; | 45 int num_sent_client_hellos() const; |
45 | 46 |
46 private: | 47 private: |
48 // ChannelIDSourceCallbackImpl is passed as the callback method to | |
49 // GetChannelIDKey. The ChannelIDSource calls this class with the result of | |
50 // channel ID lookup when lookup is performed asynchronously. | |
51 class ChannelIDSourceCallbackImpl : public ChannelIDSourceCallback { | |
52 public: | |
53 explicit ChannelIDSourceCallbackImpl(QuicCryptoClientStream* stream); | |
54 virtual ~ChannelIDSourceCallbackImpl(); | |
55 | |
56 // ChannelIDSourceCallback interface. | |
57 virtual void Run(scoped_ptr<ChannelIDKey>* channel_id_key) OVERRIDE; | |
58 | |
59 // Cancel causes any future callbacks to be ignored. It must be called on | |
60 // the same thread as the callback will be made on. | |
61 void Cancel(); | |
62 | |
63 private: | |
64 QuicCryptoClientStream* stream_; | |
65 }; | |
66 | |
47 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. | 67 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. |
48 // The ProofVerifier calls this class with the result of proof verification | 68 // The ProofVerifier calls this class with the result of proof verification |
49 // when verification is performed asynchronously. | 69 // when verification is performed asynchronously. |
50 class ProofVerifierCallbackImpl : public ProofVerifierCallback { | 70 class ProofVerifierCallbackImpl : public ProofVerifierCallback { |
51 public: | 71 public: |
52 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); | 72 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); |
53 virtual ~ProofVerifierCallbackImpl(); | 73 virtual ~ProofVerifierCallbackImpl(); |
54 | 74 |
55 // ProofVerifierCallback interface. | 75 // ProofVerifierCallback interface. |
56 virtual void Run(bool ok, | 76 virtual void Run(bool ok, |
57 const string& error_details, | 77 const string& error_details, |
58 scoped_ptr<ProofVerifyDetails>* details) OVERRIDE; | 78 scoped_ptr<ProofVerifyDetails>* details) OVERRIDE; |
59 | 79 |
60 // Cancel causes any future callbacks to be ignored. It must be called on | 80 // Cancel causes any future callbacks to be ignored. It must be called on |
61 // the same thread as the callback will be made on. | 81 // the same thread as the callback will be made on. |
62 void Cancel(); | 82 void Cancel(); |
63 | 83 |
64 private: | 84 private: |
65 QuicCryptoClientStream* stream_; | 85 QuicCryptoClientStream* stream_; |
66 }; | 86 }; |
67 | 87 |
68 friend class test::CryptoTestUtils; | 88 friend class test::CryptoTestUtils; |
89 friend class ChannelIDSourceCallbackImpl; | |
69 friend class ProofVerifierCallbackImpl; | 90 friend class ProofVerifierCallbackImpl; |
Ryan Hamilton
2014/06/25 18:55:15
I *think* that you can remove these two friend sta
wtc
2014/06/28 16:03:30
You are right. I verified these two inner classes
| |
70 | 91 |
71 enum State { | 92 enum State { |
72 STATE_IDLE, | 93 STATE_IDLE, |
73 STATE_INITIALIZE, | 94 STATE_INITIALIZE, |
74 STATE_SEND_CHLO, | 95 STATE_SEND_CHLO, |
75 STATE_RECV_REJ, | 96 STATE_RECV_REJ, |
76 STATE_VERIFY_PROOF, | 97 STATE_VERIFY_PROOF, |
77 STATE_VERIFY_PROOF_COMPLETE, | 98 STATE_VERIFY_PROOF_COMPLETE, |
99 STATE_GET_CHANNEL_ID, | |
100 STATE_GET_CHANNEL_ID_COMPLETE, | |
78 STATE_RECV_SHLO, | 101 STATE_RECV_SHLO, |
79 }; | 102 }; |
80 | 103 |
81 // DoHandshakeLoop performs a step of the handshake state machine. Note that | 104 // DoHandshakeLoop performs a step of the handshake state machine. Note that |
82 // |in| may be NULL if the call did not result from a received message. | 105 // |in| may be NULL if the call did not result from a received message. |
83 void DoHandshakeLoop(const CryptoHandshakeMessage* in); | 106 void DoHandshakeLoop(const CryptoHandshakeMessage* in); |
84 | 107 |
85 // Called to set the proof of |cached| valid. Also invokes the session's | 108 // Called to set the proof of |cached| valid. Also invokes the session's |
86 // OnProofValid() method. | 109 // OnProofValid() method. |
87 void SetCachedProofValid(QuicCryptoClientConfig::CachedState* cached); | 110 void SetCachedProofValid(QuicCryptoClientConfig::CachedState* cached); |
88 | 111 |
89 QuicClientSessionBase* client_session(); | 112 QuicClientSessionBase* client_session(); |
90 | 113 |
91 State next_state_; | 114 State next_state_; |
92 // num_client_hellos_ contains the number of client hello messages that this | 115 // num_client_hellos_ contains the number of client hello messages that this |
93 // connection has sent. | 116 // connection has sent. |
94 int num_client_hellos_; | 117 int num_client_hellos_; |
95 | 118 |
96 QuicCryptoClientConfig* const crypto_config_; | 119 QuicCryptoClientConfig* const crypto_config_; |
97 | 120 |
98 // Client's connection nonce (4-byte timestamp + 28 random bytes) | 121 // Client's connection nonce (4-byte timestamp + 28 random bytes) |
99 std::string nonce_; | 122 std::string nonce_; |
100 // Server's (hostname, port, is_https, privacy_mode) tuple. | 123 // Server's (hostname, port, is_https, privacy_mode) tuple. |
101 const QuicServerId server_id_; | 124 const QuicServerId server_id_; |
102 | 125 |
103 // Generation counter from QuicCryptoClientConfig's CachedState. | 126 // Generation counter from QuicCryptoClientConfig's CachedState. |
104 uint64 generation_counter_; | 127 uint64 generation_counter_; |
105 | 128 |
129 // channel_id_source_callback_ contains the callback object that we passed | |
130 // to an asynchronous channel ID lookup. The ChannelIDSource owns this | |
131 // object. | |
132 ChannelIDSourceCallbackImpl* channel_id_source_callback_; | |
133 | |
134 // These members are used to store the result of an asynchronous channel ID | |
135 // lookup. These members must not be used after | |
136 // STATE_GET_CHANNEL_ID_COMPLETE. | |
137 scoped_ptr<ChannelIDKey> channel_id_key_; | |
138 | |
106 // proof_verify_callback_ contains the callback object that we passed to an | 139 // proof_verify_callback_ contains the callback object that we passed to an |
107 // asynchronous proof verification. The ProofVerifier owns this object. | 140 // asynchronous proof verification. The ProofVerifier owns this object. |
108 ProofVerifierCallbackImpl* proof_verify_callback_; | 141 ProofVerifierCallbackImpl* proof_verify_callback_; |
109 | 142 |
110 // These members are used to store the result of an asynchronous proof | 143 // These members are used to store the result of an asynchronous proof |
111 // verification. These members must not be used after | 144 // verification. These members must not be used after |
112 // STATE_VERIFY_PROOF_COMPLETE. | 145 // STATE_VERIFY_PROOF_COMPLETE. |
113 bool verify_ok_; | 146 bool verify_ok_; |
114 string verify_error_details_; | 147 string verify_error_details_; |
115 scoped_ptr<ProofVerifyDetails> verify_details_; | 148 scoped_ptr<ProofVerifyDetails> verify_details_; |
116 scoped_ptr<ProofVerifyContext> verify_context_; | 149 scoped_ptr<ProofVerifyContext> verify_context_; |
117 | 150 |
118 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); | 151 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); |
119 }; | 152 }; |
120 | 153 |
121 } // namespace net | 154 } // namespace net |
122 | 155 |
123 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 156 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
OLD | NEW |