From 9ac7c1d9032816e161b64f8e283bffac99b85c2e Mon Sep 17 00:00:00 2001 From: Mohammed Attia Date: Tue, 1 Apr 2014 14:23:27 +0200 Subject: Add tests for DSA parameters and key generation --- tests/hazmat/backends/test_openssl.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 016da0fc..86404fe9 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -21,7 +21,7 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.backends.openssl.backend import Backend, backend from cryptography.hazmat.primitives import hashes, interfaces -from cryptography.hazmat.primitives.asymmetric import padding, rsa +from cryptography.hazmat.primitives.asymmetric import dsa, padding, rsa from cryptography.hazmat.primitives.ciphers import Cipher from cryptography.hazmat.primitives.ciphers.algorithms import AES from cryptography.hazmat.primitives.ciphers.modes import CBC @@ -192,6 +192,17 @@ class TestOpenSSL(object): res = backend._lib.ENGINE_free(e) assert res == 1 + @pytest.mark.skipif( + backend._lib.OPENSSL_VERSION_NUMBER >= 0x1000000f, + reason="Requires an older OpenSSL. Must be < 1.0.0" + ) + def test_large_key_size_on_old_openssl(self): + with pytest.raises(ValueError): + dsa.DSAParameters.generate(2048, backend=backend) + + with pytest.raises(ValueError): + dsa.DSAParameters.generate(3072, backend=backend) + class TestOpenSSLRandomEngine(object): def teardown_method(self, method): -- cgit v1.2.3 From 97c27c698dc5325aff3887cf13e0e58bcfd1acfe Mon Sep 17 00:00:00 2001 From: Mohammed Attia Date: Wed, 2 Apr 2014 03:46:57 +0200 Subject: Add DSABackend --- tests/hazmat/backends/test_openssl.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/hazmat/backends/test_openssl.py') diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 86404fe9..6ab16627 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -28,6 +28,8 @@ from cryptography.hazmat.primitives.ciphers.modes import CBC from ...utils import raises_unsupported_algorithm +from cryptography.utils import bit_length + @utils.register_interface(interfaces.Mode) class DummyMode(object): @@ -203,6 +205,16 @@ class TestOpenSSL(object): with pytest.raises(ValueError): dsa.DSAParameters.generate(3072, backend=backend) + @pytest.mark.skipif( + backend._lib.OPENSSL_VERSION_NUMBER < 0x1000000f, + reason="Requires a newer OpenSSL. Must be >= 1.0.0" + ) + def test_large_key_size_on_new_openssl(self): + parameters = dsa.DSAParameters.generate(2048, backend) + assert bit_length(parameters.p) == 2048 + parameters = dsa.DSAParameters.generate(3072, backend) + assert bit_length(parameters.p) == 3072 + class TestOpenSSLRandomEngine(object): def teardown_method(self, method): -- cgit v1.2.3