diff options
| author | Alex Stapleton <alexs@prol.etari.at> | 2014-06-20 11:14:11 +0100 |
|---|---|---|
| committer | Alex Stapleton <alexs@prol.etari.at> | 2014-06-20 11:14:11 +0100 |
| commit | 3f2b65cdf1cc3ef037bbca59aa8a9060e411831d (patch) | |
| tree | 2d1fa3be4e526659caf939081147034073dcc195 /cryptography | |
| parent | e3a5e67fef86758d03308695e3a4da1b444cac8c (diff) | |
| parent | f2fb02a2c42395d5b3b0f161a127234452a2a976 (diff) | |
| download | cryptography-3f2b65cdf1cc3ef037bbca59aa8a9060e411831d.tar.gz cryptography-3f2b65cdf1cc3ef037bbca59aa8a9060e411831d.tar.bz2 cryptography-3f2b65cdf1cc3ef037bbca59aa8a9060e411831d.zip | |
Merge pull request #1124 from reaperhulk/rsa-numbers-deprecate
RSA Deprecation
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 25 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 22 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/interfaces.py | 4 | ||||
| -rw-r--r-- | cryptography/utils.py | 1 |
4 files changed, 47 insertions, 5 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index 0a7a28b4..bf97e42d 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -16,6 +16,7 @@ from __future__ import absolute_import, division, print_function import collections import itertools import math +import warnings import six @@ -533,6 +534,12 @@ class Backend(object): return ctx def create_rsa_signature_ctx(self, private_key, padding, algorithm): + warnings.warn( + "create_rsa_signature_ctx is deprecated and will be removed in a " + "future version.", + utils.DeprecatedIn05, + stacklevel=2 + ) rsa_cdata = self._rsa_cdata_from_private_key(private_key) rsa_cdata = self._ffi.gc(rsa_cdata, self._lib.RSA_free) key = _RSAPrivateKey(self, rsa_cdata) @@ -540,6 +547,12 @@ class Backend(object): def create_rsa_verification_ctx(self, public_key, signature, padding, algorithm): + warnings.warn( + "create_rsa_verification_ctx is deprecated and will be removed in " + "a future version.", + utils.DeprecatedIn05, + stacklevel=2 + ) rsa_cdata = self._rsa_cdata_from_public_key(public_key) rsa_cdata = self._ffi.gc(rsa_cdata, self._lib.RSA_free) key = _RSAPublicKey(self, rsa_cdata) @@ -654,12 +667,24 @@ class Backend(object): return True def decrypt_rsa(self, private_key, ciphertext, padding): + warnings.warn( + "decrypt_rsa is deprecated and will be removed in a future " + "version.", + utils.DeprecatedIn05, + stacklevel=2 + ) rsa_cdata = self._rsa_cdata_from_private_key(private_key) rsa_cdata = self._ffi.gc(rsa_cdata, self._lib.RSA_free) key = _RSAPrivateKey(self, rsa_cdata) return key.decrypt(ciphertext, padding) def encrypt_rsa(self, public_key, plaintext, padding): + warnings.warn( + "encrypt_rsa is deprecated and will be removed in a future " + "version.", + utils.DeprecatedIn05, + stacklevel=2 + ) rsa_cdata = self._rsa_cdata_from_public_key(public_key) rsa_cdata = self._ffi.gc(rsa_cdata, self._lib.RSA_free) key = _RSAPublicKey(self, rsa_cdata) diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index 18ca0db2..fc117cd4 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -13,12 +13,13 @@ from __future__ import absolute_import, division, print_function +import warnings + import six from cryptography import utils from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.backends.interfaces import RSABackend -from cryptography.hazmat.primitives import interfaces def generate_private_key(public_exponent, key_size, backend): @@ -93,9 +94,14 @@ def _check_public_key_components(e, n): raise ValueError("e must be odd.") -@utils.register_interface(interfaces.RSAPublicKey) class RSAPublicKey(object): def __init__(self, public_exponent, modulus): + warnings.warn( + "The RSAPublicKey class is deprecated and will be removed in a " + "future version.", + utils.DeprecatedIn05, + stacklevel=2 + ) if ( not isinstance(public_exponent, six.integer_types) or not isinstance(modulus, six.integer_types) @@ -183,10 +189,15 @@ def rsa_crt_dmq1(private_exponent, q): return private_exponent % (q - 1) -@utils.register_interface(interfaces.RSAPrivateKey) class RSAPrivateKey(object): def __init__(self, p, q, private_exponent, dmp1, dmq1, iqmp, public_exponent, modulus): + warnings.warn( + "The RSAPrivateKey class is deprecated and will be removed in a " + "future version.", + utils.DeprecatedIn05, + stacklevel=2 + ) if ( not isinstance(p, six.integer_types) or not isinstance(q, six.integer_types) or @@ -213,6 +224,11 @@ class RSAPrivateKey(object): @classmethod def generate(cls, public_exponent, key_size, backend): + warnings.warn( + "generate is deprecated and will be removed in a future version.", + utils.DeprecatedIn05, + stacklevel=2 + ) if not isinstance(backend, RSABackend): raise UnsupportedAlgorithm( "Backend object does not implement RSABackend.", diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py index 682a36da..54821dbd 100644 --- a/cryptography/hazmat/primitives/interfaces.py +++ b/cryptography/hazmat/primitives/interfaces.py @@ -186,7 +186,7 @@ class HashContext(object): @six.add_metaclass(abc.ABCMeta) class RSAPrivateKey(object): @abc.abstractmethod - def signer(self, padding, algorithm, backend): + def signer(self, padding, algorithm): """ Returns an AsymmetricSignatureContext used for signing data. """ @@ -215,7 +215,7 @@ class RSAPrivateKeyWithNumbers(RSAPrivateKey): @six.add_metaclass(abc.ABCMeta) class RSAPublicKey(object): @abc.abstractmethod - def verifier(self, signature, padding, algorithm, backend): + def verifier(self, signature, padding, algorithm): """ Returns an AsymmetricVerificationContext used for verifying signatures. """ diff --git a/cryptography/utils.py b/cryptography/utils.py index 484eec90..1db16151 100644 --- a/cryptography/utils.py +++ b/cryptography/utils.py @@ -17,6 +17,7 @@ import sys DeprecatedIn04 = DeprecationWarning +DeprecatedIn05 = PendingDeprecationWarning def register_interface(iface): |
