Cloudflare's Automatic Key Exchange optimizes TLS 1.3 handshakes to origin servers by dynamically selecting the optimal key agreement algorithm, including post-quantum secure options, reducing latency and ensuring future-proof security. This system design leverages out-of-band scanning and adaptive rollout mechanisms to enhance connection efficiency and security at scale, avoiding breaking changes for millions of domains. The innovation addresses the "harvest-now, decrypt-later" threat by automatically enabling post-quantum cryptography without manual configuration.
Read original on Cloudflare BlogCloudflare developed Automatic Key Exchange to solve a critical problem in TLS 1.3 handshakes to origin servers: the need to guess the key agreement algorithm in the initial ClientHello. A wrong guess leads to a `HelloRetryRequest` (HRR), adding a full network round trip and significant latency. By replacing this guess with an intelligent, data-driven approach, Cloudflare dramatically reduced HRRs and improved connection setup times.
The Challenge of Predictive Key Exchange
TLS 1.3's "predictive key exchange" aims for a single round-trip handshake. However, it requires the client (Cloudflare, acting as a reverse proxy) to send a key share with its `ClientHello` before knowing the origin's preferred algorithm. A mismatch necessitates a retry, effectively doubling the handshake latency for that connection.
A key driver for Automatic Key Exchange is the push towards post-quantum (PQ) security. Traditional key shares (like X25519) are small, fitting into a single packet. PQ key shares (e.g., X25519MLKEM768) are significantly larger, potentially splitting the `ClientHello` across multiple packets, which can break connections with legacy middleboxes or origin servers. Cloudflare initially advertised PQ support but used HRR as a "safety valve" – requiring origins to request PQ via a retry. This ensured compatibility but sacrificed latency. The new system enables leading with PQ key shares where compatible, without risking outages, moving closer to the goal of making the Internet quantum-secure by 2029 (Q-Day) without manual intervention from millions of website operators.