crypto: clarify require("crypto").getRandomValues is Node.js specific

Refs: https://github.com/nodejs/node/pull/41779
Refs: https://github.com/nodejs/node/pull/41760
PR-URL: https://github.com/nodejs/node/pull/41782
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
Antoine du Hamel 2022-02-22 17:51:50 +01:00 committed by GitHub
parent e8a972a340
commit 470c2845cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -4139,7 +4139,9 @@ added: v17.4.0
* `typedArray` {Buffer|TypedArray|DataView|ArrayBuffer}
* Returns: {Buffer|TypedArray|DataView|ArrayBuffer} Returns `typedArray`.
A convenient alias for [`crypto.webcrypto.getRandomValues()`][].
A convenient alias for [`crypto.webcrypto.getRandomValues()`][]. This
implementation is not compliant with the Web Crypto spec, to write
web-compatible code use [`crypto.webcrypto.getRandomValues()`][] instead.
### `crypto.hkdf(digest, ikm, salt, info, keylen, callback)`

View File

@ -252,6 +252,10 @@ function getFipsForced() {
return 1;
}
function getRandomValues(array) {
return lazyWebCrypto().crypto.getRandomValues(array);
}
ObjectDefineProperty(constants, 'defaultCipherList', {
value: getOptionValue('--tls-cipher-list')
});
@ -303,7 +307,7 @@ ObjectDefineProperties(module.exports, {
getRandomValues: {
configurable: false,
enumerable: true,
get() { return lazyWebCrypto().crypto.getRandomValues; },
get: () => getRandomValues,
set: undefined,
},