src: seed V8 from the OS CSPRNG instead of OpenSSL's DRBG by colinhacks · Pull Request #65796 · nodejs/node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions src/node.cc
3 changes: 3 additions & 0 deletions test/addons/openssl-providers/test-legacy-provider-option.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ if (getFips()) {
common.skip('this test cannot be run in FIPS mode');
}
providers.testProviderPresent('legacy');
// The explicit legacy load disables OpenSSL's provider fallback, so the
// default provider has to be active before it runs.
providers.testProviderPresent('default');
7 changes: 7 additions & 0 deletions test/fixtures/openssl3-conf/random_unavailable.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodejs_conf = nodejs_init

[nodejs_init]
random = random_sect

[random_sect]
random = NO-SUCH-DRBG
18 changes: 18 additions & 0 deletions test/parallel/test-crypto-no-algorithm.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,21 @@ if (isMainThread) {
assert(common.nodeProcessAborted(cp.status, cp.signal),
`process did not abort, code:${cp.status} signal:${cp.signal}`);
}

// AIX keeps OpenSSL as V8's entropy source, so a DRBG that cannot be
// fetched still aborts at startup there.
if (!common.isAIX) {
// A configuration whose random section names a DRBG that cannot be
// fetched starts normally; the first crypto call fails, without a hang.
const fixtures = require('../common/fixtures');
const { spawnSync } = require('node:child_process');
const randomConf = fixtures.path('openssl3-conf', 'random_unavailable.cnf');
const cp = spawnSync(process.execPath,
[ `--openssl-config=${randomConf}`, '-e',
'require("node:crypto").randomBytes(8)' ],
{ encoding: 'utf8' });
assert(!common.nodeProcessAborted(cp.status, cp.signal),
`process aborted, code:${cp.status} signal:${cp.signal}`);
assert.strictEqual(cp.status, 1);
assert.match(cp.stderr, /unable to fetch drbg/);
}
35 changes: 35 additions & 0 deletions test/parallel/test-crypto-secure-heap.js
Loading