You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
quic: select AEAD and header-protection cipher from negotiated suite
The built-in QUIC/H3 stack derived its packet-protection AEAD and
header-protection (HP) cipher from the length of the exported TLS 1.3
traffic secret alone: a 48-byte secret was treated as AES-256-GCM and
anything else as AES-128-GCM. ChaCha20-Poly1305 was never selected.
Per RFC 9001 (5.3, 5.4) the AEAD and HP algorithms are fixed by the
negotiated TLS 1.3 cipher suite, not by the secret length. Because
TLS_AES_128_GCM_SHA256 and TLS_CHACHA20_POLY1305_SHA256 both use SHA-256,
they produce identical 32-byte secrets, so a ChaCha20 handshake was
mis-keyed with AES header protection and failed ("reserved bits" /
decryption failure) whenever ChaCha20-Poly1305 was negotiated.
Make the choice cipher-suite aware:
- add enum lws_tls_quic_aead and wsi->tls.quic_aead, reported by the
TLS backend from the negotiated suite;
- every QUIC-capable TLS backend now reports it from the negotiated
cipher as the traffic secrets are installed:
* mbedTLS: maps the negotiated TLS 1.3 ciphersuite id in the
traffic-secret export callback (the suite is only available there
mid-handshake; ssl->session, which
mbedtls_ssl_get_ciphersuite_id_from_ssl() reads, is not yet set);
* OpenSSL/BoringSSL/AWS-LC/LibreSSL: from the SSL_CIPHER handed to
set_{read,write}_secret();
* wolfSSL: from SSL_get_current_cipher() in set_encryption_secrets();
* GnuTLS: from gnutls_cipher_get();
* SChannel: from the SEC_TRAFFIC_SECRETS symmetric alg / key size;
- lws_quic_set_keys() selects the internal cipher_type from the
reported AEAD, falling back to the legacy length heuristic only when
a backend does not report it (still correct for AES-128 vs AES-256
GCM, blind to ChaCha20 as before).
The correct SHA-256/SHA-384 HKDF hash is still chosen from the secret
length, which is unambiguous (it mirrors the suite's PRF hash size).
Note: to build mbedtls support for quic/h3 after this patch, you
need to patch mbedtls with "Epoch 2" patches from
https://libwebsockets.org/git/mbedtls/log?h=development
0 commit comments