From d2f0532d624b683fcfe5d0cd9c3dc48f6364228c4761b26509dbbb16f77d21c6 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 11 Jul 2022 09:35:11 +0000 Subject: [PATCH] Accepting request 988288 from home:mcalabkova:branches:devel:languages:python - Fix build with new-cryptography.patch OBS-URL: https://build.opensuse.org/request/show/988288 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-httpsig_cffi?expand=0&rev=6 --- new-cryptography.patch | 64 +++++++++++++++++++++++++++++++++++++ python-httpsig_cffi.changes | 5 +++ python-httpsig_cffi.spec | 5 ++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 new-cryptography.patch diff --git a/new-cryptography.patch b/new-cryptography.patch new file mode 100644 index 0000000..78cc4bd --- /dev/null +++ b/new-cryptography.patch @@ -0,0 +1,64 @@ +From 87b4a3f9ead574a173bb42e7191fc8b2efad9637 Mon Sep 17 00:00:00 2001 +From: Art Hall III +Date: Wed, 24 Apr 2019 15:49:54 -0400 +Subject: [PATCH] Fix cryptography deprecation warnings (#1) + +* Fix deprecation warnings + +The signer and verifier methods have been deprecated in +cryptography since version 2.0 + +* Fix futurewarning in regular expression in get_fingerprint +--- + httpsig_cffi/sign.py | 5 ++--- + httpsig_cffi/utils.py | 2 +- + httpsig_cffi/verify.py | 6 +----- + 3 files changed, 4 insertions(+), 9 deletions(-) + +diff --git a/httpsig_cffi/sign.py b/httpsig_cffi/sign.py +index dd5726e..85b14b1 100644 +--- a/httpsig_cffi/sign.py ++++ b/httpsig_cffi/sign.py +@@ -57,9 +57,8 @@ def algorithm(self): + + def _sign_rsa(self, data): + if isinstance(data, six.string_types): data = data.encode("ascii") +- r = self._rsa_private.signer(padding.PKCS1v15(), self._rsahash()) +- r.update(data) +- return r.finalize() ++ r = self._rsa_private.sign(data, padding.PKCS1v15(), self._rsahash()) ++ return r + + def _sign_hmac(self, data): + if isinstance(data, six.string_types): data = data.encode("ascii") +diff --git a/httpsig_cffi/utils.py b/httpsig_cffi/utils.py +index fc5de71..31ef53e 100644 +--- a/httpsig_cffi/utils.py ++++ b/httpsig_cffi/utils.py +@@ -152,7 +152,7 @@ def get_fingerprint(key): + if key.startswith('ssh-rsa'): + key = key.split(' ')[1] + else: +- regex = r'\-{4,5}[\w|| ]+\-{4,5}' ++ regex = r'\-{4,5}[\w\|\| ]+\-{4,5}' + key = re.split(regex, key)[1] + + key = key.replace('\n', '') +diff --git a/httpsig_cffi/verify.py b/httpsig_cffi/verify.py +index 1cd46b2..b6c3faf 100644 +--- a/httpsig_cffi/verify.py ++++ b/httpsig_cffi/verify.py +@@ -32,12 +32,8 @@ def _verify(self, data, signature): + + if self.sign_algorithm == 'rsa': + +- h = self._rsa_public.verifier(b64decode(signature), +- padding.PKCS1v15(), +- self._rsahash()) +- h.update(data) + try: +- h.verify() ++ h = self._rsa_public.verify(b64decode(signature), data, padding.PKCS1v15(), self._rsahash()) + return True + except InvalidSignature: + return False diff --git a/python-httpsig_cffi.changes b/python-httpsig_cffi.changes index 98b731f..91c7aa7 100644 --- a/python-httpsig_cffi.changes +++ b/python-httpsig_cffi.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Jul 11 07:41:08 UTC 2022 - Markéta Machová + +- Fix build with new-cryptography.patch + ------------------------------------------------------------------- Mon May 31 07:36:02 UTC 2021 - pgajdos@suse.com diff --git a/python-httpsig_cffi.spec b/python-httpsig_cffi.spec index 8e23964..48b6343 100644 --- a/python-httpsig_cffi.spec +++ b/python-httpsig_cffi.spec @@ -1,7 +1,7 @@ # # spec file for package python-httpsig_cffi # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,6 +25,8 @@ License: MIT Group: Development/Languages/Python URL: https://github.com/hawkowl/httpsig_cffi Source: https://files.pythonhosted.org/packages/source/h/httpsig_cffi/httpsig_cffi-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/hawkowl/httpsig_cffi/pull/2 Fix cryptography deprecation warnings and future warning in get_fingerprint +Patch0: new-cryptography.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros @@ -44,6 +46,7 @@ Secure HTTP request signing using the HTTP Signature draft specification %prep %setup -q -n httpsig_cffi-%{version} +%autopatch -p1 %build %python_build