Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
crypto: remove incorrect constructor invocation
  • Loading branch information
gc committed Oct 4, 2021
commit 1baf50cee1c0905df45a8a3400163e80dad4abe0
2 changes: 1 addition & 1 deletion lib/internal/crypto/ec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
36 changes: 36 additions & 0 deletions test/parallel/test-crypto-subtle-hash-constructor-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use strict';

const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const crypto = require('crypto').webcrypto;


async function generateKey() {
const { privateKey } = await crypto.subtle.generateKey(
{
name: 'NODE-ED25519',
namedCurve: 'NODE-ED25519'
},
true,
['sign', 'verify']
);
const signature = await crypto.subtle.sign(
{
name: 'NODE-ED25519',
hash: 'SHA-256'
},
privateKey,
'-'
);
return signature;
}

generateKey().catch(common.mustCall((err) => {
assert.strictEqual(err.name, 'DOMException');
assert.strictEqual(err.message, 'Hash is not permitted for NODE-ED25519');
assert.ok(err instanceof DOMException);
}))