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 a8926d1

Browse filesBrowse files
gcdanielleadams
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 5f3f3a5 commit a8926d1
Copy full SHA for a8926d1

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+55
-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
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --expose-internals
12
'use strict';
23

34
const common = require('../common');
@@ -11,6 +12,9 @@ const {
1112
webcrypto: { subtle }
1213
} = require('crypto');
1314

15+
const { internalBinding } = require('internal/test/binding');
16+
const { DOMException } = internalBinding('messaging');
17+
1418
async function generateKey(namedCurve) {
1519
return subtle.generateKey(
1620
{
@@ -429,3 +433,53 @@ assert.rejects(
429433
}
430434
}
431435
}
436+
437+
{
438+
// See: https://github.com/nodejs/node/pull/40300
439+
for (const namedCurve of ['NODE-ED25519', 'NODE-ED448']) {
440+
assert.rejects(
441+
(async () => {
442+
const { privateKey } = await generateKey(namedCurve);
443+
return subtle.sign(
444+
{
445+
name: namedCurve,
446+
hash: 'SHA-256'
447+
},
448+
privateKey,
449+
Buffer.from('abc')
450+
);
451+
})(),
452+
(err) => {
453+
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
454+
assert(err instanceof DOMException);
455+
return true;
456+
}).then(common.mustCall());
457+
458+
assert.rejects(
459+
(async () => {
460+
const { publicKey, privateKey } = await generateKey(namedCurve);
461+
const signature = await subtle.sign(
462+
{
463+
name: namedCurve,
464+
},
465+
privateKey,
466+
Buffer.from('abc')
467+
).catch(common.mustNotCall());
468+
469+
return subtle.verify(
470+
{
471+
name: namedCurve,
472+
hash: 'SHA-256',
473+
},
474+
publicKey,
475+
signature,
476+
Buffer.from('abc')
477+
);
478+
})(),
479+
(err) => {
480+
assert.strictEqual(err.message, `Hash is not permitted for ${namedCurve}`);
481+
assert(err instanceof DOMException);
482+
return true;
483+
}).then(common.mustCall());
484+
}
485+
}

0 commit comments

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