From 3dee1d1bb140370e1163e636f6df72e288b6311b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Wed, 4 Mar 2026 11:16:25 +0100 Subject: [PATCH 1/2] crypto: fix importKey required argument count check --- lib/internal/crypto/webcrypto.js | 2 +- test/parallel/test-webcrypto-export-import.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js index 2333919e06a2fe..3ba8e9c63846d2 100644 --- a/lib/internal/crypto/webcrypto.js +++ b/lib/internal/crypto/webcrypto.js @@ -865,7 +865,7 @@ async function importKey( webidl ??= require('internal/crypto/webidl'); const prefix = "Failed to execute 'importKey' on 'SubtleCrypto'"; - webidl.requiredArguments(arguments.length, 4, { prefix }); + webidl.requiredArguments(arguments.length, 5, { prefix }); format = webidl.converters.KeyFormat(format, { prefix, context: '1st argument', diff --git a/test/parallel/test-webcrypto-export-import.js b/test/parallel/test-webcrypto-export-import.js index faf7aef01a1844..6c8f36a62eccb3 100644 --- a/test/parallel/test-webcrypto-export-import.js +++ b/test/parallel/test-webcrypto-export-import.js @@ -435,3 +435,11 @@ if (!process.features.openssl_is_boringssl) { subtle.importKey('jwk', jwk, { name: 'HMAC', hash: 'SHA3-256' }, false, ['sign', 'verify']).then(common.mustCall()); } } + +{ + const keyData = new Uint8Array(32); + assert.rejects( + subtle.importKey('raw', keyData, { name: 'HMAC', hash: 'SHA-256' }, false), + { code: 'ERR_MISSING_ARGS' } + ).then(common.mustCall()); +} From 9c5bf319ca8c9092a5cf42440fd47caf5fa81f8b Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Wed, 4 Mar 2026 11:17:48 +0100 Subject: [PATCH 2/2] crypto: add missing AES dictionaries --- lib/internal/crypto/util.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index a91a60e09c04dd..5ec1d409ec05b9 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -480,6 +480,8 @@ function createSupportedAlgorithms(algorithmDefs) { const kSupportedAlgorithms = createSupportedAlgorithms(kAlgorithmDefinitions); const simpleAlgorithmDictionaries = { + AesCbcParams: { iv: 'BufferSource' }, + AesCtrParams: { counter: 'BufferSource' }, AeadParams: { iv: 'BufferSource', additionalData: 'BufferSource' }, // publicExponent is not strictly a BufferSource but it is a Uint8Array that we normalize // this way