@@ -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 ) ;
@@ -126,8 +124,6 @@ bob.generateKeys();
126
124
const aSecret = alice . computeSecret ( bob . getPublicKey ( ) ) . toString ( 'hex' ) ;
127
125
const bSecret = bob . computeSecret ( alice . getPublicKey ( ) ) . toString ( 'hex' ) ;
128
126
assert . strictEqual ( aSecret , bSecret ) ;
129
- assert . strictEqual ( alice . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
130
- assert . strictEqual ( bob . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
131
127
132
128
/* Ensure specific generator (buffer) works as expected.
133
129
* The values below (modp2/modp2buf) are for a 1024 bits long prime from
@@ -158,8 +154,6 @@ const modp2buf = Buffer.from([
158
154
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
159
155
. toString ( 'hex' ) ;
160
156
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
161
- assert . strictEqual ( modp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
162
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
163
157
}
164
158
165
159
for ( const buf of [ modp2buf , ...common . getArrayBufferViews ( modp2buf ) ] ) {
@@ -172,7 +166,6 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
172
166
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
173
167
. toString ( 'hex' ) ;
174
168
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
175
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
176
169
}
177
170
178
171
{
@@ -184,7 +177,6 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
184
177
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
185
178
. toString ( 'hex' ) ;
186
179
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
187
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
188
180
}
189
181
190
182
{
@@ -196,17 +188,20 @@ for (const buf of [modp2buf, ...common.getArrayBufferViews(modp2buf)]) {
196
188
const exmodp2Secret = exmodp2 . computeSecret ( modp2 . getPublicKey ( ) )
197
189
. toString ( 'hex' ) ;
198
190
assert . strictEqual ( modp2Secret , exmodp2Secret ) ;
199
- assert . strictEqual ( exmodp2 . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
200
191
}
201
192
202
-
193
+ // Second OAKLEY group, see
194
+ // https://github.com/nodejs/node-v0.x-archive/issues/2338 and
195
+ // https://xml2rfc.tools.ietf.org/public/rfc/html/rfc2412.html#anchor49
203
196
const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' +
204
197
'020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' +
205
198
'4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' +
206
199
'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF' ;
207
- const bad_dh = crypto . createDiffieHellman ( p , 'hex' ) ;
208
- assert . strictEqual ( bad_dh . verifyError , DH_NOT_SUITABLE_GENERATOR ) ;
200
+ crypto . createDiffieHellman ( p , 'hex' ) ;
209
201
202
+ // Confirm DH_check() results are exposed for optional examination.
203
+ const bad_dh = crypto . createDiffieHellman ( '02' , 'hex' ) ;
204
+ assert . notStrictEqual ( bad_dh . verifyError , 0 ) ;
210
205
211
206
const availableCurves = new Set ( crypto . getCurves ( ) ) ;
212
207
const availableHashes = new Set ( crypto . getHashes ( ) ) ;
0 commit comments