aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_serialization.py
diff options
context:
space:
mode:
authorAviv Palivoda <palaviv@gmail.com>2017-03-06 04:24:55 +0200
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-03-05 22:24:55 -0400
commite44efb634fb1db024fcd6e110eacbf59abbc4782 (patch)
treec651a6852af687260bda8e9feda88f6b64a6b036 /tests/hazmat/primitives/test_serialization.py
parent3bab4e5e356409920e17e2a0aad1eec4f2135e6a (diff)
downloadcryptography-e44efb634fb1db024fcd6e110eacbf59abbc4782.tar.gz
cryptography-e44efb634fb1db024fcd6e110eacbf59abbc4782.tar.bz2
cryptography-e44efb634fb1db024fcd6e110eacbf59abbc4782.zip
DH subgroup order (q) (#3369)
* Support DH q (subgroup order) * Change RFC5114.txt to NIST format * Add tests for DH q * Update docs for DH q * Fix pep8 * Improve test covergae for DH q * Create _dh_params_dup that copy q if DHparams_dup don't On OpenSSL < 1.0.2 DHparams_dup don't copy q. _dh_params_dup call DHparams_dup and if the version is smaller than 1.0.2 copy q manually * Copy q manually on libressl * Add to test vectors serialized RFC5114 2048 bit DH parameters with 224 bit subgroup * Support serialization of DH with q * Add tests for serialization of DH with q * Support DH serialization with q only if Cryptography_HAS_EVP_PKEY_DHX is true * Raise exception when trying to serialize DH X9.42 when not supported * raise unsupported key type when deserilizing DH X9.42 if not supported * pep8 fixes * Fix test_serialization * Add dhx_serialization_supported method to DHBacked * document q in dh_parameters_supported * Rename dhx_serialization_supported to dh_x942_serialization_supported
Diffstat (limited to 'tests/hazmat/primitives/test_serialization.py')
-rw-r--r--tests/hazmat/primitives/test_serialization.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index dad056c6..bc16b5f8 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -236,10 +236,12 @@ class TestDERSerialization(object):
""").encode()
bad_der = base64.b64decode(b"".join(key_data.splitlines()))
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(bad_der, None, backend)
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(
bad_der, b"this password will not be used", backend
)
@@ -575,12 +577,14 @@ class TestPEMSerialization(object):
def test_wrong_private_format(self, backend):
key_data = b"---- NOT A KEY ----\n"
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(
key_data, None, backend
)
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(
key_data, b"this password will not be used", backend
)
@@ -588,7 +592,8 @@ class TestPEMSerialization(object):
def test_wrong_public_format(self, backend):
key_data = b"---- NOT A KEY ----\n"
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_public_key(key_data, backend)
def test_corrupt_traditional_format(self, backend):
@@ -720,12 +725,14 @@ class TestPEMSerialization(object):
password = b"this password is wrong"
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(
key_data, None, backend
)
- with pytest.raises(ValueError):
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM):
load_pem_private_key(
key_data, password, backend
)