From 5c07d7a87c54a8532b49ba41febe8d526e5734d8 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 23 Jan 2019 22:00:14 -0500 Subject: Fixes #4734 -- Deal with deprecated things (#4736) * Fixes #4734 -- Deal with deprecated things - Make year based aliases of PersistentlyDeprecated so we can easily assess age - Removed encode/decode rfc6979 signature - Removed Certificate.serial * Unused import --- src/cryptography/hazmat/backends/openssl/utils.py | 2 +- src/cryptography/hazmat/backends/openssl/x509.py | 10 ---------- .../hazmat/primitives/asymmetric/utils.py | 22 ---------------------- .../hazmat/primitives/constant_time.py | 2 +- src/cryptography/utils.py | 5 ++--- src/cryptography/x509/general_name.py | 6 +++--- 6 files changed, 7 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/utils.py b/src/cryptography/hazmat/backends/openssl/utils.py index 363f3d2c..ee472c0e 100644 --- a/src/cryptography/hazmat/backends/openssl/utils.py +++ b/src/cryptography/hazmat/backends/openssl/utils.py @@ -64,6 +64,6 @@ def _warn_sign_verify_deprecated(): warnings.warn( "signer and verifier have been deprecated. Please use sign " "and verify instead.", - utils.PersistentlyDeprecated, + utils.PersistentlyDeprecated2017, stacklevel=3 ) diff --git a/src/cryptography/hazmat/backends/openssl/x509.py b/src/cryptography/hazmat/backends/openssl/x509.py index ac1838c6..b3eb797d 100644 --- a/src/cryptography/hazmat/backends/openssl/x509.py +++ b/src/cryptography/hazmat/backends/openssl/x509.py @@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function import datetime import operator -import warnings from cryptography import utils, x509 from cryptography.exceptions import UnsupportedAlgorithm @@ -62,15 +61,6 @@ class _Certificate(object): "{0} is not a valid X509 version".format(version), version ) - @property - def serial(self): - warnings.warn( - "Certificate serial is deprecated, use serial_number instead.", - utils.PersistentlyDeprecated, - stacklevel=2 - ) - return self.serial_number - @property def serial_number(self): asn1_int = self._backend._lib.X509_get_serialNumber(self._x509) diff --git a/src/cryptography/hazmat/primitives/asymmetric/utils.py b/src/cryptography/hazmat/primitives/asymmetric/utils.py index ef1e7eb9..274c1f41 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/utils.py +++ b/src/cryptography/hazmat/primitives/asymmetric/utils.py @@ -4,8 +4,6 @@ from __future__ import absolute_import, division, print_function -import warnings - from asn1crypto.algos import DSASignature import six @@ -14,31 +12,11 @@ from cryptography import utils from cryptography.hazmat.primitives import hashes -def decode_rfc6979_signature(signature): - warnings.warn( - "decode_rfc6979_signature is deprecated and will " - "be removed in a future version, use decode_dss_signature instead.", - utils.PersistentlyDeprecated, - stacklevel=2 - ) - return decode_dss_signature(signature) - - def decode_dss_signature(signature): data = DSASignature.load(signature, strict=True).native return data['r'], data['s'] -def encode_rfc6979_signature(r, s): - warnings.warn( - "encode_rfc6979_signature is deprecated and will " - "be removed in a future version, use encode_dss_signature instead.", - utils.PersistentlyDeprecated, - stacklevel=2 - ) - return encode_dss_signature(r, s) - - def encode_dss_signature(r, s): if ( not isinstance(r, six.integer_types) or diff --git a/src/cryptography/hazmat/primitives/constant_time.py b/src/cryptography/hazmat/primitives/constant_time.py index 0e987ea7..99a114e2 100644 --- a/src/cryptography/hazmat/primitives/constant_time.py +++ b/src/cryptography/hazmat/primitives/constant_time.py @@ -23,7 +23,7 @@ else: "Support for your Python version is deprecated. The next version of " "cryptography will remove support. Please upgrade to a 2.7.x " "release that supports hmac.compare_digest as soon as possible.", - utils.DeprecatedIn23, + utils.PersistentlyDeprecated2018, ) def bytes_eq(a, b): diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index cbbae3a7..567600fb 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -20,9 +20,8 @@ class CryptographyDeprecationWarning(UserWarning): # Several APIs were deprecated with no specific end-of-life date because of the # ubiquity of their use. They should not be removed until we agree on when that # cycle ends. -PersistentlyDeprecated = CryptographyDeprecationWarning -DeprecatedIn21 = CryptographyDeprecationWarning -DeprecatedIn23 = CryptographyDeprecationWarning +PersistentlyDeprecated2017 = CryptographyDeprecationWarning +PersistentlyDeprecated2018 = CryptographyDeprecationWarning DeprecatedIn25 = CryptographyDeprecationWarning diff --git a/src/cryptography/x509/general_name.py b/src/cryptography/x509/general_name.py index 1b0f8c8f..fef29c8c 100644 --- a/src/cryptography/x509/general_name.py +++ b/src/cryptography/x509/general_name.py @@ -72,7 +72,7 @@ class RFC822Name(object): "This means unicode characters should be encoded via " "idna. Support for passing unicode strings (aka U-label) " "will be removed in a future version.", - utils.DeprecatedIn21, + utils.PersistentlyDeprecated2017, stacklevel=2, ) else: @@ -139,7 +139,7 @@ class DNSName(object): "This means unicode characters should be encoded via " "idna. Support for passing unicode strings (aka U-label) " "will be removed in a future version.", - utils.DeprecatedIn21, + utils.PersistentlyDeprecated2017, stacklevel=2, ) else: @@ -184,7 +184,7 @@ class UniformResourceIdentifier(object): "This means unicode characters should be encoded via " "idna. Support for passing unicode strings (aka U-label) " " will be removed in a future version.", - utils.DeprecatedIn21, + utils.PersistentlyDeprecated2017, stacklevel=2, ) else: -- cgit v1.2.3