crypto: fix importKey required argument count check

PR-URL: https://github.com/nodejs/node/pull/62099
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Filip Skokan authored and Node.js GitHub Bot committed 2026-03-06 10:39:51 +00:00
1 parent a06e789625
commit 856231e8c4
2 files changed
+9 -1

No files matched your search

+1 -1
View File
@@ -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',
@@ -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());
}