Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/openssl/, dev-libs/openssl/files/
Date: Mon, 25 Nov 2019 00:13:43
Message-Id: 1574640504.5303fe62cef99c176381cd4788984b1b4f3e2ad7.whissi@gentoo
1 commit: 5303fe62cef99c176381cd4788984b1b4f3e2ad7
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Mon Nov 25 00:07:51 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Mon Nov 25 00:08:24 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5303fe62
7
8 dev-libs/openssl: reenable the stitched AES-CBC-HMAC-SHA implementations
9
10 Package-Manager: Portage-2.3.79, Repoman-2.3.18
11 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
12
13 ...stitched-AES-CBC-HMAC-SHA-implementations.patch | 62 ++++
14 dev-libs/openssl/openssl-1.1.1d-r3.ebuild | 331 +++++++++++++++++++++
15 2 files changed, 393 insertions(+)
16
17 diff --git a/dev-libs/openssl/files/openssl-1.1.1d-reenable-the-stitched-AES-CBC-HMAC-SHA-implementations.patch b/dev-libs/openssl/files/openssl-1.1.1d-reenable-the-stitched-AES-CBC-HMAC-SHA-implementations.patch
18 new file mode 100644
19 index 00000000000..dc8fe7146b7
20 --- /dev/null
21 +++ b/dev-libs/openssl/files/openssl-1.1.1d-reenable-the-stitched-AES-CBC-HMAC-SHA-implementations.patch
22 @@ -0,0 +1,62 @@
23 +From 61cc715240d2d3f9511ca88043a3e9797c11482f Mon Sep 17 00:00:00 2001
24 +From: Richard Levitte <levitte@×××××××.org>
25 +Date: Thu, 3 Oct 2019 08:28:31 +0200
26 +Subject: [PATCH] Define AESNI_ASM if AESNI assembler is included, and use it
27 +
28 +Because we have cases where basic assembler support isn't present, but
29 +AESNI asssembler support is, we need a separate macro that indicates
30 +that, and use it.
31 +
32 +Reviewed-by: Tomas Mraz <tmraz@×××××××××××××.org>
33 +Reviewed-by: Paul Dale <paul.dale@××××××.com>
34 +(Merged from https://github.com/openssl/openssl/pull/10080)
35 +---
36 + Configure | 1 +
37 + crypto/evp/e_aes_cbc_hmac_sha1.c | 2 +-
38 + crypto/evp/e_aes_cbc_hmac_sha256.c | 4 ++--
39 + 3 files changed, 4 insertions(+), 3 deletions(-)
40 +
41 +diff --git a/Configure b/Configure
42 +index 811bee81f54..f498ac2f81b 100755
43 +--- a/Configure
44 ++++ b/Configure
45 +@@ -1376,6 +1376,7 @@ unless ($disabled{asm}) {
46 + }
47 + if ($target{aes_asm_src}) {
48 + push @{$config{lib_defines}}, "AES_ASM" if ($target{aes_asm_src} =~ m/\baes-/);;
49 ++ push @{$config{lib_defines}}, "AESNI_ASM" if ($target{aes_asm_src} =~ m/\baesni-/);;
50 + # aes-ctr.fake is not a real file, only indication that assembler
51 + # module implements AES_ctr32_encrypt...
52 + push @{$config{lib_defines}}, "AES_CTR_ASM" if ($target{aes_asm_src} =~ s/\s*aes-ctr\.fake//);
53 +diff --git a/crypto/evp/e_aes_cbc_hmac_sha1.c b/crypto/evp/e_aes_cbc_hmac_sha1.c
54 +index c9f5969162c..27c36b46e7a 100644
55 +--- a/crypto/evp/e_aes_cbc_hmac_sha1.c
56 ++++ b/crypto/evp/e_aes_cbc_hmac_sha1.c
57 +@@ -33,7 +33,7 @@ typedef struct {
58 +
59 + #define NO_PAYLOAD_LENGTH ((size_t)-1)
60 +
61 +-#if defined(AES_ASM) && ( \
62 ++#if defined(AESNI_ASM) && ( \
63 + defined(__x86_64) || defined(__x86_64__) || \
64 + defined(_M_AMD64) || defined(_M_X64) )
65 +
66 +diff --git a/crypto/evp/e_aes_cbc_hmac_sha256.c b/crypto/evp/e_aes_cbc_hmac_sha256.c
67 +index d5178313ae3..cc622b6faa8 100644
68 +--- a/crypto/evp/e_aes_cbc_hmac_sha256.c
69 ++++ b/crypto/evp/e_aes_cbc_hmac_sha256.c
70 +@@ -34,7 +34,7 @@ typedef struct {
71 +
72 + # define NO_PAYLOAD_LENGTH ((size_t)-1)
73 +
74 +-#if defined(AES_ASM) && ( \
75 ++#if defined(AESNI_ASM) && ( \
76 + defined(__x86_64) || defined(__x86_64__) || \
77 + defined(_M_AMD64) || defined(_M_X64) )
78 +
79 +@@ -947,4 +947,4 @@ const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void)
80 + {
81 + return NULL;
82 + }
83 +-#endif
84 ++#endif /* AESNI_ASM */
85
86 diff --git a/dev-libs/openssl/openssl-1.1.1d-r3.ebuild b/dev-libs/openssl/openssl-1.1.1d-r3.ebuild
87 new file mode 100644
88 index 00000000000..977c384a375
89 --- /dev/null
90 +++ b/dev-libs/openssl/openssl-1.1.1d-r3.ebuild
91 @@ -0,0 +1,331 @@
92 +# Copyright 1999-2019 Gentoo Authors
93 +# Distributed under the terms of the GNU General Public License v2
94 +
95 +EAPI="7"
96 +
97 +inherit flag-o-matic toolchain-funcs multilib multilib-minimal
98 +
99 +MY_P=${P/_/-}
100 +
101 +# This patch set is based on the following files from Fedora 31,
102 +# see https://src.fedoraproject.org/rpms/openssl/blob/f31/f/openssl.spec
103 +# for more details:
104 +# - hobble-openssl (SOURCE1)
105 +# - ec_curve.c (SOURCE12) -- MODIFIED
106 +# - ectest.c (SOURCE13)
107 +# - openssl-1.1.1-ec-curves.patch (PATCH37) -- MODIFIED
108 +BINDIST_PATCH_SET="openssl-1.1.1d-bindist-1.0.tar.xz"
109 +
110 +DESCRIPTION="full-strength general purpose cryptography library (including SSL and TLS)"
111 +HOMEPAGE="https://www.openssl.org/"
112 +SRC_URI="mirror://openssl/source/${MY_P}.tar.gz
113 + bindist? (
114 + mirror://gentoo/${BINDIST_PATCH_SET}
115 + https://dev.gentoo.org/~whissi/dist/openssl/${BINDIST_PATCH_SET}
116 + )"
117 +
118 +LICENSE="openssl"
119 +SLOT="0/1.1" # .so version of libssl/libcrypto
120 +[[ "${PV}" = *_pre* ]] || \
121 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sh ~sparc ~x86 ~x86-linux"
122 +IUSE="+asm bindist elibc_musl rfc3779 sctp cpu_flags_x86_sse2 sslv3 static-libs test tls-heartbeat vanilla zlib"
123 +RESTRICT="!bindist? ( bindist )"
124 +
125 +RDEPEND=">=app-misc/c_rehash-1.7-r1
126 + zlib? ( >=sys-libs/zlib-1.2.8-r1[static-libs(+)?,${MULTILIB_USEDEP}] )"
127 +DEPEND="${RDEPEND}"
128 +BDEPEND="
129 + >=dev-lang/perl-5
130 + sctp? ( >=net-misc/lksctp-tools-1.0.12 )
131 + test? (
132 + sys-apps/diffutils
133 + sys-devel/bc
134 + )"
135 +PDEPEND="app-misc/ca-certificates"
136 +
137 +PATCHES=(
138 + "${FILESDIR}"/${PN}-1.1.0j-parallel_install_fix.patch #671602
139 + "${FILESDIR}"/${P}-fix-zlib.patch
140 + "${FILESDIR}"/${P}-fix-potential-memleaks-w-BN_to_ASN1_INTEGER.patch
141 + "${FILESDIR}"/${P}-reenable-the-stitched-AES-CBC-HMAC-SHA-implementations.patch
142 +)
143 +
144 +S="${WORKDIR}/${MY_P}"
145 +
146 +# force upgrade to prevent broken login, bug 696950
147 +RDEPEND+=" !<net-misc/openssh-8.0_p1-r3"
148 +
149 +MULTILIB_WRAPPED_HEADERS=(
150 + usr/include/openssl/opensslconf.h
151 +)
152 +
153 +pkg_setup() {
154 + [[ ${MERGE_TYPE} == binary ]] && return
155 +
156 + # must check in pkg_setup; sysctl don't work with userpriv!
157 + if has test ${FEATURES}; then
158 + if use sctp; then
159 + # test_ssl_new will fail with "Ensure SCTP AUTH chunks are enabled in kernel"
160 + # if sctp.auth_enable is not enabled.
161 + local sctp_auth_status=$(sysctl -n net.sctp.auth_enable 2>/dev/null)
162 + if [[ -z "${sctp_auth_status}" || ${sctp_auth_status} != 1 ]]; then
163 + die "FEATURES=test with USE=sctp requires net.sctp.auth_enable=1!"
164 + fi
165 + fi
166 + fi
167 +}
168 +
169 +src_prepare() {
170 + # allow openssl to be cross-compiled
171 + cp "${FILESDIR}"/gentoo.config-1.0.2 gentoo.config || die
172 + chmod a+rx gentoo.config || die
173 +
174 + if use bindist; then
175 + mv "${WORKDIR}"/bindist-patches/hobble-openssl "${WORKDIR}" || die
176 + bash "${WORKDIR}"/hobble-openssl || die
177 +
178 + cp -f "${WORKDIR}"/bindist-patches/ec_curve.c "${S}"/crypto/ec/ || die
179 + cp -f "${WORKDIR}"/bindist-patches/ectest.c "${S}"/test/ || die
180 +
181 + eapply "${WORKDIR}"/bindist-patches/ec-curves.patch
182 +
183 + local known_failing_test
184 + for known_failing_test in \
185 + 30-test_evp_extra.t \
186 + 80-test_ssl_new.t \
187 + ; do
188 + ebegin "Disabling test '${known_failing_test}' which is known to fail with USE=bindist"
189 + rm test/recipes/${known_failing_test} || die
190 + eend $?
191 + done
192 +
193 + # Also see the configure parts below:
194 + # enable-ec \
195 + # $(use_ssl !bindist ec2m) \
196 + fi
197 +
198 + # keep this in sync with app-misc/c_rehash
199 + SSL_CNF_DIR="/etc/ssl"
200 +
201 + # Make sure we only ever touch Makefile.org and avoid patching a file
202 + # that gets blown away anyways by the Configure script in src_configure
203 + rm -f Makefile
204 +
205 + if ! use vanilla ; then
206 + if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]] ; then
207 + [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}"
208 + fi
209 + fi
210 +
211 + eapply_user #332661
212 +
213 + if has test ${FEATURES}; then
214 + if use sctp; then
215 + if has network-sandbox ${FEATURES}; then
216 + ebegin "Disabling test '80-test_ssl_new.t' which is known to fail with FEATURES=network-sandbox"
217 + rm test/recipes/80-test_ssl_new.t || die
218 + eend $?
219 + fi
220 + fi
221 + fi
222 +
223 + # make sure the man pages are suffixed #302165
224 + # don't bother building man pages if they're disabled
225 + # Make DOCDIR Gentoo compliant
226 + sed -i \
227 + -e '/^MANSUFFIX/s:=.*:=ssl:' \
228 + -e '/^MAKEDEPPROG/s:=.*:=$(CC):' \
229 + -e $(has noman FEATURES \
230 + && echo '/^install:/s:install_docs::' \
231 + || echo '/^MANDIR=/s:=.*:='${EPREFIX}'/usr/share/man:') \
232 + -e "/^DOCDIR/s@\$(BASENAME)@&-${PVR}@" \
233 + Configurations/unix-Makefile.tmpl \
234 + || die
235 +
236 + # quiet out unknown driver argument warnings since openssl
237 + # doesn't have well-split CFLAGS and we're making it even worse
238 + # and 'make depend' uses -Werror for added fun (#417795 again)
239 + [[ ${CC} == *clang* ]] && append-flags -Qunused-arguments
240 +
241 + append-flags -fno-strict-aliasing
242 + append-flags $(test-flags-CC -Wa,--noexecstack)
243 + append-cppflags -DOPENSSL_NO_BUF_FREELISTS
244 +
245 + # Prefixify Configure shebang (#141906)
246 + sed \
247 + -e "1s,/usr/bin/env,${EPREFIX}&," \
248 + -i Configure || die
249 + # Remove test target when FEATURES=test isn't set
250 + if ! use test ; then
251 + sed \
252 + -e '/^$config{dirs}/s@ "test",@@' \
253 + -i Configure || die
254 + fi
255 + # The config script does stupid stuff to prompt the user. Kill it.
256 + sed -i '/stty -icanon min 0 time 50; read waste/d' config || die
257 + ./config --test-sanity || die "I AM NOT SANE"
258 +
259 + multilib_copy_sources
260 +}
261 +
262 +multilib_src_configure() {
263 + unset APPS #197996
264 + unset SCRIPTS #312551
265 + unset CROSS_COMPILE #311473
266 +
267 + tc-export CC AR RANLIB RC
268 +
269 + # Clean out patent-or-otherwise-encumbered code
270 + # Camellia: Royalty Free https://en.wikipedia.org/wiki/Camellia_(cipher)
271 + # IDEA: Expired https://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
272 + # EC: ????????? ??/??/2015 https://en.wikipedia.org/wiki/Elliptic_Curve_Cryptography
273 + # MDC2: Expired https://en.wikipedia.org/wiki/MDC-2
274 + # RC5: Expired https://en.wikipedia.org/wiki/RC5
275 +
276 + use_ssl() { usex $1 "enable-${2:-$1}" "no-${2:-$1}" " ${*:3}" ; }
277 + echoit() { echo "$@" ; "$@" ; }
278 +
279 + local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo "Heimdal")
280 +
281 + # See if our toolchain supports __uint128_t. If so, it's 64bit
282 + # friendly and can use the nicely optimized code paths. #460790
283 + local ec_nistp_64_gcc_128
284 + # Disable it for now though #469976
285 + #if ! use bindist ; then
286 + # echo "__uint128_t i;" > "${T}"/128.c
287 + # if ${CC} ${CFLAGS} -c "${T}"/128.c -o /dev/null >&/dev/null ; then
288 + # ec_nistp_64_gcc_128="enable-ec_nistp_64_gcc_128"
289 + # fi
290 + #fi
291 +
292 + local sslout=$(./gentoo.config)
293 + einfo "Use configuration ${sslout:-(openssl knows best)}"
294 + local config="Configure"
295 + [[ -z ${sslout} ]] && config="config"
296 +
297 + # Fedora hobbled-EC needs 'no-ec2m'
298 + # 'srp' was restricted until early 2017 as well.
299 + # "disable-deprecated" option breaks too many consumers.
300 + # Don't set it without thorough revdeps testing.
301 + # Make sure user flags don't get added *yet* to avoid duplicated
302 + # flags.
303 + CFLAGS= LDFLAGS= echoit \
304 + ./${config} \
305 + ${sslout} \
306 + $(use cpu_flags_x86_sse2 || echo "no-sse2") \
307 + enable-camellia \
308 + enable-ec \
309 + $(use_ssl !bindist ec2m) \
310 + enable-srp \
311 + $(use elibc_musl && echo "no-async") \
312 + ${ec_nistp_64_gcc_128} \
313 + enable-idea \
314 + enable-mdc2 \
315 + enable-rc5 \
316 + $(use_ssl sslv3 ssl3) \
317 + $(use_ssl sslv3 ssl3-method) \
318 + $(use_ssl asm) \
319 + $(use_ssl rfc3779) \
320 + $(use_ssl sctp) \
321 + $(use_ssl tls-heartbeat heartbeats) \
322 + $(use_ssl zlib) \
323 + --prefix="${EPREFIX}"/usr \
324 + --openssldir="${EPREFIX}"${SSL_CNF_DIR} \
325 + --libdir=$(get_libdir) \
326 + shared threads \
327 + || die
328 +
329 + # Clean out hardcoded flags that openssl uses
330 + local DEFAULT_CFLAGS=$(grep ^CFLAGS= Makefile | LC_ALL=C sed \
331 + -e 's:^CFLAGS=::' \
332 + -e 's:\(^\| \)-fomit-frame-pointer::g' \
333 + -e 's:\(^\| \)-O[^ ]*::g' \
334 + -e 's:\(^\| \)-march=[^ ]*::g' \
335 + -e 's:\(^\| \)-mcpu=[^ ]*::g' \
336 + -e 's:\(^\| \)-m[^ ]*::g' \
337 + -e 's:^ *::' \
338 + -e 's: *$::' \
339 + -e 's: \+: :g' \
340 + -e 's:\\:\\\\:g'
341 + )
342 +
343 + # Now insert clean default flags with user flags
344 + sed -i \
345 + -e "/^CFLAGS=/s|=.*|=${DEFAULT_CFLAGS} ${CFLAGS}|" \
346 + -e "/^LDFLAGS=/s|=[[:space:]]*$|=${LDFLAGS}|" \
347 + Makefile || die
348 +}
349 +
350 +multilib_src_compile() {
351 + # depend is needed to use $confopts; it also doesn't matter
352 + # that it's -j1 as the code itself serializes subdirs
353 + emake -j1 depend
354 + emake all
355 +}
356 +
357 +multilib_src_test() {
358 + emake -j1 test
359 +}
360 +
361 +multilib_src_install() {
362 + # We need to create $ED/usr on our own to avoid a race condition #665130
363 + if [[ ! -d "${ED}/usr" ]]; then
364 + # We can only create this directory once
365 + mkdir "${ED}"/usr || die
366 + fi
367 +
368 + emake DESTDIR="${D}" install
369 +}
370 +
371 +multilib_src_install_all() {
372 + # openssl installs perl version of c_rehash by default, but
373 + # we provide a shell version via app-misc/c_rehash
374 + rm "${ED}"/usr/bin/c_rehash || die
375 +
376 + dodoc CHANGES* FAQ NEWS README doc/*.txt doc/${PN}-c-indent.el
377 +
378 + # This is crappy in that the static archives are still built even
379 + # when USE=static-libs. But this is due to a failing in the openssl
380 + # build system: the static archives are built as PIC all the time.
381 + # Only way around this would be to manually configure+compile openssl
382 + # twice; once with shared lib support enabled and once without.
383 + use static-libs || rm -f "${ED}"/usr/lib*/lib*.a
384 +
385 + # create the certs directory
386 + keepdir ${SSL_CNF_DIR}/certs
387 +
388 + # Namespace openssl programs to prevent conflicts with other man pages
389 + cd "${ED}"/usr/share/man || die
390 + local m d s
391 + for m in $(find . -type f | xargs grep -L '#include') ; do
392 + d=${m%/*} ; d=${d#./} ; m=${m##*/}
393 + [[ ${m} == openssl.1* ]] && continue
394 + [[ -n $(find -L ${d} -type l) ]] && die "erp, broken links already!"
395 + mv ${d}/{,ssl-}${m}
396 + # fix up references to renamed man pages
397 + sed -i '/^[.]SH "SEE ALSO"/,/^[.]/s:\([^(, ]*(1)\):ssl-\1:g' ${d}/ssl-${m}
398 + ln -s ssl-${m} ${d}/openssl-${m}
399 + # locate any symlinks that point to this man page ... we assume
400 + # that any broken links are due to the above renaming
401 + for s in $(find -L ${d} -type l) ; do
402 + s=${s##*/}
403 + rm -f ${d}/${s}
404 + # We don't want to "|| die" here
405 + ln -s ssl-${m} ${d}/ssl-${s}
406 + ln -s ssl-${s} ${d}/openssl-${s}
407 + done
408 + done
409 + [[ -n $(find -L ${d} -type l) ]] && die "broken manpage links found :("
410 +
411 + dodir /etc/sandbox.d #254521
412 + echo 'SANDBOX_PREDICT="/dev/crypto"' > "${ED}"/etc/sandbox.d/10openssl
413 +
414 + diropts -m0700
415 + keepdir ${SSL_CNF_DIR}/private
416 +}
417 +
418 +pkg_postinst() {
419 + ebegin "Running 'c_rehash ${EROOT}${SSL_CNF_DIR}/certs/' to rebuild hashes #333069"
420 + c_rehash "${EROOT}${SSL_CNF_DIR}/certs" >/dev/null
421 + eend $?
422 +}