Browse Source

rsa_get0_all_params(): Allow zero CRT params

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/10557)
master
Richard Levitte 3 years ago
parent
commit
a9127c1d11
2 changed files with 11 additions and 1 deletions
  1. +7
    -1
      crypto/rsa/rsa_ameth.c
  2. +4
    -0
      crypto/rsa/rsa_lib.c

+ 7
- 1
crypto/rsa/rsa_ameth.c View File

@ -1120,7 +1120,13 @@ static int rsa_pkey_export_to(const EVP_PKEY *from, void *to_keydata,
numexps = sk_BIGNUM_const_num(exps);
numcoeffs = sk_BIGNUM_const_num(coeffs);
if (numprimes < 2 || numexps < 2 || numcoeffs < 1)
/*
* It's permisssible to have zero primes, i.e. no CRT params.
* Otherwise, there must be at least two, as many exponents,
* and one coefficient less.
*/
if (numprimes != 0
&& (numprimes < 2 || numexps < 2 || numcoeffs < 1))
goto err;
/* assert that an OSSL_PARAM_BLD has enough space. */


+ 4
- 0
crypto/rsa/rsa_lib.c View File

@ -780,6 +780,10 @@ int rsa_get0_all_params(RSA *r, STACK_OF(BIGNUM_const) *primes,
if (r == NULL)
return 0;
/* If |p| is NULL, there are no CRT parameters */
if (RSA_get0_p(r) == NULL)
return 1;
sk_BIGNUM_const_push(primes, RSA_get0_p(r));
sk_BIGNUM_const_push(primes, RSA_get0_q(r));
sk_BIGNUM_const_push(exps, RSA_get0_dmp1(r));


Loading…
Cancel
Save