OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_CRYPTO_SERVER_CONFIG_H_ | 5 #ifndef NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_H_ |
6 #define NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_H_ | 6 #define NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_piece.h" | 9 #include "base/strings/string_piece.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // decrypting source address tokens. It can be of any length as it is fed | 47 // decrypting source address tokens. It can be of any length as it is fed |
48 // into a KDF before use. In tests, use TESTING. | 48 // into a KDF before use. In tests, use TESTING. |
49 explicit QuicCryptoServerConfig( | 49 explicit QuicCryptoServerConfig( |
50 base::StringPiece source_address_token_secret); | 50 base::StringPiece source_address_token_secret); |
51 ~QuicCryptoServerConfig(); | 51 ~QuicCryptoServerConfig(); |
52 | 52 |
53 // TESTING is a magic parameter for passing to the constructor in tests. | 53 // TESTING is a magic parameter for passing to the constructor in tests. |
54 static const char TESTING[]; | 54 static const char TESTING[]; |
55 | 55 |
56 // DefaultConfig generates a QuicServerConfigProtobuf protobuf suitable for | 56 // DefaultConfig generates a QuicServerConfigProtobuf protobuf suitable for |
57 // using in tests. |extra_tags| contains additional key/value pairs that will | 57 // using in tests. If |expiry_time| is non-zero then it's used as the expiry |
58 // be inserted into the config. If |expiry_time| is non-zero then it's used | 58 // for the server config in UNIX epoch seconds. Otherwise the default expiry |
59 // as the expiry for the server config in UNIX epoch seconds. Otherwise the | 59 // time is six months from now. |
60 // default expiry time is six months from now. | |
61 static QuicServerConfigProtobuf* DefaultConfig( | 60 static QuicServerConfigProtobuf* DefaultConfig( |
62 QuicRandom* rand, | 61 QuicRandom* rand, |
63 const QuicClock* clock, | 62 const QuicClock* clock, |
64 const CryptoHandshakeMessage& extra_tags, | |
65 uint64 expiry_time); | 63 uint64 expiry_time); |
66 | 64 |
67 // AddConfig adds a QuicServerConfigProtobuf to the availible configurations. | 65 // AddConfig adds a QuicServerConfigProtobuf to the availible configurations. |
68 // It returns the SCFG message from the config if successful. The caller | 66 // It returns the SCFG message from the config if successful. The caller |
69 // takes ownership of the CryptoHandshakeMessage. | 67 // takes ownership of the CryptoHandshakeMessage. |
70 CryptoHandshakeMessage* AddConfig(QuicServerConfigProtobuf* protobuf); | 68 CryptoHandshakeMessage* AddConfig(QuicServerConfigProtobuf* protobuf); |
71 | 69 |
72 // AddDefaultConfig creates a config and then calls AddConfig to add it. See | 70 // AddDefaultConfig calls DefaultConfig to create a config and then calls |
73 // the comment for |DefaultConfig| for details of the arguments. | 71 // AddConfig to add it. See the comment for |DefaultConfig| for details of |
| 72 // the arguments. |
74 CryptoHandshakeMessage* AddDefaultConfig( | 73 CryptoHandshakeMessage* AddDefaultConfig( |
75 QuicRandom* rand, | 74 QuicRandom* rand, |
76 const QuicClock* clock, | 75 const QuicClock* clock, |
77 const CryptoHandshakeMessage& extra_tags, | |
78 uint64 expiry_time); | 76 uint64 expiry_time); |
79 | 77 |
80 // ProcessClientHello processes |client_hello| and decides whether to accept | 78 // ProcessClientHello processes |client_hello| and decides whether to accept |
81 // or reject the connection. If the connection is to be accepted, |out| is | 79 // or reject the connection. If the connection is to be accepted, |out| is |
82 // set to the contents of the ServerHello, |out_params| is completed and | 80 // set to the contents of the ServerHello, |out_params| is completed and |
83 // QUIC_NO_ERROR is returned. Otherwise |out| is set to be a REJ message and | 81 // QUIC_NO_ERROR is returned. Otherwise |out| is set to be a REJ message and |
84 // an error code is returned. | 82 // an error code is returned. |
85 // | 83 // |
86 // client_hello: the incoming client hello message. | 84 // client_hello: the incoming client hello message. |
87 // guid: the GUID for the connection, which is used in key derivation. | 85 // guid: the GUID for the connection, which is used in key derivation. |
88 // client_ip: the IP address of the client, which is used to generate and | 86 // client_ip: the IP address of the client, which is used to generate and |
89 // validate source-address tokens. | 87 // validate source-address tokens. |
90 // clock: used to validate client nonces and ephemeral keys. | 88 // clock: used to validate client nonces and ephemeral keys. |
91 // rand: an entropy source | 89 // rand: an entropy source |
92 // params: the state of the handshake. This may be updated with a server | 90 // params: the state of the handshake. This may be updated with a server |
93 // nonce when we send a rejection. After a successful handshake, this will | 91 // nonce when we send a rejection. After a successful handshake, this will |
94 // contain the state of the connection. | 92 // contain the state of the connection. |
95 // out: the resulting handshake message (either REJ or SHLO) | 93 // out: the resulting handshake message (either REJ or SHLO) |
96 // error_details: used to store a string describing any error. | 94 // error_details: used to store a string describing any error. |
97 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello, | 95 QuicErrorCode ProcessClientHello(const CryptoHandshakeMessage& client_hello, |
98 QuicGuid guid, | 96 QuicGuid guid, |
99 const IPEndPoint& client_ip, | 97 const IPEndPoint& client_ip, |
100 const QuicClock* now, | 98 const QuicClock* clock, |
101 QuicRandom* rand, | 99 QuicRandom* rand, |
102 QuicCryptoNegotiatedParameters* params, | 100 QuicCryptoNegotiatedParameters* params, |
103 CryptoHandshakeMessage* out, | 101 CryptoHandshakeMessage* out, |
104 std::string* error_details) const; | 102 std::string* error_details) const; |
105 | 103 |
106 // SetProofSource installs |proof_source| as the ProofSource for handshakes. | 104 // SetProofSource installs |proof_source| as the ProofSource for handshakes. |
107 // This object takes ownership of |proof_source|. | 105 // This object takes ownership of |proof_source|. |
108 void SetProofSource(ProofSource* proof_source); | 106 void SetProofSource(ProofSource* proof_source); |
109 | 107 |
110 // SetEphemeralKeySource installs an object that can cache ephemeral keys for | 108 // SetEphemeralKeySource installs an object that can cache ephemeral keys for |
111 // a short period of time. This object takes ownership of | 109 // a short period of time. This object takes ownership of |
112 // |ephemeral_key_source|. If not set then ephemeral keys will be generated | 110 // |ephemeral_key_source|. If not set then ephemeral keys will be generated |
113 // per-connection. | 111 // per-connection. |
114 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source); | 112 void SetEphemeralKeySource(EphemeralKeySource* ephemeral_key_source); |
115 | 113 |
| 114 // set_strike_register_max_entries sets the maximum number of entries that |
| 115 // the internal strike register will hold. If the strike register fills up |
| 116 // then the oldest entries (by the client's clock) will be dropped. |
| 117 void set_strike_register_max_entries(uint32 max_entries); |
| 118 |
| 119 // set_strike_register_window_secs sets the number of seconds around the |
| 120 // current time that the strike register will attempt to be authoritative |
| 121 // for. Setting a larger value allows for greater client clock-skew, but |
| 122 // means that the quiescent startup period must be longer. |
| 123 void set_strike_register_window_secs(uint32 window_secs); |
| 124 |
| 125 // set_source_address_token_future_secs sets the number of seconds into the |
| 126 // future that source-address tokens will be accepted from. Since |
| 127 // source-address tokens are authenticated, this should only happen if |
| 128 // another, valid server has clock-skew. |
| 129 void set_source_address_token_future_secs(uint32 future_secs); |
| 130 |
| 131 // set_source_address_token_lifetime_secs sets the number of seconds that a |
| 132 // source-address token will be valid for. |
| 133 void set_source_address_token_lifetime_secs(uint32 lifetime_secs); |
| 134 |
116 private: | 135 private: |
117 friend class test::QuicCryptoServerConfigPeer; | 136 friend class test::QuicCryptoServerConfigPeer; |
118 | 137 |
119 // Config represents a server config: a collection of preferences and | 138 // Config represents a server config: a collection of preferences and |
120 // Diffie-Hellman public values. | 139 // Diffie-Hellman public values. |
121 struct Config : public QuicCryptoConfig { | 140 struct Config : public QuicCryptoConfig { |
122 Config(); | 141 Config(); |
123 ~Config(); | 142 ~Config(); |
124 | 143 |
125 // serialized contains the bytes of this server config, suitable for sending | 144 // serialized contains the bytes of this server config, suitable for sending |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 scoped_ptr<QuicEncrypter> source_address_token_encrypter_; | 189 scoped_ptr<QuicEncrypter> source_address_token_encrypter_; |
171 scoped_ptr<QuicDecrypter> source_address_token_decrypter_; | 190 scoped_ptr<QuicDecrypter> source_address_token_decrypter_; |
172 | 191 |
173 // proof_source_ contains an object that can provide certificate chains and | 192 // proof_source_ contains an object that can provide certificate chains and |
174 // signatures. | 193 // signatures. |
175 scoped_ptr<ProofSource> proof_source_; | 194 scoped_ptr<ProofSource> proof_source_; |
176 | 195 |
177 // ephemeral_key_source_ contains an object that caches ephemeral keys for a | 196 // ephemeral_key_source_ contains an object that caches ephemeral keys for a |
178 // short period of time. | 197 // short period of time. |
179 scoped_ptr<EphemeralKeySource> ephemeral_key_source_; | 198 scoped_ptr<EphemeralKeySource> ephemeral_key_source_; |
| 199 |
| 200 // These fields store configuration values. See the comments for their |
| 201 // respective setter functions. |
| 202 uint32 strike_register_max_entries_; |
| 203 uint32 strike_register_window_secs_; |
| 204 uint32 source_address_token_future_secs_; |
| 205 uint32 source_address_token_lifetime_secs_; |
180 }; | 206 }; |
181 | 207 |
182 } // namespace net | 208 } // namespace net |
183 | 209 |
184 #endif // NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_H_ | 210 #endif // NET_QUIC_CRYPTO_CRYPTO_SERVER_CONFIG_H_ |
OLD | NEW |