mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Use the modp14 prime instead of generating fresh parameters for tests of constructors, key setters, and memory retention. Keep generic DiffieHellman instances and the existing setter and leak assertions. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/65980 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: LiviaMedeiros <livia@cirno.name>
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
const { hasFIPS } = require('../common/crypto');
|
|
|
|
const prime = crypto.getDiffieHellman('modp14').getPrime('buffer');
|
|
|
|
{
|
|
const DiffieHellman = crypto.DiffieHellman;
|
|
|
|
const dh = DiffieHellman(prime, 'buffer');
|
|
assert(dh instanceof DiffieHellman, 'DiffieHellman is expected to return a ' +
|
|
'new instance when called without `new`');
|
|
}
|
|
|
|
{
|
|
const DiffieHellmanGroup = crypto.DiffieHellmanGroup;
|
|
const dhg = DiffieHellmanGroup(hasFIPS(3) ? 'modp14' : 'modp5');
|
|
assert(dhg instanceof DiffieHellmanGroup, 'DiffieHellmanGroup is expected ' +
|
|
'to return a new instance when ' +
|
|
'called without `new`');
|
|
}
|
|
|
|
{
|
|
const ECDH = crypto.ECDH;
|
|
const ecdh = ECDH('prime256v1');
|
|
assert(ecdh instanceof ECDH, 'ECDH is expected to return a new instance ' +
|
|
'when called without `new`');
|
|
}
|