diff --git a/doc/api/tls.md b/doc/api/tls.md index 942733df8cc..f3fb9bbaf41 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -122,24 +122,65 @@ Perfect forward secrecy is achieved by randomly generating a key pair for key-agreement on every TLS/SSL handshake (in contrast to using the same key for all sessions). Methods implementing this technique are called "ephemeral". -Currently two methods are commonly used to achieve perfect forward secrecy (note -the character "E" appended to the traditional abbreviations): +The following key-agreement methods provide perfect forward secrecy (note the +character "E" appended to the traditional abbreviations): * [ECDHE][]: An ephemeral version of the Elliptic Curve Diffie-Hellman key-agreement protocol. * [DHE][]: An ephemeral version of the Diffie-Hellman key-agreement protocol. +* Hybrid post-quantum key exchange: TLSv1.3 groups such as `X25519MLKEM768` + that combine ECDHE with the ML-KEM key-encapsulation mechanism. The session + keys stay secret as long as either component is unbroken, which protects + recorded traffic against later decryption by a quantum computer. + +Perfect forward secrecy is enabled by default. With TLSv1.3, the default group +list prefers `X25519MLKEM768`. With TLSv1.2, which does not support the +post-quantum groups, ECDHE is used. The `ecdhCurve` option can be used to +customize the list of supported ECDH curves for TLSv1.2 and below, and the list +of supported TLS groups for TLSv1.3. See [`tls.createSecureContext()`][] for +more info. + +DHE is used with TLSv1.2 when the client offers one of the [RFC 7919][] FFDHE +groups, such as `ffdhe2048`, in its supported groups. It can also be enabled for +other clients by setting the `dhparam` option to `'auto'`. Custom DHE +parameters are also supported but discouraged in favor of automatically +selected, well-known parameters. + +Perfect forward secrecy was optional up to TLSv1.2. The default cipher list +still includes TLSv1.2 cipher suites with RSA key exchange, which do not +provide it. As of TLSv1.3, (EC)DHE or a hybrid post-quantum group is always +used (with the exception of PSK-only connections). + +#### Requiring post-quantum key exchange + +To accept only connections that use a hybrid post-quantum group, require +TLSv1.3 and limit `ecdhCurve` to post-quantum groups. Peers that support only +TLSv1.2 or only classical groups fail the handshake. -Perfect forward secrecy using ECDHE is enabled by default. The `ecdhCurve` -option can be used when creating a TLS server to customize the list of supported -ECDH curves for TLSv1.2 and below, and the list of supported TLS groups for -TLSv1.3. See [`tls.createServer()`][] for more info. +```mjs +import { createServer } from 'node:tls'; + +const server = createServer({ + key, + cert, + minVersion: 'TLSv1.3', + ecdhCurve: 'X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024', +}); +``` -DHE is disabled by default but can be enabled alongside ECDHE by setting the -`dhparam` option to `'auto'`. Custom DHE parameters are also supported but -discouraged in favor of automatically selected, well-known parameters. +```cjs +const { createServer } = require('node:tls'); + +const server = createServer({ + key, + cert, + minVersion: 'TLSv1.3', + ecdhCurve: 'X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024', +}); +``` -Perfect forward secrecy was optional up to TLSv1.2. As of TLSv1.3, (EC)DHE is -always used (with the exception of PSK-only connections). +The same options can be passed to [`tls.connect()`][] to require post-quantum +key exchange on the client. ### ALPN and SNI @@ -2151,17 +2192,24 @@ changes: * `crl` {string|string\[]|Buffer|Buffer\[]} PEM formatted CRLs (Certificate Revocation Lists). * `dhparam` {string|Buffer} `'auto'` or custom Diffie-Hellman parameters, - required for non-ECDHE [perfect forward secrecy][]. If omitted or invalid, - the parameters are silently discarded and DHE ciphers will not be available. - [ECDHE][]-based [perfect forward secrecy][] will still be available. + used for DHE [perfect forward secrecy][] with TLSv1.2 clients that do not + offer an [RFC 7919][] FFDHE group. If omitted or invalid, the parameters + are silently discarded and DHE ciphers are only available to clients that + offer an FFDHE group. [ECDHE][]-based [perfect forward secrecy][] will + still be available. * `ecdhCurve` {string} A string describing a named curve, TLS group, or colon-separated list of named curves or TLS groups to use for key agreement, - for example `P-521:P-384:P-256`, `X25519`, or `X25519MLKEM768`. The + for example `X25519MLKEM768:X25519`, `X25519`, or `P-521:P-384:P-256`. The historical name of this option refers to ECDH key agreement in TLSv1.2 and below. In TLSv1.3, this option configures the TLS Supported Groups and key share groups offered or accepted by the TLS stack. Set to `auto` to - select the group automatically. Use [`crypto.getCurves()`][] to obtain a - list of available elliptic curve names. For TLS group names, use + use the OpenSSL default list, which prefers the `X25519MLKEM768` hybrid + post-quantum group. A list replaces the default list, so a list without a + post-quantum group disables post-quantum key exchange. The `DEFAULT` + keyword stands for the default list within a list, for example + `DEFAULT:SecP384r1MLKEM1024`. See [perfect forward secrecy][]. Use + [`crypto.getCurves()`][] to obtain a list of available elliptic curve + names. For TLS group names, use `openssl list -tls-groups` or consult the [IANA TLS Supported Groups registry][]. **Default:** [`tls.DEFAULT_ECDH_CURVE`][]. @@ -2595,8 +2643,10 @@ changes: description: Default value changed to `'auto'`. --> -The default named curve or TLS group list to use for key agreement in a TLS -server. The default value is `'auto'`. See [`tls.createSecureContext()`][] for +The default named curve or TLS group list to use for key agreement in TLS +clients and servers. The default value is `'auto'`, which uses the OpenSSL +default list. With the bundled OpenSSL, that list prefers the `X25519MLKEM768` +hybrid post-quantum group for TLSv1.3. See [`tls.createSecureContext()`][] for further information. ## `tls.DEFAULT_MAX_VERSION` @@ -2660,6 +2710,7 @@ added: v0.11.3 [RFC 4279]: https://tools.ietf.org/html/rfc4279 [RFC 5077]: https://tools.ietf.org/html/rfc5077 [RFC 5929]: https://tools.ietf.org/html/rfc5929 +[RFC 7919]: https://tools.ietf.org/html/rfc7919 [RFC 8879]: https://tools.ietf.org/html/rfc8879 [SSL_METHODS]: https://www.openssl.org/docs/man3.0/man7/ssl.html#Dealing-with-Protocol-Methods [Session Resumption]: #session-resumption