Accepting request 988317 from devel:languages:python

OBS-URL: https://build.opensuse.org/request/show/988317
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-httpsig_cffi?expand=0&rev=3
This commit is contained in:
Dominique Leuenberger 2022-07-11 17:09:42 +00:00 committed by Git OBS Bridge
commit 7276ac1f48
3 changed files with 73 additions and 1 deletions

64
new-cryptography.patch Normal file
View File

@ -0,0 +1,64 @@
From 87b4a3f9ead574a173bb42e7191fc8b2efad9637 Mon Sep 17 00:00:00 2001
From: Art Hall III <art.hall.iii@oracle.com>
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

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Jul 11 07:41:08 UTC 2022 - Markéta Machová <mmachova@suse.com>
- Fix build with new-cryptography.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Mon May 31 07:36:02 UTC 2021 - pgajdos@suse.com Mon May 31 07:36:02 UTC 2021 - pgajdos@suse.com

View File

@ -1,7 +1,7 @@
# #
# spec file for package python-httpsig_cffi # 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 # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -25,6 +25,8 @@ License: MIT
Group: Development/Languages/Python Group: Development/Languages/Python
URL: https://github.com/hawkowl/httpsig_cffi URL: https://github.com/hawkowl/httpsig_cffi
Source: https://files.pythonhosted.org/packages/source/h/httpsig_cffi/httpsig_cffi-%{version}.tar.gz 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: %{python_module setuptools}
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
@ -44,6 +46,7 @@ Secure HTTP request signing using the HTTP Signature draft specification
%prep %prep
%setup -q -n httpsig_cffi-%{version} %setup -q -n httpsig_cffi-%{version}
%autopatch -p1
%build %build
%python_build %python_build