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

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

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

Powered by Google App Engine
This is Rietveld 408576698