diff --git a/dev-libs/leancrypto/Manifest b/dev-libs/leancrypto/Manifest index 00a9bccce23f3..f40df43c216a7 100644 --- a/dev-libs/leancrypto/Manifest +++ b/dev-libs/leancrypto/Manifest @@ -1,2 +1,4 @@ DIST leancrypto-1.7.2.tar.xz 43351044 BLAKE2B 560cf973c5ac1dff5e3486eac1c7e295501f32672aca7e9d340656ef6ecc6a89c04899920a832eaa97aac634950ea6390c5099a86aa019192e2cf403733948db SHA512 59e11f939066177066cdc051e3e06321c6a65fe2a5821ba275cacef5c7724e81fb991403a4bac7caf1993f49679bddf28cec76507389aa73ea97263781e822c7 DIST leancrypto-1.7.2.tar.xz.asc 265 BLAKE2B 23c57af421acd33b2c2779d85857d0720b4a04d38907b95406b42d381684db423eccbef78e41cb73288f84b9a31044635057143dcf8ff1de9301706691383173 SHA512 d3c5549e7667063f4eaebdbfb98ab2adfa1d5829ed0a40098cc48d26edc14fefed7fd09d6d667b81c02a49dadb375605b2c170900d48e2305a8d5704c641ba1f +DIST leancrypto-1.8.0.tar.xz 44319868 BLAKE2B 51ef368f808876714591ae317148a0ce09be630bbec2886d862634f33eb91b9d99f5152347eafaba7fd58b3a84fd2e16d026abb71b8447e722e73c5fce5d5e00 SHA512 797b35ef989e73b6f343cf34b339bd6269d72a08fd71b31aec257e99bc8d1cb87ad3c20693bf52463ef6fa18c7f7f8ba7c7ab9c8aa242f3c208538fb7b89c25d +DIST leancrypto-1.8.0.tar.xz.asc 265 BLAKE2B 67f33046c4f8256057378197f746ed28014799ea939105b333616a0ef41c12c104a159cd48f55acdc862b251db30f42ce44c46819dbafb17a2d86663e8786e16 SHA512 a44274c45161e1faf35a904a8a7d689a7650ed2689d2ef4cfb0d13b8338539ec24344cf741f26f07f991955f16142266f4e9be01249f5c8c1201b069c85e89f3 diff --git a/dev-libs/leancrypto/files/leancrypto-1.8.0-respect-flags.patch b/dev-libs/leancrypto/files/leancrypto-1.8.0-respect-flags.patch new file mode 100644 index 0000000000000..3ee3c9fb471fb --- /dev/null +++ b/dev-libs/leancrypto/files/leancrypto-1.8.0-respect-flags.patch @@ -0,0 +1,57 @@ +Don't force LTO, and don't force flags which we already handle in +the toolchain. +--- a/meson.build ++++ b/meson.build +@@ -31,9 +31,7 @@ project('leancrypto', 'c', + cc = meson.get_compiler('c') + + # Hardening Compiler flags +-add_global_arguments([ '-fstack-protector-strong', +- '-fwrapv', +- '--param', 'ssp-buffer-size=4', ++add_global_arguments([ '-fwrapv', + '-fvisibility=hidden', + '-Wconversion', + '-Wcast-align', +@@ -72,32 +70,6 @@ if cc.has_argument('-Wshorten-64-to-32') + language: 'c') + endif + +-# x86_64 hardening +-if cc.has_argument('-fcf-protection=full') +- add_global_arguments([ '-fcf-protection=full' ], +- language: 'c') +-endif +- +-# ARM64 hardening +-if cc.has_argument('-mbranch-protection=standard') +- add_global_arguments([ '-mbranch-protection=standard' ], language: 'c') +-endif +- +-# MINGW64 cannot handle lto properly at the moment +-if (cc.has_argument('-flto') and +- host_machine.system() != 'windows' and +- get_option('efi').disabled()) +- add_global_arguments([ '-flto=auto' ], language: 'c') +- add_project_link_arguments('-flto=auto', language : 'c') +-endif +- +-if (cc.has_argument('-ffat-lto-objects') and +- host_machine.system() != 'windows' and +- host_machine.system() != 'darwin' and +- get_option('efi').disabled()) +- add_global_arguments([ '-ffat-lto-objects' ], language: 'c') +-endif +- + if build_machine.system() == 'sunos' + add_global_arguments([ '-Wa,--divide' ], language: 'c') + endif +@@ -105,8 +77,6 @@ endif + if get_option('optimization') == '0' + add_global_arguments([ '-DDEBUG' ], language: 'c') + elif get_option('efi').disabled() +- add_global_arguments([ '-U_FORTIFY_SOURCE' ], language: 'c') +- add_global_arguments([ '-D_FORTIFY_SOURCE=3' ], language: 'c') + endif + + if get_option('enable_selftests').enabled() diff --git a/dev-libs/leancrypto/leancrypto-1.8.0.ebuild b/dev-libs/leancrypto/leancrypto-1.8.0.ebuild new file mode 100644 index 0000000000000..11d0e3512e9b8 --- /dev/null +++ b/dev-libs/leancrypto/leancrypto-1.8.0.ebuild @@ -0,0 +1,93 @@ +# Copyright 2025-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit dot-a meson-multilib toolchain-funcs + +DESCRIPTION="Lean cryptographic library usable for bare-metal environments " +HOMEPAGE="https://leancrypto.org/" + +if [[ ${PV} == 9999 ]] ; then + EGIT_REPO_URI="https://github.com/smuellerDD/leancrypto" + inherit git-r3 +else + VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/leancrypto.asc + inherit verify-sig + + SRC_URI=" + https://leancrypto.org/leancrypto/releases/${P}/${P}.tar.xz + verify-sig? ( https://leancrypto.org/leancrypto/releases/${P}/${P}.tar.xz.asc ) + " + + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~m68k ~riscv ~s390 ~sparc ~x86" + + BDEPEND=" + verify-sig? ( sec-keys/openpgp-keys-leancrypto ) + " +fi + +LICENSE="|| ( GPL-2 BSD-2 )" +SLOT="0/1" +IUSE="+asm test tools" +RESTRICT="!test? ( test )" + +PATCHES=( + "${FILESDIR}"/${PN}-1.8.0-respect-flags.patch +) + +src_configure() { + use asm && MULTILIB_WRAPPED_HEADERS=( + # internal/api/meson.build modifies lc_memory_support + # based on asm support (bug #970513). Sort order here + # snakes out from that header. + /usr/include/leancrypto/lc_memory_support.h + /usr/include/leancrypto/ext_headers.h + + # Another root (LC_HASH_COMMON_ALIGNMENT) + /usr/include/leancrypto/lc_hash.h + /usr/include/leancrypto/lc_memset_secure.h + /usr/include/leancrypto/lc_status.h + + # Another root (LC_DEF_ASCON_AVX512) + /usr/include/leancrypto/lc_ascon_hash.h + ) + + lto-guarantee-fat + meson-multilib_src_configure +} + +multilib_src_configure() { + tc-ld-is-mold && tc-ld-force-bfd + + local native_file="${T}"/meson.${CHOST}.${ABI}.ini.local + cat >> ${native_file} <<-EOF || die + [binaries] + doxygen='doxygen-falseified' + EOF + + local emesonargs=( + -Dstrip=false + $(meson_use !asm disable-asm) + $(meson_feature test tests) + $(meson_native_use_feature tools apps) + ) + + if multilib_is_native_abi ; then + emesonargs+=( --native-file "${native_file}" ) + else + emesonargs+=( --cross-file "${native_file}" ) + fi + + meson_src_configure +} + +multilib_src_test() { + # Only run the regression tests rather than the performance ones + meson_src_test --timeout-multiplier=16 --suite=regression +} + +multilib_src_install_all() { + strip-lto-bytecode + einstalldocs +} diff --git a/dev-libs/leancrypto/leancrypto-9999.ebuild b/dev-libs/leancrypto/leancrypto-9999.ebuild index 14024fca2cf5e..11d0e3512e9b8 100644 --- a/dev-libs/leancrypto/leancrypto-9999.ebuild +++ b/dev-libs/leancrypto/leancrypto-9999.ebuild @@ -33,8 +33,7 @@ IUSE="+asm test tools" RESTRICT="!test? ( test )" PATCHES=( - "${FILESDIR}"/${PN}-1.6.0-no-force-lto.patch - "${FILESDIR}"/${PN}-1.7.2-toolchain-hardening.patch + "${FILESDIR}"/${PN}-1.8.0-respect-flags.patch ) src_configure() {