forked from pool/openssl-1_1
d99d49a007
- Update to 1.1.0h OpenSSL Security Advisory [27 Mar 2018] * Constructed ASN.1 types with a recursive definition could exceed the stack (CVE-2018-0739) (bsc#1087102) * rsaz_1024_mul_avx2 overflow bug on x86_64 (CVE-2017-3738) (bsc#1071906) - refresh patches: * 0001-Axe-builtin-printf-implementation-use-glibc-instead.patch * openssl-1.1.0-fips.patch * openssl-pkgconfig.patch * openssl-rsakeygen-minimum-distance.patch * openssl-static-deps.patch OBS-URL: https://build.opensuse.org/request/show/591684 OBS-URL: https://build.opensuse.org/package/show/security:tls/openssl-1_1?expand=0&rev=7
48 lines
1.7 KiB
Diff
48 lines
1.7 KiB
Diff
Index: openssl-1.1.0h/crypto/rsa/rsa_gen.c
|
|
===================================================================
|
|
--- openssl-1.1.0h.orig/crypto/rsa/rsa_gen.c 2018-03-27 16:34:44.709128590 +0200
|
|
+++ openssl-1.1.0h/crypto/rsa/rsa_gen.c 2018-03-27 16:34:44.753129312 +0200
|
|
@@ -420,6 +420,19 @@ static int rsa_builtin_keygen(RSA *rsa,
|
|
bitsp = (bits + 1) / 2;
|
|
bitsq = bits - bitsp;
|
|
|
|
+ /* prepare a maximum for p and q */
|
|
+ /* 0xB504F334 is (sqrt(2)/2)*2^32 */
|
|
+ if (!BN_set_word(r0, 0xB504F334))
|
|
+ goto err;
|
|
+ if (!BN_lshift(r0, r0, bitsp - 32))
|
|
+ goto err;
|
|
+
|
|
+ /* prepare minimum p and q difference */
|
|
+ if (!BN_one(r3))
|
|
+ goto err;
|
|
+ if (!BN_lshift(r3, r3, bitsp - 100))
|
|
+ goto err;
|
|
+
|
|
/* We need the RSA components non-NULL */
|
|
if (!rsa->n && ((rsa->n = BN_new()) == NULL))
|
|
goto err;
|
|
@@ -446,6 +459,8 @@ static int rsa_builtin_keygen(RSA *rsa,
|
|
for (;;) {
|
|
if (!BN_generate_prime_ex(rsa->p, bitsp, 0, NULL, NULL, cb))
|
|
goto err;
|
|
+ if (BN_cmp(rsa->p, r0) < 0)
|
|
+ continue;
|
|
if (!BN_sub(r2, rsa->p, BN_value_one()))
|
|
goto err;
|
|
ERR_set_mark();
|
|
@@ -471,6 +486,13 @@ static int rsa_builtin_keygen(RSA *rsa,
|
|
if (!BN_generate_prime_ex(rsa->q, bitsq, 0, NULL, NULL, cb))
|
|
goto err;
|
|
} while (BN_cmp(rsa->p, rsa->q) == 0);
|
|
+ if (BN_cmp(rsa->q, r0) < 0)
|
|
+ continue;
|
|
+ /* check for minimum distance between p and q, 2^(bitsp-100) */
|
|
+ if (!BN_sub(r2, rsa->q, rsa->p))
|
|
+ goto err;
|
|
+ if (BN_ucmp(r2, r3) <= 0)
|
|
+ continue;
|
|
if (!BN_sub(r2, rsa->q, BN_value_one()))
|
|
goto err;
|
|
ERR_set_mark();
|