aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_serialization.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-03-09 09:21:25 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2017-03-09 08:21:25 -0500
commit4bd9a076a858ea28579fe80252a9e48654d78b90 (patch)
tree39527a4494a2274e383ef9412cb94670b1d3decc /tests/hazmat/primitives/test_serialization.py
parentd5e05f27f03046c671d23f09f84cddb8237df0f8 (diff)
downloadcryptography-4bd9a076a858ea28579fe80252a9e48654d78b90.tar.gz
cryptography-4bd9a076a858ea28579fe80252a9e48654d78b90.tar.bz2
cryptography-4bd9a076a858ea28579fe80252a9e48654d78b90.zip
reverts a change to our exceptions (#3429)
Trying to be too specific about why key loading fails is very difficult when you're using the same logic across DH, EC, RSA, and DSA. This makes it less fancy.
Diffstat (limited to 'tests/hazmat/primitives/test_serialization.py')
-rw-r--r--tests/hazmat/primitives/test_serialization.py25
1 files changed, 8 insertions, 17 deletions
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index bc16b5f8..f4b953e6 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -236,12 +236,10 @@ class TestDERSerialization(object):
""").encode()
bad_der = base64.b64decode(b"".join(key_data.splitlines()))
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(bad_der, None, backend)
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(
bad_der, b"this password will not be used", backend
)
@@ -577,14 +575,12 @@ class TestPEMSerialization(object):
def test_wrong_private_format(self, backend):
key_data = b"---- NOT A KEY ----\n"
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(
key_data, None, backend
)
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(
key_data, b"this password will not be used", backend
)
@@ -592,8 +588,7 @@ class TestPEMSerialization(object):
def test_wrong_public_format(self, backend):
key_data = b"---- NOT A KEY ----\n"
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_public_key(key_data, backend)
def test_corrupt_traditional_format(self, backend):
@@ -725,14 +720,12 @@ class TestPEMSerialization(object):
password = b"this password is wrong"
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(
key_data, None, backend
)
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
+ with pytest.raises(ValueError):
load_pem_private_key(
key_data, password, backend
)
@@ -852,9 +845,7 @@ class TestPEMSerialization(object):
]
)
def test_load_bad_oid_key(self, key_file, password, backend):
- with raises_unsupported_algorithm(
- _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
- ):
+ with pytest.raises(ValueError):
load_vectors_from_file(
os.path.join(
"asymmetric", "PKCS8", key_file),