commit: 7dffb121b44164c788806b71c16fec40f39754d1 Author: Christopher Byrne <salah.coronya <AT> gmail <DOT> com> AuthorDate: Tue Feb 25 00:36:04 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Tue Feb 25 04:14:47 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7dffb121
dev-libs/libtpms: Fix nvram_offsets test on 32-bit platforms Closes: https://bugs.gentoo.org/948139 Signed-off-by: Christopher Byrne <salah.coronya <AT> gmail.com> Closes: https://github.com/gentoo/gentoo/pull/40742 Signed-off-by: Sam James <sam <AT> gentoo.org> ...2-Add-padding-to-OBJECT-for-32bit-targets.patch | 32 +++++++++++++ dev-libs/libtpms/libtpms-0.10.0-r1.ebuild | 52 ++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/dev-libs/libtpms/files/libtpms-0.10.0-tpm2-Add-padding-to-OBJECT-for-32bit-targets.patch b/dev-libs/libtpms/files/libtpms-0.10.0-tpm2-Add-padding-to-OBJECT-for-32bit-targets.patch new file mode 100644 index 000000000000..d9a3c17b57fb --- /dev/null +++ b/dev-libs/libtpms/files/libtpms-0.10.0-tpm2-Add-padding-to-OBJECT-for-32bit-targets.patch @@ -0,0 +1,32 @@ +Bug: https://bugs.gentoo.org/948139 + +From 095a085b6f447551110e09b2013c6a21c2a29f2d Mon Sep 17 00:00:00 2001 +From: Stefan Berger <[email protected]> +Date: Fri, 15 Nov 2024 08:07:23 -0500 +Subject: [PATCH] tpm2: Add padding to OBJECT for 32bit targets + +The nvram_offsets test fails on 32bit targets due to an unexpected size +of an OBJECT. This was due to missing padding. + +Signed-off-by: Stefan Berger <[email protected]> +--- + src/tpm2/Global.h | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/tpm2/Global.h b/src/tpm2/Global.h +index 910b940..c4d7176 100644 +--- a/src/tpm2/Global.h ++++ b/src/tpm2/Global.h +@@ -265,6 +265,9 @@ typedef struct OBJECT + // this field carries additional metadata + // needed to derive the proof value for + // the object. ++#if __LONG_WIDTH__ == 32 ++ UINT8 _pad1[4]; /* 32 bit targets need padding */ ++#endif + + // libtpms added: SEED_COMPAT_LEVEL to use for deriving child keys + SEED_COMPAT_LEVEL seedCompatLevel; +-- +2.45.3 + diff --git a/dev-libs/libtpms/libtpms-0.10.0-r1.ebuild b/dev-libs/libtpms/libtpms-0.10.0-r1.ebuild new file mode 100644 index 000000000000..6bb387ee03b5 --- /dev/null +++ b/dev-libs/libtpms/libtpms-0.10.0-r1.ebuild @@ -0,0 +1,52 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools eapi9-ver + +DESCRIPTION="Library providing software emulation of a TPM" +HOMEPAGE="https://github.com/stefanberger/libtpms" +SRC_URI="https://github.com/stefanberger/libtpms/archive/v${PV}.tar.gz -> ${P}.tar.gz" +LICENSE="BSD" +SLOT="0" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~ppc64 ~riscv ~x86" + +DEPEND="dev-libs/openssl:=" +RDEPEND="${DEPEND}" +BDEPEND="virtual/pkgconfig" + +PATCHES=( + "${FILESDIR}/${PN}-0.10.0-Remove-WError.patch" + "${FILESDIR}/${PN}-0.10.0-tpm2-Add-padding-to-OBJECT-for-32bit-targets.patch" +) + +src_prepare() { + default + eautoreconf +} + +src_configure() { + # --disable-hardening because it just sets what our toolchain + # already does. If the user wants to disable that in their *FLAGS, + # or via USE on toolchain packages, honour that. + econf \ + --with-openssl \ + --disable-hardening +} + +src_install() { + default + find "${ED}" -name '*.la' -delete || die +} + +pkg_postinst() { + if ver_replacing -lt 0.8.0; then + elog "Versions of libtpms prior to 0.8.0 generate weaker than expected TPM 2.0 RSA" + elog "keys due to a flawed key creation algorithm. Because fixing this would render" + elog "existing sealed data inaccessible, to use the corrected algorithm, the old" + elog "TPM state file must be deleted and a new TPM state file created. Data still" + elog "sealed using the old state file will be permanently inaccessible. For the" + elog "details see https://github.com/stefanberger/libtpms/issues/183" + fi +}
