crypto: forbid passing Float16Array to getRandomValues()

PR-URL: https://github.com/nodejs/node/pull/57880
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Livia Medeiros 2025-04-17 16:26:53 +09:00 committed by GitHub
parent e61937b82c
commit c11c7be36e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 8 deletions

View File

@ -57,6 +57,7 @@ const {
isArrayBufferView,
isAnyArrayBuffer,
isTypedArray,
isFloat16Array,
isFloat32Array,
isFloat64Array,
} = require('internal/util/types');
@ -315,6 +316,7 @@ function onJobDone(buf, callback, error) {
// be an integer-type TypedArray.
function getRandomValues(data) {
if (!isTypedArray(data) ||
isFloat16Array(data) ||
isFloat32Array(data) ||
isFloat64Array(data)) {
// Ordinarily this would be an ERR_INVALID_ARG_TYPE. However,

View File

@ -11,14 +11,6 @@ module.exports = {
'historical.any.js': {
'skip': 'Not relevant in Node.js context',
},
'getRandomValues.any.js': {
'fail': {
'note': 'Node.js does not support Float16Array',
'expected': [
'Float16 arrays',
],
},
},
'sign_verify/eddsa_small_order_points.https.any.js': {
'fail': {
'note': 'see https://github.com/nodejs/node/issues/54572',

View File

@ -1,3 +1,5 @@
// Flags: --js-float16array
// TODO(LiviaMedeiros): once `Float16Array` is unflagged in v8, remove the line above
'use strict';
const common = require('../common');