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/cert/cert_verify_result.h" | 10 #include "net/cert/cert_verify_result.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 virtual bool CryptoConnect(); | 41 virtual bool CryptoConnect(); |
42 | 42 |
43 // num_sent_client_hellos returns the number of client hello messages that | 43 // num_sent_client_hellos returns the number of client hello messages that |
44 // have been sent. If the handshake has completed then this is one greater | 44 // have been sent. If the handshake has completed then this is one greater |
45 // than the number of round-trips needed for the handshake. | 45 // than the number of round-trips needed for the handshake. |
46 int num_sent_client_hellos() const; | 46 int num_sent_client_hellos() const; |
47 | 47 |
48 // Gets the SSL connection information. | 48 // Gets the SSL connection information. |
49 virtual bool GetSSLInfo(SSLInfo* ssl_info); | 49 virtual bool GetSSLInfo(SSLInfo* ssl_info); |
50 | 50 |
51 void OnIOComplete(int result); | |
52 | |
51 private: | 53 private: |
52 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. | 54 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof. |
53 // The ProofVerifier calls this class with the result of proof verification | 55 // The ProofVerifier calls this class with the result of proof verification |
54 // when verification is performed asynchronously. | 56 // when verification is performed asynchronously. |
55 class ProofVerifierCallbackImpl : public ProofVerifierCallback { | 57 class ProofVerifierCallbackImpl : public ProofVerifierCallback { |
56 public: | 58 public: |
57 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); | 59 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream); |
58 virtual ~ProofVerifierCallbackImpl(); | 60 virtual ~ProofVerifierCallbackImpl(); |
59 | 61 |
60 // ProofVerifierCallback interface. | 62 // ProofVerifierCallback interface. |
61 virtual void Run(bool ok, | 63 virtual void Run(bool ok, |
62 const string& error_details, | 64 const string& error_details, |
63 scoped_ptr<ProofVerifyDetails>* details) OVERRIDE; | 65 scoped_ptr<ProofVerifyDetails>* details) OVERRIDE; |
64 | 66 |
65 // Cancel causes any future callbacks to be ignored. It must be called on | 67 // Cancel causes any future callbacks to be ignored. It must be called on |
66 // the same thread as the callback will be made on. | 68 // the same thread as the callback will be made on. |
67 void Cancel(); | 69 void Cancel(); |
68 | 70 |
69 private: | 71 private: |
70 QuicCryptoClientStream* stream_; | 72 QuicCryptoClientStream* stream_; |
71 }; | 73 }; |
72 | 74 |
73 friend class test::CryptoTestUtils; | 75 friend class test::CryptoTestUtils; |
74 friend class ProofVerifierCallbackImpl; | 76 friend class ProofVerifierCallbackImpl; |
75 | 77 |
76 enum State { | 78 enum State { |
77 STATE_IDLE, | 79 STATE_IDLE, |
80 STATE_LOAD_QUIC_SERVER_INFO, | |
81 STATE_LOAD_QUIC_SERVER_INFO_COMPLETE, | |
78 STATE_SEND_CHLO, | 82 STATE_SEND_CHLO, |
79 STATE_RECV_REJ, | 83 STATE_RECV_REJ, |
80 STATE_VERIFY_PROOF, | 84 STATE_VERIFY_PROOF, |
81 STATE_VERIFY_PROOF_COMPLETE, | 85 STATE_VERIFY_PROOF_COMPLETE, |
82 STATE_RECV_SHLO, | 86 STATE_RECV_SHLO, |
83 }; | 87 }; |
84 | 88 |
85 // DoHandshakeLoop performs a step of the handshake state machine. Note that | 89 // DoHandshakeLoop performs a step of the handshake state machine. Note that |
86 // |in| may be NULL if the call did not result from a received message | 90 // |in| may be NULL if the call did not result from a received message |
87 void DoHandshakeLoop(const CryptoHandshakeMessage* in); | 91 void DoHandshakeLoop(const CryptoHandshakeMessage* in); |
88 | 92 |
93 // TODO(rtenneti): convert the other states of the state machine into DoXXX | |
94 // functions. | |
95 | |
96 // Call QuicServerInfo's WaitForDataReady to load the server information from | |
97 // the disk cache. | |
98 int DoLoadQuicServerInfo(QuicCryptoClientConfig::CachedState* cached); | |
99 void DoLoadQuicServerInfoComplete( | |
100 QuicCryptoClientConfig::CachedState* cached); | |
101 | |
89 State next_state_; | 102 State next_state_; |
90 // num_client_hellos_ contains the number of client hello messages that this | 103 // num_client_hellos_ contains the number of client hello messages that this |
91 // connection has sent. | 104 // connection has sent. |
92 int num_client_hellos_; | 105 int num_client_hellos_; |
93 | 106 |
94 QuicCryptoClientConfig* const crypto_config_; | 107 QuicCryptoClientConfig* const crypto_config_; |
95 | 108 |
96 // Client's connection nonce (4-byte timestamp + 28 random bytes) | 109 // Client's connection nonce (4-byte timestamp + 28 random bytes) |
97 std::string nonce_; | 110 std::string nonce_; |
98 // Server's hostname | 111 // Server's hostname |
99 std::string server_hostname_; | 112 std::string server_hostname_; |
100 | 113 |
101 // Generation counter from QuicCryptoClientConfig's CachedState. | 114 // Generation counter from QuicCryptoClientConfig's CachedState. |
102 uint64 generation_counter_; | 115 uint64 generation_counter_; |
103 | 116 |
104 // proof_verify_callback_ contains the callback object that we passed to an | 117 // proof_verify_callback_ contains the callback object that we passed to an |
105 // asynchronous proof verification. The ProofVerifier owns this object. | 118 // asynchronous proof verification. The ProofVerifier owns this object. |
106 ProofVerifierCallbackImpl* proof_verify_callback_; | 119 ProofVerifierCallbackImpl* proof_verify_callback_; |
107 | 120 |
108 // These members are used to store the result of an asynchronous proof | 121 // These members are used to store the result of an asynchronous proof |
109 // verification. These members must not be used after | 122 // verification. These members must not be used after |
110 // STATE_VERIFY_PROOF_COMPLETE. | 123 // STATE_VERIFY_PROOF_COMPLETE. |
111 bool verify_ok_; | 124 bool verify_ok_; |
112 string verify_error_details_; | 125 string verify_error_details_; |
113 scoped_ptr<ProofVerifyDetails> verify_details_; | 126 scoped_ptr<ProofVerifyDetails> verify_details_; |
114 | 127 |
128 // This member is used to store the result of an asynchronous disk cache read. | |
129 // It must not be used after STATE_LOAD_QUIC_SERVER_INFO_COMPLETE. | |
130 int quic_server_info_data_ready_result_; | |
wtc
2014/02/13 23:48:43
1. Please list this member after cert_verify_resul
ramant (doing other things)
2014/02/15 00:36:12
Done.
| |
131 | |
115 // The result of certificate verification. | 132 // The result of certificate verification. |
116 scoped_ptr<CertVerifyResult> cert_verify_result_; | 133 scoped_ptr<CertVerifyResult> cert_verify_result_; |
117 | 134 |
118 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); | 135 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream); |
119 }; | 136 }; |
120 | 137 |
121 } // namespace net | 138 } // namespace net |
122 | 139 |
123 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ | 140 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_ |
OLD | NEW |