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

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

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
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>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string_piece.h" 14 #include "base/strings/string_piece.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "net/base/ip_endpoint.h" 16 #include "net/base/ip_endpoint.h"
17 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
18 #include "net/quic/crypto/cached_network_parameters.h" 18 #include "net/quic/crypto/cached_network_parameters.h"
19 #include "net/quic/crypto/crypto_handshake.h" 19 #include "net/quic/crypto/crypto_handshake.h"
20 #include "net/quic/crypto/crypto_handshake_message.h" 20 #include "net/quic/crypto/crypto_handshake_message.h"
21 #include "net/quic/crypto/crypto_protocol.h" 21 #include "net/quic/crypto/crypto_protocol.h"
22 #include "net/quic/crypto/crypto_secret_boxer.h" 22 #include "net/quic/crypto/crypto_secret_boxer.h"
23 #include "net/quic/crypto/source_address_token.h"
23 #include "net/quic/quic_time.h" 24 #include "net/quic/quic_time.h"
24 25
25 namespace net { 26 namespace net {
26 27
27 class CryptoHandshakeMessage; 28 class CryptoHandshakeMessage;
28 class EphemeralKeySource; 29 class EphemeralKeySource;
29 class KeyExchange; 30 class KeyExchange;
30 class ProofSource; 31 class ProofSource;
31 class QuicClock; 32 class QuicClock;
32 class QuicDecrypter; 33 class QuicDecrypter;
(...skipping 14 matching lines...) Expand all
47 const QuicWallTime now; 48 const QuicWallTime now;
48 49
49 // Outputs from EvaluateClientHello. 50 // Outputs from EvaluateClientHello.
50 bool valid_source_address_token; 51 bool valid_source_address_token;
51 bool client_nonce_well_formed; 52 bool client_nonce_well_formed;
52 bool unique; 53 bool unique;
53 base::StringPiece sni; 54 base::StringPiece sni;
54 base::StringPiece client_nonce; 55 base::StringPiece client_nonce;
55 base::StringPiece server_nonce; 56 base::StringPiece server_nonce;
56 base::StringPiece user_agent_id; 57 base::StringPiece user_agent_id;
58 SourceAddressTokens source_address_tokens;
57 59
58 // Errors from EvaluateClientHello. 60 // Errors from EvaluateClientHello.
59 std::vector<uint32> reject_reasons; 61 std::vector<uint32> reject_reasons;
60 COMPILE_ASSERT(sizeof(QuicTag) == sizeof(uint32), header_out_of_sync); 62 COMPILE_ASSERT(sizeof(QuicTag) == sizeof(uint32), header_out_of_sync);
61 }; 63 };
62 64
63 namespace test { 65 namespace test {
64 class QuicCryptoServerConfigPeer; 66 class QuicCryptoServerConfigPeer;
65 } // namespace test 67 } // namespace test
66 68
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 CryptoHandshakeMessage* out, 252 CryptoHandshakeMessage* out,
251 std::string* error_details) const; 253 std::string* error_details) const;
252 254
253 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing 255 // BuildServerConfigUpdateMessage sets |out| to be a SCUP message containing
254 // the current primary config, an up to date source-address token, and cert 256 // the current primary config, an up to date source-address token, and cert
255 // chain and proof in the case of secure QUIC. Returns true if successfully 257 // chain and proof in the case of secure QUIC. Returns true if successfully
256 // filled |out|. 258 // filled |out|.
257 // 259 //
258 // |cached_network_params| is optional, and can be nullptr. 260 // |cached_network_params| is optional, and can be nullptr.
259 bool BuildServerConfigUpdateMessage( 261 bool BuildServerConfigUpdateMessage(
262 const SourceAddressTokens& previous_source_address_tokens,
260 const IPEndPoint& server_ip, 263 const IPEndPoint& server_ip,
261 const IPEndPoint& client_ip, 264 const IPEndPoint& client_ip,
262 const QuicClock* clock, 265 const QuicClock* clock,
263 QuicRandom* rand, 266 QuicRandom* rand,
264 const QuicCryptoNegotiatedParameters& params, 267 const QuicCryptoNegotiatedParameters& params,
265 const CachedNetworkParameters* cached_network_params, 268 const CachedNetworkParameters* cached_network_params,
266 CryptoHandshakeMessage* out) const; 269 CryptoHandshakeMessage* out) const;
267 270
268 // SetProofSource installs |proof_source| as the ProofSource for handshakes. 271 // SetProofSource installs |proof_source| as the ProofSource for handshakes.
269 // This object takes ownership of |proof_source|. 272 // This object takes ownership of |proof_source|.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 438
436 // ParseConfigProtobuf parses the given config protobuf and returns a 439 // ParseConfigProtobuf parses the given config protobuf and returns a
437 // scoped_refptr<Config> if successful. The caller adopts the reference to the 440 // scoped_refptr<Config> if successful. The caller adopts the reference to the
438 // Config. On error, ParseConfigProtobuf returns nullptr. 441 // Config. On error, ParseConfigProtobuf returns nullptr.
439 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf); 442 scoped_refptr<Config> ParseConfigProtobuf(QuicServerConfigProtobuf* protobuf);
440 443
441 // NewSourceAddressToken returns a fresh source address token for the given 444 // NewSourceAddressToken returns a fresh source address token for the given
442 // IP address. |cached_network_params| is optional, and can be nullptr. 445 // IP address. |cached_network_params| is optional, and can be nullptr.
443 std::string NewSourceAddressToken( 446 std::string NewSourceAddressToken(
444 const Config& config, 447 const Config& config,
448 const SourceAddressTokens& previous_tokens,
445 const IPEndPoint& ip, 449 const IPEndPoint& ip,
446 QuicRandom* rand, 450 QuicRandom* rand,
447 QuicWallTime now, 451 QuicWallTime now,
448 const CachedNetworkParameters* cached_network_params) const; 452 const CachedNetworkParameters* cached_network_params) const;
449 453
450 // ValidateSourceAddressToken returns HANDSHAKE_OK if the source address token 454 // ParseSourceAddressToken parses the source address tokens contained in
451 // in |token| is a valid and timely token for the IP address |ip| given that 455 // the encrypted |token|, and populates |tokens| with the parsed tokens.
452 // the current time is |now|. Otherwise it returns the reason for failure. 456 // Returns HANDSHAKE_OK if |token| could be parsed, or the reason for the
453 // |cached_network_params| is populated if |token| contains a 457 // failure.
454 // CachedNetworkParameters proto. 458 HandshakeFailureReason ParseSourceAddressToken(
459 const Config& config,
460 base::StringPiece token,
461 SourceAddressTokens* tokens) const;
462
463 // ValidateSourceAddressToken returns HANDSHAKE_OK if the source address
464 // tokens in |tokens| contain a valid and timely token for the IP address
465 // |ip| given that the current time is |now|. Otherwise it returns the
466 // reason for failure. |cached_network_params| is populated if the valid
467 // token contains a CachedNetworkParameters proto.
468 // TODO(rch): remove this method when we remove:
469 // FLAGS_quic_use_multiple_address_in_source_tokens.
455 HandshakeFailureReason ValidateSourceAddressToken( 470 HandshakeFailureReason ValidateSourceAddressToken(
456 const Config& config, 471 const Config& config,
457 base::StringPiece token, 472 base::StringPiece token,
458 const IPEndPoint& ip, 473 const IPEndPoint& ip,
459 QuicWallTime now, 474 QuicWallTime now,
460 CachedNetworkParameters* cached_network_params) const; 475 CachedNetworkParameters* cached_network_params) const;
461 476
477 // ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address
478 // tokens in |tokens| contain a valid and timely token for the IP address
479 // |ip| given that the current time is |now|. Otherwise it returns the
480 // reason for failure. |cached_network_params| is populated if the valid
481 // token contains a CachedNetworkParameters proto.
482 HandshakeFailureReason ValidateSourceAddressTokens(
483 const SourceAddressTokens& tokens,
484 const IPEndPoint& ip,
485 QuicWallTime now,
486 CachedNetworkParameters* cached_network_params) const;
487
488 // ValidateSingleSourceAddressToken returns HANDSHAKE_OK if the source
489 // address token in |token| is a timely token for the IP address |ip|
490 // given that the current time is |now|. Otherwise it returns the reason
491 // for failure.
492 HandshakeFailureReason ValidateSingleSourceAddressToken(
493 const SourceAddressToken& token,
494 const IPEndPoint& ip,
495 QuicWallTime now) const;
496
497 // Returns HANDSHAKE_OK if the source address token in |token| is a timely
498 // token given that the current time is |now|. Otherwise it returns the
499 // reason for failure.
500 HandshakeFailureReason ValidateSourceAddressTokenTimestamp(
501 const SourceAddressToken& token,
502 QuicWallTime now) const;
503
462 // NewServerNonce generates and encrypts a random nonce. 504 // NewServerNonce generates and encrypts a random nonce.
463 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const; 505 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const;
464 506
465 // ValidateServerNonce decrypts |token| and verifies that it hasn't been 507 // ValidateServerNonce decrypts |token| and verifies that it hasn't been
466 // previously used and is recent enough that it is plausible that it was part 508 // previously used and is recent enough that it is plausible that it was part
467 // of a very recently provided rejection ("recent" will be on the order of 509 // of a very recently provided rejection ("recent" will be on the order of
468 // 10-30 seconds). If so, it records that it has been used and returns 510 // 10-30 seconds). If so, it records that it has been used and returns
469 // HANDSHAKE_OK. Otherwise it returns the reason for failure. 511 // HANDSHAKE_OK. Otherwise it returns the reason for failure.
470 HandshakeFailureReason ValidateServerNonce( 512 HandshakeFailureReason ValidateServerNonce(
471 base::StringPiece echoed_server_nonce, 513 base::StringPiece echoed_server_nonce,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 uint32 source_address_token_lifetime_secs_; 577 uint32 source_address_token_lifetime_secs_;
536 uint32 server_nonce_strike_register_max_entries_; 578 uint32 server_nonce_strike_register_max_entries_;
537 uint32 server_nonce_strike_register_window_secs_; 579 uint32 server_nonce_strike_register_window_secs_;
538 580
539 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig); 581 DISALLOW_COPY_AND_ASSIGN(QuicCryptoServerConfig);
540 }; 582 };
541 583
542 } // namespace net 584 } // namespace net
543 585
544 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_ 586 #endif // NET_QUIC_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698