Blame SOURCES/openssl-1.0.2k-cc-reqs.patch

7779df
diff -up openssl-1.0.2k/crypto/rsa/rsa_gen.c.cc-reqs openssl-1.0.2k/crypto/rsa/rsa_gen.c
7779df
--- openssl-1.0.2k/crypto/rsa/rsa_gen.c.cc-reqs	2017-02-06 16:42:47.313963001 +0100
7779df
+++ openssl-1.0.2k/crypto/rsa/rsa_gen.c	2017-02-06 16:46:54.453628783 +0100
7779df
@@ -474,6 +474,12 @@ static int rsa_builtin_keygen(RSA *rsa,
7779df
     if (!rsa->iqmp && ((rsa->iqmp = BN_new()) == NULL))
7779df
         goto err;
7779df
 
7779df
+    /* prepare minimum p and q difference */
7779df
+    if (!BN_one(r3))
7779df
+        goto err;
7779df
+    if (bitsp > 100 && !BN_lshift(r3, r3, bitsp - 100))
7779df
+        goto err;
7779df
+
7779df
     if (BN_copy(rsa->e, e_value) == NULL)
7779df
         goto err;
7779df
 
7779df
@@ -502,7 +508,9 @@ static int rsa_builtin_keygen(RSA *rsa,
7779df
         do {
7779df
             if (!BN_generate_prime_ex(rsa->q, bitsq, 0, NULL, NULL, cb))
7779df
                 goto err;
7779df
-        } while ((BN_cmp(rsa->p, rsa->q) == 0) && (++degenerate < 3));
7779df
+            if (!BN_sub(r2, rsa->q, rsa->p))
7779df
+                goto err;
7779df
+        } while ((BN_ucmp(r2, r3) <= 0) && (++degenerate < 3));
7779df
         if (degenerate == 3) {
7779df
             ok = 0;             /* we set our own err */
7779df
             RSAerr(RSA_F_RSA_BUILTIN_KEYGEN, RSA_R_KEY_SIZE_TOO_SMALL);