crypto: remove incorrect constructor invocation

PR-URL: https://github.com/nodejs/node/pull/40300
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
gc authored and Filip Skokan committed 2021-10-05 20:51:54 +02:00
1 parent 0d2b6aca60
commit 28f711b552
2 files changed
+51 -1

No files matched your search

+1 -1
View File
@@ -482,7 +482,7 @@ function ecdsaSignVerify(key, data, { name, hash }, signature) {
// Fall through
case 'NODE-ED448':
if (hash !== undefined)
throw new lazyDOMException(`Hash is not permitted for ${name}`);
throw lazyDOMException(`Hash is not permitted for ${name}`);
break;
default:
if (hash === undefined)
@@ -429,3 +429,53 @@ assert.rejects(
}
}
}
{
// See: https://github.com/nodejs/node/pull/40300
for (const namedCurve of ['NODE-ED25519', 'NODE-ED448']) {
assert.rejects(
(async () => {
const { privateKey } = await generateKey(namedCurve);
return subtle.sign(
{
name: namedCurve,
hash: 'SHA-256'
},
privateKey,
Buffer.from('abc')
);
})(),
(err) => {
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
assert(err instanceof DOMException);
return true;
}).then(common.mustCall());
assert.rejects(
(async () => {
const { publicKey, privateKey } = await generateKey(namedCurve);
const signature = await subtle.sign(
{
name: namedCurve,
},
privateKey,
Buffer.from('abc')
).catch(common.mustNotCall());
return subtle.verify(
{
name: namedCurve,
hash: 'SHA-256',
},
publicKey,
signature,
Buffer.from('abc')
);
})(),
(err) => {
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
assert(err instanceof DOMException);
return true;
}).then(common.mustCall());
}
}