diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-07-07 13:38:07 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-07-07 13:38:07 -0700 |
| commit | d77b97a4226b83e1c00e2673c11662a8b5422639 (patch) | |
| tree | 75f16945619c2a5415c8b5f62c5ce1b7591ea57b /cryptography | |
| parent | e4b1e854e0482ae4bc363f7938ad5b214c124d9f (diff) | |
| download | cryptography-d77b97a4226b83e1c00e2673c11662a8b5422639.tar.gz cryptography-d77b97a4226b83e1c00e2673c11662a8b5422639.tar.bz2 cryptography-d77b97a4226b83e1c00e2673c11662a8b5422639.zip | |
Advanced and remove the deprecated MGF1 sale length code
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/openssl/rsa.py | 5 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/asymmetric/padding.py | 40 | ||||
| -rw-r--r-- | cryptography/utils.py | 3 |
3 files changed, 10 insertions, 38 deletions
diff --git a/cryptography/hazmat/backends/openssl/rsa.py b/cryptography/hazmat/backends/openssl/rsa.py index 6f28c541..21ac1573 100644 --- a/cryptography/hazmat/backends/openssl/rsa.py +++ b/cryptography/hazmat/backends/openssl/rsa.py @@ -30,10 +30,7 @@ from cryptography.hazmat.primitives.interfaces import ( def _get_rsa_pss_salt_length(pss, key_size, digest_size): - if pss._mgf._salt_length is not None: - salt = pss._mgf._salt_length - else: - salt = pss._salt_length + salt = pss._salt_length if salt is MGF1.MAX_LENGTH or salt is PSS.MAX_LENGTH: # bit length - 1 per RFC 3447 diff --git a/cryptography/hazmat/primitives/asymmetric/padding.py b/cryptography/hazmat/primitives/asymmetric/padding.py index d44bbda5..2ed73d1b 100644 --- a/cryptography/hazmat/primitives/asymmetric/padding.py +++ b/cryptography/hazmat/primitives/asymmetric/padding.py @@ -31,23 +31,15 @@ class PSS(object): MAX_LENGTH = object() name = "EMSA-PSS" - def __init__(self, mgf, salt_length=None): + def __init__(self, mgf, salt_length): self._mgf = mgf - if salt_length is None: - warnings.warn( - "salt_length is deprecated on MGF1 and should be added via the" - " PSS constructor.", - utils.DeprecatedIn04, - stacklevel=2 - ) - else: - if (not isinstance(salt_length, six.integer_types) and - salt_length is not self.MAX_LENGTH): - raise TypeError("salt_length must be an integer.") - - if salt_length is not self.MAX_LENGTH and salt_length < 0: - raise ValueError("salt_length must be zero or greater.") + if (not isinstance(salt_length, six.integer_types) and + salt_length is not self.MAX_LENGTH): + raise TypeError("salt_length must be an integer.") + + if salt_length is not self.MAX_LENGTH and salt_length < 0: + raise ValueError("salt_length must be zero or greater.") if salt_length is None and self._mgf._salt_length is None: raise ValueError("You must supply salt_length.") @@ -71,24 +63,8 @@ class OAEP(object): class MGF1(object): MAX_LENGTH = object() - def __init__(self, algorithm, salt_length=None): + def __init__(self, algorithm): if not isinstance(algorithm, interfaces.HashAlgorithm): raise TypeError("Expected instance of interfaces.HashAlgorithm.") self._algorithm = algorithm - - if salt_length is not None: - warnings.warn( - "salt_length is deprecated on MGF1 and should be passed to " - "the PSS constructor instead.", - utils.DeprecatedIn04, - stacklevel=2 - ) - if (not isinstance(salt_length, six.integer_types) and - salt_length is not self.MAX_LENGTH): - raise TypeError("salt_length must be an integer.") - - if salt_length is not self.MAX_LENGTH and salt_length < 0: - raise ValueError("salt_length must be zero or greater.") - - self._salt_length = salt_length diff --git a/cryptography/utils.py b/cryptography/utils.py index 1db16151..9c574085 100644 --- a/cryptography/utils.py +++ b/cryptography/utils.py @@ -16,8 +16,7 @@ from __future__ import absolute_import, division, print_function import sys -DeprecatedIn04 = DeprecationWarning -DeprecatedIn05 = PendingDeprecationWarning +DeprecatedIn05 = DeprecationWarning def register_interface(iface): |
