Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds initial support for the Encrypted ClientHello (ECH) extension, as specified by draft-ietf-tls-esni-08. A few features are not implemented, including client- and server-side padding. This commit also adds basic support for handshake metrics: * Adds a callback `EventHandler()` to `Config`, which can be called at various points during the handshake to respond to various events. For example, this callback can be used to record metrics. * Adds calls to `EventHandler()` just before closing the TLS connection for resolving ECH usage: whether the client offered, greased, or bypassed ECH; and whether the server accepted, rejected, or bypassed ECH. crypto/tls: Fix the testingTriggerHRR condition The server sends an HRR if the client does not offer a key share for a key exchange algorithm the server doesn't support. For testing purposes, it's useful to trigger this codepath manually. If testingTriggerHRR is set, then the server only advertises support for algorithms that the client supports, but did not provide a key share for. This change fixes a bug in the trigger logic. It seemed to work for the existing algorithm preferences, but could break if the preferences change. crypto/tls: Move draft-ietf-tls-esni-08 to -09 Most significant spec changes include: * Bump HPKE-05 to -07. * Derive acceptance confirmation from handshake secret. * Reuse HPKE context across HRR. * Use a new codepoint to distinguish between CHI/CHO. * Bind context handle to AEAD encryption. Other changes: * Remove hrrPsk from ECHProvider.Context (breaks API). * Prune retry configs of unknown version returned by the ECH provider. * Add EXP_ECHKeySet, a default implementation of the ECH provider. (This will be useful for interop testing.) * Require that the ECH extension not appear in OuterExtensions. * Add event handler for outer SNI / public name mismatch. * Remove implementation of HPKE-05 crypto/tls: Move draft-ietf-tls-esni-09 to 10 This change adds support for ECH-10 and removes support for ECH-09. The primary changes are moving to HPKE-08 and changing the ECHConfig identifier from a client-computed value to a server-chosen value. ECHProviders MUST use rejection sampling in choosing the configuration identifier so as to not introduce conflicts. crypto/tls: Add cipher suite checks to ECH unit tests Test that UnmarshalECHConfigs (resp. EXP_UnmarshalECHKeys) parses the correct number of cipher suites. crypto/tls: Fix an ECH bug triggered by HRR Per the spec, the server checks that the config_id matches in ClientHelloOuter1 and ClientHelloOuter2. We fail to correctly store the first config_id, resulting in the server enforcing, in effect, that the second config_id is equal to 0. This bug wasn't exercised by our unit tests because the test data uses 0 as the config_id. crypto/tls: Upgrade draft-ietf-tls-esni-10 to 11 Drops support for the previous version of ECH and adds support for the next one. There's one caveat, however. In draft-ietf-tls-esni-11, the ECHConfig.version uses the same codepoint as in the previous draft. This is a bug in draft 11 that will be fixed in a future draft. In the meantime, we use the codepoint from draft 11. crypto/tls: Refactor client state machine Before draft-ietf-tls-esni-11, there was no way for a client that offered ECH to tell whether a HelloRetryRequest (HRR) was sent by the client-facing or backend server. Starting in draft-ietf-tls-esni-11 there is an explicit signal of ECH acceptance after HRR. This allows us to simplify the client state machine. crypto/tls: Move draft-ietf-tls-esni-11 to 12 Drops support for the previous draft and adds support for the next one. This change also includes the ClientHelloInner padding scheme described in Section 6.1.3. crypto/tls: Reject ECH on invalid encapsulated key The ECH provider aborts if it gets an encapsulated key it's unable to parse, causing the ECH server to abort with an "internal_error" alert. This condition can be triggered by a client that generates a GREASE ECH extension with a config_id that happens to match a known config, but uses the incorrect KEM algorithm. This changes the server behavior so that it rejects instead.
- Loading branch information