commit:     e70b056198310f608b8faddfcb24a96f2dfab9e6
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 19 14:55:30 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jul 19 15:05:52 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e70b0561

dev-libs/openssl: patch CVE-2023-2975, CVE-2023-3446 for 3.0.9

Bug: https://bugs.gentoo.org/910556
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/openssl-3.0.9-CVE-2023-2975.patch        | 109 ++++++++
 .../files/openssl-3.0.9-CVE-2023-3446.patch        | 120 +++++++++
 dev-libs/openssl/openssl-3.0.9-r2.ebuild           | 290 +++++++++++++++++++++
 3 files changed, 519 insertions(+)

diff --git a/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-2975.patch 
b/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-2975.patch
new file mode 100644
index 000000000000..908e57251cb9
--- /dev/null
+++ b/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-2975.patch
@@ -0,0 +1,109 @@
+https://github.com/openssl/openssl/commit/00e2f5eea29994d19293ec4e8c8775ba73678598
+https://github.com/openssl/openssl/commit/96318a8d21bed334d78797eca5b32790775d5f05
+
+From 00e2f5eea29994d19293ec4e8c8775ba73678598 Mon Sep 17 00:00:00 2001
+From: Tomas Mraz <to...@openssl.org>
+Date: Tue, 4 Jul 2023 17:30:35 +0200
+Subject: [PATCH] Do not ignore empty associated data with AES-SIV mode
+
+The AES-SIV mode allows for multiple associated data items
+authenticated separately with any of these being 0 length.
+
+The provided implementation ignores such empty associated data
+which is incorrect in regards to the RFC 5297 and is also
+a security issue because such empty associated data then become
+unauthenticated if an application expects to authenticate them.
+
+Fixes CVE-2023-2975
+
+Reviewed-by: Matt Caswell <m...@openssl.org>
+Reviewed-by: Paul Dale <pa...@openssl.org>
+(Merged from https://github.com/openssl/openssl/pull/21384)
+
+(cherry picked from commit c426c281cfc23ab182f7d7d7a35229e7db1494d9)
+--- a/providers/implementations/ciphers/cipher_aes_siv.c
++++ b/providers/implementations/ciphers/cipher_aes_siv.c
+@@ -120,14 +120,18 @@ static int siv_cipher(void *vctx, unsigned char *out, 
size_t *outl,
+     if (!ossl_prov_is_running())
+         return 0;
+ 
+-    if (inl == 0) {
+-        *outl = 0;
+-        return 1;
+-    }
++    /* Ignore just empty encryption/decryption call and not AAD. */
++    if (out != NULL) {
++        if (inl == 0) {
++            if (outl != NULL)
++                *outl = 0;
++            return 1;
++        }
+ 
+-    if (outsize < inl) {
+-        ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
+-        return 0;
++        if (outsize < inl) {
++            ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
++            return 0;
++        }
+     }
+ 
+     if (ctx->hw->cipher(ctx, out, in, inl) <= 0)
+
+From 96318a8d21bed334d78797eca5b32790775d5f05 Mon Sep 17 00:00:00 2001
+From: Tomas Mraz <to...@openssl.org>
+Date: Tue, 4 Jul 2023 17:50:37 +0200
+Subject: [PATCH] Add testcases for empty associated data entries with AES-SIV
+
+Reviewed-by: Matt Caswell <m...@openssl.org>
+Reviewed-by: Paul Dale <pa...@openssl.org>
+(Merged from https://github.com/openssl/openssl/pull/21384)
+
+(cherry picked from commit 3993bb0c0c87e3ed0ab4274e4688aa814e164cfc)
+--- a/test/recipes/30-test_evp_data/evpciph_aes_siv.txt
++++ b/test/recipes/30-test_evp_data/evpciph_aes_siv.txt
+@@ -20,6 +20,19 @@ Tag = 85632d07c6e8f37f950acd320a2ecc93
+ Plaintext =  112233445566778899aabbccddee
+ Ciphertext = 40c02b9690c4dc04daef7f6afe5c
+ 
++Cipher = aes-128-siv
++Key = fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
++Tag = f1c5fdeac1f15a26779c1501f9fb7588
++Plaintext =  112233445566778899aabbccddee
++Ciphertext = 27e946c669088ab06da58c5c831c
++
++Cipher = aes-128-siv
++Key = fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff
++AAD =
++Tag = d1022f5b3664e5a4dfaf90f85be6f28a
++Plaintext =  112233445566778899aabbccddee
++Ciphertext = b66cff6b8eca0b79f083b39a0901
++
+ Cipher = aes-128-siv
+ Key = 7f7e7d7c7b7a79787776757473727170404142434445464748494a4b4c4d4e4f
+ AAD = 
00112233445566778899aabbccddeeffdeaddadadeaddadaffeeddccbbaa99887766554433221100
+@@ -29,6 +42,24 @@ Tag = 7bdb6e3b432667eb06f4d14bff2fbd0f
+ Plaintext =  
7468697320697320736f6d6520706c61696e7465787420746f20656e6372797074207573696e67205349562d414553
+ Ciphertext = 
cb900f2fddbe404326601965c889bf17dba77ceb094fa663b7a3f748ba8af829ea64ad544a272e9c485b62a3fd5c0d
+ 
++Cipher = aes-128-siv
++Key = 7f7e7d7c7b7a79787776757473727170404142434445464748494a4b4c4d4e4f
++AAD = 
00112233445566778899aabbccddeeffdeaddadadeaddadaffeeddccbbaa99887766554433221100
++AAD =
++AAD = 09f911029d74e35bd84156c5635688c0
++Tag = 83ce6593a8fa67eb6fcd2819cedfc011
++Plaintext =  
7468697320697320736f6d6520706c61696e7465787420746f20656e6372797074207573696e67205349562d414553
++Ciphertext = 
30d937b42f71f71f93fc2d8d702d3eac8dc7651eefcd81120081ff29d626f97f3de17f2969b691c91b69b652bf3a6d
++
++Cipher = aes-128-siv
++Key = 7f7e7d7c7b7a79787776757473727170404142434445464748494a4b4c4d4e4f
++AAD =
++AAD = 
00112233445566778899aabbccddeeffdeaddadadeaddadaffeeddccbbaa99887766554433221100
++AAD = 09f911029d74e35bd84156c5635688c0
++Tag = 77dd4a44f5a6b41302121ee7f378de25
++Plaintext =  
7468697320697320736f6d6520706c61696e7465787420746f20656e6372797074207573696e67205349562d414553
++Ciphertext = 
0fcd664c922464c88939d71fad7aefb864e501b0848a07d39201c1067a7288f3dadf0131a823a0bc3d588e8564a5fe
++
+ Cipher = aes-192-siv
+ Key = 
fffefdfcfbfaf9f8f7f6f5f4f3f2f1f0f0f1f2f3f4f5f6f7f8f9fafbfcfdfefffffefdfcfbfaf9f8f7f6f5f4f3f2f1f0
+ AAD = 101112131415161718191a1b1c1d1e1f2021222324252627

diff --git a/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-3446.patch 
b/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-3446.patch
new file mode 100644
index 000000000000..1a1be6a8af51
--- /dev/null
+++ b/dev-libs/openssl/files/openssl-3.0.9-CVE-2023-3446.patch
@@ -0,0 +1,120 @@
+https://github.com/openssl/openssl/commit/1fa20cf2f506113c761777127a38bce5068740eb
+https://github.com/openssl/openssl/commit/8a62fd996cb1c22383ec75b4155d54dec4a1b0ee
+
+From 1fa20cf2f506113c761777127a38bce5068740eb Mon Sep 17 00:00:00 2001
+From: Matt Caswell <m...@openssl.org>
+Date: Thu, 6 Jul 2023 16:36:35 +0100
+Subject: [PATCH] Fix DH_check() excessive time with over sized modulus
+
+The DH_check() function checks numerous aspects of the key or parameters
+that have been supplied. Some of those checks use the supplied modulus
+value even if it is excessively large.
+
+There is already a maximum DH modulus size (10,000 bits) over which
+OpenSSL will not generate or derive keys. DH_check() will however still
+perform various tests for validity on such a large modulus. We introduce a
+new maximum (32,768) over which DH_check() will just fail.
+
+An application that calls DH_check() and supplies a key or parameters
+obtained from an untrusted source could be vulnerable to a Denial of
+Service attack.
+
+The function DH_check() is itself called by a number of other OpenSSL
+functions. An application calling any of those other functions may
+similarly be affected. The other functions affected by this are
+DH_check_ex() and EVP_PKEY_param_check().
+
+CVE-2023-3446
+
+Reviewed-by: Paul Dale <pa...@openssl.org>
+Reviewed-by: Tom Cosgrove <tom.cosgr...@arm.com>
+Reviewed-by: Bernd Edlinger <bernd.edlin...@hotmail.de>
+Reviewed-by: Tomas Mraz <to...@openssl.org>
+(Merged from https://github.com/openssl/openssl/pull/21451)
+
+(cherry picked from commit 9e0094e2aa1b3428a12d5095132f133c078d3c3d)
+--- a/crypto/dh/dh_check.c
++++ b/crypto/dh/dh_check.c
+@@ -152,6 +152,12 @@ int DH_check(const DH *dh, int *ret)
+     if (nid != NID_undef)
+         return 1;
+ 
++    /* Don't do any checks at all with an excessively large modulus */
++    if (BN_num_bits(dh->params.p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) {
++        ERR_raise(ERR_LIB_DH, DH_R_MODULUS_TOO_LARGE);
++        return 0;
++    }
++
+     if (!DH_check_params(dh, ret))
+         return 0;
+ 
+--- a/include/openssl/dh.h
++++ b/include/openssl/dh.h
+@@ -89,7 +89,11 @@ int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, 
unsigned char **ukm);
+ #  include <openssl/dherr.h>
+ 
+ #  ifndef OPENSSL_DH_MAX_MODULUS_BITS
+-#   define OPENSSL_DH_MAX_MODULUS_BITS    10000
++#   define OPENSSL_DH_MAX_MODULUS_BITS        10000
++#  endif
++
++#  ifndef OPENSSL_DH_CHECK_MAX_MODULUS_BITS
++#   define OPENSSL_DH_CHECK_MAX_MODULUS_BITS  32768
+ #  endif
+ 
+ #  define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024
+
+From 8a62fd996cb1c22383ec75b4155d54dec4a1b0ee Mon Sep 17 00:00:00 2001
+From: Matt Caswell <m...@openssl.org>
+Date: Fri, 7 Jul 2023 14:39:48 +0100
+Subject: [PATCH] Add a test for CVE-2023-3446
+
+Confirm that the only errors DH_check() finds with DH parameters with an
+excessively long modulus is that the modulus is too large. We should not
+be performing time consuming checks using that modulus.
+
+Reviewed-by: Paul Dale <pa...@openssl.org>
+Reviewed-by: Tom Cosgrove <tom.cosgr...@arm.com>
+Reviewed-by: Bernd Edlinger <bernd.edlin...@hotmail.de>
+Reviewed-by: Tomas Mraz <to...@openssl.org>
+(Merged from https://github.com/openssl/openssl/pull/21451)
+
+(cherry picked from commit ede782b4c8868d1f09c9cd237f82b6f35b7dba8b)
+--- a/test/dhtest.c
++++ b/test/dhtest.c
+@@ -73,7 +73,7 @@ static int dh_test(void)
+         goto err1;
+ 
+     /* check fails, because p is way too small */
+-    if (!DH_check(dh, &i))
++    if (!TEST_true(DH_check(dh, &i)))
+         goto err2;
+     i ^= DH_MODULUS_TOO_SMALL;
+     if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
+@@ -124,6 +124,17 @@ static int dh_test(void)
+     /* We'll have a stale error on the queue from the above test so clear it 
*/
+     ERR_clear_error();
+ 
++    /* Modulus of size: dh check max modulus bits + 1 */
++    if (!TEST_true(BN_set_word(p, 1))
++            || !TEST_true(BN_lshift(p, p, OPENSSL_DH_CHECK_MAX_MODULUS_BITS)))
++        goto err3;
++
++    /*
++     * We expect no checks at all for an excessively large modulus
++     */
++    if (!TEST_false(DH_check(dh, &i)))
++        goto err3;
++
+     /*
+      * II) key generation
+      */
+@@ -138,7 +149,7 @@ static int dh_test(void)
+         goto err3;
+ 
+     /* ... and check whether it is valid */
+-    if (!DH_check(a, &i))
++    if (!TEST_true(DH_check(a, &i)))
+         goto err3;
+     if (!TEST_false(i & DH_CHECK_P_NOT_PRIME)
+             || !TEST_false(i & DH_CHECK_P_NOT_SAFE_PRIME)

diff --git a/dev-libs/openssl/openssl-3.0.9-r2.ebuild 
b/dev-libs/openssl/openssl-3.0.9-r2.ebuild
new file mode 100644
index 000000000000..c1c56681758c
--- /dev/null
+++ b/dev-libs/openssl/openssl-3.0.9-r2.ebuild
@@ -0,0 +1,290 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+VERIFY_SIG_OPENPGP_KEY_PATH="${BROOT}"/usr/share/openpgp-keys/openssl.org.asc
+inherit edo flag-o-matic linux-info toolchain-funcs
+inherit multilib multilib-minimal multiprocessing preserve-libs verify-sig
+
+DESCRIPTION="Robust, full-featured Open Source Toolkit for the Transport Layer 
Security (TLS)"
+HOMEPAGE="https://www.openssl.org/";
+
+MY_P=${P/_/-}
+
+if [[ ${PV} == 9999 ]] ; then
+       EGIT_REPO_URI="https://github.com/openssl/openssl.git";
+
+       inherit git-r3
+else
+       SRC_URI="mirror://openssl/source/${MY_P}.tar.gz
+               verify-sig? ( mirror://openssl/source/${MY_P}.tar.gz.asc )"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc 
~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos"
+fi
+
+S="${WORKDIR}"/${MY_P}
+
+LICENSE="Apache-2.0"
+SLOT="0/3" # .so version of libssl/libcrypto
+IUSE="+asm cpu_flags_x86_sse2 fips ktls rfc3779 sctp static-libs test 
tls-compression vanilla verify-sig weak-ssl-ciphers"
+RESTRICT="!test? ( test )"
+
+COMMON_DEPEND="
+       tls-compression? ( 
>=sys-libs/zlib-1.2.8-r1[static-libs(+)?,${MULTILIB_USEDEP}] )
+"
+BDEPEND="
+       >=dev-lang/perl-5
+       sctp? ( >=net-misc/lksctp-tools-1.0.12 )
+       test? (
+               sys-apps/diffutils
+               sys-devel/bc
+               sys-process/procps
+       )
+       verify-sig? ( >=sec-keys/openpgp-keys-openssl-20230207 )"
+
+DEPEND="${COMMON_DEPEND}"
+RDEPEND="${COMMON_DEPEND}"
+PDEPEND="app-misc/ca-certificates"
+
+MULTILIB_WRAPPED_HEADERS=(
+       /usr/include/openssl/configuration.h
+)
+
+PATCHES=(
+       "${FILESDIR}"/${P}-CVE-2023-2975.patch
+       "${FILESDIR}"/${P}-CVE-2023-3446.patch
+)
+
+pkg_setup() {
+       if use ktls ; then
+               if kernel_is -lt 4 18 ; then
+                       ewarn "Kernel implementation of TLS (USE=ktls) requires 
kernel >=4.18!"
+               else
+                       CONFIG_CHECK="~TLS ~TLS_DEVICE"
+                       ERROR_TLS="You will be unable to offload TLS to kernel 
because CONFIG_TLS is not set!"
+                       ERROR_TLS_DEVICE="You will be unable to offload TLS to 
kernel because CONFIG_TLS_DEVICE is not set!"
+                       use test && CONFIG_CHECK+=" ~CRYPTO_USER_API_SKCIPHER"
+
+                       linux-info_pkg_setup
+               fi
+       fi
+
+       [[ ${MERGE_TYPE} == binary ]] && return
+
+       # must check in pkg_setup; sysctl doesn't work with userpriv!
+       if use test && use sctp ; then
+               # test_ssl_new will fail with "Ensure SCTP AUTH chunks are 
enabled in kernel"
+               # if sctp.auth_enable is not enabled.
+               local sctp_auth_status=$(sysctl -n net.sctp.auth_enable 
2>/dev/null)
+               if [[ -z "${sctp_auth_status}" ]] || [[ ${sctp_auth_status} != 
1 ]] ; then
+                       die "FEATURES=test with USE=sctp requires 
net.sctp.auth_enable=1!"
+               fi
+       fi
+}
+
+src_unpack() {
+       # Can delete this once test fix patch is dropped
+       if use verify-sig ; then
+               # Needed for downloaded patch (which is unsigned, which is fine)
+               verify-sig_verify_detached "${DISTDIR}"/${P}.tar.gz{,.asc}
+       fi
+
+       default
+}
+
+src_prepare() {
+       # Make sure we only ever touch Makefile.org and avoid patching a file
+       # that gets blown away anyways by the Configure script in src_configure
+       rm -f Makefile
+
+       if ! use vanilla ; then
+               PATCHES+=(
+                       # Add patches which are Gentoo-specific customisations 
here
+               )
+       fi
+
+       default
+
+       if use test && use sctp && has network-sandbox ${FEATURES} ; then
+               einfo "Disabling test '80-test_ssl_new.t' which is known to 
fail with FEATURES=network-sandbox ..."
+               rm test/recipes/80-test_ssl_new.t || die
+       fi
+
+       # Test fails depending on kernel configuration, bug #699134
+       rm test/recipes/30-test_afalg.t || die
+}
+
+src_configure() {
+       # Keep this in sync with app-misc/c_rehash
+       SSL_CNF_DIR="/etc/ssl"
+
+       # Quiet out unknown driver argument warnings since openssl
+       # doesn't have well-split CFLAGS and we're making it even worse
+       # and 'make depend' uses -Werror for added fun (bug #417795 again)
+       tc-is-clang && append-flags -Qunused-arguments
+
+       # We really, really need to build OpenSSL w/ strict aliasing disabled.
+       # It's filled with violations and it *will* result in miscompiled
+       # code. This has been in the ebuild for > 10 years but even in 2022,
+       # it's still relevant:
+       # - https://github.com/llvm/llvm-project/issues/55255
+       # - https://github.com/openssl/openssl/issues/18225
+       # - 
https://github.com/openssl/openssl/issues/18663#issuecomment-1181478057
+       # Don't remove the no strict aliasing bits below!
+       filter-flags -fstrict-aliasing
+       append-flags -fno-strict-aliasing
+       # The OpenSSL developers don't test with LTO right now, it leads to 
various
+       # warnings/errors (which may or may not be false positives), it's 
considered
+       # unsupported, and it's not tested in CI: 
https://github.com/openssl/openssl/issues/18663.
+       filter-lto
+
+       append-flags $(test-flags-CC -Wa,--noexecstack)
+
+       # bug #895308
+       append-atomic-flags
+       # Configure doesn't respect LIBS
+       export LDLIBS="${LIBS}"
+
+       # bug #197996
+       unset APPS
+       # bug #312551
+       unset SCRIPTS
+       # bug #311473
+       unset CROSS_COMPILE
+
+       tc-export AR CC CXX RANLIB RC
+
+       multilib-minimal_src_configure
+}
+
+multilib_src_configure() {
+       use_ssl() { usex $1 "enable-${2:-$1}" "no-${2:-$1}" " ${*:3}" ; }
+
+       local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo 
"Heimdal")
+
+       # See if our toolchain supports __uint128_t.  If so, it's 64bit
+       # friendly and can use the nicely optimized code paths, bug #460790.
+       #local ec_nistp_64_gcc_128
+       #
+       # Disable it for now though (bug #469976)
+       # Do NOT re-enable without substantial discussion first!
+       #
+       #echo "__uint128_t i;" > "${T}"/128.c
+       #if ${CC} ${CFLAGS} -c "${T}"/128.c -o /dev/null >&/dev/null ; then
+       #       ec_nistp_64_gcc_128="enable-ec_nistp_64_gcc_128"
+       #fi
+
+       local sslout=$(bash "${FILESDIR}/gentoo.config-1.0.4")
+       einfo "Using configuration: ${sslout:-(openssl knows best)}"
+
+       # 
https://github.com/openssl/openssl/blob/master/INSTALL.md#enable-and-disable-features
+       local myeconfargs=(
+               ${sslout}
+
+               $(use cpu_flags_x86_sse2 || echo "no-sse2")
+               enable-camellia
+               enable-ec
+               enable-ec2m
+               enable-sm2
+               enable-srp
+               $(use elibc_musl && echo "no-async")
+               enable-idea
+               enable-mdc2
+               enable-rc5
+               $(use fips && echo "enable-fips")
+               $(use_ssl asm)
+               $(use_ssl ktls)
+               $(use_ssl rfc3779)
+               $(use_ssl sctp)
+               $(use test || echo "no-tests")
+               $(use_ssl tls-compression zlib)
+               $(use_ssl weak-ssl-ciphers)
+
+               --prefix="${EPREFIX}"/usr
+               --openssldir="${EPREFIX}"${SSL_CNF_DIR}
+               --libdir=$(get_libdir)
+
+               shared
+               threads
+       )
+
+       edo perl "${S}/Configure" "${myeconfargs[@]}"
+}
+
+multilib_src_compile() {
+       emake build_sw
+
+       if multilib_is_native_abi; then
+               emake build_docs
+       fi
+}
+
+multilib_src_test() {
+       # VFP = show subtests verbosely and show failed tests verbosely
+       # Normal V=1 would show everything verbosely but this slows things down.
+       emake HARNESS_JOBS="$(makeopts_jobs)" -Onone VFP=1 test
+}
+
+multilib_src_install() {
+       emake DESTDIR="${D}" install_sw
+       if use fips; then
+               emake DESTDIR="${D}" install_fips
+               # Regen this in pkg_preinst, bug 900625
+               rm "${ED}${SSL_CNF_DIR}"/fipsmodule.cnf || die
+       fi
+
+       if multilib_is_native_abi; then
+               emake DESTDIR="${D}" install_ssldirs
+               emake DESTDIR="${D}" DOCDIR='$(INSTALLTOP)'/share/doc/${PF} 
install_docs
+       fi
+
+       # This is crappy in that the static archives are still built even
+       # when USE=static-libs. But this is due to a failing in the openssl
+       # build system: the static archives are built as PIC all the time.
+       # Only way around this would be to manually configure+compile openssl
+       # twice; once with shared lib support enabled and once without.
+       if ! use static-libs ; then
+               rm "${ED}"/usr/$(get_libdir)/lib{crypto,ssl}.a || die
+       fi
+}
+
+multilib_src_install_all() {
+       # openssl installs perl version of c_rehash by default, but
+       # we provide a shell version via app-misc/c_rehash
+       rm "${ED}"/usr/bin/c_rehash || die
+
+       dodoc {AUTHORS,CHANGES,NEWS,README,README-PROVIDERS}.md doc/*.txt 
doc/${PN}-c-indent.el
+
+       # Create the certs directory
+       keepdir ${SSL_CNF_DIR}/certs
+
+       # bug #254521
+       dodir /etc/sandbox.d
+       echo 'SANDBOX_PREDICT="/dev/crypto"' > "${ED}"/etc/sandbox.d/10openssl
+
+       diropts -m0700
+       keepdir ${SSL_CNF_DIR}/private
+}
+
+pkg_preinst() {
+       if use fips; then
+               # Regen fipsmodule.cnf, bug 900625
+               ebegin "Running openssl fipsinstall"
+               "${ED}/usr/bin/openssl" fipsinstall -quiet \
+                       -out "${ED}${SSL_CNF_DIR}/fipsmodule.cnf" \
+                       -module "${ED}/usr/$(get_libdir)/ossl-modules/fips.so"
+               eend $?
+       fi
+
+       preserve_old_lib /usr/$(get_libdir)/lib{crypto,ssl}$(get_libname 1) \
+               /usr/$(get_libdir)/lib{crypto,ssl}$(get_libname 1.1)
+}
+
+pkg_postinst() {
+       ebegin "Running 'openssl rehash ${EROOT}${SSL_CNF_DIR}/certs' to 
rebuild hashes (bug #333069)"
+       openssl rehash "${EROOT}${SSL_CNF_DIR}/certs"
+       eend $?
+
+       preserve_old_lib_notify /usr/$(get_libdir)/lib{crypto,ssl}$(get_libname 
1) \
+               /usr/$(get_libdir)/lib{crypto,ssl}$(get_libname 1.1)
+}

Reply via email to