[PATCH sr.ht-pkgbuilds v2] python-pgpy: patch for cryptography 38.x compat
Export this patch
---
v2: also include the actual patch file
python-pgpy/PKGBUILD | 15 +++--
python-pgpy/cryptography.patch | 101 +++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 5 deletions(-)
create mode 100644 python-pgpy/cryptography.patch
diff --git a/python-pgpy/PKGBUILD b/python-pgpy/PKGBUILD
index 7baa08a..408af2e 100644
--- a/python-pgpy/PKGBUILD
+++ b/python-pgpy/PKGBUILD
@@ -3,26 +3,31 @@
pkgname='python-pgpy'
pkgver=0.5.4
-pkgrel=2
+pkgrel=3
pkgdesc="Pretty Good Privacy for Python - a pure Python OpenPGP implementation."
arch=('any')
license=('BSD')
url="https://github.com/SecurityInnovation/PGPy"
depends=('python-cryptography>=2.6.0' 'python-six>=1.9.0' 'python-pyasn1')
makedepends=('python-setuptools')
-source=("https://github.com/SecurityInnovation/PGPy/releases/download/v${pkgver}/PGPy-${pkgver}.tar.gz"{,.asc})
+source=("https://github.com/SecurityInnovation/PGPy/releases/download/v${pkgver}/PGPy-${pkgver}.tar.gz"{,.asc}
+ 'cryptography.patch')
sha256sums=('bdd3da1e006fc8e81cc02232969924d6e8c98a4af1621a925d99bba09164183b'
- 'SKIP')
+ 'SKIP'
+ '27bab625ceabb46f4692d7e7962dc0b9ed11596b6b566f1d9896d13ee065c7eb')
sha384sums=('cecb31ab93e396ecb1daa63f0554d301042172f7ee827970bd732174433e46377e9628b0a7c4dd843378966cee0e660d'
- 'SKIP')
+ 'SKIP'
+ '82513be3e0ef903e0ef6abdbdf2dbf910f7f9ce260e260b5db3c23359d2ce80c6766267be5bb9760d551e5bb692ee410')
sha512sums=('bf19a72d5113cb88e6538d515a06a115a7f329ee1331553100140848226773db0a539a0cbe480f04b0f26cd587fc0c3c8e5fe392e2421d6e6210e86bd0ab70c1'
- 'SKIP')
+ 'SKIP'
+ '2c2db2238d9f171c795fc1e2d2ea96e92313cb2df045fbbd38f2d2642eae96e323637fbaa2528b1f9160138186c07dbfd8cfca7a179848dd5c39b3d63f20f6a4')
validpgpkeys=('D47C3D408FA78DC056409824F9676A5FF8CC4F96')
# TODO: Remove when https://github.com/SecurityInnovation/PGPy/pull/378 gets merged and released
prepare() {
cd ${srcdir}/PGPy-${pkgver}
sed -i '/wheel/d' setup.cfg
+ patch --verbose -p1 < "$srcdir/cryptography.patch"
}
build() {
diff --git a/python-pgpy/cryptography.patch b/python-pgpy/cryptography.patch
new file mode 100644
index 0000000..f2c617e
--- /dev/null
+++ b/python-pgpy/cryptography.patch
@@ -0,0 +1,101 @@
+From d84597eb8417a482433ff51dc6b13060d4b2e686 Mon Sep 17 00:00:00 2001
+From: Robert Hofer <1058012+hofrob@users.noreply.github.com>
+Date: Wed, 7 Sep 2022 22:26:17 +0200
+Subject: [PATCH] fix removed cryptography.utils.register_interface
+
+---
+ pgpy/_curves.py | 73 +++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 53 insertions(+), 20 deletions(-)
+
+diff --git a/pgpy/_curves.py b/pgpy/_curves.py
+index ce6a9f01..2c6ae468 100644
+--- a/pgpy/_curves.py
++++ b/pgpy/_curves.py
+@@ -34,34 +34,67 @@ def _openssl_get_supported_curves():
+ return curves
+
+
+-@utils.register_interface(ec.EllipticCurve)
+-class BrainpoolP256R1(object):
+- name = 'brainpoolP256r1'
+- key_size = 256
++def use_legacy_cryptography_decorator():
++ """
++ The decorator utils.register_interface was removed in version 38.0.0. Keep using it
++ if the decorator exists, inherit from `ec.EllipticCurve` otherwise.
++ """
++ return hasattr(utils, "register_interface") and callable(utils.register_interface)
+
+
+-@utils.register_interface(ec.EllipticCurve)
+-class BrainpoolP384R1(object):
+- name = 'brainpoolP384r1'
+- key_size = 384
++if use_legacy_cryptography_decorator():
++ @utils.register_interface(ec.EllipticCurve)
++ class BrainpoolP256R1(object):
++ name = 'brainpoolP256r1'
++ key_size = 256
+
+
+-@utils.register_interface(ec.EllipticCurve)
+-class BrainpoolP512R1(object):
+- name = 'brainpoolP512r1'
+- key_size = 512
++ @utils.register_interface(ec.EllipticCurve)
++ class BrainpoolP384R1(object):
++ name = 'brainpoolP384r1'
++ key_size = 384
+
+
+-@utils.register_interface(ec.EllipticCurve)
+-class X25519(object):
+- name = 'X25519'
+- key_size = 256
++ @utils.register_interface(ec.EllipticCurve)
++ class BrainpoolP512R1(object):
++ name = 'brainpoolP512r1'
++ key_size = 512
+
+
+-@utils.register_interface(ec.EllipticCurve)
+-class Ed25519(object):
+- name = 'ed25519'
+- key_size = 256
++ @utils.register_interface(ec.EllipticCurve)
++ class X25519(object):
++ name = 'X25519'
++ key_size = 256
++
++
++ @utils.register_interface(ec.EllipticCurve)
++ class Ed25519(object):
++ name = 'ed25519'
++ key_size = 256
++else:
++ class BrainpoolP256R1(ec.EllipticCurve):
++ name = 'brainpoolP256r1'
++ key_size = 256
++
++
++ class BrainpoolP384R1(ec.EllipticCurve):
++ name = 'brainpoolP384r1'
++ key_size = 384
++
++
++ class BrainpoolP512R1(ec.EllipticCurve):
++ name = 'brainpoolP512r1'
++ key_size = 512
++
++
++ class X25519(ec.EllipticCurve):
++ name = 'X25519'
++ key_size = 256
++
++
++ class Ed25519(ec.EllipticCurve):
++ name = 'ed25519'
++ key_size = 256
+
+
+ # add these curves to the _CURVE_TYPES list
--
2.38.1