aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-19 09:34:56 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-20 16:53:04 -0500
commit8ab7a360330daa195ea1c0cf70d606dc7dce88c8 (patch)
tree4800e1b4b3c4d03bc0dfb7d4560e5d5576262a2f
parent73dd4d5bd713f80fc0ffe04921d61d993437d458 (diff)
downloadcryptography-8ab7a360330daa195ea1c0cf70d606dc7dce88c8.tar.gz
cryptography-8ab7a360330daa195ea1c0cf70d606dc7dce88c8.tar.bz2
cryptography-8ab7a360330daa195ea1c0cf70d606dc7dce88c8.zip
remove InvalidDecryption and replace with ValueError
-rw-r--r--cryptography/exceptions.py4
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py8
-rw-r--r--docs/exceptions.rst4
-rw-r--r--docs/hazmat/primitives/asymmetric/rsa.rst7
-rw-r--r--tests/hazmat/primitives/test_rsa.py4
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(),