2018-03-29 13:44:09 +00:00
|
|
|
diff -up openssl-1.1.0h/crypto/rsa/rsa_gen.c.cc-reqs openssl-1.1.0h/crypto/rsa/rsa_gen.c
|
|
|
|
--- openssl-1.1.0h/crypto/rsa/rsa_gen.c.cc-reqs 2018-03-27 15:50:39.000000000 +0200
|
|
|
|
+++ openssl-1.1.0h/crypto/rsa/rsa_gen.c 2018-03-29 14:37:53.405048562 +0200
|
|
|
|
@@ -86,6 +86,12 @@ static int rsa_builtin_keygen(RSA *rsa,
|
2016-10-11 08:31:54 +00:00
|
|
|
if (!rsa->iqmp && ((rsa->iqmp = BN_secure_new()) == NULL))
|
2015-04-23 11:57:26 +00:00
|
|
|
goto err;
|
|
|
|
|
|
|
|
+ /* prepare minimum p and q difference */
|
|
|
|
+ if (!BN_one(r3))
|
|
|
|
+ goto err;
|
|
|
|
+ if (bitsp > 100 && !BN_lshift(r3, r3, bitsp - 100))
|
|
|
|
+ goto err;
|
|
|
|
+
|
2017-01-26 15:24:24 +00:00
|
|
|
if (BN_copy(rsa->e, e_value) == NULL)
|
|
|
|
goto err;
|
2015-04-23 11:57:26 +00:00
|
|
|
|
2018-03-29 13:44:09 +00:00
|
|
|
@@ -118,7 +124,9 @@ static int rsa_builtin_keygen(RSA *rsa,
|
2015-04-23 11:57:26 +00:00
|
|
|
do {
|
|
|
|
if (!BN_generate_prime_ex(rsa->q, bitsq, 0, NULL, NULL, cb))
|
|
|
|
goto err;
|
2017-06-02 13:32:15 +00:00
|
|
|
- } while (BN_cmp(rsa->p, rsa->q) == 0);
|
2015-04-23 11:57:26 +00:00
|
|
|
+ if (!BN_sub(r2, rsa->q, rsa->p))
|
|
|
|
+ goto err;
|
2017-06-02 13:32:15 +00:00
|
|
|
+ } while (BN_ucmp(r2, r3) <= 0);
|
|
|
|
if (!BN_sub(r2, rsa->q, BN_value_one()))
|
|
|
|
goto err;
|
2018-03-29 13:44:09 +00:00
|
|
|
ERR_set_mark();
|