forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-crypto-dh-constructor.js
More file actions
34 lines (28 loc) · 1.1 KB
/
test-crypto-dh-constructor.js
File metadata and controls
34 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const crypto = require('crypto');
const size = common.hasFipsCrypto || common.hasOpenSSL3 ? 1024 : 256;
const dh1 = crypto.createDiffieHellman(size);
const p1 = dh1.getPrime('buffer');
{
const DiffieHellman = crypto.DiffieHellman;
const dh = DiffieHellman(p1, 'buffer');
assert(dh instanceof DiffieHellman, 'DiffieHellman is expected to return a ' +
'new instance when called without `new`');
}
{
const DiffieHellmanGroup = crypto.DiffieHellmanGroup;
const dhg = DiffieHellmanGroup('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`');
}