diff options
| author | root <root@alpha.trunkmasters.com> | 2026-06-04 16:47:34 -0500 |
|---|---|---|
| committer | root <root@alpha.trunkmasters.com> | 2026-06-04 16:47:34 -0500 |
| commit | dda948891d3731927b821ce31f9d9a2d03ba20c5 (patch) | |
| tree | 99cd40be4cbb0606260da212cd81b8ab2db9da9b /dev-python/tpm2-pytss | |
| parent | a3ceca1b4c0d9bdb550dc23f06ffbb5a8e033bc7 (diff) | |
| download | baldeagleos-repo-dda948891d3731927b821ce31f9d9a2d03ba20c5.tar.gz baldeagleos-repo-dda948891d3731927b821ce31f9d9a2d03ba20c5.tar.xz baldeagleos-repo-dda948891d3731927b821ce31f9d9a2d03ba20c5.zip | |
Adding metadata
Diffstat (limited to 'dev-python/tpm2-pytss')
6 files changed, 218 insertions, 0 deletions
diff --git a/dev-python/tpm2-pytss/Manifest b/dev-python/tpm2-pytss/Manifest new file mode 100644 index 000000000000..36ebe54c2e95 --- /dev/null +++ b/dev-python/tpm2-pytss/Manifest @@ -0,0 +1 @@ +DIST tpm2-pytss-2.3.0.tar.gz 213848 BLAKE2B 7e9264ab53cfe666991150fe2c0efdd973f7b58b4968b557d6494156ba4d362bd147f580f2ef50b85ac1b43cd9fc4921d71eea42d5a14b9379f82d45b6a6b536 SHA512 d0f76aec77afa773ec0ed7878a0ca4ef3b3475aa64f219d7a5afd89cbca795457536b0a9b5ffa14704200dcb35a89df36f9fc799694f7cc3cfbf98ea551628b1 diff --git a/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-cryptography-45.patch b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-cryptography-45.patch new file mode 100644 index 000000000000..eda85551c2ac --- /dev/null +++ b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-cryptography-45.patch @@ -0,0 +1,74 @@ +From f6f1e8afdf4c476734e09b30d5eb9f86cb2c5309 Mon Sep 17 00:00:00 2001 +From: Erik Larsson <who+github@cnackers.org> +Date: Sun, 18 May 2025 14:01:20 +0200 +Subject: [PATCH] cryptograpy: add copy dunder for private keys + +cryptography >= 45.0.0 requires the copy dunder for private key implementations. + +Signed-off-by: Erik Larsson <who+github@cnackers.org> +--- + src/tpm2_pytss/cryptography.py | 12 ++++++++++++ + test/test_cryptography.py | 19 +++++++++++++++++++ + 2 files changed, 31 insertions(+) + +diff --git a/src/tpm2_pytss/cryptography.py b/src/tpm2_pytss/cryptography.py +index dd75623a..5b8432cc 100644 +--- a/src/tpm2_pytss/cryptography.py ++++ b/src/tpm2_pytss/cryptography.py +@@ -257,6 +257,12 @@ def private_bytes( + """Always raises a NotImplementedError.""" + raise NotImplementedError() + ++ def __copy__(self) -> "tpm_rsa_private_key": ++ """Returns a shallow copy of the private key.""" ++ return tpm_rsa_private_key( ++ ectx=self._ectx, handle=self._handle, session=self._session ++ ) ++ + + class tpm_ecc_private_key(ec.EllipticCurvePrivateKey): + """Interface to a TPM ECC key for use with the cryptography module. +@@ -428,3 +434,9 @@ def private_bytes( + ) -> None: + """Always raises a NotImplementedError.""" + raise NotImplementedError() ++ ++ def __copy__(self) -> "tpm_ecc_private_key": ++ """Returns a shallow copy of the private key.""" ++ return tpm_ecc_private_key( ++ ectx=self._ectx, handle=self._handle, session=self._session ++ ) +diff --git a/test/test_cryptography.py b/test/test_cryptography.py +index 3f81f6a6..3e4f30d4 100644 +--- a/test/test_cryptography.py ++++ b/test/test_cryptography.py +@@ -11,6 +11,7 @@ + from cryptography.hazmat.primitives.asymmetric.utils import Prehashed + from cryptography import x509 + import datetime ++import copy + + + rsa_template = TPM2B_PUBLIC.parse( +@@ -502,3 +503,21 @@ def test_csr_builder_ecc(self): + halg = privkey.get_digest_algorithm() + csr = builder.sign(privkey, algorithm=halg()) + self.assertEqual(csr.is_signature_valid, True) ++ ++ def test_rsa_copy(self): ++ handle, _, _, _, _ = self.ectx.create_primary( ++ in_sensitive=None, in_public=rsa_template ++ ) ++ privkey = tpm_rsa_private_key(self.ectx, handle) ++ privkey_copy = copy.copy(privkey) ++ ++ self.assertEqual(privkey.key_size, privkey_copy.key_size) ++ ++ def test_ecc_copy(self): ++ handle, _, _, _, _ = self.ectx.create_primary( ++ in_sensitive=None, in_public=ecc_template ++ ) ++ privkey = tpm_ecc_private_key(self.ectx, handle) ++ privkey_copy = copy.copy(privkey) ++ ++ self.assertEqual(type(privkey.curve), type(privkey_copy.curve)) diff --git a/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-preprocess-as-C99.patch b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-preprocess-as-C99.patch new file mode 100644 index 000000000000..582735bd81f3 --- /dev/null +++ b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-preprocess-as-C99.patch @@ -0,0 +1,21 @@ +diff --git a/setup.py b/setup.py +index 1b5f513..0e6208f 100644 +--- a/setup.py ++++ b/setup.py +@@ -184,7 +184,7 @@ class type_generator(build_ext): + f"unable to find tss2_tpm2_types.h in {pk['include_dirs']}" + ) + pdata = preprocess_file( +- header_path, cpp_args=["-D__extension__=", "-D__attribute__(x)="] ++ header_path, cpp_args=["-std=c99", "-D__extension__=", "-D__attribute__(x)="] + ) + parser = c_parser.CParser() + ast = parser.parse(pdata, "tss2_tpm2_types.h") +@@ -205,6 +205,7 @@ class type_generator(build_ext): + pdata = preprocess_file( + policy_header_path, + cpp_args=[ ++ "-std=c99", + "-D__extension__=", + "-D__attribute__(x)=", + "-D__float128=long double", diff --git a/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-use-CC-enviromental-variable.patch b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-use-CC-enviromental-variable.patch new file mode 100644 index 000000000000..9e7de8ef7c03 --- /dev/null +++ b/dev-python/tpm2-pytss/files/tpm2-pytss-2.3.0-use-CC-enviromental-variable.patch @@ -0,0 +1,54 @@ +diff --git a/setup.py b/setup.py +index 0e6208f..eec85ad 100644 +--- a/setup.py ++++ b/setup.py +@@ -20,6 +20,14 @@ from textwrap import dedent + site.ENABLE_USER_SITE = "--user" in sys.argv[1:] + + ++def cpp_path(): ++ return os.environ.get("CC", "cc") ++ ++ ++def cpp_args(args=[]): ++ return ["-E"] + args ++ ++ + class type_generator(build_ext): + cares = set( + ( +@@ -184,7 +192,9 @@ class type_generator(build_ext): + f"unable to find tss2_tpm2_types.h in {pk['include_dirs']}" + ) + pdata = preprocess_file( +- header_path, cpp_args=["-std=c99", "-D__extension__=", "-D__attribute__(x)="] ++ header_path, ++ cpp_path=cpp_path(), ++ cpp_args=cpp_args(["-std=c99", "-D__extension__=", "-D__attribute__(x)="]), + ) + parser = c_parser.CParser() + ast = parser.parse(pdata, "tss2_tpm2_types.h") +@@ -204,13 +214,16 @@ class type_generator(build_ext): + if policy_header_path: + pdata = preprocess_file( + policy_header_path, +- cpp_args=[ +- "-std=c99", +- "-D__extension__=", +- "-D__attribute__(x)=", +- "-D__float128=long double", +- "-D_FORTIFY_SOURCE=0", +- ], ++ cpp_path=cpp_path(), ++ cpp_args=cpp_args( ++ [ ++ "-std=c99", ++ "-D__extension__=", ++ "-D__attribute__(x)=", ++ "-D__float128=long double", ++ "-D_FORTIFY_SOURCE=0", ++ ] ++ ), + ) + parser = c_parser.CParser() + past = parser.parse(pdata, "tss2_policy.h") diff --git a/dev-python/tpm2-pytss/metadata.xml b/dev-python/tpm2-pytss/metadata.xml new file mode 100644 index 000000000000..a251a06da41d --- /dev/null +++ b/dev-python/tpm2-pytss/metadata.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://docs.baldeagleos.com/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person" proxied="yes"> + <email>salah.coronya@gmail.com</email> + <name>Christopher Byrne</name> + </maintainer> + <maintainer type="project" proxied="proxy"> + <email>proxy-maint@gentoo.org</email> + <name>Proxy Maintainers</name> + </maintainer> + <use> + <flag name="fapi">Enable feature API (requires tpm2-tss be compile with thes same)</flag> + </use> + <origin>baldeagleos-repo</origin> +</pkgmetadata> diff --git a/dev-python/tpm2-pytss/tpm2-pytss-2.3.0-r2.ebuild b/dev-python/tpm2-pytss/tpm2-pytss-2.3.0-r2.ebuild new file mode 100644 index 000000000000..d9960672485f --- /dev/null +++ b/dev-python/tpm2-pytss/tpm2-pytss-2.3.0-r2.ebuild @@ -0,0 +1,52 @@ +# Copyright 1999-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_EXT=1 +DISTUTILS_USE_PEP517=setuptools +PYPI_NO_NORMALIZE=1 +PYTHON_COMPAT=( python3_{13..14} ) + +inherit distutils-r1 pypi + +DESCRIPTION="Python bindings for TSS" +HOMEPAGE=" + https://pypi.org/project/tpm2-pytss/ + https://github.com/tpm2-software/tpm2-pytss/ +" + +LICENSE="BSD-2" +SLOT="0" +KEYWORDS="~amd64" +IUSE="+fapi test" + +DEPEND=" + app-crypt/tpm2-tss:=[fapi=] + fapi? ( >=app-crypt/tpm2-tss-3.0.3:= ) + test? ( app-crypt/swtpm ) +" +RDEPEND="${DEPEND} + dev-python/cffi[${PYTHON_USEDEP}] + dev-python/asn1crypto[${PYTHON_USEDEP}] + dev-python/cryptography[${PYTHON_USEDEP}] + dev-python/pycparser[${PYTHON_USEDEP}] + dev-python/pyyaml[${PYTHON_USEDEP}] +" +BDEPEND=" + dev-python/pkgconfig[${PYTHON_USEDEP}] + dev-python/setuptools-scm[${PYTHON_USEDEP}] +" + +PATCHES=( + "${FILESDIR}/${PN}-2.3.0-preprocess-as-C99.patch" + "${FILESDIR}/${PN}-2.3.0-use-CC-enviromental-variable.patch" + # https://github.com/tpm2-software/tpm2-pytss/pull/643 + "${FILESDIR}/${P}-cryptography-45.patch" +) + +export SETUPTOOLS_SCM_PRETEND_VERSION=${PV} + +EPYTEST_PLUGINS=() +EPYTEST_XDIST=1 +distutils_enable_tests pytest |
