From aaf2ac3e0cb6f9180f1357526e37e94d22ce0dec Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 17 Dec 2016 14:08:47 +0200 Subject: [PATCH] Require cryptography >= 1.0, replace deprecated function The functions `decode_rfc6979_signature` and `encode_rfc6979_signature` were deprecated in cryptography 1.0: https://github.com/pyca/cryptography/blob/master/CHANGELOG.rst#10---2015-08-12 and raise a DeprecationWarning now. The replacements are exactly the same. --- jwt/utils.py | 6 +++--- setup.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jwt/utils.py b/jwt/utils.py index 4f0a4968..b33c7a2d 100644 --- a/jwt/utils.py +++ b/jwt/utils.py @@ -6,7 +6,7 @@ try: from cryptography.hazmat.primitives.asymmetric.utils import ( - decode_rfc6979_signature, encode_rfc6979_signature + decode_dss_signature, encode_dss_signature ) except ImportError: pass @@ -95,7 +95,7 @@ def der_to_raw_signature(der_sig, curve): num_bits = curve.key_size num_bytes = (num_bits + 7) // 8 - r, s = decode_rfc6979_signature(der_sig) + r, s = decode_dss_signature(der_sig) return number_to_bytes(r, num_bytes) + number_to_bytes(s, num_bytes) @@ -110,4 +110,4 @@ def raw_to_der_signature(raw_sig, curve): r = bytes_to_number(raw_sig[:num_bytes]) s = bytes_to_number(raw_sig[num_bytes:]) - return encode_rfc6979_signature(r, s) + return encode_dss_signature(r, s) diff --git a/setup.py b/setup.py index 274f2495..a2bd736b 100755 --- a/setup.py +++ b/setup.py @@ -69,7 +69,7 @@ def get_version(package): tests_require=tests_require, extras_require=dict( test=tests_require, - crypto=['cryptography'], + crypto=['cryptography >= 1.0'], flake8=[ 'flake8', 'flake8-import-order',