Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: dev-libs/openssl/, dev-libs/openssl/files/
Date: Mon, 19 Nov 2018 14:53:40
Message-Id: 1542639206.0d6773f8e9422113d42c128b659b273775cee6c8.grobian@gentoo
1 commit: 0d6773f8e9422113d42c128b659b273775cee6c8
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 19 14:53:26 2018 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 19 14:53:26 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=0d6773f8
7
8 dev-libs/openssl: sync
9
10 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
11 Package-Manager: Portage-2.3.40.3-prefix, Repoman-2.3.9
12
13 dev-libs/openssl/Manifest | 18 +--
14 .../files/openssl-1.1.0i-CVE-2018-0734.patch | 131 +++++++++++++++++++++
15 .../files/openssl-1.1.0i-CVE-2018-0735.patch | 44 +++++++
16 .../files/openssl-1.1.1-CVE-2018-0734.patch | 131 +++++++++++++++++++++
17 .../files/openssl-1.1.1-CVE-2018-0735.patch | 44 +++++++
18 ...l-1.0.2o-r6.ebuild => openssl-1.0.2p-r1.ebuild} | 39 +++---
19 ...l-1.1.0h-r2.ebuild => openssl-1.1.0i-r3.ebuild} | 12 +-
20 7 files changed, 389 insertions(+), 30 deletions(-)
21
22 diff --git a/dev-libs/openssl/Manifest b/dev-libs/openssl/Manifest
23 index 9bd5105d08..e5ab2701a9 100644
24 --- a/dev-libs/openssl/Manifest
25 +++ b/dev-libs/openssl/Manifest
26 @@ -1,11 +1,11 @@
27 -DIST openssl-1.0.2-patches-1.4.tar.xz 12864 BLAKE2B ace6a782ef97b61af44988f978d089adffb06894617f9d66d3fce664c04d360b2774e1dd38c2171151fa93fe92428d405674bc2d452d520f10da426f95d09aee SHA512 d152af2841f1bf11c7f2a5ebba9a2b903fb4bcdef0468c56af0f9cc8c020adbf4490ac1a62f5bae8cbe18e379934fa997bfda1c2d49ec62365c07a0c0515a72d
28 -DIST openssl-1.0.2o.tar.gz 5329472 BLAKE2B 30226db49be04317da3a76cce68d5aa401decd198f92505bddb0c72a7ef6a79f3c9c06d4a816db734e2a0991ebcab8b207feced26d83639e50c821d9e76ddc45 SHA512 8a2c93657c85143e76785bb32ee836908c31a6f5f8db993fa9777acba6079e630cdddd03edbad65d1587199fc13a1507789eacf038b56eb99139c2091d9df7fd
29 -DIST openssl-1.0.2o_ec_curve.c 17254 BLAKE2B d40d8d6e770443f07abe70e2c4ddda6aec1cc8e37dc1f226a3fdd9ed5d228f09c6d372e8956b1948b55ee1d57d1429493e7288d0f54d9466a37fec805c85aacb SHA512 8e92fb100bcf4bd918c82b9a6cbd75a55abe1a2c08230a007e441c51577f974f8cc336e9ac8a672b32641480428ca8cead5380da1fe81bacb088145a1b754a15
30 -DIST openssl-1.0.2o_ectest.c 30735 BLAKE2B 95333a27f1cf0a4305a3cee7f6d46b9d4673582ca9acfcf5ba2a0d9d317ab6219cd0d2ff0ba3a55a317c8f5819342f05cc17ba80ec2c92b2b4cab9a3552382e1 SHA512 f2e4d34327b490bc8371f0845c69df3f9fc51ea16f0ea0de0411a0c1fa9d49bb2b6fafc363eb3b3cd919dc7c24e4a0d075c6ff878c01d70dae918f2540874c19
31 -DIST openssl-1.0.2o_hobble-openssl 1302 BLAKE2B 647caa6a0f4c53a2e77baa3b8e5961eaef3bb0ff38e7d5475eab8deef3439f7fe49028ec9ed0406f3453870b62cac67c496b3a048ee4c9ff4c6866d520235960 SHA512 3d757a4708e74a03dd5cb9b8114dfe442ed9520739a6eca693be4c4265771696f1449ea06d1c9bcfc6e94fc9b0dd0c10e153f1c3b0334831c0550b36cd63326e
32 +DIST openssl-1.0.2-patches-1.6.tar.xz 16004 BLAKE2B 28c7e9a8c8b09a34aa6ed21dec18b04c1d6140276e319cfa99b63db5ae188ca7837c444e8352748ffc86e6df7676534aef2f28788e825ee8207c0f876efb5b7b SHA512 eac9bbbebd8d942707ef385ee466929045bb4698985f7a0fb16f529f2101a246735cc2e654bfbdaa8a178224bb5ac564478a7587e6156cfcbdfe62a719bfb0a3
33 +DIST openssl-1.0.2p.tar.gz 5338192 BLAKE2B fe4c0e2bf75d47a76e7377c7977be7bcaaa532061ab89ee989786eeb6495295711a29a88bf026c85d9ed55c97e71b0e9c8cf4c29b6e58a3dc56bcff518666823 SHA512 958c5a7c3324bbdc8f07dfb13e11329d9a1b4452c07cf41fbd2d42b5fe29c95679332a3476d24c2dc2b88be16e4a24744aba675a05a388c0905756c77a8a2f16
34 +DIST openssl-1.0.2p_ec_curve.c 17254 BLAKE2B d40d8d6e770443f07abe70e2c4ddda6aec1cc8e37dc1f226a3fdd9ed5d228f09c6d372e8956b1948b55ee1d57d1429493e7288d0f54d9466a37fec805c85aacb SHA512 8e92fb100bcf4bd918c82b9a6cbd75a55abe1a2c08230a007e441c51577f974f8cc336e9ac8a672b32641480428ca8cead5380da1fe81bacb088145a1b754a15
35 +DIST openssl-1.0.2p_ectest.c 30735 BLAKE2B 95333a27f1cf0a4305a3cee7f6d46b9d4673582ca9acfcf5ba2a0d9d317ab6219cd0d2ff0ba3a55a317c8f5819342f05cc17ba80ec2c92b2b4cab9a3552382e1 SHA512 f2e4d34327b490bc8371f0845c69df3f9fc51ea16f0ea0de0411a0c1fa9d49bb2b6fafc363eb3b3cd919dc7c24e4a0d075c6ff878c01d70dae918f2540874c19
36 +DIST openssl-1.0.2p_hobble-openssl 1302 BLAKE2B 647caa6a0f4c53a2e77baa3b8e5961eaef3bb0ff38e7d5475eab8deef3439f7fe49028ec9ed0406f3453870b62cac67c496b3a048ee4c9ff4c6866d520235960 SHA512 3d757a4708e74a03dd5cb9b8114dfe442ed9520739a6eca693be4c4265771696f1449ea06d1c9bcfc6e94fc9b0dd0c10e153f1c3b0334831c0550b36cd63326e
37 DIST openssl-1.1.0-build.patch 3028 BLAKE2B f8cf981ed3717af234ce02fa50f27cdbcbf2b766968a5957fc6f0a4ea997549505fa77398444d7f3b9a75f66048447fe62542b9cb1d5f0268add87c44915a6fd SHA512 b19a912900970052f80c67f28975e793ae9e70ebfc62efae0544e09931079e98c4cd29ce1cc8d937ceca97aff9a12fdc1ff9ce6c2b47fea68c79e7065464a0f0
38 DIST openssl-1.1.0-ec-curves.patch 2967 BLAKE2B 1c639514445ea85cf731732aa7901b5a03ddb5f637b0483ab2ec6825433ad978723c5a07316db684bdaca4a12fc673b4e049a49c0cd4dbe5f25a5e2bd3b75cf5 SHA512 8fb9c6759ae2077ad3697ba77e85ab3970fd8b3f64b21eb260b4f6333b7ebf2f5a53c7eee311229edfbd96a2b904ec5e5e00dfa5b62cf1105fece13069077bd2
39 -DIST openssl-1.1.0h.tar.gz 5422717 BLAKE2B 11de1468855c0bb1836fb346c8efdfedd06139a774fc4dbae1b0e95fea7a33aa39b541e3d2d27f83f2b5f4dd3846cca2356020aa6ec81793085842ab78b3a127 SHA512 fb7750fcd98e6126eb5b92e7ed63d811a5cfa3391d98572003d925f6c7b477690df86a9aa1fa6bf6bf33d02c6c7aee6cff50a38faa8911409f310645898fda39
40 -DIST openssl-1.1.0h_ec_curve.c 18393 BLAKE2B 49dca7ddbc23270e5927454925df7bb18c8d9eb58f79e3a4fbcd8b7fc22fad36e2cb54ff9b63c2beeeea15c0c075a96e4ce8d03991355419af41fa9dc2aed3ad SHA512 ee3e576825bccdf02cede4205ab92c42ae9dd3a8e75ce58617a3a5980a61d144eb3c5197d9dcd378a5d49bf34c4b2f591aa6a619fee92b7a22825d72681ab879
41 -DIST openssl-1.1.0h_ectest.c 29907 BLAKE2B 73dc800c1de5449f14d7753f7f7b8e672cd36bd4570e6df07f246d1d823c7dbbeef492f25cdd0ebfd693f5956732bc84c9d91fc6a22c854fe4b245ecf3890bda SHA512 90cec9d46326cb7216236811c8e963032b6fa7500117cea36f28534eb50a5ab1260c7f9a5c8c490d845236b0769576a8d97bc7471f970e9c5e70cb3408c20dae
42 -DIST openssl-1.1.0h_hobble-openssl 1117 BLAKE2B c3a1477e63331e83cf1cbe58e9ef131ec500a311e22d3da55034800ca353c387b2e202575acf3badb00b236ff91d4bac1bb131a33930939646d26bec27be6e04 SHA512 fa9cc70afa11a7a292548b4bddbba8159824a364ce5c279b483768e6ae2aa4b5491d9bf2cc734819f30a11c8ee0d91bcb991c4a7ab357296aeb4c04feac74826
43 +DIST openssl-1.1.0i.tar.gz 5453234 BLAKE2B ae6bec9c116769d98a77165b96fb7d201fe2ede8ee98e3cb68eba496cc90a5fae38dbcbb68b824c9eeacb25605aa80c3ccca9b4f00725658da3ad646834b0f9d SHA512 4a9d454031f644a3072a980f4ea20df976f6c5c58178549dfa62fd4dcf1417509e3be517d2ccb265c87688836f2993531b142fc5971bac5c41d33060057627df
44 +DIST openssl-1.1.0i_ec_curve.c 18401 BLAKE2B f969071ac1b5d0e43b50d54e50b5c4d9201fc8b94458902e9849f14841b5505a2e43ed57a8c13255f042a211af9ee904776c155c36da838a8ad22e1052b02bc1 SHA512 a1c2bb3c3e3d342bddc8c952985e87fc4bad2e8142d5d760b18f346c44c20f00db61c4856f3dcf879b2098e0c036330762915f65d80a1a2cba717d2caeb95457
45 +DIST openssl-1.1.0i_ectest.c 30688 BLAKE2B 6673ef0fd139af82d830794179b19b9e06be25fac4a13b8bdfa5fd5dad25f594ce8eab118aab9ec2aab25001e1de127c03f8e1a04f4f3ef4c464b7fb1811ed4a SHA512 240fc72916caf4a8b0af774ce307abfe9a93a762eba6fae760cec79d619fe3db0d6919fc92a8951cb031f73958237700b45f590aa7f9f2890762cccda1f1e74b
46 +DIST openssl-1.1.0i_hobble-openssl 1117 BLAKE2B c3a1477e63331e83cf1cbe58e9ef131ec500a311e22d3da55034800ca353c387b2e202575acf3badb00b236ff91d4bac1bb131a33930939646d26bec27be6e04 SHA512 fa9cc70afa11a7a292548b4bddbba8159824a364ce5c279b483768e6ae2aa4b5491d9bf2cc734819f30a11c8ee0d91bcb991c4a7ab357296aeb4c04feac74826
47
48 diff --git a/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0734.patch b/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0734.patch
49 new file mode 100644
50 index 0000000000..47b082f408
51 --- /dev/null
52 +++ b/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0734.patch
53 @@ -0,0 +1,131 @@
54 +CVE-2018-0734
55 +https://github.com/openssl/openssl/commit/415c33563528667868c3c653a612e6fc8736fd79
56 +https://github.com/openssl/openssl/commit/ef11e19d1365eea2b1851e6f540a0bf365d303e7
57 +
58 +--- a/crypto/dsa/dsa_ossl.c
59 ++++ b/crypto/dsa/dsa_ossl.c
60 +@@ -11,6 +11,7 @@
61 +
62 + #include <stdio.h>
63 + #include "internal/cryptlib.h"
64 ++#include "internal/bn_int.h"
65 + #include <openssl/bn.h>
66 + #include <openssl/sha.h>
67 + #include "dsa_locl.h"
68 +@@ -25,6 +26,8 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len,
69 + DSA_SIG *sig, DSA *dsa);
70 + static int dsa_init(DSA *dsa);
71 + static int dsa_finish(DSA *dsa);
72 ++static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
73 ++ BN_CTX *ctx);
74 +
75 + static DSA_METHOD openssl_dsa_meth = {
76 + "OpenSSL DSA method",
77 +@@ -180,9 +183,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
78 + {
79 + BN_CTX *ctx = NULL;
80 + BIGNUM *k, *kinv = NULL, *r = *rp;
81 +- BIGNUM *l, *m;
82 ++ BIGNUM *l;
83 + int ret = 0;
84 +- int q_bits;
85 ++ int q_bits, q_words;
86 +
87 + if (!dsa->p || !dsa->q || !dsa->g) {
88 + DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS);
89 +@@ -191,8 +194,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
90 +
91 + k = BN_new();
92 + l = BN_new();
93 +- m = BN_new();
94 +- if (k == NULL || l == NULL || m == NULL)
95 ++ if (k == NULL || l == NULL)
96 + goto err;
97 +
98 + if (ctx_in == NULL) {
99 +@@ -203,9 +205,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
100 +
101 + /* Preallocate space */
102 + q_bits = BN_num_bits(dsa->q);
103 +- if (!BN_set_bit(k, q_bits)
104 +- || !BN_set_bit(l, q_bits)
105 +- || !BN_set_bit(m, q_bits))
106 ++ q_words = bn_get_top(dsa->q);
107 ++ if (!bn_wexpand(k, q_words + 2)
108 ++ || !bn_wexpand(l, q_words + 2))
109 + goto err;
110 +
111 + /* Get random k */
112 +@@ -240,14 +242,17 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
113 + * small timing information leakage. We then choose the sum that is
114 + * one bit longer than the modulus.
115 + *
116 +- * TODO: revisit the BN_copy aiming for a memory access agnostic
117 +- * conditional copy.
118 ++ * There are some concerns about the efficacy of doing this. More
119 ++ * specificly refer to the discussion starting with:
120 ++ * https://github.com/openssl/openssl/pull/7486#discussion_r228323705
121 ++ * The fix is to rework BN so these gymnastics aren't required.
122 + */
123 + if (!BN_add(l, k, dsa->q)
124 +- || !BN_add(m, l, dsa->q)
125 +- || !BN_copy(k, BN_num_bits(l) > q_bits ? l : m))
126 ++ || !BN_add(k, l, dsa->q))
127 + goto err;
128 +
129 ++ BN_consttime_swap(BN_is_bit_set(l, q_bits), k, l, q_words + 2);
130 ++
131 + if ((dsa)->meth->bn_mod_exp != NULL) {
132 + if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx,
133 + dsa->method_mont_p))
134 +@@ -260,8 +265,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
135 + if (!BN_mod(r, r, dsa->q, ctx))
136 + goto err;
137 +
138 +- /* Compute part of 's = inv(k) (m + xr) mod q' */
139 +- if ((kinv = BN_mod_inverse(NULL, k, dsa->q, ctx)) == NULL)
140 ++ /* Compute part of 's = inv(k) (m + xr) mod q' */
141 ++ if ((kinv = dsa_mod_inverse_fermat(k, dsa->q, ctx)) == NULL)
142 + goto err;
143 +
144 + BN_clear_free(*kinvp);
145 +@@ -275,7 +280,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
146 + BN_CTX_free(ctx);
147 + BN_clear_free(k);
148 + BN_clear_free(l);
149 +- BN_clear_free(m);
150 + return ret;
151 + }
152 +
153 +@@ -395,3 +399,31 @@ static int dsa_finish(DSA *dsa)
154 + BN_MONT_CTX_free(dsa->method_mont_p);
155 + return (1);
156 + }
157 ++
158 ++/*
159 ++ * Compute the inverse of k modulo q.
160 ++ * Since q is prime, Fermat's Little Theorem applies, which reduces this to
161 ++ * mod-exp operation. Both the exponent and modulus are public information
162 ++ * so a mod-exp that doesn't leak the base is sufficient. A newly allocated
163 ++ * BIGNUM is returned which the caller must free.
164 ++ */
165 ++static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
166 ++ BN_CTX *ctx)
167 ++{
168 ++ BIGNUM *res = NULL;
169 ++ BIGNUM *r, *e;
170 ++
171 ++ if ((r = BN_new()) == NULL)
172 ++ return NULL;
173 ++
174 ++ BN_CTX_start(ctx);
175 ++ if ((e = BN_CTX_get(ctx)) != NULL
176 ++ && BN_set_word(r, 2)
177 ++ && BN_sub(e, q, r)
178 ++ && BN_mod_exp_mont(r, k, e, q, ctx, NULL))
179 ++ res = r;
180 ++ else
181 ++ BN_free(r);
182 ++ BN_CTX_end(ctx);
183 ++ return res;
184 ++}
185
186 diff --git a/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0735.patch b/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0735.patch
187 new file mode 100644
188 index 0000000000..5762c04fa3
189 --- /dev/null
190 +++ b/dev-libs/openssl/files/openssl-1.1.0i-CVE-2018-0735.patch
191 @@ -0,0 +1,44 @@
192 +From 56fb454d281a023b3f950d969693553d3f3ceea1 Mon Sep 17 00:00:00 2001
193 +From: Pauli <paul.dale@××××××.com>
194 +Date: Fri, 26 Oct 2018 10:54:58 +1000
195 +Subject: [PATCH] Timing vulnerability in ECDSA signature generation
196 + (CVE-2018-0735)
197 +
198 +Preallocate an extra limb for some of the big numbers to avoid a reallocation
199 +that can potentially provide a side channel.
200 +
201 +Reviewed-by: Bernd Edlinger <bernd.edlinger@×××××××.de>
202 +(Merged from https://github.com/openssl/openssl/pull/7486)
203 +
204 +(cherry picked from commit 99540ec79491f59ed8b46b4edf130e17dc907f52)
205 +---
206 + crypto/ec/ec_mult.c | 6 +++---
207 + 1 file changed, 3 insertions(+), 3 deletions(-)
208 +
209 +diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
210 +index 22bb30ffa1..ff882cce20 100644
211 +--- a/crypto/ec/ec_mult.c
212 ++++ b/crypto/ec/ec_mult.c
213 +@@ -177,8 +177,8 @@ static int ec_mul_consttime(const EC_GROUP *group, EC_POINT *r,
214 + */
215 + cardinality_bits = BN_num_bits(cardinality);
216 + group_top = bn_get_top(cardinality);
217 +- if ((bn_wexpand(k, group_top + 1) == NULL)
218 +- || (bn_wexpand(lambda, group_top + 1) == NULL))
219 ++ if ((bn_wexpand(k, group_top + 2) == NULL)
220 ++ || (bn_wexpand(lambda, group_top + 2) == NULL))
221 + goto err;
222 +
223 + if (!BN_copy(k, scalar))
224 +@@ -205,7 +205,7 @@ static int ec_mul_consttime(const EC_GROUP *group, EC_POINT *r,
225 + * k := scalar + 2*cardinality
226 + */
227 + kbit = BN_is_bit_set(lambda, cardinality_bits);
228 +- BN_consttime_swap(kbit, k, lambda, group_top + 1);
229 ++ BN_consttime_swap(kbit, k, lambda, group_top + 2);
230 +
231 + group_top = bn_get_top(group->field);
232 + if ((bn_wexpand(s->X, group_top) == NULL)
233 +--
234 +2.19.1
235 +
236
237 diff --git a/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0734.patch b/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0734.patch
238 new file mode 100644
239 index 0000000000..dbc379c80d
240 --- /dev/null
241 +++ b/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0734.patch
242 @@ -0,0 +1,131 @@
243 +CVE-2018-0734
244 +https://github.com/openssl/openssl/commit/f1b12b8713a739f27d74e6911580b2e70aea2fa4
245 +https://github.com/openssl/openssl/commit/8abfe72e8c1de1b95f50aa0d9134803b4d00070f
246 +
247 +--- a/crypto/dsa/dsa_ossl.c
248 ++++ b/crypto/dsa/dsa_ossl.c
249 +@@ -9,6 +9,7 @@
250 +
251 + #include <stdio.h>
252 + #include "internal/cryptlib.h"
253 ++#include "internal/bn_int.h"
254 + #include <openssl/bn.h>
255 + #include <openssl/sha.h>
256 + #include "dsa_locl.h"
257 +@@ -23,6 +24,8 @@ static int dsa_do_verify(const unsigned char *dgst, int dgst_len,
258 + DSA_SIG *sig, DSA *dsa);
259 + static int dsa_init(DSA *dsa);
260 + static int dsa_finish(DSA *dsa);
261 ++static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
262 ++ BN_CTX *ctx);
263 +
264 + static DSA_METHOD openssl_dsa_meth = {
265 + "OpenSSL DSA method",
266 +@@ -178,9 +181,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
267 + {
268 + BN_CTX *ctx = NULL;
269 + BIGNUM *k, *kinv = NULL, *r = *rp;
270 +- BIGNUM *l, *m;
271 ++ BIGNUM *l;
272 + int ret = 0;
273 +- int q_bits;
274 ++ int q_bits, q_words;
275 +
276 + if (!dsa->p || !dsa->q || !dsa->g) {
277 + DSAerr(DSA_F_DSA_SIGN_SETUP, DSA_R_MISSING_PARAMETERS);
278 +@@ -189,8 +192,7 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
279 +
280 + k = BN_new();
281 + l = BN_new();
282 +- m = BN_new();
283 +- if (k == NULL || l == NULL || m == NULL)
284 ++ if (k == NULL || l == NULL)
285 + goto err;
286 +
287 + if (ctx_in == NULL) {
288 +@@ -201,9 +203,9 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
289 +
290 + /* Preallocate space */
291 + q_bits = BN_num_bits(dsa->q);
292 +- if (!BN_set_bit(k, q_bits)
293 +- || !BN_set_bit(l, q_bits)
294 +- || !BN_set_bit(m, q_bits))
295 ++ q_words = bn_get_top(dsa->q);
296 ++ if (!bn_wexpand(k, q_words + 2)
297 ++ || !bn_wexpand(l, q_words + 2))
298 + goto err;
299 +
300 + /* Get random k */
301 +@@ -238,14 +240,17 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
302 + * small timing information leakage. We then choose the sum that is
303 + * one bit longer than the modulus.
304 + *
305 +- * TODO: revisit the BN_copy aiming for a memory access agnostic
306 +- * conditional copy.
307 ++ * There are some concerns about the efficacy of doing this. More
308 ++ * specificly refer to the discussion starting with:
309 ++ * https://github.com/openssl/openssl/pull/7486#discussion_r228323705
310 ++ * The fix is to rework BN so these gymnastics aren't required.
311 + */
312 + if (!BN_add(l, k, dsa->q)
313 +- || !BN_add(m, l, dsa->q)
314 +- || !BN_copy(k, BN_num_bits(l) > q_bits ? l : m))
315 ++ || !BN_add(k, l, dsa->q))
316 + goto err;
317 +
318 ++ BN_consttime_swap(BN_is_bit_set(l, q_bits), k, l, q_words + 2);
319 ++
320 + if ((dsa)->meth->bn_mod_exp != NULL) {
321 + if (!dsa->meth->bn_mod_exp(dsa, r, dsa->g, k, dsa->p, ctx,
322 + dsa->method_mont_p))
323 +@@ -258,8 +263,8 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
324 + if (!BN_mod(r, r, dsa->q, ctx))
325 + goto err;
326 +
327 +- /* Compute part of 's = inv(k) (m + xr) mod q' */
328 +- if ((kinv = BN_mod_inverse(NULL, k, dsa->q, ctx)) == NULL)
329 ++ /* Compute part of 's = inv(k) (m + xr) mod q' */
330 ++ if ((kinv = dsa_mod_inverse_fermat(k, dsa->q, ctx)) == NULL)
331 + goto err;
332 +
333 + BN_clear_free(*kinvp);
334 +@@ -273,7 +278,6 @@ static int dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in,
335 + BN_CTX_free(ctx);
336 + BN_clear_free(k);
337 + BN_clear_free(l);
338 +- BN_clear_free(m);
339 + return ret;
340 + }
341 +
342 +@@ -393,3 +397,31 @@ static int dsa_finish(DSA *dsa)
343 + BN_MONT_CTX_free(dsa->method_mont_p);
344 + return 1;
345 + }
346 ++
347 ++/*
348 ++ * Compute the inverse of k modulo q.
349 ++ * Since q is prime, Fermat's Little Theorem applies, which reduces this to
350 ++ * mod-exp operation. Both the exponent and modulus are public information
351 ++ * so a mod-exp that doesn't leak the base is sufficient. A newly allocated
352 ++ * BIGNUM is returned which the caller must free.
353 ++ */
354 ++static BIGNUM *dsa_mod_inverse_fermat(const BIGNUM *k, const BIGNUM *q,
355 ++ BN_CTX *ctx)
356 ++{
357 ++ BIGNUM *res = NULL;
358 ++ BIGNUM *r, *e;
359 ++
360 ++ if ((r = BN_new()) == NULL)
361 ++ return NULL;
362 ++
363 ++ BN_CTX_start(ctx);
364 ++ if ((e = BN_CTX_get(ctx)) != NULL
365 ++ && BN_set_word(r, 2)
366 ++ && BN_sub(e, q, r)
367 ++ && BN_mod_exp_mont(r, k, e, q, ctx, NULL))
368 ++ res = r;
369 ++ else
370 ++ BN_free(r);
371 ++ BN_CTX_end(ctx);
372 ++ return res;
373 ++}
374
375 diff --git a/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0735.patch b/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0735.patch
376 new file mode 100644
377 index 0000000000..295f5dbe8d
378 --- /dev/null
379 +++ b/dev-libs/openssl/files/openssl-1.1.1-CVE-2018-0735.patch
380 @@ -0,0 +1,44 @@
381 +From b1d6d55ece1c26fa2829e2b819b038d7b6d692b4 Mon Sep 17 00:00:00 2001
382 +From: Pauli <paul.dale@××××××.com>
383 +Date: Fri, 26 Oct 2018 10:54:58 +1000
384 +Subject: [PATCH] Timing vulnerability in ECDSA signature generation
385 + (CVE-2018-0735)
386 +
387 +Preallocate an extra limb for some of the big numbers to avoid a reallocation
388 +that can potentially provide a side channel.
389 +
390 +Reviewed-by: Bernd Edlinger <bernd.edlinger@×××××××.de>
391 +(Merged from https://github.com/openssl/openssl/pull/7486)
392 +
393 +(cherry picked from commit 99540ec79491f59ed8b46b4edf130e17dc907f52)
394 +---
395 + crypto/ec/ec_mult.c | 6 +++---
396 + 1 file changed, 3 insertions(+), 3 deletions(-)
397 +
398 +diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
399 +index 7e1b3650e7..0e0a5e1394 100644
400 +--- a/crypto/ec/ec_mult.c
401 ++++ b/crypto/ec/ec_mult.c
402 +@@ -206,8 +206,8 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
403 + */
404 + cardinality_bits = BN_num_bits(cardinality);
405 + group_top = bn_get_top(cardinality);
406 +- if ((bn_wexpand(k, group_top + 1) == NULL)
407 +- || (bn_wexpand(lambda, group_top + 1) == NULL)) {
408 ++ if ((bn_wexpand(k, group_top + 2) == NULL)
409 ++ || (bn_wexpand(lambda, group_top + 2) == NULL)) {
410 + ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);
411 + goto err;
412 + }
413 +@@ -244,7 +244,7 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
414 + * k := scalar + 2*cardinality
415 + */
416 + kbit = BN_is_bit_set(lambda, cardinality_bits);
417 +- BN_consttime_swap(kbit, k, lambda, group_top + 1);
418 ++ BN_consttime_swap(kbit, k, lambda, group_top + 2);
419 +
420 + group_top = bn_get_top(group->field);
421 + if ((bn_wexpand(s->X, group_top) == NULL)
422 +--
423 +2.19.1
424 +
425
426 diff --git a/dev-libs/openssl/openssl-1.0.2o-r6.ebuild b/dev-libs/openssl/openssl-1.0.2p-r1.ebuild
427 similarity index 90%
428 rename from dev-libs/openssl/openssl-1.0.2o-r6.ebuild
429 rename to dev-libs/openssl/openssl-1.0.2p-r1.ebuild
430 index abda3fe827..925641f754 100644
431 --- a/dev-libs/openssl/openssl-1.0.2o-r6.ebuild
432 +++ b/dev-libs/openssl/openssl-1.0.2p-r1.ebuild
433 @@ -1,18 +1,21 @@
434 -# Copyright 1999-2018 Gentoo Foundation
435 +# Copyright 1999-2018 Gentoo Authors
436 # Distributed under the terms of the GNU General Public License v2
437
438 EAPI="6"
439
440 inherit eutils flag-o-matic toolchain-funcs multilib multilib-minimal
441
442 -PATCH_SET="openssl-1.0.2-patches-1.4"
443 +PATCH_SET="openssl-1.0.2-patches-1.6"
444 MY_P=${P/_/-}
445 DESCRIPTION="full-strength general purpose cryptography library (including SSL and TLS)"
446 HOMEPAGE="https://www.openssl.org/"
447 SRC_URI="mirror://openssl/source/${MY_P}.tar.gz
448 - mirror://gentoo/${PATCH_SET}.tar.xz
449 - https://dev.gentoo.org/~whissi/dist/${PN}/${PATCH_SET}.tar.xz
450 - https://dev.gentoo.org/~polynomial-c/dist/${PATCH_SET}.tar.xz"
451 + !vanilla? (
452 + mirror://gentoo/${PATCH_SET}.tar.xz
453 + https://dev.gentoo.org/~chutzpah/dist/${PN}/${PATCH_SET}.tar.xz
454 + https://dev.gentoo.org/~whissi/dist/${PN}/${PATCH_SET}.tar.xz
455 + https://dev.gentoo.org/~polynomial-c/dist/${PATCH_SET}.tar.xz
456 + )"
457
458 LICENSE="openssl"
459 SLOT="0"
460 @@ -74,7 +77,7 @@ src_prepare() {
461 for i in "${FEDORA_PATCH[@]}" ; do
462 eapply "${DISTDIR}"/"${i}"
463 done
464 - eapply "${FILESDIR}"/openssl-1.0.2o-hobble-ecc.patch
465 + eapply "${FILESDIR}"/openssl-1.0.2p-hobble-ecc.patch
466 # Also see the configure parts below:
467 # enable-ec \
468 # $(use_ssl !bindist ec2m) \
469 @@ -90,7 +93,6 @@ src_prepare() {
470
471 if ! use vanilla ; then
472 eapply "${WORKDIR}"/patch/*.patch
473 - eapply "${FILESDIR}"/${P}-CVE-2018-0732.patch
474 fi
475
476 eapply_user
477 @@ -107,7 +109,7 @@ src_prepare() {
478 -e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
479 -e $(has noman FEATURES \
480 && echo '/^install:/s:install_docs::' \
481 - || echo '/^MANDIR=/s:=.*:='${EPREFIX}'/usr/share/man:') \
482 + || echo '/^MANDIR=/s:=.*:='${EPREFIX%/}'/usr/share/man:') \
483 Makefile.org \
484 || die
485 # show the actual commands in the log
486 @@ -126,7 +128,8 @@ src_prepare() {
487 # since we're forcing $(CC) as makedep anyway, just fix
488 # the conditional as always-on
489 # helps clang (#417795), and versioned gcc (#499818)
490 - sed -i 's/expr.*MAKEDEPEND.*;/true;/' util/domd || die
491 + # this breaks build with 1.0.2p, not sure if it is needed anymore
492 + #sed -i 's/expr.*MAKEDEPEND.*;/true;/' util/domd || die
493
494 # quiet out unknown driver argument warnings since openssl
495 # doesn't have well-split CFLAGS and we're making it even worse
496 @@ -213,8 +216,8 @@ multilib_src_configure() {
497 $(use_ssl sslv3 ssl3) \
498 $(use_ssl tls-heartbeat heartbeats) \
499 $(use_ssl zlib) \
500 - --prefix="${EPREFIX}"/usr \
501 - --openssldir="${EPREFIX}"${SSL_CNF_DIR} \
502 + --prefix="${EPREFIX%/}"/usr \
503 + --openssldir="${EPREFIX%/}"${SSL_CNF_DIR} \
504 --libdir=$(get_libdir) \
505 shared threads \
506 || die
507 @@ -237,7 +240,7 @@ multilib_src_configure() {
508 multilib_src_compile() {
509 # depend is needed to use $confopts; it also doesn't matter
510 # that it's -j1 as the code itself serializes subdirs
511 - emake -j1 depend
512 + emake -j1 V=1 depend
513 emake all
514 # rehash is needed to prep the certs/ dir; do this
515 # separately to avoid parallel build issues.
516 @@ -249,13 +252,19 @@ multilib_src_test() {
517 }
518
519 multilib_src_install() {
520 - emake INSTALL_PREFIX="${D}" install
521 + # We need to create $ED/usr on our own to avoid a race condition #665130
522 + if [[ ! -d "${ED%/}/usr" ]]; then
523 + # We can only create this directory once
524 + mkdir "${ED%/}"/usr || die
525 + fi
526 +
527 + emake INSTALL_PREFIX="${D%/}" install
528 }
529
530 multilib_src_install_all() {
531 # openssl installs perl version of c_rehash by default, but
532 # we provide a shell version via app-misc/c_rehash
533 - rm "${ED}"/usr/bin/c_rehash || die
534 + rm "${ED%/}"/usr/bin/c_rehash || die
535
536 local -a DOCS=( CHANGES* FAQ NEWS README doc/*.txt doc/c-indentation.el )
537 einstalldocs
538 @@ -267,7 +276,7 @@ multilib_src_install_all() {
539 # build system: the static archives are built as PIC all the time.
540 # Only way around this would be to manually configure+compile openssl
541 # twice; once with shared lib support enabled and once without.
542 - use static-libs || find "${ED}"usr/lib* -mindepth 1 -maxdepth 1 \
543 + use static-libs || find "${ED}"/usr/lib* -mindepth 1 -maxdepth 1 \
544 -name "lib*.a" -not -name "*.dll.a" -not -name "*$(get_libname)" -delete
545
546 # create the certs directory
547
548 diff --git a/dev-libs/openssl/openssl-1.1.0h-r2.ebuild b/dev-libs/openssl/openssl-1.1.0i-r3.ebuild
549 similarity index 97%
550 rename from dev-libs/openssl/openssl-1.1.0h-r2.ebuild
551 rename to dev-libs/openssl/openssl-1.1.0i-r3.ebuild
552 index dbd701f3c0..348a3a8a12 100644
553 --- a/dev-libs/openssl/openssl-1.1.0h-r2.ebuild
554 +++ b/dev-libs/openssl/openssl-1.1.0i-r3.ebuild
555 @@ -1,4 +1,4 @@
556 -# Copyright 1999-2018 Gentoo Foundation
557 +# Copyright 1999-2018 Gentoo Authors
558 # Distributed under the terms of the GNU General Public License v2
559
560 EAPI="6"
561 @@ -36,7 +36,7 @@ SOURCE13=ectest.c
562 PATCH1=openssl-1.1.0-build.patch # Fixes EVP testcase for EC
563 PATCH37=openssl-1.1.0-ec-curves.patch
564 FEDORA_GIT_BASE='https://src.fedoraproject.org/cgit/rpms/openssl.git/plain/'
565 -FEDORA_GIT_BRANCH='f27'
566 +FEDORA_GIT_BRANCH='f28'
567 FEDORA_SRC_URI=()
568 FEDORA_SOURCE=( $SOURCE1 $SOURCE12 $SOURCE13 )
569 FEDORA_PATCH=( $PATCH1 $PATCH37 )
570 @@ -56,8 +56,8 @@ MULTILIB_WRAPPED_HEADERS=(
571
572 PATCHES=(
573 "${FILESDIR}"/${PN}-1.0.2a-x32-asm.patch #542618
574 - "${FILESDIR}"/${P}-CVE-2018-0737.patch
575 - "${FILESDIR}"/${P}-CVE-2018-0732.patch
576 + "${FILESDIR}"/${P}-CVE-2018-0734.patch
577 + "${FILESDIR}"/${P}-CVE-2018-0735.patch
578 )
579
580 src_prepare() {
581 @@ -103,7 +103,7 @@ src_prepare() {
582 -e $(has noman FEATURES \
583 && echo '/^install:/s:install_docs::' \
584 || echo '/^MANDIR=/s:=.*:='${EPREFIX}'/usr/share/man:') \
585 - -e "/^DOCDIR/s@\$(BASENAME)@&-${PF}@" \
586 + -e "/^DOCDIR/s@\$(BASENAME)@&-${PVR}@" \
587 Configurations/unix-Makefile.tmpl \
588 || die
589
590 @@ -247,7 +247,7 @@ multilib_src_install_all() {
591 # build system: the static archives are built as PIC all the time.
592 # Only way around this would be to manually configure+compile openssl
593 # twice; once with shared lib support enabled and once without.
594 - use static-libs || find "${ED}"usr/lib* -mindepth 1 -maxdepth 1 \
595 + use static-libs || find "${ED%/}"/usr/lib* -mindepth 1 -maxdepth 1 \
596 -name "lib*.a" -not -name "*.dll.a" -not -name "*$(get_libname)" -delete
597
598 # create the certs directory