OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 26 matching lines...) Expand all Loading... |
37 public: | 37 public: |
38 CachedState(); | 38 CachedState(); |
39 explicit CachedState(scoped_ptr<QuicServerInfo> quic_server_info); | 39 explicit CachedState(scoped_ptr<QuicServerInfo> quic_server_info); |
40 ~CachedState(); | 40 ~CachedState(); |
41 | 41 |
42 // IsComplete returns true if this object contains enough information to | 42 // IsComplete returns true if this object contains enough information to |
43 // perform a handshake with the server. |now| is used to judge whether any | 43 // perform a handshake with the server. |now| is used to judge whether any |
44 // cached server config has expired. | 44 // cached server config has expired. |
45 bool IsComplete(QuicWallTime now) const; | 45 bool IsComplete(QuicWallTime now) const; |
46 | 46 |
| 47 // IsEmpty returns true if |server_config_| is empty. |
| 48 bool IsEmpty() const; |
| 49 |
47 // GetServerConfig returns the parsed contents of |server_config|, or NULL | 50 // GetServerConfig returns the parsed contents of |server_config|, or NULL |
48 // if |server_config| is empty. The return value is owned by this object | 51 // if |server_config| is empty. The return value is owned by this object |
49 // and is destroyed when this object is. | 52 // and is destroyed when this object is. |
50 const CryptoHandshakeMessage* GetServerConfig() const; | 53 const CryptoHandshakeMessage* GetServerConfig() const; |
51 | 54 |
52 // SetServerConfig checks that |server_config| parses correctly and stores | 55 // SetServerConfig checks that |server_config| parses correctly and stores |
53 // it in |server_config_|. |now| is used to judge whether |server_config| | 56 // it in |server_config_|. |now| is used to judge whether |server_config| |
54 // has expired. | 57 // has expired. |
55 QuicErrorCode SetServerConfig(base::StringPiece server_config, | 58 QuicErrorCode SetServerConfig(base::StringPiece server_config, |
56 QuicWallTime now, | 59 QuicWallTime now, |
57 std::string* error_details); | 60 std::string* error_details); |
58 | 61 |
59 // InvalidateServerConfig clears the cached server config (if any). | 62 // InvalidateServerConfig clears the cached server config (if any). |
60 void InvalidateServerConfig(); | 63 void InvalidateServerConfig(); |
61 | 64 |
62 // SetProof stores a certificate chain and signature. | 65 // SetProof stores a certificate chain and signature. |
63 void SetProof(const std::vector<std::string>& certs, | 66 void SetProof(const std::vector<std::string>& certs, |
64 base::StringPiece signature); | 67 base::StringPiece signature); |
65 | 68 |
66 // Clears the certificate chain and signature and invalidates the proof. | 69 // Clears the certificate chain and signature and invalidates the proof. |
67 void ClearProof(); | 70 void ClearProof(); |
68 | 71 |
69 // SetProofValid records that the certificate chain and signature have been | 72 // SetProofValid records that the certificate chain and signature have been |
70 // validated and that it's safe to assume that the server is legitimate. | 73 // validated and that it's safe to assume that the server is legitimate. It |
| 74 // persists the server config information to disk cache. |
71 // (Note: this does not check the chain or signature.) | 75 // (Note: this does not check the chain or signature.) |
72 void SetProofValid(); | 76 void SetProofValid(); |
73 | 77 |
74 // If the server config or the proof has changed then it needs to be | 78 // If the server config or the proof has changed then it needs to be |
75 // revalidated. Helper function to keep server_config_valid_ and | 79 // revalidated. Helper function to keep server_config_valid_ and |
76 // generation_counter_ in sync. | 80 // generation_counter_ in sync. |
77 void SetProofInvalid(); | 81 void SetProofInvalid(); |
78 | 82 |
79 const std::string& server_config() const; | 83 const std::string& server_config() const; |
80 const std::string& source_address_token() const; | 84 const std::string& source_address_token() const; |
81 const std::vector<std::string>& certs() const; | 85 const std::vector<std::string>& certs() const; |
82 const std::string& signature() const; | 86 const std::string& signature() const; |
83 bool proof_valid() const; | 87 bool proof_valid() const; |
84 uint64 generation_counter() const; | 88 uint64 generation_counter() const; |
85 const ProofVerifyDetails* proof_verify_details() const; | 89 const ProofVerifyDetails* proof_verify_details() const; |
| 90 QuicServerInfo* quic_server_info() const; |
86 | 91 |
87 void set_source_address_token(base::StringPiece token); | 92 void set_source_address_token(base::StringPiece token); |
88 | 93 |
89 // SetProofVerifyDetails takes ownership of |details|. | 94 // SetProofVerifyDetails takes ownership of |details|. |
90 void SetProofVerifyDetails(ProofVerifyDetails* details); | 95 void SetProofVerifyDetails(ProofVerifyDetails* details); |
91 | 96 |
92 // Copy the |server_config_|, |source_address_token_|, |certs_| and | 97 // Copy the |server_config_|, |source_address_token_|, |certs_| and |
93 // |server_config_sig_| from the |other|. The remaining fields, | 98 // |server_config_sig_| from the |other|. The remaining fields, |
94 // |generation_counter_|, |proof_verify_details_|, and |scfg_| remain | 99 // |generation_counter_|, |proof_verify_details_|, and |scfg_| remain |
95 // unchanged. | 100 // unchanged. |
96 void InitializeFrom(const CachedState& other); | 101 void InitializeFrom(const CachedState& other); |
97 | 102 |
| 103 // Fill out the |server_config_|, |source_address_token_|, |certs_| and |
| 104 // |server_config_sig_| fields from |quic_server_info_|. |quic_server_info_| |
| 105 // reads this information from the disk cache. |now| is used to judge |
| 106 // whether server config from disk cache has expired. Returns true if it has |
| 107 // loaded the data from disk cache successfully. |
| 108 bool LoadQuicServerInfo(QuicWallTime now); |
| 109 |
| 110 // Save the server config information so that we can perform 0-RTT handshake |
| 111 // with a server. |
| 112 void SaveQuicServerInfo(); |
| 113 |
98 private: | 114 private: |
99 std::string server_config_; // A serialized handshake message. | 115 std::string server_config_; // A serialized handshake message. |
100 std::string source_address_token_; // An opaque proof of IP ownership. | 116 std::string source_address_token_; // An opaque proof of IP ownership. |
101 std::vector<std::string> certs_; // A list of certificates in leaf-first | 117 std::vector<std::string> certs_; // A list of certificates in leaf-first |
102 // order. | 118 // order. |
103 std::string server_config_sig_; // A signature of |server_config_|. | 119 std::string server_config_sig_; // A signature of |server_config_|. |
104 bool server_config_valid_; // True if |server_config_| is correctly | 120 bool server_config_valid_; // True if |server_config_| is correctly |
105 // signed and |certs_| has been | 121 // signed and |certs_| has been |
106 // validated. | 122 // validated. |
| 123 bool need_to_persist_; // Persist to disk if True. |
107 // Generation counter associated with the |server_config_|, |certs_| and | 124 // Generation counter associated with the |server_config_|, |certs_| and |
108 // |server_config_sig_| combination. It is incremented whenever we set | 125 // |server_config_sig_| combination. It is incremented whenever we set |
109 // server_config_valid_ to false. | 126 // server_config_valid_ to false. |
110 uint64 generation_counter_; | 127 uint64 generation_counter_; |
111 | 128 |
112 scoped_ptr<ProofVerifyDetails> proof_verify_details_; | 129 scoped_ptr<ProofVerifyDetails> proof_verify_details_; |
113 | 130 |
114 // scfg contains the cached, parsed value of |server_config|. | 131 // scfg contains the cached, parsed value of |server_config|. |
115 mutable scoped_ptr<CryptoHandshakeMessage> scfg_; | 132 mutable scoped_ptr<CryptoHandshakeMessage> scfg_; |
116 | 133 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 246 |
230 scoped_ptr<ProofVerifier> proof_verifier_; | 247 scoped_ptr<ProofVerifier> proof_verifier_; |
231 scoped_ptr<ChannelIDSigner> channel_id_signer_; | 248 scoped_ptr<ChannelIDSigner> channel_id_signer_; |
232 | 249 |
233 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); | 250 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); |
234 }; | 251 }; |
235 | 252 |
236 } // namespace net | 253 } // namespace net |
237 | 254 |
238 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 255 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
OLD | NEW |