summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/crypto.js7
-rw-r--r--lib/internal/crypto/diffiehellman.js3
-rw-r--r--test/parallel/test-crypto-classes.js1
3 files changed, 6 insertions, 5 deletions
diff --git a/lib/crypto.js b/lib/crypto.js
index 1c8c6b36fb..eb797b86ee 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -79,10 +79,6 @@ const {
} = require('internal/crypto/util');
const Certificate = require('internal/crypto/certificate');
-function createECDH(curve) {
- return new ECDH(curve);
-}
-
module.exports = exports = {
// Methods
_toBuf: toBuf,
@@ -92,7 +88,7 @@ module.exports = exports = {
createDecipheriv: Decipheriv,
createDiffieHellman: DiffieHellman,
createDiffieHellmanGroup: DiffieHellmanGroup,
- createECDH,
+ createECDH: ECDH,
createHash: Hash,
createHmac: Hmac,
createSign: Sign,
@@ -124,6 +120,7 @@ module.exports = exports = {
Decipheriv,
DiffieHellman,
DiffieHellmanGroup,
+ ECDH,
Hash,
Hmac,
Sign,
diff --git a/lib/internal/crypto/diffiehellman.js b/lib/internal/crypto/diffiehellman.js
index b891a0b354..71fd13819c 100644
--- a/lib/internal/crypto/diffiehellman.js
+++ b/lib/internal/crypto/diffiehellman.js
@@ -168,6 +168,9 @@ DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
function ECDH(curve) {
+ if (!(this instanceof ECDH))
+ return new ECDH(curve);
+
if (typeof curve !== 'string')
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'curve', 'string');
diff --git a/test/parallel/test-crypto-classes.js b/test/parallel/test-crypto-classes.js
index ed6bfd76c1..3923cb0dc7 100644
--- a/test/parallel/test-crypto-classes.js
+++ b/test/parallel/test-crypto-classes.js
@@ -18,6 +18,7 @@ const TEST_CASES = {
'Verify': ['RSA-SHA1'],
'DiffieHellman': [1024],
'DiffieHellmanGroup': ['modp5'],
+ 'ECDH': ['prime256v1'],
'Credentials': []
};