From 77e95a016376dfdd08ef44549bd4ecc252fb3bf5 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 25 Sep 2014 12:28:07 -0500 Subject: deprecate backend method names for elliptic curve number loading fixes #1270 --- tests/hazmat/backends/test_openssl.py | 38 ++++++++++++++++++++++++++++++++++- 1 file changed, 37 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 110bbdba..5933b107 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -28,7 +28,7 @@ from cryptography.hazmat.backends.openssl.backend import ( Backend, backend ) from cryptography.hazmat.primitives import hashes, interfaces -from cryptography.hazmat.primitives.asymmetric import dsa, padding, rsa +from cryptography.hazmat.primitives.asymmetric import dsa, ec, 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, CTR @@ -569,3 +569,39 @@ class TestDeprecatedDSABackendMethods(object): b"\x00" * 128, hashes.SHA1() ) + + +@pytest.mark.elliptic +class TestDeprecatedECBackendMethods(object): + def test_elliptic_curve_private_key_from_numbers(self): + d = 5634846038258869671139984276180670841223409490498798721258 + y = 4131560123026307384858369684985976479488628761329758810693 + x = 3402090428547195623222463880060959356423657484435591627791 + curve = ec.SECP192R1() + pub_numbers = ec.EllipticCurvePublicNumbers( + x=x, + y=y, + curve=curve + ) + numbers = ec.EllipticCurvePrivateNumbers( + private_value=d, + public_numbers=pub_numbers + ) + pytest.deprecated_call( + backend.elliptic_curve_private_key_from_numbers, + numbers + ) + + def test_elliptic_curve_public_key_from_numbers(self): + y = 4131560123026307384858369684985976479488628761329758810693 + x = 3402090428547195623222463880060959356423657484435591627791 + curve = ec.SECP192R1() + pub_numbers = ec.EllipticCurvePublicNumbers( + x=x, + y=y, + curve=curve + ) + pytest.deprecated_call( + backend.elliptic_curve_public_key_from_numbers, + pub_numbers + ) -- cgit v1.2.3 From 25228af9ce544108927cc769e5cfcf6f215cbc89 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Thu, 25 Sep 2014 13:02:00 -0500 Subject: skip deprecated tests on platforms that don't support ec (old rhel) --- tests/hazmat/backends/test_openssl.py | 11 +++++++++++ 1 file changed, 11 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 5933b107..eecc7942 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -37,6 +37,15 @@ from cryptography.hazmat.primitives.interfaces import BlockCipherAlgorithm from ...utils import load_vectors_from_file, raises_unsupported_algorithm +def _skip_curve_unsupported(backend, curve): + if not backend.elliptic_curve_supported(curve): + pytest.skip( + "Curve {0} is not supported by this backend {1}".format( + curve.name, backend + ) + ) + + @utils.register_interface(interfaces.Mode) class DummyMode(object): name = "dummy-mode" @@ -578,6 +587,7 @@ class TestDeprecatedECBackendMethods(object): y = 4131560123026307384858369684985976479488628761329758810693 x = 3402090428547195623222463880060959356423657484435591627791 curve = ec.SECP192R1() + _skip_curve_unsupported(backend, curve) pub_numbers = ec.EllipticCurvePublicNumbers( x=x, y=y, @@ -596,6 +606,7 @@ class TestDeprecatedECBackendMethods(object): y = 4131560123026307384858369684985976479488628761329758810693 x = 3402090428547195623222463880060959356423657484435591627791 curve = ec.SECP192R1() + _skip_curve_unsupported(backend, curve) pub_numbers = ec.EllipticCurvePublicNumbers( x=x, y=y, -- cgit v1.2.3 From e04f6fc6fcc5105ce66279eacd9df0683d538ee9 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Fri, 26 Sep 2014 12:16:14 -0500 Subject: remove duplicate _skip_curve_unsupported --- tests/hazmat/backends/test_openssl.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (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 eecc7942..bfe6040e 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -34,18 +34,10 @@ from cryptography.hazmat.primitives.ciphers.algorithms import AES from cryptography.hazmat.primitives.ciphers.modes import CBC, CTR from cryptography.hazmat.primitives.interfaces import BlockCipherAlgorithm +from ..primitives.test_ec import _skip_curve_unsupported from ...utils import load_vectors_from_file, raises_unsupported_algorithm -def _skip_curve_unsupported(backend, curve): - if not backend.elliptic_curve_supported(curve): - pytest.skip( - "Curve {0} is not supported by this backend {1}".format( - curve.name, backend - ) - ) - - @utils.register_interface(interfaces.Mode) class DummyMode(object): name = "dummy-mode" -- cgit v1.2.3