Skip to content

Commit c11c7be

Browse files
crypto: forbid passing Float16Array to getRandomValues()
PR-URL: #57880 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent e61937b commit c11c7be

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

lib/internal/crypto/random.js

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const {
5757
isArrayBufferView,
5858
isAnyArrayBuffer,
5959
isTypedArray,
60+
isFloat16Array,
6061
isFloat32Array,
6162
isFloat64Array,
6263
} = require('internal/util/types');
@@ -315,6 +316,7 @@ function onJobDone(buf, callback, error) {
315316
// be an integer-type TypedArray.
316317
function getRandomValues(data) {
317318
if (!isTypedArray(data) ||
319+
isFloat16Array(data) ||
318320
isFloat32Array(data) ||
319321
isFloat64Array(data)) {
320322
// Ordinarily this would be an ERR_INVALID_ARG_TYPE. However,

test/wpt/status/WebCryptoAPI.cjs

-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,6 @@ module.exports = {
1111
'historical.any.js': {
1212
'skip': 'Not relevant in Node.js context',
1313
},
14-
'getRandomValues.any.js': {
15-
'fail': {
16-
'note': 'Node.js does not support Float16Array',
17-
'expected': [
18-
'Float16 arrays',
19-
],
20-
},
21-
},
2214
'sign_verify/eddsa_small_order_points.https.any.js': {
2315
'fail': {
2416
'note': 'see https://github.com/nodejs/node/issues/54572',

test/wpt/test-webcrypto.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Flags: --js-float16array
2+
// TODO(LiviaMedeiros): once `Float16Array` is unflagged in v8, remove the line above
13
'use strict';
24

35
const common = require('../common');

0 commit comments

Comments
 (0)