Skip to content
Prev Previous commit
Next Next commit
check getRandomValues argument presence
  • Loading branch information
panva committed Nov 22, 2022
commit 57fe0e3b741b84b20b16a6ae58258b7eb8afdc1d
3 changes: 3 additions & 0 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const { Buffer, kMaxLength } = require('buffer');
const {
codes: {
ERR_INVALID_ARG_TYPE,
ERR_MISSING_ARGS,
ERR_OUT_OF_RANGE,
ERR_OPERATION_FAILED,
}
Expand Down Expand Up @@ -310,6 +311,8 @@ function onJobDone(buf, callback, error) {
// not allowed to exceed 65536 bytes, and can only
// be an integer-type TypedArray.
function getRandomValues(data) {
if (arguments.length < 1)
throw new ERR_MISSING_ARGS('typedArray');
if (!isTypedArray(data) ||
isFloat32Array(data) ||
isFloat64Array(data)) {
Expand Down
1 change: 0 additions & 1 deletion test/wpt/status/WebCryptoAPI.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"idlharness.https.any.js": {
"fail": {
"expected": [
"Crypto interface: calling getRandomValues(ArrayBufferView) on crypto with too few arguments must throw TypeError",
"CryptoKey interface: existence and properties of interface object",
"CryptoKey interface: existence and properties of interface prototype object",
"Window interface: attribute crypto"
Expand Down