Skip to content

Commit 33596f6

Browse files
committed
[Tests] node 17+ requires a DH key length of >= 512
1 parent 1179f7c commit 33596f6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

test/node/dh.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var test = require('tape');
44
var cryptoB = require('../../');
55
var crypto = require('crypto');
6+
var semverSatisfies = require('semver/functions/satisfies');
67

78
test('diffie-hellman mod groups', function (t) {
89
[
@@ -39,11 +40,12 @@ test('diffie-hellman key lengths', function (t) {
3940
[
4041
64,
4142
65,
42-
192
43+
192,
44+
512,
45+
1024
4346
].forEach(function (len) {
44-
t.test(String(len), function (st) {
45-
st.plan(3);
46-
47+
var modulusTooSmall = semverSatisfies(process.version, '>= 17') && len < 512;
48+
t.test(String(len), { skip: modulusTooSmall && 'node 17+ requires a length >= 512' }, function (st) {
4749
var dh2 = cryptoB.createDiffieHellman(len);
4850
var prime2 = dh2.getPrime();
4951
var p2 = prime2.toString('hex');
@@ -60,6 +62,8 @@ test('diffie-hellman key lengths', function (t) {
6062
var pub1 = dh1.computeSecret(pubk2).toString('hex');
6163
var pub2 = dh2.computeSecret(dh1.getPublicKey()).toString('hex');
6264
st.equals(pub1, pub2, 'equal secrets');
65+
66+
st.end();
6367
});
6468
});
6569
});

0 commit comments

Comments
 (0)