aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_multibackend.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-09-27 11:59:56 -0400
committerAlex Gaynor <alex.gaynor@gmail.com>2014-09-27 11:59:56 -0400
commite9022fee01112d00d97ebc499a48f5d71fb83af7 (patch)
tree8645894150322408d44d200c6e303fa20e868f99 /tests/hazmat/backends/test_multibackend.py
parent45d4c5909bd857986b901d59fd4d77bce63bfeff (diff)
parentcff58d8d28ad15a8f7abaaa6ff5320a7d1f5b2f9 (diff)
downloadcryptography-e9022fee01112d00d97ebc499a48f5d71fb83af7.tar.gz
cryptography-e9022fee01112d00d97ebc499a48f5d71fb83af7.tar.bz2
cryptography-e9022fee01112d00d97ebc499a48f5d71fb83af7.zip
Merge pull request #1348 from reaperhulk/improve-naming-consistency
deprecate backend method names for elliptic curve number loading
Diffstat (limited to 'tests/hazmat/backends/test_multibackend.py')
-rw-r--r--tests/hazmat/backends/test_multibackend.py59
1 files changed, 57 insertions, 2 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index 45c12b34..61bda54c 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -13,6 +13,8 @@
from __future__ import absolute_import, division, print_function
+import pytest
+
from cryptography import utils
from cryptography.exceptions import (
UnsupportedAlgorithm, _Reasons
@@ -191,6 +193,10 @@ class DummyEllipticCurveBackend(object):
if not self.elliptic_curve_supported(curve):
raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
+ def load_elliptic_curve_private_numbers(self, numbers):
+ if not self.elliptic_curve_supported(numbers.public_numbers.curve):
+ raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
+
def elliptic_curve_private_key_from_numbers(self, numbers):
if not self.elliptic_curve_supported(numbers.public_numbers.curve):
raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
@@ -199,6 +205,10 @@ class DummyEllipticCurveBackend(object):
if not self.elliptic_curve_supported(numbers.curve):
raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
+ def load_elliptic_curve_public_numbers(self, numbers):
+ if not self.elliptic_curve_supported(numbers.curve):
+ raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
+
@utils.register_interface(PKCS8SerializationBackend)
class DummyPKCS8SerializationBackend(object):
@@ -463,7 +473,7 @@ class TestMultiBackend(object):
backend.generate_elliptic_curve_private_key(ec.SECT283K1())
- backend.elliptic_curve_private_key_from_numbers(
+ backend.load_elliptic_curve_private_numbers(
ec.EllipticCurvePrivateNumbers(
1,
ec.EllipticCurvePublicNumbers(
@@ -474,7 +484,7 @@ class TestMultiBackend(object):
)
)
- backend.elliptic_curve_public_key_from_numbers(
+ backend.load_elliptic_curve_public_numbers(
ec.EllipticCurvePublicNumbers(
2,
3,
@@ -493,6 +503,51 @@ class TestMultiBackend(object):
backend.generate_elliptic_curve_private_key(ec.SECT163K1())
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE):
+ backend.load_elliptic_curve_private_numbers(
+ ec.EllipticCurvePrivateNumbers(
+ 1,
+ ec.EllipticCurvePublicNumbers(
+ 2,
+ 3,
+ ec.SECT163K1()
+ )
+ )
+ )
+
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE):
+ backend.load_elliptic_curve_public_numbers(
+ ec.EllipticCurvePublicNumbers(
+ 2,
+ 3,
+ ec.SECT163K1()
+ )
+ )
+
+ def test_deprecated_elliptic_curve(self):
+ backend = MultiBackend([
+ DummyEllipticCurveBackend([
+ ec.SECT283K1
+ ])
+ ])
+
+ assert backend.elliptic_curve_signature_algorithm_supported(
+ ec.ECDSA(hashes.SHA256()),
+ ec.SECT163K1()
+ ) is False
+
+ pub_numbers = ec.EllipticCurvePublicNumbers(2, 3, ec.SECT283K1())
+ numbers = ec.EllipticCurvePrivateNumbers(1, pub_numbers)
+
+ pytest.deprecated_call(
+ backend.elliptic_curve_private_key_from_numbers,
+ numbers
+ )
+ pytest.deprecated_call(
+ backend.elliptic_curve_public_key_from_numbers,
+ pub_numbers
+ )
+
+ with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE):
backend.elliptic_curve_private_key_from_numbers(
ec.EllipticCurvePrivateNumbers(
1,