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 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()); +}