| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 // GetServerConfig returns the parsed contents of |server_config|, or | 71 // GetServerConfig returns the parsed contents of |server_config|, or |
| 72 // nullptr if |server_config| is empty. The return value is owned by this | 72 // nullptr if |server_config| is empty. The return value is owned by this |
| 73 // object and is destroyed when this object is. | 73 // object and is destroyed when this object is. |
| 74 const CryptoHandshakeMessage* GetServerConfig() const; | 74 const CryptoHandshakeMessage* GetServerConfig() const; |
| 75 | 75 |
| 76 // SetServerConfig checks that |server_config| parses correctly and stores | 76 // SetServerConfig checks that |server_config| parses correctly and stores |
| 77 // it in |server_config_|. |now| is used to judge whether |server_config| | 77 // it in |server_config_|. |now| is used to judge whether |server_config| |
| 78 // has expired. | 78 // has expired. |
| 79 ServerConfigState SetServerConfig(base::StringPiece server_config, | 79 ServerConfigState SetServerConfig(base::StringPiece server_config, |
| 80 QuicWallTime now, | 80 QuicWallTime now, |
| 81 QuicWallTime expiry_time, |
| 81 std::string* error_details); | 82 std::string* error_details); |
| 82 | 83 |
| 83 // InvalidateServerConfig clears the cached server config (if any). | 84 // InvalidateServerConfig clears the cached server config (if any). |
| 84 void InvalidateServerConfig(); | 85 void InvalidateServerConfig(); |
| 85 | 86 |
| 86 // SetProof stores a certificate chain and signature. | 87 // SetProof stores a certificate chain and signature. |
| 87 void SetProof(const std::vector<std::string>& certs, | 88 void SetProof(const std::vector<std::string>& certs, |
| 88 base::StringPiece cert_sct, | 89 base::StringPiece cert_sct, |
| 89 base::StringPiece chlo_hash, | 90 base::StringPiece chlo_hash, |
| 90 base::StringPiece signature); | 91 base::StringPiece signature); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 143 |
| 143 // This function should only be called when has_server_nonce is true. | 144 // This function should only be called when has_server_nonce is true. |
| 144 // Returns the next server_nonce specified by the server and removes it | 145 // Returns the next server_nonce specified by the server and removes it |
| 145 // from the queue of nonces. | 146 // from the queue of nonces. |
| 146 std::string GetNextServerNonce(); | 147 std::string GetNextServerNonce(); |
| 147 | 148 |
| 148 // SetProofVerifyDetails takes ownership of |details|. | 149 // SetProofVerifyDetails takes ownership of |details|. |
| 149 void SetProofVerifyDetails(ProofVerifyDetails* details); | 150 void SetProofVerifyDetails(ProofVerifyDetails* details); |
| 150 | 151 |
| 151 // Copy the |server_config_|, |source_address_token_|, |certs_|, | 152 // Copy the |server_config_|, |source_address_token_|, |certs_|, |
| 152 // |cert_sct_|, |chlo_hash_| and |server_config_sig_| from the |other|. The | 153 // |expiration_time_|, |cert_sct_|, |chlo_hash_| and |server_config_sig_| |
| 153 // remaining fields, |generation_counter_|, |proof_verify_details_|, and | 154 // from the |other|. The remaining fields, |generation_counter_|, |
| 154 // |scfg_| remain unchanged. | 155 // |proof_verify_details_|, and |scfg_| remain unchanged. |
| 155 void InitializeFrom(const CachedState& other); | 156 void InitializeFrom(const CachedState& other); |
| 156 | 157 |
| 157 // Initializes this cached state based on the arguments provided. | 158 // Initializes this cached state based on the arguments provided. |
| 158 // Returns false if there is a problem parsing the server config. | 159 // Returns false if there is a problem parsing the server config. |
| 159 bool Initialize(base::StringPiece server_config, | 160 bool Initialize(base::StringPiece server_config, |
| 160 base::StringPiece source_address_token, | 161 base::StringPiece source_address_token, |
| 161 const std::vector<std::string>& certs, | 162 const std::vector<std::string>& certs, |
| 162 base::StringPiece cert_sct, | 163 base::StringPiece cert_sct, |
| 163 base::StringPiece chlo_hash, | 164 base::StringPiece chlo_hash, |
| 164 base::StringPiece signature, | 165 base::StringPiece signature, |
| 165 QuicWallTime now); | 166 QuicWallTime now, |
| 167 QuicWallTime expiration_time); |
| 166 | 168 |
| 167 private: | 169 private: |
| 168 std::string server_config_; // A serialized handshake message. | 170 std::string server_config_; // A serialized handshake message. |
| 169 std::string source_address_token_; // An opaque proof of IP ownership. | 171 std::string source_address_token_; // An opaque proof of IP ownership. |
| 170 std::vector<std::string> certs_; // A list of certificates in leaf-first | 172 std::vector<std::string> certs_; // A list of certificates in leaf-first |
| 171 // order. | 173 // order. |
| 172 std::string cert_sct_; // Signed timestamp of the leaf cert. | 174 std::string cert_sct_; // Signed timestamp of the leaf cert. |
| 173 std::string chlo_hash_; // Hash of the CHLO message. | 175 std::string chlo_hash_; // Hash of the CHLO message. |
| 174 std::string server_config_sig_; // A signature of |server_config_|. | 176 std::string server_config_sig_; // A signature of |server_config_|. |
| 175 bool server_config_valid_; // True if |server_config_| is correctly | 177 bool server_config_valid_; // True if |server_config_| is correctly |
| 176 // signed and |certs_| has been | 178 // signed and |certs_| has been |
| 177 // validated. | 179 // validated. |
| 180 QuicWallTime expiration_time_; // Time when the config is no longer |
| 181 // valid. |
| 178 // Generation counter associated with the |server_config_|, |certs_| and | 182 // Generation counter associated with the |server_config_|, |certs_| and |
| 179 // |server_config_sig_| combination. It is incremented whenever we set | 183 // |server_config_sig_| combination. It is incremented whenever we set |
| 180 // server_config_valid_ to false. | 184 // server_config_valid_ to false. |
| 181 uint64_t generation_counter_; | 185 uint64_t generation_counter_; |
| 182 | 186 |
| 183 std::unique_ptr<ProofVerifyDetails> proof_verify_details_; | 187 std::unique_ptr<ProofVerifyDetails> proof_verify_details_; |
| 184 | 188 |
| 185 // scfg contains the cached, parsed value of |server_config|. | 189 // scfg contains the cached, parsed value of |server_config|. |
| 186 mutable std::unique_ptr<CryptoHandshakeMessage> scfg_; | 190 mutable std::unique_ptr<CryptoHandshakeMessage> scfg_; |
| 187 | 191 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 390 |
| 387 // The |user_agent_id_| passed in QUIC's CHLO message. | 391 // The |user_agent_id_| passed in QUIC's CHLO message. |
| 388 std::string user_agent_id_; | 392 std::string user_agent_id_; |
| 389 | 393 |
| 390 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); | 394 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientConfig); |
| 391 }; | 395 }; |
| 392 | 396 |
| 393 } // namespace net | 397 } // namespace net |
| 394 | 398 |
| 395 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ | 399 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_CLIENT_CONFIG_H_ |
| OLD | NEW |