aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/backends')
-rw-r--r--tests/hazmat/backends/test_multibackend.py19
-rw-r--r--tests/hazmat/backends/test_openssl.py6
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index 4d17cdb0..2a533750 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -152,10 +152,7 @@ class DummyEllipticCurveBackend(object):
):
return (
isinstance(signature_algorithm, ec.ECDSA) and
- any(
- isinstance(curve, curve_type)
- for curve_type in self._curves
- )
+ self.elliptic_curve_supported(curve)
)
def generate_elliptic_curve_private_key(self, curve):
@@ -170,6 +167,12 @@ class DummyEllipticCurveBackend(object):
if not self.elliptic_curve_supported(numbers.curve):
raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE)
+ def elliptic_curve_exchange_algorithm_supported(self, algorithm, curve):
+ return (
+ isinstance(algorithm, ec.ECDH) and
+ self.elliptic_curve_supported(curve)
+ )
+
@utils.register_interface(PEMSerializationBackend)
class DummyPEMSerializationBackend(object):
@@ -462,6 +465,14 @@ class TestMultiBackend(object):
)
)
+ assert backend.elliptic_curve_exchange_algorithm_supported(
+ ec.ECDH(), ec.SECT283K1()
+ )
+ backend2 = MultiBackend([DummyEllipticCurveBackend([])])
+ assert not backend2.elliptic_curve_exchange_algorithm_supported(
+ ec.ECDH(), ec.SECT163K1()
+ )
+
def test_pem_serialization_backend(self):
backend = MultiBackend([DummyPEMSerializationBackend()])
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index 8fd0d711..85331595 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -551,6 +551,12 @@ class TestOpenSSLEllipticCurve(object):
with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE):
_sn_to_elliptic_curve(backend, b"fake")
+ def test_elliptic_curve_exchange_algorithm_supported(self, monkeypatch):
+ monkeypatch.setattr(backend, "_lib", DummyLibrary())
+ assert not backend.elliptic_curve_exchange_algorithm_supported(
+ ec.ECDH(), ec.SECP256R1()
+ )
+
@pytest.mark.requires_backend_interface(interface=RSABackend)
class TestRSAPEMSerialization(object):