From c57d7976036b6ddacb537dbce3b3f4eff846a8d2 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 3 Dec 2026 16:08:06 +0000 Subject: [PATCH] tls: add tls.getGroups() Return the names of the TLS groups that can be used in the ecdhCurve option. Requires OpenSSL 3.5 or later. Assisted-by: Claude Opus 5.5 Signed-off-by: James M Snell --- doc/api/tls.md | 19 +++++++++++++++ lib/tls.js | 5 ++++ src/crypto/crypto_cipher.cc | 36 ++++++++++++++++++++++++++++ src/crypto/crypto_cipher.h | 1 + test/parallel/test-tls-get-groups.js | 30 +++++++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 test/parallel/test-tls-get-groups.js diff --git a/doc/api/tls.md b/doc/api/tls.md index 942733df8cc7..c3b884292504 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -2541,6 +2541,25 @@ TLSv1.2 and below. console.log(tls.getCiphers()); // ['aes128-gcm-sha256', 'aes128-sha', ...] ``` +## `tls.getGroups()` + + + +* Returns: {string\[]} + +Returns an array with the names of the TLS groups that can be used in the +`ecdhCurve` option of [`tls.createSecureContext()`][] and in +[`tls.DEFAULT_ECDH_CURVE`][]. Not all supported groups are enabled by default. + +Requires OpenSSL 3.5 or later. Throws `ERR_CRYPTO_UNSUPPORTED_OPERATION` +otherwise. + +```js +console.log(tls.getGroups()); // ['MLKEM1024', 'MLKEM512', 'MLKEM768', ...] +``` + ## `tls.getCertificateCompressionAlgorithms()`