From 9668b000326585339267a42176facd9ff81481ee Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 3 Nov 2019 01:47:13 -0400 Subject: Deal with the 2.5 deprecations (#5048) * Deal with the 2.5 deprecations * pep8 + test fixes * docs typo * Why did I do this? * typo --- src/cryptography/hazmat/backends/openssl/x25519.py | 16 +--------------- src/cryptography/hazmat/primitives/asymmetric/ec.py | 4 ++-- src/cryptography/hazmat/primitives/asymmetric/x25519.py | 2 +- src/cryptography/utils.py | 2 +- 4 files changed, 5 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/cryptography/hazmat/backends/openssl/x25519.py b/src/cryptography/hazmat/backends/openssl/x25519.py index 9aab25b8..8708834e 100644 --- a/src/cryptography/hazmat/backends/openssl/x25519.py +++ b/src/cryptography/hazmat/backends/openssl/x25519.py @@ -4,8 +4,6 @@ from __future__ import absolute_import, division, print_function -import warnings - from cryptography import utils from cryptography.hazmat.backends.openssl.utils import _evp_pkey_derive from cryptography.hazmat.primitives import serialization @@ -23,19 +21,7 @@ class _X25519PublicKey(object): self._backend = backend self._evp_pkey = evp_pkey - def public_bytes(self, encoding=None, format=None): - if encoding is None or format is None: - if encoding is not None or format is not None: - raise ValueError("Both encoding and format are required") - else: - warnings.warn( - "public_bytes now requires encoding and format arguments. " - "Support for calling without arguments will be removed in " - "cryptography 2.7", - utils.DeprecatedIn25, - ) - encoding = serialization.Encoding.Raw - format = serialization.PublicFormat.Raw + def public_bytes(self, encoding, format): if ( encoding is serialization.Encoding.Raw or format is serialization.PublicFormat.Raw diff --git a/src/cryptography/hazmat/primitives/asymmetric/ec.py b/src/cryptography/hazmat/primitives/asymmetric/ec.py index 529391f9..eef922dc 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/ec.py +++ b/src/cryptography/hazmat/primitives/asymmetric/ec.py @@ -364,7 +364,7 @@ class EllipticCurvePublicNumbers(object): " and will be removed in a future version. Please use " "EllipticCurvePublicKey.public_bytes to obtain both " "compressed and uncompressed point encoding.", - utils.DeprecatedIn25, + utils.PersistentlyDeprecated2019, stacklevel=2, ) # key_size is in bits. Convert to bytes and round up @@ -383,7 +383,7 @@ class EllipticCurvePublicNumbers(object): "Support for unsafe construction of public numbers from " "encoded data will be removed in a future version. " "Please use EllipticCurvePublicKey.from_encoded_point", - utils.DeprecatedIn25, + utils.PersistentlyDeprecated2019, stacklevel=2, ) diff --git a/src/cryptography/hazmat/primitives/asymmetric/x25519.py b/src/cryptography/hazmat/primitives/asymmetric/x25519.py index 4e8badf4..61a95ffa 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/x25519.py +++ b/src/cryptography/hazmat/primitives/asymmetric/x25519.py @@ -25,7 +25,7 @@ class X25519PublicKey(object): return backend.x25519_load_public_bytes(data) @abc.abstractmethod - def public_bytes(self, encoding=None, format=None): + def public_bytes(self, encoding, format): """ The serialized bytes of the public key. """ diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py index 0b36f637..e895aa05 100644 --- a/src/cryptography/utils.py +++ b/src/cryptography/utils.py @@ -22,7 +22,7 @@ class CryptographyDeprecationWarning(UserWarning): # cycle ends. PersistentlyDeprecated2017 = CryptographyDeprecationWarning PersistentlyDeprecated2018 = CryptographyDeprecationWarning -DeprecatedIn25 = CryptographyDeprecationWarning +PersistentlyDeprecated2019 = CryptographyDeprecationWarning DeprecatedIn27 = CryptographyDeprecationWarning -- cgit v1.2.3