Skip to content

Commit 24465b0

Browse files
authored
Merge branch 'main' into patch-9
2 parents 36ce832 + 21eac79 commit 24465b0

File tree

321 files changed

+5602
-1392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

321 files changed

+5602
-1392
lines changed

BUILDING.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Depending on the host platform, the selection of toolchains may vary.
157157
| ---------------- | -------------------------------------------------------------- |
158158
| Linux | GCC >= 12.2 |
159159
| Windows | Visual Studio >= 2022 with the Windows 10 SDK on a 64-bit host |
160-
| macOS | Xcode >= 16.1 (Apple LLVM >= 17) |
160+
| macOS | Xcode >= 16.3 (Apple LLVM >= 19) |
161161

162162
### Official binary platforms and toolchains
163163

@@ -249,7 +249,7 @@ FreeBSD and OpenBSD users may also need to install `libexecinfo`.
249249

250250
#### macOS prerequisites
251251

252-
* Xcode Command Line Tools >= 13 for macOS
252+
* Xcode Command Line Tools >= 16.3 for macOS
253253
* [A supported version of Python][Python versions]
254254
* For test coverage, your Python installation must include pip.
255255

@@ -637,7 +637,7 @@ Refs:
637637
* The current [version of Python][Python versions] from the
638638
[Microsoft Store](https://apps.microsoft.com/store/search?publisher=Python+Software+Foundation)
639639
* The "Desktop development with C++" workload from
640-
[Visual Studio 2022 (17.6 or newer)](https://visualstudio.microsoft.com/downloads/)
640+
[Visual Studio 2022 (17.13 or newer)](https://visualstudio.microsoft.com/downloads/)
641641
or the "C++ build tools" workload from the
642642
[Build Tools](https://aka.ms/vs/17/release/vs_buildtools.exe),
643643
with the default optional components. Starting with Node.js v24, ClangCL is required to compile
@@ -659,9 +659,7 @@ Optional requirements to build the MSI installer package:
659659

660660
Optional requirements for compiling for Windows on ARM (ARM64):
661661

662-
* Visual Studio 17.6.0 or newer
663-
> **Note:** There is [a bug](https://github.com/nodejs/build/issues/3739) in `17.10.x`
664-
> preventing Node.js from compiling.
662+
* Visual Studio 17.13.0 or newer
665663
* Visual Studio optional components
666664
* Visual C++ compilers and libraries for ARM64
667665
* Visual C++ ATL for ARM64

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,3 +2639,28 @@ The externally maintained libraries used by Node.js are:
26392639
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26402640
SOFTWARE.
26412641
"""
2642+
2643+
- sonic-boom, located at lib/internal/streams/fast-utf8-stream.js, is licensed as follows:
2644+
"""
2645+
MIT License
2646+
2647+
Copyright (c) 2017 Matteo Collina
2648+
2649+
Permission is hereby granted, free of charge, to any person obtaining a copy
2650+
of this software and associated documentation files (the "Software"), to deal
2651+
in the Software without restriction, including without limitation the rights
2652+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2653+
copies of the Software, and to permit persons to whom the Software is
2654+
furnished to do so, subject to the following conditions:
2655+
2656+
The above copyright notice and this permission notice shall be included in all
2657+
copies or substantial portions of the Software.
2658+
2659+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2660+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2661+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2662+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2663+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2664+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2665+
SOFTWARE.
2666+
"""

benchmark/crypto/create-keyobject.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ function readKeyPair(publicKeyName, privateKeyName) {
1818
}
1919

2020
const keyFixtures = {
21-
ec: readKeyPair('ec_p256_public', 'ec_p256_private'),
22-
rsa: readKeyPair('rsa_public_2048', 'rsa_private_2048'),
23-
ed25519: readKeyPair('ed25519_public', 'ed25519_private'),
21+
'ec': readKeyPair('ec_p256_public', 'ec_p256_private'),
22+
'rsa': readKeyPair('rsa_public_2048', 'rsa_private_2048'),
23+
'ed25519': readKeyPair('ed25519_public', 'ed25519_private'),
24+
'ml-dsa-44': readKeyPair('ml_dsa_44_public', 'ml_dsa_44_private'),
2425
};
2526

2627
const bench = common.createBenchmark(main, {
27-
keyType: ['rsa', 'ec', 'ed25519'],
28+
keyType: ['rsa', 'ec', 'ed25519', 'ml-dsa-44'],
2829
keyFormat: ['pkcs8', 'spki', 'der-pkcs8', 'der-spki', 'jwk-public', 'jwk-private'],
2930
n: [1e3],
3031
});

benchmark/crypto/oneshot-sign.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ const fs = require('fs');
66
const path = require('path');
77
const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/');
88

9+
function readKey(name) {
10+
return fs.readFileSync(`${fixtures_keydir}/${name}.pem`, 'utf8');
11+
}
12+
913
const keyFixtures = {
10-
ec: fs.readFileSync(`${fixtures_keydir}/ec_p256_private.pem`, 'utf-8'),
11-
rsa: fs.readFileSync(`${fixtures_keydir}/rsa_private_2048.pem`, 'utf-8'),
12-
ed25519: fs.readFileSync(`${fixtures_keydir}/ed25519_private.pem`, 'utf-8'),
14+
'ec': readKey('ec_p256_private'),
15+
'rsa': readKey('rsa_private_2048'),
16+
'ed25519': readKey('ed25519_private'),
17+
'ml-dsa-44': readKey('ml_dsa_44_private'),
1318
};
1419

1520
const data = crypto.randomBytes(256);
@@ -18,7 +23,7 @@ let pems;
1823
let keyObjects;
1924

2025
const bench = common.createBenchmark(main, {
21-
keyType: ['rsa', 'ec', 'ed25519'],
26+
keyType: ['rsa', 'ec', 'ed25519', 'ml-dsa-44'],
2227
mode: ['sync', 'async', 'async-parallel'],
2328
keyFormat: ['pem', 'der', 'jwk', 'keyObject', 'keyObject.unique'],
2429
n: [1e3],
@@ -90,6 +95,7 @@ function main({ n, mode, keyFormat, keyType }) {
9095
digest = 'sha256';
9196
break;
9297
case 'ed25519':
98+
case 'ml-dsa-44':
9399
break;
94100
default:
95101
throw new Error('not implemented');

benchmark/crypto/oneshot-verify.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ function readKeyPair(publicKeyName, privateKeyName) {
1818
}
1919

2020
const keyFixtures = {
21-
ec: readKeyPair('ec_p256_public', 'ec_p256_private'),
22-
rsa: readKeyPair('rsa_public_2048', 'rsa_private_2048'),
23-
ed25519: readKeyPair('ed25519_public', 'ed25519_private'),
21+
'ec': readKeyPair('ec_p256_public', 'ec_p256_private'),
22+
'rsa': readKeyPair('rsa_public_2048', 'rsa_private_2048'),
23+
'ed25519': readKeyPair('ed25519_public', 'ed25519_private'),
24+
'ml-dsa-44': readKeyPair('ml_dsa_44_public', 'ml_dsa_44_private'),
2425
};
2526

2627
const data = crypto.randomBytes(256);
@@ -29,7 +30,7 @@ let pems;
2930
let keyObjects;
3031

3132
const bench = common.createBenchmark(main, {
32-
keyType: ['rsa', 'ec', 'ed25519'],
33+
keyType: ['rsa', 'ec', 'ed25519', 'ml-dsa-44'],
3334
mode: ['sync', 'async', 'async-parallel'],
3435
keyFormat: ['pem', 'der', 'jwk', 'keyObject', 'keyObject.unique'],
3536
n: [1e3],
@@ -104,6 +105,7 @@ function main({ n, mode, keyFormat, keyType }) {
104105
digest = 'sha256';
105106
break;
106107
case 'ed25519':
108+
case 'ml-dsa-44':
107109
break;
108110
default:
109111
throw new Error('not implemented');

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.17',
41+
'v8_embedder_string': '-node.18',
4242

4343
##### V8 defaults for Node.js #####
4444

configure.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,18 +1117,20 @@ def try_check_compiler(cc, lang):
11171117

11181118
with proc:
11191119
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
1120-
b'__clang_major__ __clang_minor__ __clang_patchlevel__')
1120+
b'__clang_major__ __clang_minor__ __clang_patchlevel__ '
1121+
b'__APPLE__')
11211122

11221123
if sys.platform == 'zos':
1123-
values = (to_utf8(proc.communicate()[0]).split('\n')[-2].split() + ['0'] * 7)[0:7]
1124+
values = (to_utf8(proc.communicate()[0]).split('\n')[-2].split() + ['0'] * 7)[0:8]
11241125
else:
1125-
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
1126+
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:8]
11261127

11271128
is_clang = values[0] == '1'
11281129
gcc_version = tuple(map(int, values[1:1+3]))
11291130
clang_version = tuple(map(int, values[4:4+3])) if is_clang else None
1131+
is_apple = values[7] == '1'
11301132

1131-
return (True, is_clang, clang_version, gcc_version)
1133+
return (True, is_clang, clang_version, gcc_version, is_apple)
11321134

11331135

11341136
#
@@ -1205,7 +1207,7 @@ def get_gas_version(cc):
12051207
warn(f'Could not recognize `gas`: {gas_ret}')
12061208
return '0.0'
12071209

1208-
def get_openssl_version():
1210+
def get_openssl_version(o):
12091211
"""Parse OpenSSL version from opensslv.h header file.
12101212
12111213
Returns the version as a number matching OPENSSL_VERSION_NUMBER format:
@@ -1219,6 +1221,9 @@ def get_openssl_version():
12191221
args = ['-I', 'deps/openssl/openssl/include'] + args
12201222
elif options.shared_openssl_includes:
12211223
args = ['-I', options.shared_openssl_includes] + args
1224+
else:
1225+
for dir in o['include_dirs']:
1226+
args = ['-I', dir] + args
12221227

12231228
proc = subprocess.Popen(
12241229
shlex.split(CC) + args,
@@ -1289,18 +1294,18 @@ def check_compiler(o):
12891294
o['variables']['openssl_no_asm'] = 1
12901295
return
12911296

1292-
ok, is_clang, clang_version, gcc_version = try_check_compiler(CXX, 'c++')
1297+
ok, is_clang, clang_version, gcc_version, is_apple = try_check_compiler(CXX, 'c++')
12931298
o['variables']['clang'] = B(is_clang)
12941299
version_str = ".".join(map(str, clang_version if is_clang else gcc_version))
1295-
print_verbose(f"Detected {'clang ' if is_clang else ''}C++ compiler (CXX={CXX}) version: {version_str}")
1300+
print_verbose(f"Detected {'Apple ' if is_apple else ''}{'clang ' if is_clang else ''}C++ compiler (CXX={CXX}) version: {version_str}")
12961301
if not ok:
12971302
warn(f'failed to autodetect C++ compiler version (CXX={CXX})')
1298-
elif clang_version < (19, 1, 0) if is_clang else gcc_version < (12, 2, 0):
1299-
warn(f'C++ compiler (CXX={CXX}, {version_str}) too old, need g++ 12.2.0 or clang++ 19.1.0')
1303+
elif (is_apple and clang_version < (17, 0, 0) or not is_apple and clang_version < (19, 1, 0)) if is_clang else gcc_version < (12, 2, 0):
1304+
warn(f'C++ compiler (CXX={CXX}, {version_str}) too old, need g++ 12.2.0, clang++ 19.1.0, or Apple clang++ 17.0.0')
13001305

1301-
ok, is_clang, clang_version, gcc_version = try_check_compiler(CC, 'c')
1306+
ok, is_clang, clang_version, gcc_version, is_apple = try_check_compiler(CC, 'c')
13021307
version_str = ".".join(map(str, clang_version if is_clang else gcc_version))
1303-
print_verbose(f"Detected {'clang ' if is_clang else ''}C compiler (CC={CC}) version: {version_str}")
1308+
print_verbose(f"Detected {'Apple ' if is_apple else ''}{'clang ' if is_clang else ''}C compiler (CC={CC}) version: {version_str}")
13041309
if not ok:
13051310
warn(f'failed to autodetect C compiler version (CC={CC})')
13061311
elif not is_clang and gcc_version < (4, 2, 0):
@@ -1478,7 +1483,7 @@ def configure_zos(o):
14781483

14791484
def clang_version_ge(version_checked):
14801485
for compiler in [(CC, 'c'), (CXX, 'c++')]:
1481-
_, is_clang, clang_version, _1 = (
1486+
_, is_clang, clang_version, _1, _2 = (
14821487
try_check_compiler(compiler[0], compiler[1])
14831488
)
14841489
if is_clang and clang_version >= version_checked:
@@ -1487,7 +1492,7 @@ def clang_version_ge(version_checked):
14871492

14881493
def gcc_version_ge(version_checked):
14891494
for compiler in [(CC, 'c'), (CXX, 'c++')]:
1490-
_, is_clang, _1, gcc_version = (
1495+
_, is_clang, _1, gcc_version, _2 = (
14911496
try_check_compiler(compiler[0], compiler[1])
14921497
)
14931498
if is_clang or gcc_version < version_checked:
@@ -1887,10 +1892,10 @@ def without_ssl_error(option):
18871892
if options.quic:
18881893
o['defines'] += ['NODE_OPENSSL_HAS_QUIC']
18891894

1890-
o['variables']['openssl_version'] = get_openssl_version()
1891-
18921895
configure_library('openssl', o)
18931896

1897+
o['variables']['openssl_version'] = get_openssl_version(o)
1898+
18941899
def configure_sqlite(o):
18951900
o['variables']['node_use_sqlite'] = b(not options.without_sqlite)
18961901
if options.without_sqlite:

deps/ncrypto/ncrypto.cc

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,31 @@ EVPKeyPointer EVPKeyPointer::NewRawPrivate(
18971897
EVP_PKEY_new_raw_private_key(id, nullptr, data.data, data.len));
18981898
}
18991899

1900+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
1901+
EVPKeyPointer EVPKeyPointer::NewRawSeed(
1902+
int id, const Buffer<const unsigned char>& data) {
1903+
if (id == 0) return {};
1904+
1905+
OSSL_PARAM params[] = {
1906+
OSSL_PARAM_construct_octet_string(OSSL_PKEY_PARAM_ML_DSA_SEED,
1907+
const_cast<unsigned char*>(data.data),
1908+
data.len),
1909+
OSSL_PARAM_END};
1910+
1911+
EVP_PKEY_CTX* ctx = EVP_PKEY_CTX_new_id(id, nullptr);
1912+
if (ctx == nullptr) return {};
1913+
1914+
EVP_PKEY* pkey = nullptr;
1915+
if (ctx == nullptr || EVP_PKEY_fromdata_init(ctx) <= 0 ||
1916+
EVP_PKEY_fromdata(ctx, &pkey, EVP_PKEY_KEYPAIR, params) <= 0) {
1917+
EVP_PKEY_CTX_free(ctx);
1918+
return {};
1919+
}
1920+
1921+
return EVPKeyPointer(pkey);
1922+
}
1923+
#endif
1924+
19001925
EVPKeyPointer EVPKeyPointer::NewDH(DHPointer&& dh) {
19011926
if (!dh) return {};
19021927
auto key = New();
@@ -1942,7 +1967,16 @@ EVP_PKEY* EVPKeyPointer::release() {
19421967

19431968
int EVPKeyPointer::id(const EVP_PKEY* key) {
19441969
if (key == nullptr) return 0;
1945-
return EVP_PKEY_id(key);
1970+
int type = EVP_PKEY_id(key);
1971+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
1972+
// https://github.com/openssl/openssl/issues/27738#issuecomment-3013215870
1973+
if (type == -1) {
1974+
if (EVP_PKEY_is_a(key, "ML-DSA-44")) return EVP_PKEY_ML_DSA_44;
1975+
if (EVP_PKEY_is_a(key, "ML-DSA-65")) return EVP_PKEY_ML_DSA_65;
1976+
if (EVP_PKEY_is_a(key, "ML-DSA-87")) return EVP_PKEY_ML_DSA_87;
1977+
}
1978+
#endif
1979+
return type;
19461980
}
19471981

19481982
int EVPKeyPointer::base_id(const EVP_PKEY* key) {
@@ -1998,6 +2032,31 @@ DataPointer EVPKeyPointer::rawPublicKey() const {
19982032
return {};
19992033
}
20002034

2035+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2036+
DataPointer EVPKeyPointer::rawSeed() const {
2037+
if (!pkey_) return {};
2038+
switch (id()) {
2039+
case EVP_PKEY_ML_DSA_44:
2040+
case EVP_PKEY_ML_DSA_65:
2041+
case EVP_PKEY_ML_DSA_87:
2042+
break;
2043+
default:
2044+
unreachable();
2045+
}
2046+
2047+
size_t seed_len = 32;
2048+
if (auto data = DataPointer::Alloc(seed_len)) {
2049+
const Buffer<unsigned char> buf = data;
2050+
size_t len = data.size();
2051+
if (EVP_PKEY_get_octet_string_param(
2052+
get(), OSSL_PKEY_PARAM_ML_DSA_SEED, buf.data, len, &seed_len) != 1)
2053+
return {};
2054+
return data;
2055+
}
2056+
return {};
2057+
}
2058+
#endif
2059+
20012060
DataPointer EVPKeyPointer::rawPrivateKey() const {
20022061
if (!pkey_) return {};
20032062
if (auto data = DataPointer::Alloc(rawPrivateKeySize())) {
@@ -2453,7 +2512,18 @@ bool EVPKeyPointer::isRsaVariant() const {
24532512
bool EVPKeyPointer::isOneShotVariant() const {
24542513
if (!pkey_) return false;
24552514
int type = id();
2456-
return type == EVP_PKEY_ED25519 || type == EVP_PKEY_ED448;
2515+
switch (type) {
2516+
case EVP_PKEY_ED25519:
2517+
case EVP_PKEY_ED448:
2518+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2519+
case EVP_PKEY_ML_DSA_44:
2520+
case EVP_PKEY_ML_DSA_65:
2521+
case EVP_PKEY_ML_DSA_87:
2522+
#endif
2523+
return true;
2524+
default:
2525+
return false;
2526+
}
24572527
}
24582528

24592529
bool EVPKeyPointer::isSigVariant() const {

deps/ncrypto/ncrypto.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030

3131
#if OPENSSL_VERSION_MAJOR >= 3
3232
#define OSSL3_CONST const
33+
#if OPENSSL_VERSION_MINOR >= 5
34+
#include <openssl/core_names.h>
35+
#endif
3336
#else
3437
#define OSSL3_CONST
3538
#endif
@@ -817,6 +820,10 @@ class EVPKeyPointer final {
817820
const Buffer<const unsigned char>& data);
818821
static EVPKeyPointer NewRawPrivate(int id,
819822
const Buffer<const unsigned char>& data);
823+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
824+
static EVPKeyPointer NewRawSeed(int id,
825+
const Buffer<const unsigned char>& data);
826+
#endif
820827
static EVPKeyPointer NewDH(DHPointer&& dh);
821828
static EVPKeyPointer NewRSA(RSAPointer&& rsa);
822829

@@ -910,6 +917,10 @@ class EVPKeyPointer final {
910917
DataPointer rawPrivateKey() const;
911918
BIOPointer derPublicKey() const;
912919

920+
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
921+
DataPointer rawSeed() const;
922+
#endif
923+
913924
Result<BIOPointer, bool> writePrivateKey(
914925
const PrivateKeyEncodingConfig& config) const;
915926
Result<BIOPointer, bool> writePublicKey(

0 commit comments

Comments
 (0)