Skip to content

Commit

Permalink
Don't (re-)initialize the FFC_PARAMs in dh_init and dsa_init
Browse files Browse the repository at this point in the history
The initialization was introduced in commit dc8de3e and
changes the behaviour of the `init` method for DSA and DH
between 1.1.1 and 3.0, while the behaviour for RSA and EC_KEY
remains unchanged.

The initialization is not necessary in 3.x and master imho and
breaks the use-case of intercepting the methods of an existing
key.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #22185)

(cherry picked from commit 706512e)
  • Loading branch information
mspncp authored and t8m committed Oct 4, 2023
1 parent d40ccbc commit 16546f4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion crypto/dh/dh_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ static int dh_bn_mod_exp(const DH *dh, BIGNUM *r,
static int dh_init(DH *dh)
{
dh->flags |= DH_FLAG_CACHE_MONT_P;
ossl_ffc_params_init(&dh->params);
dh->dirty_cnt++;
return 1;
}
Expand Down
2 changes: 2 additions & 0 deletions crypto/dh/dh_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ static DH *dh_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
goto err;
#endif /* FIPS_MODULE */

ossl_ffc_params_init(&ret->params);

if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
ERR_raise(ERR_LIB_DH, ERR_R_INIT_FAIL);
goto err;
Expand Down
2 changes: 2 additions & 0 deletions crypto/dsa/dsa_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ static DSA *dsa_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
goto err;
#endif

ossl_ffc_params_init(&ret->params);

if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
ERR_raise(ERR_LIB_DSA, ERR_R_INIT_FAIL);
goto err;
Expand Down
1 change: 0 additions & 1 deletion crypto/dsa/dsa_ossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len,
static int dsa_init(DSA *dsa)
{
dsa->flags |= DSA_FLAG_CACHE_MONT_P;
ossl_ffc_params_init(&dsa->params);
dsa->dirty_cnt++;
return 1;
}
Expand Down

0 comments on commit 16546f4

Please sign in to comment.