Skip to content

Commit 1baf50c

Browse files
committed
crypto: remove incorrect constructor invocation
1 parent 1811396 commit 1baf50c

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/internal/crypto/ec.js

+1-1
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)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
8+
const assert = require('assert');
9+
const crypto = require('crypto').webcrypto;
10+
11+
12+
async function generateKey() {
13+
const { privateKey } = await crypto.subtle.generateKey(
14+
{
15+
name: 'NODE-ED25519',
16+
namedCurve: 'NODE-ED25519'
17+
},
18+
true,
19+
['sign', 'verify']
20+
);
21+
const signature = await crypto.subtle.sign(
22+
{
23+
name: 'NODE-ED25519',
24+
hash: 'SHA-256'
25+
},
26+
privateKey,
27+
'-'
28+
);
29+
return signature;
30+
}
31+
32+
generateKey().catch(common.mustCall((err) => {
33+
assert.strictEqual(err.name, 'DOMException');
34+
assert.strictEqual(err.message, 'Hash is not permitted for NODE-ED25519');
35+
assert.ok(err instanceof DOMException);
36+
}))

0 commit comments

Comments
 (0)