blob: 7f3f947a31369ab864b2fff7417255812e194ca9 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
6#define QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_
7
8#include <cstddef>
9#include <cstdint>
10#include <map>
11#include <memory>
vasilvv872e7a32019-03-12 16:42:44 -070012#include <string>
QUICHE teama6ef0a62019-03-07 20:34:33 -050013#include <vector>
14
QUICHE teama6ef0a62019-03-07 20:34:33 -050015#include "third_party/boringssl/src/include/openssl/base.h"
16#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h"
17#include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h"
18#include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h"
19#include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h"
20#include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h"
21#include "net/third_party/quiche/src/quic/core/crypto/proof_source.h"
22#include "net/third_party/quiche/src/quic/core/crypto/quic_compressed_certs_cache.h"
23#include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h"
24#include "net/third_party/quiche/src/quic/core/proto/cached_network_parameters.pb.h"
25#include "net/third_party/quiche/src/quic/core/proto/source_address_token.pb.h"
26#include "net/third_party/quiche/src/quic/core/quic_time.h"
27#include "net/third_party/quiche/src/quic/platform/api/quic_export.h"
28#include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h"
29#include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h"
30#include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h"
QUICHE teama6ef0a62019-03-07 20:34:33 -050031#include "net/third_party/quiche/src/quic/platform/api/quic_string_piece.h"
32
33namespace quic {
34
35class CryptoHandshakeMessage;
36class ProofSource;
37class QuicClock;
38class QuicRandom;
39class QuicServerConfigProtobuf;
40struct QuicSignedServerConfig;
41
42// ClientHelloInfo contains information about a client hello message that is
43// only kept for as long as it's being processed.
44struct ClientHelloInfo {
45 ClientHelloInfo(const QuicIpAddress& in_client_ip, QuicWallTime in_now);
46 ClientHelloInfo(const ClientHelloInfo& other);
47 ~ClientHelloInfo();
48
49 // Inputs to EvaluateClientHello.
50 const QuicIpAddress client_ip;
51 const QuicWallTime now;
52
53 // Outputs from EvaluateClientHello.
54 bool valid_source_address_token;
55 QuicStringPiece sni;
56 QuicStringPiece client_nonce;
57 QuicStringPiece server_nonce;
58 QuicStringPiece user_agent_id;
59 SourceAddressTokens source_address_tokens;
60
61 // Errors from EvaluateClientHello.
62 std::vector<uint32_t> reject_reasons;
63 static_assert(sizeof(QuicTag) == sizeof(uint32_t), "header out of sync");
64};
65
66namespace test {
67class QuicCryptoServerConfigPeer;
68} // namespace test
69
70// Hook that allows application code to subscribe to primary config changes.
71class PrimaryConfigChangedCallback {
72 public:
73 PrimaryConfigChangedCallback();
74 PrimaryConfigChangedCallback(const PrimaryConfigChangedCallback&) = delete;
75 PrimaryConfigChangedCallback& operator=(const PrimaryConfigChangedCallback&) =
76 delete;
77 virtual ~PrimaryConfigChangedCallback();
vasilvvc48c8712019-03-11 13:38:16 -070078 virtual void Run(const std::string& scid) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -050079};
80
81// Callback used to accept the result of the |client_hello| validation step.
82class QUIC_EXPORT_PRIVATE ValidateClientHelloResultCallback {
83 public:
84 // Opaque token that holds information about the client_hello and
85 // its validity. Can be interpreted by calling ProcessClientHello.
86 struct QUIC_EXPORT_PRIVATE Result : public QuicReferenceCounted {
87 Result(const CryptoHandshakeMessage& in_client_hello,
88 QuicIpAddress in_client_ip,
89 QuicWallTime in_now);
90
91 CryptoHandshakeMessage client_hello;
92 ClientHelloInfo info;
93 QuicErrorCode error_code;
vasilvvc48c8712019-03-11 13:38:16 -070094 std::string error_details;
QUICHE teama6ef0a62019-03-07 20:34:33 -050095
96 // Populated if the CHLO STK contained a CachedNetworkParameters proto.
97 CachedNetworkParameters cached_network_params;
98
99 protected:
100 ~Result() override;
101 };
102
103 ValidateClientHelloResultCallback();
104 ValidateClientHelloResultCallback(const ValidateClientHelloResultCallback&) =
105 delete;
106 ValidateClientHelloResultCallback& operator=(
107 const ValidateClientHelloResultCallback&) = delete;
108 virtual ~ValidateClientHelloResultCallback();
109 virtual void Run(QuicReferenceCountedPointer<Result> result,
110 std::unique_ptr<ProofSource::Details> details) = 0;
111};
112
113// Callback used to accept the result of the ProcessClientHello method.
114class QUIC_EXPORT_PRIVATE ProcessClientHelloResultCallback {
115 public:
116 ProcessClientHelloResultCallback();
117 ProcessClientHelloResultCallback(const ProcessClientHelloResultCallback&) =
118 delete;
119 ProcessClientHelloResultCallback& operator=(
120 const ProcessClientHelloResultCallback&) = delete;
121 virtual ~ProcessClientHelloResultCallback();
122 virtual void Run(QuicErrorCode error,
vasilvvc48c8712019-03-11 13:38:16 -0700123 const std::string& error_details,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500124 std::unique_ptr<CryptoHandshakeMessage> message,
125 std::unique_ptr<DiversificationNonce> diversification_nonce,
126 std::unique_ptr<ProofSource::Details> details) = 0;
127};
128
129// Callback used to receive the results of a call to
130// BuildServerConfigUpdateMessage.
131class BuildServerConfigUpdateMessageResultCallback {
132 public:
133 BuildServerConfigUpdateMessageResultCallback() = default;
134 virtual ~BuildServerConfigUpdateMessageResultCallback() {}
135 BuildServerConfigUpdateMessageResultCallback(
136 const BuildServerConfigUpdateMessageResultCallback&) = delete;
137 BuildServerConfigUpdateMessageResultCallback& operator=(
138 const BuildServerConfigUpdateMessageResultCallback&) = delete;
139 virtual void Run(bool ok, const CryptoHandshakeMessage& message) = 0;
140};
141
142// Object that is interested in built rejections (which include REJ, SREJ and
143// cheap SREJ).
144class RejectionObserver {
145 public:
146 RejectionObserver() = default;
147 virtual ~RejectionObserver() {}
148 RejectionObserver(const RejectionObserver&) = delete;
149 RejectionObserver& operator=(const RejectionObserver&) = delete;
150 // Called after a rejection is built.
151 virtual void OnRejectionBuilt(const std::vector<uint32_t>& reasons,
152 CryptoHandshakeMessage* out) const = 0;
153};
154
155// Factory for creating KeyExchange objects.
156class QUIC_EXPORT_PRIVATE KeyExchangeSource {
157 public:
158 virtual ~KeyExchangeSource() = default;
159
160 // Returns the default KeyExchangeSource.
161 static std::unique_ptr<KeyExchangeSource> Default();
162
QUICHE teamf03456c2019-03-21 08:54:47 -0700163 // Create a new KeyExchange using the curve specified by |type| using the
164 // specified private key. |private_key| may be empty for key-exchange
165 // mechanisms which do not hold the private key in-process. If |is_fallback|
166 // is set, |private_key| is required to be set, and a local key-exchange
167 // object should be returned.
QUICHE teamfe1aca62019-03-14 13:39:01 -0700168 virtual std::unique_ptr<AsynchronousKeyExchange> Create(
169 std::string server_config_id,
QUICHE teamf03456c2019-03-21 08:54:47 -0700170 bool is_fallback,
QUICHE teamfe1aca62019-03-14 13:39:01 -0700171 QuicTag type,
172 QuicStringPiece private_key) = 0;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500173};
174
175// QuicCryptoServerConfig contains the crypto configuration of a QUIC server.
176// Unlike a client, a QUIC server can have multiple configurations active in
177// order to support clients resuming with a previous configuration.
178// TODO(agl): when adding configurations at runtime is added, this object will
179// need to consider locking.
180class QUIC_EXPORT_PRIVATE QuicCryptoServerConfig {
181 public:
182 // ConfigOptions contains options for generating server configs.
183 struct QUIC_EXPORT_PRIVATE ConfigOptions {
184 ConfigOptions();
185 ConfigOptions(const ConfigOptions& other);
186 ~ConfigOptions();
187
188 // expiry_time is the time, in UNIX seconds, when the server config will
189 // expire. If unset, it defaults to the current time plus six months.
190 QuicWallTime expiry_time;
191 // channel_id_enabled controls whether the server config will indicate
192 // support for ChannelIDs.
193 bool channel_id_enabled;
194 // token_binding_params contains the list of Token Binding params (e.g.
195 // P256, TB10) that the server config will include.
196 QuicTagVector token_binding_params;
197 // id contains the server config id for the resulting config. If empty, a
198 // random id is generated.
vasilvvc48c8712019-03-11 13:38:16 -0700199 std::string id;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500200 // orbit contains the kOrbitSize bytes of the orbit value for the server
201 // config. If |orbit| is empty then a random orbit is generated.
vasilvvc48c8712019-03-11 13:38:16 -0700202 std::string orbit;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500203 // p256 determines whether a P-256 public key will be included in the
204 // server config. Note that this breaks deterministic server-config
205 // generation since P-256 key generation doesn't use the QuicRandom given
206 // to DefaultConfig().
207 bool p256;
208 };
209
210 // |source_address_token_secret|: secret key material used for encrypting and
211 // decrypting source address tokens. It can be of any length as it is fed
212 // into a KDF before use. In tests, use TESTING.
213 // |server_nonce_entropy|: an entropy source used to generate the orbit and
214 // key for server nonces, which are always local to a given instance of a
215 // server. Not owned.
QUICHE teamd5af58a2019-03-14 20:35:50 -0700216 // |proof_source|: provides certificate chains and signatures.
217 // |key_exchange_source|: provides key-exchange functionality.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500218 // |ssl_ctx|: The SSL_CTX used for doing TLS handshakes.
219 QuicCryptoServerConfig(QuicStringPiece source_address_token_secret,
220 QuicRandom* server_nonce_entropy,
221 std::unique_ptr<ProofSource> proof_source,
222 std::unique_ptr<KeyExchangeSource> key_exchange_source,
223 bssl::UniquePtr<SSL_CTX> ssl_ctx);
224 QuicCryptoServerConfig(const QuicCryptoServerConfig&) = delete;
225 QuicCryptoServerConfig& operator=(const QuicCryptoServerConfig&) = delete;
226 ~QuicCryptoServerConfig();
227
228 // TESTING is a magic parameter for passing to the constructor in tests.
229 static const char TESTING[];
230
231 // Generates a QuicServerConfigProtobuf protobuf suitable for
232 // AddConfig and SetConfigs.
QUICHE teambbaa8be2019-03-21 12:54:17 -0700233 static QuicServerConfigProtobuf GenerateConfig(QuicRandom* rand,
234 const QuicClock* clock,
235 const ConfigOptions& options);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500236
237 // AddConfig adds a QuicServerConfigProtobuf to the available configurations.
QUICHE teamd5af58a2019-03-14 20:35:50 -0700238 // It returns the SCFG message from the config if successful. |now| is used in
QUICHE teama6ef0a62019-03-07 20:34:33 -0500239 // conjunction with |protobuf->primary_time()| to determine whether the
240 // config should be made primary.
QUICHE teamd5af58a2019-03-14 20:35:50 -0700241 std::unique_ptr<CryptoHandshakeMessage> AddConfig(
QUICHE teambbaa8be2019-03-21 12:54:17 -0700242 const QuicServerConfigProtobuf& protobuf,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500243 QuicWallTime now);
244
245 // AddDefaultConfig calls DefaultConfig to create a config and then calls
246 // AddConfig to add it. See the comment for |DefaultConfig| for details of
247 // the arguments.
QUICHE teamd5af58a2019-03-14 20:35:50 -0700248 std::unique_ptr<CryptoHandshakeMessage> AddDefaultConfig(
249 QuicRandom* rand,
250 const QuicClock* clock,
251 const ConfigOptions& options);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500252
253 // SetConfigs takes a vector of config protobufs and the current time.
254 // Configs are assumed to be uniquely identified by their server config ID.
255 // Previously unknown configs are added and possibly made the primary config
256 // depending on their |primary_time| and the value of |now|. Configs that are
257 // known, but are missing from the protobufs are deleted, unless they are
258 // currently the primary config. SetConfigs returns false if any errors were
259 // encountered and no changes to the QuicCryptoServerConfig will occur.
QUICHE teambbaa8be2019-03-21 12:54:17 -0700260 bool SetConfigs(const std::vector<QuicServerConfigProtobuf>& protobufs,
QUICHE team99055cf2019-03-22 11:27:53 -0700261 const QuicServerConfigProtobuf* fallback_protobuf,
QUICHE teambbaa8be2019-03-21 12:54:17 -0700262 QuicWallTime now);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500263
264 // SetSourceAddressTokenKeys sets the keys to be tried, in order, when
265 // decrypting a source address token. Note that these keys are used *without*
266 // passing them through a KDF, in contradistinction to the
267 // |source_address_token_secret| argument to the constructor.
vasilvvc48c8712019-03-11 13:38:16 -0700268 void SetSourceAddressTokenKeys(const std::vector<std::string>& keys);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500269
270 // Get the server config ids for all known configs.
vasilvvc48c8712019-03-11 13:38:16 -0700271 void GetConfigIds(std::vector<std::string>* scids) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500272
273 // Checks |client_hello| for gross errors and determines whether it can be
274 // shown to be fresh (i.e. not a replay). The result of the validation step
275 // must be interpreted by calling QuicCryptoServerConfig::ProcessClientHello
276 // from the done_cb.
277 //
278 // ValidateClientHello may invoke the done_cb before unrolling the
279 // stack if it is able to assess the validity of the client_nonce
280 // without asynchronous operations.
281 //
282 // client_hello: the incoming client hello message.
283 // client_ip: the IP address of the client, which is used to generate and
284 // validate source-address tokens.
285 // server_address: the IP address and port of the server. The IP address and
286 // port may be used for certificate selection.
287 // version: protocol version used for this connection.
288 // clock: used to validate client nonces and ephemeral keys.
289 // crypto_proof: in/out parameter to which will be written the crypto proof
290 // used in reply to a proof demand. The pointed-to-object must
291 // live until the callback is invoked.
292 // done_cb: single-use callback that accepts an opaque
293 // ValidatedClientHelloMsg token that holds information about
294 // the client hello. The callback will always be called exactly
295 // once, either under the current call stack, or after the
296 // completion of an asynchronous operation.
297 void ValidateClientHello(
298 const CryptoHandshakeMessage& client_hello,
299 const QuicIpAddress& client_ip,
300 const QuicSocketAddress& server_address,
301 QuicTransportVersion version,
302 const QuicClock* clock,
303 QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof,
304 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
305
306 // ProcessClientHello processes |client_hello| and decides whether to accept
307 // or reject the connection. If the connection is to be accepted, |done_cb| is
308 // invoked with the contents of the ServerHello and QUIC_NO_ERROR. Otherwise
309 // |done_cb| is called with a REJ or SREJ message and QUIC_NO_ERROR.
310 //
311 // validate_chlo_result: Output from the asynchronous call to
312 // ValidateClientHello. Contains the client hello message and
313 // information about it.
314 // reject_only: Only generate rejections, not server hello messages.
315 // connection_id: the ConnectionId for the connection, which is used in key
316 // derivation.
317 // server_ip: the IP address of the server. The IP address may be used for
318 // certificate selection.
319 // client_address: the IP address and port of the client. The IP address is
320 // used to generate and validate source-address tokens.
321 // version: version of the QUIC protocol in use for this connection
322 // supported_versions: versions of the QUIC protocol that this server
323 // supports.
324 // clock: used to validate client nonces and ephemeral keys.
325 // rand: an entropy source
326 // compressed_certs_cache: the cache that caches a set of most recently used
327 // certs. Owned by QuicDispatcher.
328 // params: the state of the handshake. This may be updated with a server
329 // nonce when we send a rejection.
330 // crypto_proof: output structure containing the crypto proof used in reply to
331 // a proof demand.
332 // total_framing_overhead: the total per-packet overhead for a stream frame
333 // chlo_packet_size: the size, in bytes, of the CHLO packet
334 // done_cb: the callback invoked on completion
335 void ProcessClientHello(
336 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
337 validate_chlo_result,
338 bool reject_only,
339 QuicConnectionId connection_id,
340 const QuicSocketAddress& server_address,
341 const QuicSocketAddress& client_address,
342 ParsedQuicVersion version,
343 const ParsedQuicVersionVector& supported_versions,
344 bool use_stateless_rejects,
345 QuicConnectionId server_designated_connection_id,
346 const QuicClock* clock,
347 QuicRandom* rand,
348 QuicCompressedCertsCache* compressed_certs_cache,
349 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params,
350 QuicReferenceCountedPointer<QuicSignedServerConfig> crypto_proof,
351 QuicByteCount total_framing_overhead,
352 QuicByteCount chlo_packet_size,
353 std::unique_ptr<ProcessClientHelloResultCallback> done_cb) const;
354
355 // BuildServerConfigUpdateMessage invokes |cb| with a SCUP message containing
356 // the current primary config, an up to date source-address token, and cert
357 // chain and proof in the case of secure QUIC. Passes true to |cb| if the
358 // message was generated successfully, and false otherwise. This method
359 // assumes ownership of |cb|.
360 //
361 // |cached_network_params| is optional, and can be nullptr.
362 void BuildServerConfigUpdateMessage(
363 QuicTransportVersion version,
364 QuicStringPiece chlo_hash,
365 const SourceAddressTokens& previous_source_address_tokens,
366 const QuicSocketAddress& server_address,
367 const QuicIpAddress& client_ip,
368 const QuicClock* clock,
369 QuicRandom* rand,
370 QuicCompressedCertsCache* compressed_certs_cache,
371 const QuicCryptoNegotiatedParameters& params,
372 const CachedNetworkParameters* cached_network_params,
373 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const;
374
375 // set_replay_protection controls whether replay protection is enabled. If
376 // replay protection is disabled then no strike registers are needed and
377 // frontends can share an orbit value without a shared strike-register.
378 // However, an attacker can duplicate a handshake and cause a client's
379 // request to be processed twice.
380 void set_replay_protection(bool on);
381
382 // set_chlo_multiplier specifies the multiple of the CHLO message size
383 // that a REJ message must stay under when the client doesn't present a
384 // valid source-address token.
385 void set_chlo_multiplier(size_t multiplier);
386
387 // When sender is allowed to not pad client hello (not standards compliant),
388 // we need to disable the client hello check.
389 void set_validate_chlo_size(bool new_value) {
390 validate_chlo_size_ = new_value;
391 }
392
393 // Returns whether the sender is allowed to not pad the client hello.
394 bool validate_chlo_size() const { return validate_chlo_size_; }
395
396 // When QUIC is tunneled through some other mechanism, source token validation
397 // may be disabled. Do not disable it if you are not providing other
398 // protection. (|true| protects against UDP amplification attack.).
399 void set_validate_source_address_token(bool new_value) {
400 validate_source_address_token_ = new_value;
401 }
402
403 // set_source_address_token_future_secs sets the number of seconds into the
404 // future that source-address tokens will be accepted from. Since
405 // source-address tokens are authenticated, this should only happen if
406 // another, valid server has clock-skew.
407 void set_source_address_token_future_secs(uint32_t future_secs);
408
409 // set_source_address_token_lifetime_secs sets the number of seconds that a
410 // source-address token will be valid for.
411 void set_source_address_token_lifetime_secs(uint32_t lifetime_secs);
412
413 // set_enable_serving_sct enables or disables serving signed cert timestamp
414 // (RFC6962) in server hello.
415 void set_enable_serving_sct(bool enable_serving_sct);
416
417 // Set and take ownership of the callback to invoke on primary config changes.
418 void AcquirePrimaryConfigChangedCb(
419 std::unique_ptr<PrimaryConfigChangedCallback> cb);
420
421 // Returns the number of configs this object owns.
422 int NumberOfConfigs() const;
423
424 // Callers retain the ownership of |rejection_observer| which must outlive the
425 // config.
426 void set_rejection_observer(RejectionObserver* rejection_observer) {
427 rejection_observer_ = rejection_observer;
428 }
429
430 ProofSource* proof_source() const;
431
432 SSL_CTX* ssl_ctx() const;
433
434 void set_pre_shared_key(QuicStringPiece psk) {
vasilvvc48c8712019-03-11 13:38:16 -0700435 pre_shared_key_ = std::string(psk);
QUICHE teama6ef0a62019-03-07 20:34:33 -0500436 }
437
438 bool pad_rej() const { return pad_rej_; }
439 void set_pad_rej(bool new_value) { pad_rej_ = new_value; }
440
441 bool pad_shlo() const { return pad_shlo_; }
442 void set_pad_shlo(bool new_value) { pad_shlo_ = new_value; }
443
444 private:
445 friend class test::QuicCryptoServerConfigPeer;
446 friend struct QuicSignedServerConfig;
447
448 // Config represents a server config: a collection of preferences and
449 // Diffie-Hellman public values.
450 class QUIC_EXPORT_PRIVATE Config : public QuicCryptoConfig,
451 public QuicReferenceCounted {
452 public:
453 Config();
454 Config(const Config&) = delete;
455 Config& operator=(const Config&) = delete;
456
457 // TODO(rtenneti): since this is a class, we should probably do
458 // getters/setters here.
459 // |serialized| contains the bytes of this server config, suitable for
460 // sending on the wire.
vasilvvc48c8712019-03-11 13:38:16 -0700461 std::string serialized;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500462 // id contains the SCID of this server config.
vasilvvc48c8712019-03-11 13:38:16 -0700463 std::string id;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500464 // orbit contains the orbit value for this config: an opaque identifier
465 // used to identify clusters of server frontends.
466 unsigned char orbit[kOrbitSize];
467
QUICHE teamfe1aca62019-03-14 13:39:01 -0700468 // key_exchanges contains key exchange objects. The values correspond,
469 // one-to-one, with the tags in |kexs| from the parent class.
470 std::vector<std::unique_ptr<AsynchronousKeyExchange>> key_exchanges;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500471
472 // tag_value_map contains the raw key/value pairs for the config.
473 QuicTagValueMap tag_value_map;
474
475 // channel_id_enabled is true if the config in |serialized| specifies that
476 // ChannelIDs are supported.
477 bool channel_id_enabled;
478
479 // is_primary is true if this config is the one that we'll give out to
480 // clients as the current one.
481 bool is_primary;
482
483 // primary_time contains the timestamp when this config should become the
484 // primary config. A value of QuicWallTime::Zero() means that this config
485 // will not be promoted at a specific time.
486 QuicWallTime primary_time;
487
488 // expiry_time contains the timestamp when this config expires.
489 QuicWallTime expiry_time;
490
491 // Secondary sort key for use when selecting primary configs and
492 // there are multiple configs with the same primary time.
493 // Smaller numbers mean higher priority.
494 uint64_t priority;
495
496 // source_address_token_boxer_ is used to protect the
497 // source-address tokens that are given to clients.
498 // Points to either source_address_token_boxer_storage or the
499 // default boxer provided by QuicCryptoServerConfig.
500 const CryptoSecretBoxer* source_address_token_boxer;
501
502 // Holds the override source_address_token_boxer instance if the
503 // Config is not using the default source address token boxer
504 // instance provided by QuicCryptoServerConfig.
505 std::unique_ptr<CryptoSecretBoxer> source_address_token_boxer_storage;
506
507 private:
508 ~Config() override;
509 };
510
511 typedef std::map<ServerConfigID, QuicReferenceCountedPointer<Config>>
512 ConfigMap;
513
514 // Get a ref to the config with a given server config id.
515 QuicReferenceCountedPointer<Config> GetConfigWithScid(
516 QuicStringPiece requested_scid) const
517 SHARED_LOCKS_REQUIRED(configs_lock_);
518
QUICHE team1225f472019-03-19 15:52:25 -0700519 // A snapshot of the configs associated with an in-progress handshake.
520 struct Configs {
521 QuicReferenceCountedPointer<Config> requested;
522 QuicReferenceCountedPointer<Config> primary;
QUICHE team99055cf2019-03-22 11:27:53 -0700523 QuicReferenceCountedPointer<Config> fallback;
QUICHE team1225f472019-03-19 15:52:25 -0700524 };
525
526 // Get a snapshot of the current configs associated with a handshake. If this
527 // method was called earlier in this handshake |old_primary_config| should be
528 // set to the primary config returned from that invocation, otherwise nullptr.
529 //
530 // Returns true if any configs are loaded. If false is returned, |configs| is
531 // not modified.
532 bool GetCurrentConfigs(const QuicWallTime& now,
533 QuicStringPiece requested_scid,
534 QuicReferenceCountedPointer<Config> old_primary_config,
535 Configs* configs) const;
536
QUICHE teama6ef0a62019-03-07 20:34:33 -0500537 // ConfigPrimaryTimeLessThan returns true if a->primary_time <
538 // b->primary_time.
539 static bool ConfigPrimaryTimeLessThan(
540 const QuicReferenceCountedPointer<Config>& a,
541 const QuicReferenceCountedPointer<Config>& b);
542
543 // SelectNewPrimaryConfig reevaluates the primary config based on the
544 // "primary_time" deadlines contained in each.
545 void SelectNewPrimaryConfig(QuicWallTime now) const
546 EXCLUSIVE_LOCKS_REQUIRED(configs_lock_);
547
QUICHE team79fb9e22019-03-15 07:49:56 -0700548 // EvaluateClientHello checks |client_hello_state->client_hello| for gross
549 // errors and determines whether it is fresh (i.e. not a replay). The results
550 // are written to |client_hello_state->info|.
QUICHE teama6ef0a62019-03-07 20:34:33 -0500551 void EvaluateClientHello(
552 const QuicSocketAddress& server_address,
553 QuicTransportVersion version,
QUICHE team1225f472019-03-19 15:52:25 -0700554 const Configs& configs,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500555 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
556 client_hello_state,
557 std::unique_ptr<ValidateClientHelloResultCallback> done_cb) const;
558
QUICHE team4dae8412019-03-18 13:11:00 -0700559 // Convenience class which carries the arguments passed to
560 // |ProcessClientHellp| along.
561 class ProcessClientHelloContext {
562 public:
563 ProcessClientHelloContext(
564 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
565 validate_chlo_result,
566 bool reject_only,
567 QuicConnectionId connection_id,
568 const QuicSocketAddress& server_address,
569 const QuicSocketAddress& client_address,
570 ParsedQuicVersion version,
571 const ParsedQuicVersionVector& supported_versions,
572 bool use_stateless_rejects,
573 QuicConnectionId server_designated_connection_id,
574 const QuicClock* clock,
575 QuicRandom* rand,
576 QuicCompressedCertsCache* compressed_certs_cache,
577 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params,
578 QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config,
579 QuicByteCount total_framing_overhead,
580 QuicByteCount chlo_packet_size,
581 std::unique_ptr<ProcessClientHelloResultCallback> done_cb)
582 : validate_chlo_result_(validate_chlo_result),
583 reject_only_(reject_only),
584 connection_id_(connection_id),
585 server_address_(server_address),
586 client_address_(client_address),
587 version_(version),
588 supported_versions_(supported_versions),
589 use_stateless_rejects_(use_stateless_rejects),
590 server_designated_connection_id_(server_designated_connection_id),
591 clock_(clock),
592 rand_(rand),
593 compressed_certs_cache_(compressed_certs_cache),
594 params_(params),
595 signed_config_(signed_config),
596 total_framing_overhead_(total_framing_overhead),
597 chlo_packet_size_(chlo_packet_size),
598 done_cb_(std::move(done_cb)) {}
599
600 ~ProcessClientHelloContext();
601
602 // Invoke |done_cb_| with an error status
603 void Fail(QuicErrorCode error, const std::string& error_details);
604
605 // Invoke |done_cb_| with a success status
606 void Succeed(std::unique_ptr<CryptoHandshakeMessage> message,
607 std::unique_ptr<DiversificationNonce> diversification_nonce,
608 std::unique_ptr<ProofSource::Details> proof_source_details);
609
610 // Member accessors
611 QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
612 validate_chlo_result() const {
613 return validate_chlo_result_;
614 }
615 bool reject_only() const { return reject_only_; }
616 QuicConnectionId connection_id() const { return connection_id_; }
617 QuicSocketAddress server_address() const { return server_address_; }
618 QuicSocketAddress client_address() const { return client_address_; }
619 ParsedQuicVersion version() const { return version_; }
620 ParsedQuicVersionVector supported_versions() const {
621 return supported_versions_;
622 }
623 bool use_stateless_rejects() const { return use_stateless_rejects_; }
624 QuicConnectionId server_designated_connection_id() const {
625 return server_designated_connection_id_;
626 }
627 const QuicClock* clock() const { return clock_; }
628 QuicRandom* rand() const { return rand_; } // NOLINT
629 QuicCompressedCertsCache* compressed_certs_cache() const {
630 return compressed_certs_cache_;
631 }
632 QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params() const {
633 return params_;
634 }
635 QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config() const {
636 return signed_config_;
637 }
638 QuicByteCount total_framing_overhead() const {
639 return total_framing_overhead_;
640 }
641 QuicByteCount chlo_packet_size() const { return chlo_packet_size_; }
642
643 // Derived value accessors
644 const CryptoHandshakeMessage& client_hello() const {
645 return validate_chlo_result()->client_hello;
646 }
647 const ClientHelloInfo& info() const { return validate_chlo_result()->info; }
648 QuicTransportVersion transport_version() const {
649 return version().transport_version;
650 }
651
652 private:
653 const QuicReferenceCountedPointer<ValidateClientHelloResultCallback::Result>
654 validate_chlo_result_;
655 const bool reject_only_;
656 const QuicConnectionId connection_id_;
657 const QuicSocketAddress server_address_;
658 const QuicSocketAddress client_address_;
659 const ParsedQuicVersion version_;
660 const ParsedQuicVersionVector supported_versions_;
661 const bool use_stateless_rejects_;
662 const QuicConnectionId server_designated_connection_id_;
663 const QuicClock* const clock_;
664 QuicRandom* const rand_;
665 QuicCompressedCertsCache* const compressed_certs_cache_;
666 const QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> params_;
667 const QuicReferenceCountedPointer<QuicSignedServerConfig> signed_config_;
668 const QuicByteCount total_framing_overhead_;
669 const QuicByteCount chlo_packet_size_;
670 std::unique_ptr<ProcessClientHelloResultCallback> done_cb_;
671 };
672
QUICHE teama6ef0a62019-03-07 20:34:33 -0500673 // Callback class for bridging between ProcessClientHello and
674 // ProcessClientHelloAfterGetProof.
675 class ProcessClientHelloCallback;
676 friend class ProcessClientHelloCallback;
677
678 // Portion of ProcessClientHello which executes after GetProof.
679 void ProcessClientHelloAfterGetProof(
680 bool found_error,
681 std::unique_ptr<ProofSource::Details> proof_source_details,
QUICHE team4dae8412019-03-18 13:11:00 -0700682 std::unique_ptr<ProcessClientHelloContext> context,
QUICHE team1225f472019-03-19 15:52:25 -0700683 const Configs& configs) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500684
685 // Callback class for bridging between ProcessClientHelloAfterGetProof and
686 // ProcessClientHelloAfterCalculateSharedKeys.
687 class ProcessClientHelloAfterGetProofCallback;
688 friend class ProcessClientHelloAfterGetProofCallback;
689
690 // Portion of ProcessClientHello which executes after CalculateSharedKeys.
691 void ProcessClientHelloAfterCalculateSharedKeys(
692 bool found_error,
693 std::unique_ptr<ProofSource::Details> proof_source_details,
QUICHE teamfe1aca62019-03-14 13:39:01 -0700694 QuicTag key_exchange_type,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500695 std::unique_ptr<CryptoHandshakeMessage> out,
696 QuicStringPiece public_value,
QUICHE team4dae8412019-03-18 13:11:00 -0700697 std::unique_ptr<ProcessClientHelloContext> context,
QUICHE team1225f472019-03-19 15:52:25 -0700698 const Configs& configs) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500699
QUICHE team59882932019-03-27 11:02:17 -0700700 // Send a REJ which contains a different ServerConfig than the one the client
701 // originally used. This is necessary in cases where we discover in the
702 // middle of the handshake that the private key for the ServerConfig the
703 // client used is not accessible.
704 void SendRejectWithFallbackConfig(
705 std::unique_ptr<ProcessClientHelloContext> context,
706 QuicReferenceCountedPointer<Config> fallback_config) const;
707
708 // Callback class for bridging between SendRejectWithFallbackConfig and
709 // SendRejectWithFallbackConfigAfterGetProof.
710 class SendRejectWithFallbackConfigCallback;
711 friend class SendRejectWithFallbackConfigCallback;
712
713 // Portion of ProcessClientHello which executes after GetProof in the case
714 // where we have received a CHLO but need to reject it due to the ServerConfig
715 // private keys being inaccessible.
716 void SendRejectWithFallbackConfigAfterGetProof(
717 bool found_error,
718 std::unique_ptr<ProofSource::Details> proof_source_details,
719 std::unique_ptr<ProcessClientHelloContext> context,
720 QuicReferenceCountedPointer<Config> fallback_config) const;
721
QUICHE teamaa924f12019-03-21 11:26:21 -0700722 // BuildRejectionAndRecordStats calls |BuildRejection| below and also informs
723 // the RejectionObserver.
724 void BuildRejectionAndRecordStats(const ProcessClientHelloContext& context,
725 const Config& config,
726 const std::vector<uint32_t>& reject_reasons,
727 CryptoHandshakeMessage* out) const;
728
QUICHE teama6ef0a62019-03-07 20:34:33 -0500729 // BuildRejection sets |out| to be a REJ message in reply to |client_hello|.
QUICHE team4dae8412019-03-18 13:11:00 -0700730 void BuildRejection(const ProcessClientHelloContext& context,
731 const Config& config,
QUICHE teame6dcf322019-03-19 12:23:47 -0700732 const std::vector<uint32_t>& reject_reasons,
QUICHE team4dae8412019-03-18 13:11:00 -0700733 CryptoHandshakeMessage* out) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500734
735 // CompressChain compresses the certificates in |chain->certs| and returns a
736 // compressed representation. |common_sets| contains the common certificate
737 // sets known locally and |client_common_set_hashes| contains the hashes of
738 // the common sets known to the peer. |client_cached_cert_hashes| contains
739 // 64-bit, FNV-1a hashes of certificates that the peer already possesses.
vasilvvc48c8712019-03-11 13:38:16 -0700740 static std::string CompressChain(
QUICHE teama6ef0a62019-03-07 20:34:33 -0500741 QuicCompressedCertsCache* compressed_certs_cache,
742 const QuicReferenceCountedPointer<ProofSource::Chain>& chain,
vasilvvc48c8712019-03-11 13:38:16 -0700743 const std::string& client_common_set_hashes,
744 const std::string& client_cached_cert_hashes,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500745 const CommonCertSets* common_sets);
746
747 // ParseConfigProtobuf parses the given config protobuf and returns a
748 // QuicReferenceCountedPointer<Config> if successful. The caller adopts the
749 // reference to the Config. On error, ParseConfigProtobuf returns nullptr.
750 QuicReferenceCountedPointer<Config> ParseConfigProtobuf(
QUICHE team99055cf2019-03-22 11:27:53 -0700751 const QuicServerConfigProtobuf& protobuf,
752 bool is_fallback) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500753
754 // NewSourceAddressToken returns a fresh source address token for the given
755 // IP address. |cached_network_params| is optional, and can be nullptr.
vasilvvc48c8712019-03-11 13:38:16 -0700756 std::string NewSourceAddressToken(
QUICHE teama6ef0a62019-03-07 20:34:33 -0500757 const Config& config,
758 const SourceAddressTokens& previous_tokens,
759 const QuicIpAddress& ip,
760 QuicRandom* rand,
761 QuicWallTime now,
762 const CachedNetworkParameters* cached_network_params) const;
763
764 // ParseSourceAddressToken parses the source address tokens contained in
765 // the encrypted |token|, and populates |tokens| with the parsed tokens.
766 // Returns HANDSHAKE_OK if |token| could be parsed, or the reason for the
767 // failure.
768 HandshakeFailureReason ParseSourceAddressToken(
769 const Config& config,
770 QuicStringPiece token,
771 SourceAddressTokens* tokens) const;
772
773 // ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address
774 // tokens in |tokens| contain a valid and timely token for the IP address
775 // |ip| given that the current time is |now|. Otherwise it returns the
776 // reason for failure. |cached_network_params| is populated if the valid
777 // token contains a CachedNetworkParameters proto.
778 HandshakeFailureReason ValidateSourceAddressTokens(
779 const SourceAddressTokens& tokens,
780 const QuicIpAddress& ip,
781 QuicWallTime now,
782 CachedNetworkParameters* cached_network_params) const;
783
784 // ValidateSingleSourceAddressToken returns HANDSHAKE_OK if the source
785 // address token in |token| is a timely token for the IP address |ip|
786 // given that the current time is |now|. Otherwise it returns the reason
787 // for failure.
788 HandshakeFailureReason ValidateSingleSourceAddressToken(
789 const SourceAddressToken& token,
790 const QuicIpAddress& ip,
791 QuicWallTime now) const;
792
793 // Returns HANDSHAKE_OK if the source address token in |token| is a timely
794 // token given that the current time is |now|. Otherwise it returns the
795 // reason for failure.
796 HandshakeFailureReason ValidateSourceAddressTokenTimestamp(
797 const SourceAddressToken& token,
798 QuicWallTime now) const;
799
800 // NewServerNonce generates and encrypts a random nonce.
vasilvvc48c8712019-03-11 13:38:16 -0700801 std::string NewServerNonce(QuicRandom* rand, QuicWallTime now) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500802
803 // ValidateExpectedLeafCertificate checks the |client_hello| to see if it has
804 // an XLCT tag, and if so, verifies that its value matches the hash of the
805 // server's leaf certificate. |certs| is used to compare against the XLCT
806 // value. This method returns true if the XLCT tag is not present, or if the
807 // XLCT tag is present and valid. It returns false otherwise.
808 bool ValidateExpectedLeafCertificate(
809 const CryptoHandshakeMessage& client_hello,
vasilvvc48c8712019-03-11 13:38:16 -0700810 const std::vector<std::string>& certs) const;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500811
QUICHE teama6ef0a62019-03-07 20:34:33 -0500812 // Callback to receive the results of ProofSource::GetProof. Note: this
813 // callback has no cancellation support, since the lifetime of the ProofSource
814 // is controlled by this object via unique ownership. If that ownership
815 // stricture changes, this decision may need to be revisited.
816 class BuildServerConfigUpdateMessageProofSourceCallback
817 : public ProofSource::Callback {
818 public:
819 BuildServerConfigUpdateMessageProofSourceCallback(
820 const BuildServerConfigUpdateMessageProofSourceCallback&) = delete;
821 ~BuildServerConfigUpdateMessageProofSourceCallback() override;
822 void operator=(const BuildServerConfigUpdateMessageProofSourceCallback&) =
823 delete;
824 BuildServerConfigUpdateMessageProofSourceCallback(
825 const QuicCryptoServerConfig* config,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500826 QuicCompressedCertsCache* compressed_certs_cache,
827 const CommonCertSets* common_cert_sets,
828 const QuicCryptoNegotiatedParameters& params,
829 CryptoHandshakeMessage message,
830 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb);
831
832 void Run(bool ok,
833 const QuicReferenceCountedPointer<ProofSource::Chain>& chain,
834 const QuicCryptoProof& proof,
835 std::unique_ptr<ProofSource::Details> details) override;
836
837 private:
838 const QuicCryptoServerConfig* config_;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500839 QuicCompressedCertsCache* compressed_certs_cache_;
840 const CommonCertSets* common_cert_sets_;
vasilvvc48c8712019-03-11 13:38:16 -0700841 const std::string client_common_set_hashes_;
842 const std::string client_cached_cert_hashes_;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500843 const bool sct_supported_by_client_;
vasilvvc48c8712019-03-11 13:38:16 -0700844 const std::string sni_;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500845 CryptoHandshakeMessage message_;
846 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb_;
847 };
848
849 // Invoked by BuildServerConfigUpdateMessageProofSourceCallback::Run once
850 // the proof has been acquired. Finishes building the server config update
851 // message and invokes |cb|.
852 void FinishBuildServerConfigUpdateMessage(
QUICHE teama6ef0a62019-03-07 20:34:33 -0500853 QuicCompressedCertsCache* compressed_certs_cache,
854 const CommonCertSets* common_cert_sets,
vasilvvc48c8712019-03-11 13:38:16 -0700855 const std::string& client_common_set_hashes,
856 const std::string& client_cached_cert_hashes,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500857 bool sct_supported_by_client,
vasilvvc48c8712019-03-11 13:38:16 -0700858 const std::string& sni,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500859 bool ok,
860 const QuicReferenceCountedPointer<ProofSource::Chain>& chain,
vasilvvc48c8712019-03-11 13:38:16 -0700861 const std::string& signature,
862 const std::string& leaf_cert_sct,
QUICHE teama6ef0a62019-03-07 20:34:33 -0500863 std::unique_ptr<ProofSource::Details> details,
864 CryptoHandshakeMessage message,
865 std::unique_ptr<BuildServerConfigUpdateMessageResultCallback> cb) const;
866
867 // Returns true if the next config promotion should happen now.
868 bool IsNextConfigReady(QuicWallTime now) const
869 SHARED_LOCKS_REQUIRED(configs_lock_);
870
871 // replay_protection_ controls whether the server enforces that handshakes
872 // aren't replays.
873 bool replay_protection_;
874
875 // The multiple of the CHLO message size that a REJ message must stay under
876 // when the client doesn't present a valid source-address token. This is
877 // used to protect QUIC from amplification attacks.
878 size_t chlo_multiplier_;
879
880 // configs_ satisfies the following invariants:
881 // 1) configs_.empty() <-> primary_config_ == nullptr
882 // 2) primary_config_ != nullptr -> primary_config_->is_primary
883 // 3) ∀ c∈configs_, c->is_primary <-> c == primary_config_
884 mutable QuicMutex configs_lock_;
QUICHE team1225f472019-03-19 15:52:25 -0700885
QUICHE teama6ef0a62019-03-07 20:34:33 -0500886 // configs_ contains all active server configs. It's expected that there are
887 // about half-a-dozen configs active at any one time.
888 ConfigMap configs_ GUARDED_BY(configs_lock_);
QUICHE team1225f472019-03-19 15:52:25 -0700889
QUICHE teama6ef0a62019-03-07 20:34:33 -0500890 // primary_config_ points to a Config (which is also in |configs_|) which is
891 // the primary config - i.e. the one that we'll give out to new clients.
892 mutable QuicReferenceCountedPointer<Config> primary_config_
893 GUARDED_BY(configs_lock_);
QUICHE team1225f472019-03-19 15:52:25 -0700894
QUICHE team99055cf2019-03-22 11:27:53 -0700895 // fallback_config_ points to a Config (which is also in |configs_|) which is
896 // the fallback config, which will be used if the other configs are unuseable
897 // for some reason.
898 //
899 // TODO(b/112548056): This is currently always nullptr.
900 QuicReferenceCountedPointer<Config> fallback_config_
901 GUARDED_BY(configs_lock_);
902
QUICHE teama6ef0a62019-03-07 20:34:33 -0500903 // next_config_promotion_time_ contains the nearest, future time when an
904 // active config will be promoted to primary.
905 mutable QuicWallTime next_config_promotion_time_ GUARDED_BY(configs_lock_);
QUICHE team1225f472019-03-19 15:52:25 -0700906
QUICHE teama6ef0a62019-03-07 20:34:33 -0500907 // Callback to invoke when the primary config changes.
908 std::unique_ptr<PrimaryConfigChangedCallback> primary_config_changed_cb_
909 GUARDED_BY(configs_lock_);
910
911 // Used to protect the source-address tokens that are given to clients.
912 CryptoSecretBoxer source_address_token_boxer_;
913
914 // server_nonce_boxer_ is used to encrypt and validate suggested server
915 // nonces.
916 CryptoSecretBoxer server_nonce_boxer_;
917
918 // server_nonce_orbit_ contains the random, per-server orbit values that this
919 // server will use to generate server nonces (the moral equivalent of a SYN
920 // cookies).
921 uint8_t server_nonce_orbit_[8];
922
923 // proof_source_ contains an object that can provide certificate chains and
924 // signatures.
925 std::unique_ptr<ProofSource> proof_source_;
926
927 // key_exchange_source_ contains an object that can provide key exchange
928 // objects.
929 std::unique_ptr<KeyExchangeSource> key_exchange_source_;
930
931 // ssl_ctx_ contains the server configuration for doing TLS handshakes.
932 bssl::UniquePtr<SSL_CTX> ssl_ctx_;
933
934 // These fields store configuration values. See the comments for their
935 // respective setter functions.
936 uint32_t source_address_token_future_secs_;
937 uint32_t source_address_token_lifetime_secs_;
938
939 // Enable serving SCT or not.
940 bool enable_serving_sct_;
941
942 // Does not own this observer.
943 RejectionObserver* rejection_observer_;
944
945 // If non-empty, the server will operate in the pre-shared key mode by
946 // incorporating |pre_shared_key_| into the key schedule.
vasilvvc48c8712019-03-11 13:38:16 -0700947 std::string pre_shared_key_;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500948
949 // Whether REJ message should be padded to max packet size.
950 bool pad_rej_;
951
952 // Whether SHLO message should be padded to max packet size.
953 bool pad_shlo_;
954
955 // If client is allowed to send a small client hello (by disabling padding),
956 // server MUST not check for the client hello size.
957 // DO NOT disable this unless you have some other way of validating client.
958 // (e.g. in realtime scenarios, where quic is tunneled through ICE, ICE will
959 // do its own peer validation using STUN pings with ufrag/upass).
960 bool validate_chlo_size_;
961
962 // When source address is validated by some other means (e.g. when using ICE),
963 // source address token validation may be disabled.
964 bool validate_source_address_token_;
965};
966
967struct QUIC_EXPORT_PRIVATE QuicSignedServerConfig
968 : public QuicReferenceCounted {
969 QuicSignedServerConfig();
970
971 QuicCryptoProof proof;
972 QuicReferenceCountedPointer<ProofSource::Chain> chain;
973 // The server config that is used for this proof (and the rest of the
974 // request).
975 QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> config;
vasilvvc48c8712019-03-11 13:38:16 -0700976 std::string primary_scid;
QUICHE teama6ef0a62019-03-07 20:34:33 -0500977
978 protected:
979 ~QuicSignedServerConfig() override;
980};
981
982} // namespace quic
983
984#endif // QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTO_SERVER_CONFIG_H_