diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-03-13 13:48:02 -0400 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-03-13 13:48:02 -0400 |
commit | 7905fcec68fd633d0b28d371660123b7b22cca53 (patch) | |
tree | 991f2f68d82d91ea066bebc3e60b636fc0bc1713 /tests/hazmat/backends/test_openssl.py | |
parent | 710877611effc64cbdebe41c1cd91f52e9f2513c (diff) | |
parent | 22d25d5674faba9170f64e6a4714dfa0c62cc5d7 (diff) | |
download | cryptography-7905fcec68fd633d0b28d371660123b7b22cca53.tar.gz cryptography-7905fcec68fd633d0b28d371660123b7b22cca53.tar.bz2 cryptography-7905fcec68fd633d0b28d371660123b7b22cca53.zip |
Merge pull request #1754 from reaperhulk/serialize-der-part-un
support RSA DER private key serialization
Diffstat (limited to 'tests/hazmat/backends/test_openssl.py')
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index cfdc06b4..410d3d2a 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -15,7 +15,7 @@ import pytest from cryptography import utils from cryptography.exceptions import InternalError, _Reasons -from cryptography.hazmat.backends.interfaces import RSABackend +from cryptography.hazmat.backends.interfaces import DSABackend, RSABackend from cryptography.hazmat.backends.openssl.backend import ( Backend, backend ) @@ -508,11 +508,18 @@ class TestRSAPEMSerialization(object): serialization.BestAvailableEncryption(password) ) + +@pytest.mark.requires_backend_interface(interface=DSABackend) +class TestDSADERSerialization(object): def test_unsupported_private_key_encoding(self): - key = RSA_KEY_2048.private_key(backend) - with pytest.raises(ValueError): + key_bytes = load_vectors_from_file( + os.path.join("asymmetric", "PKCS8", "unenc-dsa-pkcs8.pem"), + lambda pemfile: pemfile.read().encode() + ) + key = serialization.load_pem_private_key(key_bytes, None, backend) + with pytest.raises(TypeError): key.private_bytes( serialization.Encoding.DER, - serialization.PrivateFormat.PKCS8, + serialization.PrivateFormat.TraditionalOpenSSL, serialization.NoEncryption() ) |