Add load_rsa_numbers support to MultiBackend.
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py
index b4cb688..5acec33 100644
--- a/cryptography/hazmat/backends/multibackend.py
+++ b/cryptography/hazmat/backends/multibackend.py
@@ -178,6 +178,13 @@
raise UnsupportedAlgorithm("RSA is not supported by the backend.",
_Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+ def load_rsa_numbers(self, numbers):
+ for b in self._filtered_backends(RSABackend):
+ return b.load_rsa_numbers(numbers)
+
+ raise UnsupportedAlgorithm("RSA is not supported by the backend",
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+
def generate_dsa_parameters(self, key_size):
for b in self._filtered_backends(DSABackend):
return b.generate_dsa_parameters(key_size)
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index 3fa364e..d4c89be 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -23,7 +23,7 @@
)
from cryptography.hazmat.backends.multibackend import MultiBackend
from cryptography.hazmat.primitives import cmac, hashes, hmac
-from cryptography.hazmat.primitives.asymmetric import padding
+from cryptography.hazmat.primitives.asymmetric import padding, rsa
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from ...utils import raises_unsupported_algorithm
@@ -111,6 +111,8 @@
pass
def encrypt_rsa(self, public_key, plaintext, padding):
+
+ def load_rsa_numbers(self, numbers):
pass
@@ -236,6 +238,8 @@
backend.decrypt_rsa("private_key", "encrypted", padding.PKCS1v15())
+ backend.load_rsa_numbers(rsa.RSAPublicNumbers(e=3, n=1))
+
backend = MultiBackend([])
with raises_unsupported_algorithm(
_Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
@@ -279,6 +283,11 @@
):
backend.decrypt_rsa("private_key", "encrypted", padding.PKCS1v15())
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.load_rsa_numbers(rsa.RSAPublicNumbers(e=3, n=1))
+
def test_dsa(self):
backend = MultiBackend([
DummyDSABackend()