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 22 matching lines...) Expand all Loading... | |
33 class QuicServerConfigProtobuf; | 33 class QuicServerConfigProtobuf; |
34 class StrikeRegister; | 34 class StrikeRegister; |
35 class StrikeRegisterClient; | 35 class StrikeRegisterClient; |
36 | 36 |
37 struct ClientHelloInfo; | 37 struct ClientHelloInfo; |
38 | 38 |
39 namespace test { | 39 namespace test { |
40 class QuicCryptoServerConfigPeer; | 40 class QuicCryptoServerConfigPeer; |
41 } // namespace test | 41 } // namespace test |
42 | 42 |
43 enum HandshakeFailureReason { | |
44 // Failure reasons from strike register. | |
45 // TODO(rtenneti): Implement capturing of error from strike register. | |
wtc
2014/06/19 00:13:25
I think line 44 should be deleted (seems very simi
ramant (doing other things)
2014/06/19 01:57:35
Done.
| |
46 HANDSHAKE_OK = 0, | |
47 | |
48 // Failure reasons for an invalid client nonce. | |
49 CLIENT_NONCE_UNKNOWN_FAILURE = 100, | |
50 CLIENT_NONCE_INVALID_FAILURE, | |
wtc
2014/06/19 00:13:25
It seems that we should have a CLIENT_NONCE_NOT_UN
ramant (doing other things)
2014/06/19 01:57:35
Will add it in the next CL when we verify client_n
| |
51 | |
52 // Failure reasons for an invalid server nonce. | |
53 SERVER_NONCE_INVALID_FAILURE = 200, | |
54 SERVER_NONCE_DECRYPTION_FAILURE, | |
55 SERVER_NONCE_NOT_UNIQUE_FAILURE, | |
56 | |
57 // Failure reasons for an invalid server config. | |
58 SERVER_CONFIG_INCHOATE_HELLO_FAILURE = 300, | |
59 SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE, | |
60 | |
61 // Failure reasons for an invalid source adddress token. | |
62 SOURCE_ADDRESS_TOKEN_INVALID_FAILURE = 400, | |
63 SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE, | |
64 SOURCE_ADDRESS_TOKEN_PARSE_FAILURE, | |
65 SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE, | |
66 SOURCE_ADDRESS_TOKEN_CLOCK_SKEW_FAILURE, | |
67 SOURCE_ADDRESS_TOKEN_EXPIRED_FAILURE, | |
wtc
2014/06/19 00:13:25
Nit: these enum values should be documented with o
ramant (doing other things)
2014/06/19 01:57:35
Will do in the next CL (will add the comments in t
| |
68 }; | |
69 | |
43 // Hook that allows application code to subscribe to primary config changes. | 70 // Hook that allows application code to subscribe to primary config changes. |
44 class PrimaryConfigChangedCallback { | 71 class PrimaryConfigChangedCallback { |
45 public: | 72 public: |
46 PrimaryConfigChangedCallback(); | 73 PrimaryConfigChangedCallback(); |
47 virtual ~PrimaryConfigChangedCallback(); | 74 virtual ~PrimaryConfigChangedCallback(); |
48 virtual void Run(const std::string& scid) = 0; | 75 virtual void Run(const std::string& scid) = 0; |
49 | 76 |
50 private: | 77 private: |
51 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback); | 78 DISALLOW_COPY_AND_ASSIGN(PrimaryConfigChangedCallback); |
52 }; | 79 }; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 // Config. On error, ParseConfigProtobuf returns NULL. | 405 // Config. On error, ParseConfigProtobuf returns NULL. |
379 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); | 406 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); |
380 | 407 |
381 // NewSourceAddressToken returns a fresh source address token for the given | 408 // NewSourceAddressToken returns a fresh source address token for the given |
382 // IP address. | 409 // IP address. |
383 std::string NewSourceAddressToken(const Config& config, | 410 std::string NewSourceAddressToken(const Config& config, |
384 const IPEndPoint& ip, | 411 const IPEndPoint& ip, |
385 QuicRandom* rand, | 412 QuicRandom* rand, |
386 QuicWallTime now) const; | 413 QuicWallTime now) const; |
387 | 414 |
388 // ValidateSourceAddressToken returns true if the source address token in | 415 // ValidateSourceAddressToken returns HANDSHAKE_OK if the source address token |
389 // |token| is a valid and timely token for the IP address |ip| given that the | 416 // in |token| is a valid and timely token for the IP address |ip| given that |
390 // current time is |now|. | 417 // the current time is |now|. Otherwise it returns the reason for failure. |
391 bool ValidateSourceAddressToken(const Config& config, | 418 HandshakeFailureReason ValidateSourceAddressToken(const Config& config, |
392 base::StringPiece token, | 419 base::StringPiece token, |
393 const IPEndPoint& ip, | 420 const IPEndPoint& ip, |
394 QuicWallTime now) const; | 421 QuicWallTime now) const; |
395 | 422 |
396 // NewServerNonce generates and encrypts a random nonce. | 423 // NewServerNonce generates and encrypts a random nonce. |
397 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; | 424 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; |
398 | 425 |
399 // ValidateServerNonce decrypts |token| and verifies that it hasn't been | 426 // ValidateServerNonce decrypts |token| and verifies that it hasn't been |
400 // previously used and is recent enough that it is plausible that it was part | 427 // previously used and is recent enough that it is plausible that it was part |
401 // of a very recently provided rejection ("recent" will be on the order of | 428 // of a very recently provided rejection ("recent" will be on the order of |
402 // 10-30 seconds). If so, it records that it has been used and returns true. | 429 // 10-30 seconds). If so, it records that it has been used and returns |
403 // Otherwise it returns false. | 430 // HANDSHAKE_OK. Otherwise it returns the reason for failure. |
404 bool ValidateServerNonce(base::StringPiece echoed_server_nonce, | 431 HandshakeFailureReason ValidateServerNonce( |
405 QuicWallTime now) const; | 432 base::StringPiece echoed_server_nonce, |
433 QuicWallTime now) const; | |
406 | 434 |
407 // replay_protection_ controls whether the server enforces that handshakes | 435 // replay_protection_ controls whether the server enforces that handshakes |
408 // aren't replays. | 436 // aren't replays. |
409 bool replay_protection_; | 437 bool replay_protection_; |
410 | 438 |
411 // configs_ satisfies the following invariants: | 439 // configs_ satisfies the following invariants: |
412 // 1) configs_.empty() <-> primary_config_ == NULL | 440 // 1) configs_.empty() <-> primary_config_ == NULL |
413 // 2) primary_config_ != NULL -> primary_config_->is_primary | 441 // 2) primary_config_ != NULL -> primary_config_->is_primary |
414 // 3) ∀ c∈configs_, c->is_primary <-> c == primary_config_ | 442 // 3) ∀ c∈configs_, c->is_primary <-> c == primary_config_ |
415 mutable base::Lock configs_lock_; | 443 mutable base::Lock configs_lock_; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
468 uint32 source_address_token_lifetime_secs_; | 496 uint32 source_address_token_lifetime_secs_; |
469 uint32 server_nonce_strike_register_max_entries_; | 497 uint32 server_nonce_strike_register_max_entries_; |
470 uint32 server_nonce_strike_register_window_secs_; | 498 uint32 server_nonce_strike_register_window_secs_; |
471 | 499 |
472 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); | 500 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); |
473 }; | 501 }; |
474 | 502 |
475 } // namespace net | 503 } // namespace net |
476 | 504 |
477 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ | 505 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ |
OLD | NEW |