1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5 6const assert = require('assert'); 7const crypto = require('crypto'); 8 9const size = common.hasFipsCrypto || common.hasOpenSSL3 ? 1024 : 256; 10const dh1 = crypto.createDiffieHellman(size); 11const p1 = dh1.getPrime('buffer'); 12 13{ 14 const DiffieHellman = crypto.DiffieHellman; 15 16 const dh = DiffieHellman(p1, 'buffer'); 17 assert(dh instanceof DiffieHellman, 'DiffieHellman is expected to return a ' + 18 'new instance when called without `new`'); 19} 20 21{ 22 const DiffieHellmanGroup = crypto.DiffieHellmanGroup; 23 const dhg = DiffieHellmanGroup('modp5'); 24 assert(dhg instanceof DiffieHellmanGroup, 'DiffieHellmanGroup is expected ' + 25 'to return a new instance when ' + 26 'called without `new`'); 27} 28 29{ 30 const ECDH = crypto.ECDH; 31 const ecdh = ECDH('prime256v1'); 32 assert(ecdh instanceof ECDH, 'ECDH is expected to return a new instance ' + 33 'when called without `new`'); 34} 35