summaryrefslogtreecommitdiffstats
path: root/crypto/rsa
diff options
context:
space:
mode:
authorslontis <shane.lontis@oracle.com>2022-05-30 10:03:11 +0200
committerTomas Mraz <tomas@openssl.org>2022-06-13 10:56:31 +0200
commit27c1cfd7653b7204af3301f93ccd2a3decfc309b (patch)
tree17a4ccb79fd88d58090d36bd20d963174e70974a /crypto/rsa
parentRSA keygen fixes (diff)
downloadopenssl-27c1cfd7653b7204af3301f93ccd2a3decfc309b.tar.xz
openssl-27c1cfd7653b7204af3301f93ccd2a3decfc309b.zip
RSA Keygen update - When using the default provider fallback to default multiprime keygen if e is < 65537
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/18429)
Diffstat (limited to 'crypto/rsa')
-rw-r--r--crypto/rsa/rsa_gen.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c
index ac64483e6a..4a3387f19e 100644
--- a/crypto/rsa/rsa_gen.c
+++ b/crypto/rsa/rsa_gen.c
@@ -426,20 +426,22 @@ static int rsa_keygen(OSSL_LIB_CTX *libctx, RSA *rsa, int bits, int primes,
{
int ok = 0;
+#ifdef FIPS_MODULE
+ ok = ossl_rsa_sp800_56b_generate_key(rsa, bits, e_value, cb);
+ pairwise_test = 1; /* FIPS MODE needs to always run the pairwise test */
+#else
/*
- * Only multi-prime keys or insecure keys with a small key length will use
- * the older rsa_multiprime_keygen().
+ * Only multi-prime keys or insecure keys with a small key length or a
+ * public exponent <= 2^16 will use the older rsa_multiprime_keygen().
*/
- if (primes == 2 && bits >= 2048)
+ if (primes == 2
+ && bits >= 2048
+ && (e_value == NULL || BN_num_bits(e_value) > 16))
ok = ossl_rsa_sp800_56b_generate_key(rsa, bits, e_value, cb);
-#ifndef FIPS_MODULE
else
ok = rsa_multiprime_keygen(rsa, bits, primes, e_value, cb);
#endif /* FIPS_MODULE */
-#ifdef FIPS_MODULE
- pairwise_test = 1; /* FIPS MODE needs to always run the pairwise test */
-#endif
if (pairwise_test && ok > 0) {
OSSL_CALLBACK *stcb = NULL;
void *stcbarg = NULL;