mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: use FIPS-compatible PBKDF2 inputs
Fixes: https://github.com/nodejs/node/issues/67673 Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: https://github.com/nodejs/node/pull/67675 Reviewed-By: René <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
This commit is contained in:
1 parent
06250cba58
commit
93078b41d3
1 file changed
+4
-2
@@ -8,6 +8,8 @@ if (!common.hasCrypto) { common.skip('missing crypto'); }
|
||||
// waiting for a GC that the main thread no longer performs.
|
||||
|
||||
const { pbkdf2, pbkdf2Sync } = require('crypto');
|
||||
const password = 'top secret';
|
||||
const salt = '0123456789abcdef';
|
||||
|
||||
// A small live set keeps the old generation limit low.
|
||||
const keep = [];
|
||||
@@ -16,7 +18,7 @@ for (let i = 0; i < 1e5; i++) keep.push({ i });
|
||||
// Pick an iteration count that keeps the threadpool busy for about a second.
|
||||
const probeIterations = 2e5;
|
||||
const start = process.hrtime.bigint();
|
||||
pbkdf2Sync('a', 'b', probeIterations, 64, 'sha512');
|
||||
pbkdf2Sync(password, salt, probeIterations, 64, 'sha512');
|
||||
const nsPerIteration = Number(process.hrtime.bigint() - start) /
|
||||
probeIterations;
|
||||
const iterations = Math.ceil(1e9 / nsPerIteration);
|
||||
@@ -24,7 +26,7 @@ const iterations = Math.ceil(1e9 / nsPerIteration);
|
||||
setTimeout(() => {
|
||||
// uv_library_shutdown() waits for this job, so the main thread stays out of
|
||||
// JS and cannot serve the GC that the stress allocation task asks for.
|
||||
pbkdf2('a', 'b', iterations, 64, 'sha512', () => {});
|
||||
pbkdf2(password, salt, iterations, 64, 'sha512', () => {});
|
||||
// Use up the old generation budget, so that the next background allocation
|
||||
// fails and parks that task in CollectionBarrier.
|
||||
for (let i = 0; i < 40; i++) new Array(1e5).fill(i);
|
||||
|
||||
Reference in new issue
Block a user