Merge pull request #1426 from alex/read-only-property
Added a utility for implementing a read only property of another field
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py
index db18978..e873f50 100644
--- a/cryptography/hazmat/backends/multibackend.py
+++ b/cryptography/hazmat/backends/multibackend.py
@@ -210,6 +210,12 @@
raise UnsupportedAlgorithm("DSA is not supported by the backend.",
_Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+ def load_dsa_parameter_numbers(self, numbers):
+ for b in self._filtered_backends(DSABackend):
+ return b.load_dsa_parameter_numbers(numbers)
+ raise UnsupportedAlgorithm("DSA is not supported by the backend.",
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+
def cmac_algorithm_supported(self, algorithm):
return any(
b.cmac_algorithm_supported(algorithm)
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index 93934ad..c50b6cf 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -131,6 +131,9 @@
def load_dsa_public_numbers(self, numbers):
pass
+ def load_dsa_parameter_numbers(self, numbers):
+ pass
+
@utils.register_interface(CMACBackend)
class DummyCMACBackend(object):
@@ -330,6 +333,7 @@
backend.dsa_parameters_supported(1, 2, 3)
backend.load_dsa_private_numbers("numbers")
backend.load_dsa_public_numbers("numbers")
+ backend.load_dsa_parameter_numbers("numbers")
backend = MultiBackend([])
with raises_unsupported_algorithm(
@@ -367,6 +371,11 @@
):
backend.load_dsa_public_numbers("numbers")
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.load_dsa_parameter_numbers("numbers")
+
def test_cmac(self):
backend = MultiBackend([
DummyCMACBackend([algorithms.AES])