@@ -3575,7 +3575,7 @@ OPENSSL_EXPORT const char *SSL_early_data_reason_string(
3575
3575
enum ssl_early_data_reason_t reason );
3576
3576
3577
3577
3578
- // Encrypted Client Hello .
3578
+ // Encrypted ClientHello .
3579
3579
//
3580
3580
// ECH is a mechanism for encrypting the entire ClientHello message in TLS 1.3.
3581
3581
// This can prevent observers from seeing cleartext information about the
@@ -3589,6 +3589,72 @@ OPENSSL_EXPORT const char *SSL_early_data_reason_string(
3589
3589
// as part of this connection.
3590
3590
OPENSSL_EXPORT void SSL_set_enable_ech_grease (SSL * ssl , int enable );
3591
3591
3592
+ // SSL_ECH_SERVER_CONFIG_LIST_new returns a newly-allocated
3593
+ // |SSL_ECH_SERVER_CONFIG_LIST| or NULL on error.
3594
+ OPENSSL_EXPORT SSL_ECH_SERVER_CONFIG_LIST * SSL_ECH_SERVER_CONFIG_LIST_new (void );
3595
+
3596
+ // SSL_ECH_SERVER_CONFIG_LIST_up_ref increments the reference count of |list|.
3597
+ OPENSSL_EXPORT void SSL_ECH_SERVER_CONFIG_LIST_up_ref (
3598
+ SSL_ECH_SERVER_CONFIG_LIST * list );
3599
+
3600
+ // SSL_ECH_SERVER_CONFIG_LIST_free releases memory associated with |list|.
3601
+ OPENSSL_EXPORT void SSL_ECH_SERVER_CONFIG_LIST_free (
3602
+ SSL_ECH_SERVER_CONFIG_LIST * list );
3603
+
3604
+ // SSL_ECH_SERVER_CONFIG_LIST_add appends an ECHConfig in |ech_config| and its
3605
+ // corresponding private key in |private_key| to |list|. When |is_retry_config|
3606
+ // is non-zero, this config will be returned to the client on configuration
3607
+ // mismatch. It returns one on success and zero on error. See also
3608
+ // |SSL_CTX_set1_ech_server_config_list|.
3609
+ //
3610
+ // This function should be called successively to register each ECHConfig in
3611
+ // decreasing order of preference. This configuration must be completed before
3612
+ // setting |list| on an |SSL_CTX| with |SSL_CTX_set1_ech_server_config_list|.
3613
+ // After that point, |list| is immutable; no more ECHConfig values may be added.
3614
+ OPENSSL_EXPORT int SSL_ECH_SERVER_CONFIG_LIST_add (
3615
+ SSL_ECH_SERVER_CONFIG_LIST * list , int is_retry_config ,
3616
+ const uint8_t * ech_config , size_t ech_config_len ,
3617
+ const uint8_t * private_key , size_t private_key_len );
3618
+
3619
+ // SSL_CTX_set1_ech_server_config_list atomically sets the refcounted |list|
3620
+ // onto |ctx|, releasing the old list. |SSL| objects associated with |ctx|, as
3621
+ // servers, will use |list| to decrypt incoming encrypted ClientHello messages.
3622
+ // It returns one on success, and zero on failure.
3623
+ //
3624
+ // If |list| does not contain any retry configs, this function will fail. Retry
3625
+ // configs are marked as such when they are added to |list| with
3626
+ // |SSL_ECH_SERVER_CONFIG_LIST_add|.
3627
+ //
3628
+ // Once |list| has been passed to this function, it is immutable. Unlike most
3629
+ // |SSL_CTX| configuration functions, this function may be called even if |ctx|
3630
+ // already has associated connections on multiple threads. This may be used to
3631
+ // rotate keys in a long-lived server process.
3632
+ //
3633
+ // The configured ECHConfig values should also be advertised out-of-band via DNS
3634
+ // (see draft-ietf-dnsop-svcb-https). Before advertising an ECHConfig in DNS,
3635
+ // deployments should ensure all instances of the service are configured with
3636
+ // the ECHConfig and corresponding private key.
3637
+ //
3638
+ // Only the most recent fully-deployed ECHConfigs should be advertised in DNS.
3639
+ // |list| may contain a newer set if those ECHConfigs are mid-deployment. It
3640
+ // should also contain older sets, until the DNS change has rolled out and the
3641
+ // old records have expired from caches.
3642
+ //
3643
+ // If there is a mismatch, |SSL| objects associated with |ctx| will complete the
3644
+ // handshake using the cleartext ClientHello and send updated ECHConfig values
3645
+ // to the client. The client will then retry to recover, but with a latency
3646
+ // penalty. This recovery flow depends on the public name in the ECHConfig.
3647
+ // Before advertising an ECHConfig in DNS, deployments must ensure all instances
3648
+ // of the service can present a valid certificate for the public name.
3649
+ //
3650
+ // BoringSSL negotiates ECH before certificate selection callbacks are called,
3651
+ // including |SSL_CTX_set_select_certificate_cb|. If ECH is negotiated, the
3652
+ // reported |SSL_CLIENT_HELLO| structure and |SSL_get_servername| function will
3653
+ // transparently reflect the inner ClientHello. Callers should select parameters
3654
+ // based on these values to correctly handle ECH as well as the recovery flow.
3655
+ OPENSSL_EXPORT int SSL_CTX_set1_ech_server_config_list (
3656
+ SSL_CTX * ctx , SSL_ECH_SERVER_CONFIG_LIST * list );
3657
+
3592
3658
3593
3659
// Alerts.
3594
3660
//
@@ -4960,6 +5026,10 @@ BSSL_NAMESPACE_BEGIN
4960
5026
BORINGSSL_MAKE_DELETER (SSL , SSL_free )
4961
5027
BORINGSSL_MAKE_DELETER (SSL_CTX , SSL_CTX_free )
4962
5028
BORINGSSL_MAKE_UP_REF (SSL_CTX , SSL_CTX_up_ref )
5029
+ BORINGSSL_MAKE_DELETER (SSL_ECH_SERVER_CONFIG_LIST ,
5030
+ SSL_ECH_SERVER_CONFIG_LIST_free )
5031
+ BORINGSSL_MAKE_UP_REF (SSL_ECH_SERVER_CONFIG_LIST ,
5032
+ SSL_ECH_SERVER_CONFIG_LIST_up_ref )
4963
5033
BORINGSSL_MAKE_DELETER (SSL_SESSION , SSL_SESSION_free )
4964
5034
BORINGSSL_MAKE_UP_REF (SSL_SESSION , SSL_SESSION_up_ref )
4965
5035
@@ -5293,6 +5363,11 @@ BSSL_NAMESPACE_END
5293
5363
#define SSL_R_NO_APPLICATION_PROTOCOL 307
5294
5364
#define SSL_R_NEGOTIATED_ALPS_WITHOUT_ALPN 308
5295
5365
#define SSL_R_ALPS_MISMATCH_ON_EARLY_DATA 309
5366
+ #define SSL_R_ECH_SERVER_CONFIG_AND_PRIVATE_KEY_MISMATCH 310
5367
+ #define SSL_R_ECH_SERVER_CONFIG_UNSUPPORTED_EXTENSION 311
5368
+ #define SSL_R_UNSUPPORTED_ECH_SERVER_CONFIG 312
5369
+ #define SSL_R_ECH_SERVER_WOULD_HAVE_NO_RETRY_CONFIGS 313
5370
+ #define SSL_R_INVALID_CLIENT_HELLO_INNER 314
5296
5371
#define SSL_R_SSLV3_ALERT_CLOSE_NOTIFY 1000
5297
5372
#define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010
5298
5373
#define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020
0 commit comments