2016-10-11 08:31:54 +00:00
|
|
|
diff -up openssl-1.1.0-pre5/crypto/rsa/rsa_gen.c.cc-reqs openssl-1.1.0-pre5/crypto/rsa/rsa_gen.c
|
|
|
|
--- openssl-1.1.0-pre5/crypto/rsa/rsa_gen.c.cc-reqs 2016-04-19 16:57:54.000000000 +0200
|
|
|
|
+++ openssl-1.1.0-pre5/crypto/rsa/rsa_gen.c 2016-07-20 17:01:49.929695542 +0200
|
|
|
|
@@ -123,6 +123,12 @@ static int rsa_builtin_keygen(RSA *rsa,
|
|
|
|
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;
|
|
|
|
+
|
|
|
|
BN_copy(rsa->e, e_value);
|
|
|
|
|
|
|
|
/* generate p and q */
|
2016-10-11 08:31:54 +00:00
|
|
|
@@ -150,7 +156,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;
|
|
|
|
- } while ((BN_cmp(rsa->p, rsa->q) == 0) && (++degenerate < 3));
|
|
|
|
+ if (!BN_sub(r2, rsa->q, rsa->p))
|
|
|
|
+ goto err;
|
|
|
|
+ } while ((BN_ucmp(r2, r3) <= 0) && (++degenerate < 3));
|
|
|
|
if (degenerate == 3) {
|
|
|
|
ok = 0; /* we set our own err */
|
|
|
|
RSAerr(RSA_F_RSA_BUILTIN_KEYGEN, RSA_R_KEY_SIZE_TOO_SMALL);
|