@@ -6,8 +6,6 @@ if (!common.hasCrypto)
6
6
const assert = require ( 'assert' ) ;
7
7
const crypto = require ( 'crypto' ) ;
8
8
9
- const DH_NOT_SUITABLE_GENERATOR = crypto . constants . DH_NOT_SUITABLE_GENERATOR ;
10
-
11
9
// Test Diffie-Hellman with two parties sharing a secret,
12
10
// using various encodings as we go along
13
11
const dh1 = crypto . createDiffieHellman ( common . hasFipsCrypto ? 1024 : 256 ) ;
@@ -121,8 +119,6 @@ bob.generateKeys();
121
119
const aSecret = alice . computeSecret ( bob . getPublicKey ( ) ) . toString ( 'hex' ) ;
122
120
const bSecret = bob . computeSecret ( alice . getPublicKey ( ) ) . toString ( 'hex' ) ;
123
121
assert . strictEqual ( aSecret , bSecret ) ;
124
- assert . strictEqual ( alice . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
125
- assert . strictEqual ( bob . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
126
122
127
123
/* Ensure specific generator (buffer) works as expected.
128
124
* The values below (modp2/modp2buf) are for a 1024 bits long prime from
@@ -153,8 +149,6 @@ const modp2buf = Buffer.from([
153
149
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
154
150
. toString ( 'hex' ) ;
155
151
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
156
- assert . strictEqual ( modp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
157
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
158
152
}
159
153
160
154
for ( const buf of [ modp2buf , ...common . getArrayBufferViews ( modp2buf ) ] ) {
@@ -167,7 +161,6 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
167
161
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
168
162
. toString ( 'hex' ) ;
169
163
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
170
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
171
164
}
172
165
173
166
{
@@ -179,7 +172,6 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
179
172
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
180
173
. toString ( 'hex' ) ;
181
174
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
182
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
183
175
}
184
176
185
177
{
@@ -191,17 +183,20 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
191
183
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
192
184
. toString ( 'hex' ) ;
193
185
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
194
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
195
186
}
196
187
197
-
188
+ // Second OAKLEY group, see
189
+ // https://github.com/nodejs/node-v0.x-archive/issues/2338 and
190
+ // https://xml2rfc.tools.ietf.org/public/rfc/html/rfc2412.html#anchor49
198
191
const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
199
192
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
200
193
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
201
194
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF' ;
202
- const bad_dh = crypto . createDiffieHellman ( p , 'hex' ) ;
203
- assert . strictEqual ( bad_dh . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
195
+ crypto . createDiffieHellman ( p , 'hex' ) ;
204
196
197
+ // Confirm DH_check() results are exposed for optional examination.
198
+ const bad_dh = crypto . createDiffieHellman ( '02' , 'hex' ) ;
199
+ assert . notStrictEqual ( bad_dh . verifyError , 0 ) ;
205
200
206
201
const availableCurves = new Set ( crypto . getCurves ( ) ) ;
207
202
const availableHashes = new Set ( crypto . getHashes ( ) ) ;
0 commit comments