Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: net/quic/crypto/quic_crypto_client_config.h

Issue 154933003: Persist server's crypto config data to disk cache for 0-RTT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undid bad upload (had problems with git merge) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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. Returns true if it has loaded
106 // the data from disk cache successfully.
wtc 2014/02/19 22:53:28 We should also document how |now| is used.
ramant (doing other things) 2014/02/20 02:34:06 Done.
107 bool LoadQuicServerInfo(QuicWallTime now);
108
109 // Save the server config information so that we can perform 0-RTT handshake
110 // with a server.
111 void SaveQuicServerInfo();
112
98 private: 113 private:
99 std::string server_config_; // A serialized handshake message. 114 std::string server_config_; // A serialized handshake message.
100 std::string source_address_token_; // An opaque proof of IP ownership. 115 std::string source_address_token_; // An opaque proof of IP ownership.
101 std::vector<std::string> certs_; // A list of certificates in leaf-first 116 std::vector<std::string> certs_; // A list of certificates in leaf-first
102 // order. 117 // order.
103 std::string server_config_sig_; // A signature of |server_config_|. 118 std::string server_config_sig_; // A signature of |server_config_|.
104 bool server_config_valid_; // True if |server_config_| is correctly 119 bool server_config_valid_; // True if |server_config_| is correctly
105 // signed and |certs_| has been 120 // signed and |certs_| has been
106 // validated. 121 // validated.
122 bool need_to_persist_; // Persist to disk if True.
107 // Generation counter associated with the |server_config_|, |certs_| and 123 // Generation counter associated with the |server_config_|, |certs_| and
108 // |server_config_sig_| combination. It is incremented whenever we set 124 // |server_config_sig_| combination. It is incremented whenever we set
109 // server_config_valid_ to false. 125 // server_config_valid_ to false.
110 uint64 generation_counter_; 126 uint64 generation_counter_;
111 127
112 scoped_ptr<ProofVerifyDetails> proof_verify_details_; 128 scoped_ptr<ProofVerifyDetails> proof_verify_details_;
113 129
114 // scfg contains the cached, parsed value of |server_config|. 130 // scfg contains the cached, parsed value of |server_config|.
115 mutable scoped_ptr<CryptoHandshakeMessage> scfg_; 131 mutable scoped_ptr<CryptoHandshakeMessage> scfg_;
116 132
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 245
230 scoped_ptr<ProofVerifier> proof_verifier_; 246 scoped_ptr<ProofVerifier> proof_verifier_;
231 scoped_ptr<ChannelIDSigner> channel_id_signer_; 247 scoped_ptr<ChannelIDSigner> channel_id_signer_;
232 248
233 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); 249 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig);
234 }; 250 };
235 251
236 } // namespace net 252 } // namespace net
237 253
238 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ 254 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698