File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 3
3
var test = require ( 'tape' ) ;
4
4
var cryptoB = require ( '../../' ) ;
5
5
var crypto = require ( 'crypto' ) ;
6
+ var semverSatisfies = require ( 'semver/functions/satisfies' ) ;
6
7
7
8
test ( 'diffie-hellman mod groups' , function ( t ) {
8
9
[
@@ -39,11 +40,12 @@ test('diffie-hellman key lengths', function (t) {
39
40
[
40
41
64 ,
41
42
65 ,
42
- 192
43
+ 192 ,
44
+ 512 ,
45
+ 1024
43
46
] . 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 ) {
47
49
var dh2 = cryptoB . createDiffieHellman ( len ) ;
48
50
var prime2 = dh2 . getPrime ( ) ;
49
51
var p2 = prime2 . toString ( 'hex' ) ;
@@ -60,6 +62,8 @@ test('diffie-hellman key lengths', function (t) {
60
62
var pub1 = dh1 . computeSecret ( pubk2 ) . toString ( 'hex' ) ;
61
63
var pub2 = dh2 . computeSecret ( dh1 . getPublicKey ( ) ) . toString ( 'hex' ) ;
62
64
st . equals ( pub1 , pub2 , 'equal secrets' ) ;
65
+
66
+ st . end ( ) ;
63
67
} ) ;
64
68
} ) ;
65
69
} ) ;
You can’t perform that action at this time.
0 commit comments