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 #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; |
| 69 friend class ProofVerifierCallbackImpl; | |
| 70 | 89 |
| 71 enum State { | 90 enum State { |
| 72 STATE_IDLE, | 91 STATE_IDLE, |
| 73 STATE_INITIALIZE, | 92 STATE_INITIALIZE, |
| 74 STATE_SEND_CHLO, | 93 STATE_SEND_CHLO, |
| 75 STATE_RECV_REJ, | 94 STATE_RECV_REJ, |
| 76 STATE_VERIFY_PROOF, | 95 STATE_VERIFY_PROOF, |
| 77 STATE_VERIFY_PROOF_COMPLETE, | 96 STATE_VERIFY_PROOF_COMPLETE, |
| 97 STATE_GET_CHANNEL_ID, | |
| 98 STATE_GET_CHANNEL_ID_COMPLETE, | |
| 78 STATE_RECV_SHLO, | 99 STATE_RECV_SHLO, |
| 79 }; | 100 }; |
| 80 | 101 |
| 81 // DoHandshakeLoop performs a step of the handshake state machine. Note that | 102 // 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. | 103 // |in| may be NULL if the call did not result from a received message. |
| 83 void DoHandshakeLoop(const CryptoHandshakeMessage* in); | 104 void DoHandshakeLoop(const CryptoHandshakeMessage* in); |
| 84 | 105 |
| 85 // Called to set the proof of |cached| valid. Also invokes the session's | 106 // Called to set the proof of |cached| valid. Also invokes the session's |
| 86 // OnProofValid() method. | 107 // OnProofValid() method. |
| 87 void SetCachedProofValid(QuicCryptoClientConfig::CachedState* cached); | 108 void SetCachedProofValid(QuicCryptoClientConfig::CachedState* cached); |
| 88 | 109 |
| 110 // Returns true if the server crypto config in |cached| requires a ChannelID | |
| 111 // and the client config settings also allow sending a ChannelID. | |
| 112 bool RequiresChannelID(QuicCryptoClientConfig::CachedState* cached); | |
| 113 | |
| 89 QuicClientSessionBase* client_session(); | 114 QuicClientSessionBase* client_session(); |
| 90 | 115 |
| 91 State next_state_; | 116 State next_state_; |
| 92 // num_client_hellos_ contains the number of client hello messages that this | 117 // num_client_hellos_ contains the number of client hello messages that this |
| 93 // connection has sent. | 118 // connection has sent. |
| 94 int num_client_hellos_; | 119 int num_client_hellos_; |
| 95 | 120 |
| 96 QuicCryptoClientConfig* const crypto_config_; | 121 QuicCryptoClientConfig* const crypto_config_; |
| 97 | 122 |
| 98 // Client's connection nonce (4-byte timestamp + 28 random bytes) | 123 // Client's connection nonce (4-byte timestamp + 28 random bytes) |
| 99 std::string nonce_; | 124 std::string nonce_; |
| 100 // Server's (hostname, port, is_https, privacy_mode) tuple. | 125 // Server's (hostname, port, is_https, privacy_mode) tuple. |
| 101 const QuicServerId server_id_; | 126 const QuicServerId server_id_; |
| 102 | 127 |
| 103 // Generation counter from QuicCryptoClientConfig's CachedState. | 128 // Generation counter from QuicCryptoClientConfig's CachedState. |
| 104 uint64 generation_counter_; | 129 uint64 generation_counter_; |
| 105 | 130 |
| 131 // channel_id_source_callback_ contains the callback object that we passed | |
| 132 // to an asynchronous channel ID lookup. The ChannelIDSource owns this | |
| 133 // object. | |
| 134 ChannelIDSourceCallbackImpl* channel_id_source_callback_; | |
| 135 | |
| 136 // These members are used to store the result of an asynchronous channel ID | |
| 137 // lookup. These members must not be used after | |
| 138 // STATE_GET_CHANNEL_ID_COMPLETE. | |
| 139 scoped_ptr<ChannelIDKey> channel_id_key_; | |
| 140 | |
| 141 // verify_context_ contains the context object that we passed to an | |
|
wtc
2014/06/28 16:03:30
Note to self: change "passed" to "pass" or "will p
| |
| 142 // asynchronous proof verification. | |
| 143 scoped_ptr<ProofVerifyContext> verify_context_; | |
| 144 | |
| 106 // proof_verify_callback_ contains the callback object that we passed to an | 145 // proof_verify_callback_ contains the callback object that we passed to an |
| 107 // asynchronous proof verification. The ProofVerifier owns this object. | 146 // asynchronous proof verification. The ProofVerifier owns this object. |
| 108 ProofVerifierCallbackImpl* proof_verify_callback_; | 147 ProofVerifierCallbackImpl* proof_verify_callback_; |
| 109 | 148 |
| 110 // These members are used to store the result of an asynchronous proof | 149 // These members are used to store the result of an asynchronous proof |
| 111 // verification. These members must not be used after | 150 // verification. These members must not be used after |
| 112 // STATE_VERIFY_PROOF_COMPLETE. | 151 // STATE_VERIFY_PROOF_COMPLETE. |
| 113 bool verify_ok_; | 152 bool verify_ok_; |
| 114 string verify_error_details_; | 153 string verify_error_details_; |
| 115 scoped_ptr<ProofVerifyDetails> verify_details_; | 154 scoped_ptr<ProofVerifyDetails> verify_details_; |
| 116 scoped_ptr<ProofVerifyContext> verify_context_; | |
| 117 | 155 |
| 118 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); | 156 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); |
| 119 }; | 157 }; |
| 120 | 158 |
| 121 } // namespace net | 159 } // namespace net |
| 122 | 160 |
| 123 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 161 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
| OLD | NEW |