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_SERVER_CONFIG_H_ | 5 #ifndef NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 6 #define NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 // primary_time contains the timestamp when this config should become the | 313 // primary_time contains the timestamp when this config should become the |
314 // primary config. A value of QuicWallTime::Zero() means that this config | 314 // primary config. A value of QuicWallTime::Zero() means that this config |
315 // will not be promoted at a specific time. | 315 // will not be promoted at a specific time. |
316 QuicWallTime primary_time; | 316 QuicWallTime primary_time; |
317 | 317 |
318 // Secondary sort key for use when selecting primary configs and | 318 // Secondary sort key for use when selecting primary configs and |
319 // there are multiple configs with the same primary time. | 319 // there are multiple configs with the same primary time. |
320 // Smaller numbers mean higher priority. | 320 // Smaller numbers mean higher priority. |
321 uint64 priority; | 321 uint64 priority; |
322 | 322 |
323 // source_address_token_boxer_ is used to protect the | |
324 // source-address tokens that are given to clients. | |
325 // Points to either source_address_token_boxer_storage or the | |
326 // default boxer provided by QuicCryptoServerConfig. | |
327 const CryptoSecretBoxer* source_address_token_boxer; | |
328 | |
329 // Holds the override source_address_token_boxer instance if the | |
330 // Config is not using the default source address token boxer | |
331 // instance provided by QuicCryptoServerConfig. | |
332 scoped_ptr<CryptoSecretBoxer> source_address_token_boxer_storage; | |
333 | |
323 private: | 334 private: |
324 friend class base::RefCounted<Config>; | 335 friend class base::RefCounted<Config>; |
325 virtual ~Config(); | 336 virtual ~Config(); |
326 | 337 |
327 DISALLOW_COPY_AND_ASSIGN(Config); | 338 DISALLOW_COPY_AND_ASSIGN(Config); |
328 }; | 339 }; |
329 | 340 |
330 typedef std::map<ServerConfigID, scoped_refptr<Config> > ConfigMap; | 341 typedef std::map<ServerConfigID, scoped_refptr<Config> > ConfigMap; |
331 | 342 |
343 // Get a ref to the config with a given server config id. | |
344 scoped_refptr<Config> GetConfigWithScid( | |
345 base::StringPiece requested_scid) const; | |
346 | |
332 // ConfigPrimaryTimeLessThan returns true if a->primary_time < | 347 // ConfigPrimaryTimeLessThan returns true if a->primary_time < |
333 // b->primary_time. | 348 // b->primary_time. |
334 static bool ConfigPrimaryTimeLessThan(const scoped_refptr<Config>& a, | 349 static bool ConfigPrimaryTimeLessThan(const scoped_refptr<Config>& a, |
335 const scoped_refptr<Config>& b); | 350 const scoped_refptr<Config>& b); |
336 | 351 |
337 // SelectNewPrimaryConfig reevaluates the primary config based on the | 352 // SelectNewPrimaryConfig reevaluates the primary config based on the |
338 // "primary_time" deadlines contained in each. | 353 // "primary_time" deadlines contained in each. |
339 void SelectNewPrimaryConfig(QuicWallTime now) const; | 354 void SelectNewPrimaryConfig(QuicWallTime now) const; |
340 | 355 |
341 // EvaluateClientHello checks |client_hello| for gross errors and determines | 356 // EvaluateClientHello checks |client_hello| for gross errors and determines |
342 // whether it can be shown to be fresh (i.e. not a replay). The results are | 357 // whether it can be shown to be fresh (i.e. not a replay). The results are |
343 // written to |info|. | 358 // written to |info|. |
344 void EvaluateClientHello( | 359 void EvaluateClientHello( |
345 const uint8* primary_orbit, | 360 const uint8* primary_orbit, |
361 scoped_refptr<Config> requested_config, | |
346 ValidateClientHelloResultCallback::Result* client_hello_state, | 362 ValidateClientHelloResultCallback::Result* client_hello_state, |
347 ValidateClientHelloResultCallback* done_cb) const; | 363 ValidateClientHelloResultCallback* done_cb) const; |
348 | 364 |
349 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. | 365 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|. |
350 void BuildRejection( | 366 void BuildRejection( |
351 const scoped_refptr<Config>& config, | 367 const scoped_refptr<Config>& config, |
352 const CryptoHandshakeMessage& client_hello, | 368 const CryptoHandshakeMessage& client_hello, |
353 const ClientHelloInfo& info, | 369 const ClientHelloInfo& info, |
354 QuicRandom* rand, | 370 QuicRandom* rand, |
355 CryptoHandshakeMessage* out) const; | 371 CryptoHandshakeMessage* out) const; |
356 | 372 |
357 // ParseConfigProtobuf parses the given config protobuf and returns a | 373 // ParseConfigProtobuf parses the given config protobuf and returns a |
358 // scoped_refptr<Config> if successful. The caller adopts the reference to the | 374 // scoped_refptr<Config> if successful. The caller adopts the reference to the |
359 // Config. On error, ParseConfigProtobuf returns NULL. | 375 // Config. On error, ParseConfigProtobuf returns NULL. |
360 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); | 376 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); |
361 | 377 |
362 // NewSourceAddressToken returns a fresh source address token for the given | 378 // NewSourceAddressToken returns a fresh source address token for the given |
363 // IP address. | 379 // IP address. |
364 std::string NewSourceAddressToken(const IPEndPoint& ip, | 380 std::string NewSourceAddressToken( |
365 QuicRandom* rand, | 381 const QuicCryptoServerConfig::Config* config, |
wtc
2014/04/07 18:38:24
Why isn't this parameter a const reference? I foun
ramant (doing other things)
2014/04/21 22:39:29
Done.
| |
366 QuicWallTime now) const; | 382 const IPEndPoint& ip, |
383 QuicRandom* rand, | |
384 QuicWallTime now) const; | |
367 | 385 |
368 // ValidateSourceAddressToken returns true if the source address token in | 386 // ValidateSourceAddressToken returns true if the source address token in |
369 // |token| is a valid and timely token for the IP address |ip| given that the | 387 // |token| is a valid and timely token for the IP address |ip| given that the |
370 // current time is |now|. | 388 // current time is |now|. |
371 bool ValidateSourceAddressToken(base::StringPiece token, | 389 bool ValidateSourceAddressToken( |
372 const IPEndPoint& ip, | 390 const QuicCryptoServerConfig::Config* config, |
373 QuicWallTime now) const; | 391 base::StringPiece token, |
392 const IPEndPoint& ip, | |
393 QuicWallTime now) const; | |
374 | 394 |
375 // NewServerNonce generates and encrypts a random nonce. | 395 // NewServerNonce generates and encrypts a random nonce. |
376 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; | 396 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; |
377 | 397 |
378 // ValidateServerNonce decrypts |token| and verifies that it hasn't been | 398 // ValidateServerNonce decrypts |token| and verifies that it hasn't been |
379 // previously used and is recent enough that it is plausible that it was part | 399 // previously used and is recent enough that it is plausible that it was part |
380 // of a very recently provided rejection ("recent" will be on the order of | 400 // of a very recently provided rejection ("recent" will be on the order of |
381 // 10-30 seconds). If so, it records that it has been used and returns true. | 401 // 10-30 seconds). If so, it records that it has been used and returns true. |
382 // Otherwise it returns false. | 402 // Otherwise it returns false. |
383 bool ValidateServerNonce(base::StringPiece echoed_server_nonce, | 403 bool ValidateServerNonce(base::StringPiece echoed_server_nonce, |
(...skipping 19 matching lines...) Expand all Loading... | |
403 mutable QuicWallTime next_config_promotion_time_; | 423 mutable QuicWallTime next_config_promotion_time_; |
404 // Callback to invoke when the primary config changes. | 424 // Callback to invoke when the primary config changes. |
405 scoped_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_; | 425 scoped_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_; |
406 | 426 |
407 // Protects access to the pointer held by strike_register_client_. | 427 // Protects access to the pointer held by strike_register_client_. |
408 mutable base::Lock strike_register_client_lock_; | 428 mutable base::Lock strike_register_client_lock_; |
409 // strike_register_ contains a data structure that keeps track of previously | 429 // strike_register_ contains a data structure that keeps track of previously |
410 // observed client nonces in order to prevent replay attacks. | 430 // observed client nonces in order to prevent replay attacks. |
411 mutable scoped_ptr<StrikeRegisterClient> strike_register_client_; | 431 mutable scoped_ptr<StrikeRegisterClient> strike_register_client_; |
412 | 432 |
413 // source_address_token_boxer_ is used to protect the source-address tokens | 433 // Default source_address_token_boxer_ used to protect the |
414 // that are given to clients. | 434 // source-address tokens that are given to clients. Individual |
415 CryptoSecretBoxer source_address_token_boxer_; | 435 // configs may use boxers with alternate secrets. |
436 CryptoSecretBoxer default_source_address_token_boxer_; | |
416 | 437 |
417 // server_nonce_boxer_ is used to encrypt and validate suggested server | 438 // server_nonce_boxer_ is used to encrypt and validate suggested server |
418 // nonces. | 439 // nonces. |
419 CryptoSecretBoxer server_nonce_boxer_; | 440 CryptoSecretBoxer server_nonce_boxer_; |
420 | 441 |
421 // server_nonce_orbit_ contains the random, per-server orbit values that this | 442 // server_nonce_orbit_ contains the random, per-server orbit values that this |
422 // server will use to generate server nonces (the moral equivalent of a SYN | 443 // server will use to generate server nonces (the moral equivalent of a SYN |
423 // cookies). | 444 // cookies). |
424 uint8 server_nonce_orbit_[8]; | 445 uint8 server_nonce_orbit_[8]; |
425 | 446 |
(...skipping 18 matching lines...) Expand all Loading... | |
444 uint32 strike_register_window_secs_; | 465 uint32 strike_register_window_secs_; |
445 uint32 source_address_token_future_secs_; | 466 uint32 source_address_token_future_secs_; |
446 uint32 source_address_token_lifetime_secs_; | 467 uint32 source_address_token_lifetime_secs_; |
447 uint32 server_nonce_strike_register_max_entries_; | 468 uint32 server_nonce_strike_register_max_entries_; |
448 uint32 server_nonce_strike_register_window_secs_; | 469 uint32 server_nonce_strike_register_window_secs_; |
449 }; | 470 }; |
450 | 471 |
451 } // namespace net | 472 } // namespace net |
452 | 473 |
453 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 474 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
OLD | NEW |