crypto: refactor randomBytes()

Use the scrypt() infrastructure to reimplement randomBytes() and
randomFill() in a simpler manner.

PR-URL: https://github.com/nodejs/node/pull/20816
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
This commit is contained in:
Ben Noordhuis 2018-05-18 11:05:20 +02:00
parent c188cc5338
commit 078bb0f0a0
4 changed files with 66 additions and 212 deletions

View file

@ -120,7 +120,7 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check
crypto.pbkdf2('password', 'salt', 1, 20, 'sha256', mc);
crypto.randomBytes(1, common.mustCall(function rb() {
testInitialized(this, 'RandomBytes');
testInitialized(this, 'AsyncWrap');
}));
if (typeof process.binding('crypto').scrypt === 'function') {