Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 28f711b

Browse filesBrowse files
gcpanva
authored andcommitted
crypto: remove incorrect constructor invocation
PR-URL: #40300 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 0d2b6ac commit 28f711b
Copy full SHA for 28f711b

File tree

Expand file treeCollapse file tree

2 files changed

+51
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+51
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/crypto/ec.js‎

Copy file name to clipboardExpand all lines: lib/internal/crypto/ec.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ function ecdsaSignVerify(key, data, { name, hash }, signature) {
482482
// Fall through
483483
case 'NODE-ED448':
484484
if (hash !== undefined)
485-
throw new lazyDOMException(`Hash is not permitted for ${name}`);
485+
throw lazyDOMException(`Hash is not permitted for ${name}`);
486486
break;
487487
default:
488488
if (hash === undefined)
Collapse file

‎test/parallel/test-webcrypto-ed25519-ed448.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-webcrypto-ed25519-ed448.js
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,53 @@ assert.rejects(
429429
}
430430
}
431431
}
432+
433+
{
434+
// See: https://github.com/nodejs/node/pull/40300
435+
for (const namedCurve of ['NODE-ED25519', 'NODE-ED448']) {
436+
assert.rejects(
437+
(async () => {
438+
const { privateKey } = await generateKey(namedCurve);
439+
return subtle.sign(
440+
{
441+
name: namedCurve,
442+
hash: 'SHA-256'
443+
},
444+
privateKey,
445+
Buffer.from('abc')
446+
);
447+
})(),
448+
(err) => {
449+
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
450+
assert(err instanceof DOMException);
451+
return true;
452+
}).then(common.mustCall());
453+
454+
assert.rejects(
455+
(async () => {
456+
const { publicKey, privateKey } = await generateKey(namedCurve);
457+
const signature = await subtle.sign(
458+
{
459+
name: namedCurve,
460+
},
461+
privateKey,
462+
Buffer.from('abc')
463+
).catch(common.mustNotCall());
464+
465+
return subtle.verify(
466+
{
467+
name: namedCurve,
468+
hash: 'SHA-256',
469+
},
470+
publicKey,
471+
signature,
472+
Buffer.from('abc')
473+
);
474+
})(),
475+
(err) => {
476+
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
477+
assert(err instanceof DOMException);
478+
return true;
479+
}).then(common.mustCall());
480+
}
481+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.