Skip to content

crypto: forbid passing Float16Array to getRandomValues() #57880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/internal/crypto/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const {
isArrayBufferView,
isAnyArrayBuffer,
isTypedArray,
isFloat16Array,
isFloat32Array,
isFloat64Array,
} = require('internal/util/types');
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 0 additions & 8 deletions test/wpt/status/WebCryptoAPI.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions test/wpt/test-webcrypto.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
Loading