diff options
-rw-r--r-- | cryptography/exceptions.py | 4 | ||||
-rw-r--r-- | cryptography/hazmat/backends/openssl/backend.py | 8 | ||||
-rw-r--r-- | docs/exceptions.rst | 4 | ||||
-rw-r--r-- | docs/hazmat/primitives/asymmetric/rsa.rst | 7 | ||||
-rw-r--r-- | tests/hazmat/primitives/test_rsa.py | 4 |
5 files changed, 8 insertions, 19 deletions
diff --git a/cryptography/exceptions.py b/cryptography/exceptions.py index fe9bf840..b4ee8feb 100644 --- a/cryptography/exceptions.py +++ b/cryptography/exceptions.py @@ -59,7 +59,3 @@ class InvalidKey(Exception): class InvalidToken(Exception): pass - - -class InvalidDecryption(Exception): - pass diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py index d7f32cd3..5e13bfc1 100644 --- a/cryptography/hazmat/backends/openssl/backend.py +++ b/cryptography/hazmat/backends/openssl/backend.py @@ -21,8 +21,8 @@ import six from cryptography import utils from cryptography.exceptions import ( - AlreadyFinalized, InternalError, InvalidDecryption, InvalidSignature, - InvalidTag, UnsupportedAlgorithm, _Reasons + AlreadyFinalized, InternalError, InvalidSignature, InvalidTag, + UnsupportedAlgorithm, _Reasons ) from cryptography.hazmat.backends.interfaces import ( CipherBackend, DSABackend, HMACBackend, HashBackend, PBKDF2HMACBackend, @@ -525,7 +525,7 @@ class Backend(object): errors[0].reason == self._lib.RSA_R_BLOCK_TYPE_IS_NOT_01 or errors[0].reason == self._lib.RSA_R_BLOCK_TYPE_IS_NOT_02 ) - raise InvalidDecryption + raise ValueError("Decryption failed") return self._ffi.buffer(buf)[:outlen[0]] @@ -550,7 +550,7 @@ class Backend(object): errors[0].reason == self._lib.RSA_R_BLOCK_TYPE_IS_NOT_01 or errors[0].reason == self._lib.RSA_R_BLOCK_TYPE_IS_NOT_02 ) - raise InvalidDecryption + raise ValueError("Decryption failed") return self._ffi.buffer(buf)[:res] diff --git a/docs/exceptions.rst b/docs/exceptions.rst index 23e0df0a..28da8ecc 100644 --- a/docs/exceptions.rst +++ b/docs/exceptions.rst @@ -43,7 +43,3 @@ Exceptions This is raised when the verify method of a one time password function's computed token does not match the expected token. - -.. class:: InvalidDecryption - - This is raised when RSA decryption does not succeed. diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst index e72e8835..aef15691 100644 --- a/docs/hazmat/primitives/asymmetric/rsa.rst +++ b/docs/hazmat/primitives/asymmetric/rsa.rst @@ -143,11 +143,8 @@ RSA :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricPadding` provider. - :raises ValueError: This is raised when the chosen hash algorithm is - too large for the key size. - - :raises cryptography.exceptions.InvalidDecryption: This is raised if - decryption fails due to invalid ciphertext. + :raises ValueError: This is raised when decryption fails or the chosen + hash algorithm is too large for the key size. .. class:: RSAPublicKey(public_exponent, modulus) diff --git a/tests/hazmat/primitives/test_rsa.py b/tests/hazmat/primitives/test_rsa.py index 74a0c111..69fd2933 100644 --- a/tests/hazmat/primitives/test_rsa.py +++ b/tests/hazmat/primitives/test_rsa.py @@ -1271,7 +1271,7 @@ class TestRSADecryption(object): key_size=512, backend=backend ) - with pytest.raises(exceptions.InvalidDecryption): + with pytest.raises(ValueError): private_key.decrypt( b"\x00" * 64, padding.PKCS1v15(), @@ -1301,7 +1301,7 @@ class TestRSADecryption(object): b"50b4c14136bd198c2f3c3ed243fce036e168d56517984a263cd66492b80804f1" b"69d210f2b9bdfb48b12f9ea05009c77da257cc600ccefe3a6283789d8ea0" ) - with pytest.raises(exceptions.InvalidDecryption): + with pytest.raises(ValueError): private_key.decrypt( ct, padding.PKCS1v15(), |