Skip to content

Commit

Permalink
Dont require CRT params on ossl_rsa_set0_all_params
Browse files Browse the repository at this point in the history
Its not required that crt params be available in an RSA key, so don't
perform an error check on them

Fixes #29135

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #22334)

(cherry picked from commit 2647726)
  • Loading branch information
nhorman authored and t8m committed Oct 18, 2023
1 parent cdfc6d4 commit cfd5b05
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crypto/rsa/rsa_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,18 +753,22 @@ int ossl_rsa_set0_all_params(RSA *r, const STACK_OF(BIGNUM) *primes,
return 0;

pnum = sk_BIGNUM_num(primes);
if (pnum < 2
|| pnum != sk_BIGNUM_num(exps)
|| pnum != sk_BIGNUM_num(coeffs) + 1)
if (pnum < 2)
return 0;

if (!RSA_set0_factors(r, sk_BIGNUM_value(primes, 0),
sk_BIGNUM_value(primes, 1))
|| !RSA_set0_crt_params(r, sk_BIGNUM_value(exps, 0),
sk_BIGNUM_value(exps, 1),
sk_BIGNUM_value(coeffs, 0)))
sk_BIGNUM_value(primes, 1)))
return 0;

if (pnum == sk_BIGNUM_num(exps)
&& pnum == sk_BIGNUM_num(coeffs) + 1) {

if (!RSA_set0_crt_params(r, sk_BIGNUM_value(exps, 0),
sk_BIGNUM_value(exps, 1),
sk_BIGNUM_value(coeffs, 0)))
return 0;
}

#ifndef FIPS_MODULE
old_infos = r->prime_infos;
#endif
Expand Down

0 comments on commit cfd5b05

Please sign in to comment.