Skip to content

Commit 11b4d50

Browse files
panvaaduh95
authored andcommitted
crypto: retain legacy DH validation
Limit the g >= p rejection needed by the provider backend to OpenSSL 3. Preserve the legacy DiffieHellman object and expose the validation result through verifyError as before. Signed-off-by: Filip Skokan <panva.ip@gmail.com> PR-URL: #64547 Refs: #64211 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 6e30204 commit 11b4d50

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/crypto/crypto_dh.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void New(const FunctionCallbackInfo<Value>& args) {
206206
}
207207
}
208208

209-
#ifndef OPENSSL_IS_BORINGSSL
209+
#if NCRYPTO_USE_OPENSSL3_PROVIDER
210210
if (BN_num_bits(bn_p.get()) >= 512 && BN_cmp(bn_g.get(), bn_p.get()) >= 0) {
211211
PutDhError(DH_R_BAD_GENERATOR);
212212
returnThrowCryptoError(env, ERR_get_error(), "Invalid generator");

‎test/parallel/test-crypto-dh-curves.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const { hasOpenSSL } = require('../common/crypto');
99
const{
1010
DH_CHECK_P_NOT_PRIME,
1111
DH_CHECK_P_NOT_SAFE_PRIME,
12+
DH_NOT_SUITABLE_GENERATOR,
1213
}=crypto.constants;
1314

1415
// Second OAKLEY group, see
@@ -76,6 +77,11 @@ if (hasOpenSSL(3)) {
7677
()=>crypto.createDiffieHellman(Buffer.from(p,'hex'),
7778
Buffer.from(p,'hex')),
7879
{code: 'ERR_OSSL_DH_BAD_GENERATOR'});
80+
}elseif(!process.features.openssl_is_boringssl){
81+
assert.strictEqual(
82+
crypto.createDiffieHellman(Buffer.from(p,'hex'),
83+
Buffer.from(p,'hex')).verifyError,
84+
DH_NOT_SUITABLE_GENERATOR);
7985
}
8086

8187
constavailableCurves=newSet(crypto.getCurves());

0 commit comments

Comments
 (0)