diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js index 0fba4e9108c..031bb9a3669 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 faf7aef01a1..6c8f36a62ec 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()); +}