We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
MultiBackend doesn't actually provide RSABackend.
We've been kind of haphazardly adding things to the interface as we add features and it's resulted in an incompletely implementation of MultiBackend.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cryptography/hazmat/backends/multibackend.py`
Content:
```
1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
4 #
5 #    http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10 # implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 
14 from __future__ import absolute_import, division, print_function
15 
16 from cryptography import utils
17 from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
18 from cryptography.hazmat.backends.interfaces import (
19     CMACBackend, CipherBackend, DSABackend, HMACBackend, HashBackend,
20     PBKDF2HMACBackend, RSABackend
21 )
22 
23 
24 @utils.register_interface(CMACBackend)
25 @utils.register_interface(CipherBackend)
26 @utils.register_interface(HashBackend)
27 @utils.register_interface(HMACBackend)
28 @utils.register_interface(PBKDF2HMACBackend)
29 @utils.register_interface(RSABackend)
30 @utils.register_interface(DSABackend)
31 class MultiBackend(object):
32     name = "multibackend"
33 
34     def __init__(self, backends):
35         self._backends = backends
36 
37     def _filtered_backends(self, interface):
38         for b in self._backends:
39             if isinstance(b, interface):
40                 yield b
41 
42     def cipher_supported(self, algorithm, mode):
43         return any(
44             b.cipher_supported(algorithm, mode)
45             for b in self._filtered_backends(CipherBackend)
46         )
47 
48     def create_symmetric_encryption_ctx(self, algorithm, mode):
49         for b in self._filtered_backends(CipherBackend):
50             try:
51                 return b.create_symmetric_encryption_ctx(algorithm, mode)
52             except UnsupportedAlgorithm:
53                 pass
54         raise UnsupportedAlgorithm(
55             "cipher {0} in {1} mode is not supported by this backend".format(
56                 algorithm.name, mode.name if mode else mode),
57             _Reasons.UNSUPPORTED_CIPHER
58         )
59 
60     def create_symmetric_decryption_ctx(self, algorithm, mode):
61         for b in self._filtered_backends(CipherBackend):
62             try:
63                 return b.create_symmetric_decryption_ctx(algorithm, mode)
64             except UnsupportedAlgorithm:
65                 pass
66         raise UnsupportedAlgorithm(
67             "cipher {0} in {1} mode is not supported by this backend".format(
68                 algorithm.name, mode.name if mode else mode),
69             _Reasons.UNSUPPORTED_CIPHER
70         )
71 
72     def hash_supported(self, algorithm):
73         return any(
74             b.hash_supported(algorithm)
75             for b in self._filtered_backends(HashBackend)
76         )
77 
78     def create_hash_ctx(self, algorithm):
79         for b in self._filtered_backends(HashBackend):
80             try:
81                 return b.create_hash_ctx(algorithm)
82             except UnsupportedAlgorithm:
83                 pass
84         raise UnsupportedAlgorithm(
85             "{0} is not a supported hash on this backend".format(
86                 algorithm.name),
87             _Reasons.UNSUPPORTED_HASH
88         )
89 
90     def hmac_supported(self, algorithm):
91         return any(
92             b.hmac_supported(algorithm)
93             for b in self._filtered_backends(HMACBackend)
94         )
95 
96     def create_hmac_ctx(self, key, algorithm):
97         for b in self._filtered_backends(HMACBackend):
98             try:
99                 return b.create_hmac_ctx(key, algorithm)
100             except UnsupportedAlgorithm:
101                 pass
102         raise UnsupportedAlgorithm(
103             "{0} is not a supported hash on this backend".format(
104                 algorithm.name),
105             _Reasons.UNSUPPORTED_HASH
106         )
107 
108     def pbkdf2_hmac_supported(self, algorithm):
109         return any(
110             b.pbkdf2_hmac_supported(algorithm)
111             for b in self._filtered_backends(PBKDF2HMACBackend)
112         )
113 
114     def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,
115                            key_material):
116         for b in self._filtered_backends(PBKDF2HMACBackend):
117             try:
118                 return b.derive_pbkdf2_hmac(
119                     algorithm, length, salt, iterations, key_material
120                 )
121             except UnsupportedAlgorithm:
122                 pass
123         raise UnsupportedAlgorithm(
124             "{0} is not a supported hash on this backend".format(
125                 algorithm.name),
126             _Reasons.UNSUPPORTED_HASH
127         )
128 
129     def generate_rsa_private_key(self, public_exponent, key_size):
130         for b in self._filtered_backends(RSABackend):
131             return b.generate_rsa_private_key(public_exponent, key_size)
132         raise UnsupportedAlgorithm("RSA is not supported by the backend",
133                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
134 
135     def create_rsa_signature_ctx(self, private_key, padding, algorithm):
136         for b in self._filtered_backends(RSABackend):
137             return b.create_rsa_signature_ctx(private_key, padding, algorithm)
138         raise UnsupportedAlgorithm("RSA is not supported by the backend",
139                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
140 
141     def create_rsa_verification_ctx(self, public_key, signature, padding,
142                                     algorithm):
143         for b in self._filtered_backends(RSABackend):
144             return b.create_rsa_verification_ctx(public_key, signature,
145                                                  padding, algorithm)
146         raise UnsupportedAlgorithm("RSA is not supported by the backend",
147                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
148 
149     def generate_dsa_parameters(self, key_size):
150         for b in self._filtered_backends(DSABackend):
151             return b.generate_dsa_parameters(key_size)
152         raise UnsupportedAlgorithm("DSA is not supported by the backend",
153                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
154 
155     def generate_dsa_private_key(self, parameters):
156         for b in self._filtered_backends(DSABackend):
157             return b.generate_dsa_private_key(parameters)
158         raise UnsupportedAlgorithm("DSA is not supported by the backend",
159                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
160 
161     def create_dsa_verification_ctx(self, public_key, signature, algorithm):
162         for b in self._filtered_backends(DSABackend):
163             return b.create_dsa_verification_ctx(public_key, signature,
164                                                  algorithm)
165         raise UnsupportedAlgorithm("DSA is not supported by the backend",
166                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
167 
168     def create_dsa_signature_ctx(self, private_key, algorithm):
169         for b in self._filtered_backends(DSABackend):
170             return b.create_dsa_signature_ctx(private_key, algorithm)
171         raise UnsupportedAlgorithm("DSA is not supported by the backend",
172                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
173 
174     def dsa_hash_supported(self, algorithm):
175         for b in self._filtered_backends(DSABackend):
176             return b.dsa_hash_supported(algorithm)
177         raise UnsupportedAlgorithm("DSA is not supported by the backend",
178                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
179 
180     def dsa_parameters_supported(self, p, q, g):
181         for b in self._filtered_backends(DSABackend):
182             return b.dsa_parameters_supported(p, q, g)
183         raise UnsupportedAlgorithm("DSA is not supported by the backend",
184                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
185 
186     def cmac_algorithm_supported(self, algorithm):
187         return any(
188             b.cmac_algorithm_supported(algorithm)
189             for b in self._filtered_backends(CMACBackend)
190         )
191 
192     def create_cmac_ctx(self, algorithm):
193         for b in self._filtered_backends(CMACBackend):
194             try:
195                 return b.create_cmac_ctx(algorithm)
196             except UnsupportedAlgorithm:
197                 pass
198         raise UnsupportedAlgorithm("This backend does not support CMAC",
199                                    _Reasons.UNSUPPORTED_CIPHER)
200
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py
--- a/cryptography/hazmat/backends/multibackend.py
+++ b/cryptography/hazmat/backends/multibackend.py
@@ -146,6 +146,24 @@
         raise UnsupportedAlgorithm("RSA is not supported by the backend",
                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
 
+    def mgf1_hash_supported(self, algorithm):
+        for b in self._filtered_backends(RSABackend):
+            return b.mgf1_hash_supported(algorithm)
+        raise UnsupportedAlgorithm("RSA is not supported by the backend",
+                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+
+    def decrypt_rsa(self, private_key, ciphertext, padding):
+        for b in self._filtered_backends(RSABackend):
+            return b.decrypt_rsa(private_key, ciphertext, padding)
+        raise UnsupportedAlgorithm("RSA is not supported by the backend",
+                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)
+
+    def encrypt_rsa(self, public_key, plaintext, padding):
+        for b in self._filtered_backends(RSABackend):
+            return b.encrypt_rsa(public_key, plaintext, padding)
+        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)

{"golden_diff": "diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py\n--- a/cryptography/hazmat/backends/multibackend.py\n+++ b/cryptography/hazmat/backends/multibackend.py\n@@ -146,6 +146,24 @@\n         raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                    _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n \n+    def mgf1_hash_supported(self, algorithm):\n+        for b in self._filtered_backends(RSABackend):\n+            return b.mgf1_hash_supported(algorithm)\n+        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n+                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n+\n+    def decrypt_rsa(self, private_key, ciphertext, padding):\n+        for b in self._filtered_backends(RSABackend):\n+            return b.decrypt_rsa(private_key, ciphertext, padding)\n+        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n+                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n+\n+    def encrypt_rsa(self, public_key, plaintext, padding):\n+        for b in self._filtered_backends(RSABackend):\n+            return b.encrypt_rsa(public_key, plaintext, padding)\n+        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n+                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n+\n     def generate_dsa_parameters(self, key_size):\n         for b in self._filtered_backends(DSABackend):\n             return b.generate_dsa_parameters(key_size)\n", "issue": "MultiBackend doesn't actually provide RSABackend.\nWe've been kind of haphazardly adding things to the interface as we add features and it's resulted in an incompletely implementation of MultiBackend.\n\n", "before_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import, division, print_function\n\nfrom cryptography import utils\nfrom cryptography.exceptions import UnsupportedAlgorithm, _Reasons\nfrom cryptography.hazmat.backends.interfaces import (\n    CMACBackend, CipherBackend, DSABackend, HMACBackend, HashBackend,\n    PBKDF2HMACBackend, RSABackend\n)\n\n\n@utils.register_interface(CMACBackend)\n@utils.register_interface(CipherBackend)\n@utils.register_interface(HashBackend)\n@utils.register_interface(HMACBackend)\n@utils.register_interface(PBKDF2HMACBackend)\n@utils.register_interface(RSABackend)\n@utils.register_interface(DSABackend)\nclass MultiBackend(object):\n    name = \"multibackend\"\n\n    def __init__(self, backends):\n        self._backends = backends\n\n    def _filtered_backends(self, interface):\n        for b in self._backends:\n            if isinstance(b, interface):\n                yield b\n\n    def cipher_supported(self, algorithm, mode):\n        return any(\n            b.cipher_supported(algorithm, mode)\n            for b in self._filtered_backends(CipherBackend)\n        )\n\n    def create_symmetric_encryption_ctx(self, algorithm, mode):\n        for b in self._filtered_backends(CipherBackend):\n            try:\n                return b.create_symmetric_encryption_ctx(algorithm, mode)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"cipher {0} in {1} mode is not supported by this backend\".format(\n                algorithm.name, mode.name if mode else mode),\n            _Reasons.UNSUPPORTED_CIPHER\n        )\n\n    def create_symmetric_decryption_ctx(self, algorithm, mode):\n        for b in self._filtered_backends(CipherBackend):\n            try:\n                return b.create_symmetric_decryption_ctx(algorithm, mode)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"cipher {0} in {1} mode is not supported by this backend\".format(\n                algorithm.name, mode.name if mode else mode),\n            _Reasons.UNSUPPORTED_CIPHER\n        )\n\n    def hash_supported(self, algorithm):\n        return any(\n            b.hash_supported(algorithm)\n            for b in self._filtered_backends(HashBackend)\n        )\n\n    def create_hash_ctx(self, algorithm):\n        for b in self._filtered_backends(HashBackend):\n            try:\n                return b.create_hash_ctx(algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def hmac_supported(self, algorithm):\n        return any(\n            b.hmac_supported(algorithm)\n            for b in self._filtered_backends(HMACBackend)\n        )\n\n    def create_hmac_ctx(self, key, algorithm):\n        for b in self._filtered_backends(HMACBackend):\n            try:\n                return b.create_hmac_ctx(key, algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def pbkdf2_hmac_supported(self, algorithm):\n        return any(\n            b.pbkdf2_hmac_supported(algorithm)\n            for b in self._filtered_backends(PBKDF2HMACBackend)\n        )\n\n    def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,\n                           key_material):\n        for b in self._filtered_backends(PBKDF2HMACBackend):\n            try:\n                return b.derive_pbkdf2_hmac(\n                    algorithm, length, salt, iterations, key_material\n                )\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def generate_rsa_private_key(self, public_exponent, key_size):\n        for b in self._filtered_backends(RSABackend):\n            return b.generate_rsa_private_key(public_exponent, key_size)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_rsa_signature_ctx(self, private_key, padding, algorithm):\n        for b in self._filtered_backends(RSABackend):\n            return b.create_rsa_signature_ctx(private_key, padding, algorithm)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_rsa_verification_ctx(self, public_key, signature, padding,\n                                    algorithm):\n        for b in self._filtered_backends(RSABackend):\n            return b.create_rsa_verification_ctx(public_key, signature,\n                                                 padding, algorithm)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def generate_dsa_parameters(self, key_size):\n        for b in self._filtered_backends(DSABackend):\n            return b.generate_dsa_parameters(key_size)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def generate_dsa_private_key(self, parameters):\n        for b in self._filtered_backends(DSABackend):\n            return b.generate_dsa_private_key(parameters)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_dsa_verification_ctx(self, public_key, signature, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.create_dsa_verification_ctx(public_key, signature,\n                                                 algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_dsa_signature_ctx(self, private_key, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.create_dsa_signature_ctx(private_key, algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def dsa_hash_supported(self, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.dsa_hash_supported(algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def dsa_parameters_supported(self, p, q, g):\n        for b in self._filtered_backends(DSABackend):\n            return b.dsa_parameters_supported(p, q, g)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def cmac_algorithm_supported(self, algorithm):\n        return any(\n            b.cmac_algorithm_supported(algorithm)\n            for b in self._filtered_backends(CMACBackend)\n        )\n\n    def create_cmac_ctx(self, algorithm):\n        for b in self._filtered_backends(CMACBackend):\n            try:\n                return b.create_cmac_ctx(algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\"This backend does not support CMAC\",\n                                   _Reasons.UNSUPPORTED_CIPHER)\n", "path": "cryptography/hazmat/backends/multibackend.py"}], "after_files": [{"content": "# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#    http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n# implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom __future__ import absolute_import, division, print_function\n\nfrom cryptography import utils\nfrom cryptography.exceptions import UnsupportedAlgorithm, _Reasons\nfrom cryptography.hazmat.backends.interfaces import (\n    CMACBackend, CipherBackend, DSABackend, HMACBackend, HashBackend,\n    PBKDF2HMACBackend, RSABackend\n)\n\n\n@utils.register_interface(CMACBackend)\n@utils.register_interface(CipherBackend)\n@utils.register_interface(HashBackend)\n@utils.register_interface(HMACBackend)\n@utils.register_interface(PBKDF2HMACBackend)\n@utils.register_interface(RSABackend)\n@utils.register_interface(DSABackend)\nclass MultiBackend(object):\n    name = \"multibackend\"\n\n    def __init__(self, backends):\n        self._backends = backends\n\n    def _filtered_backends(self, interface):\n        for b in self._backends:\n            if isinstance(b, interface):\n                yield b\n\n    def cipher_supported(self, algorithm, mode):\n        return any(\n            b.cipher_supported(algorithm, mode)\n            for b in self._filtered_backends(CipherBackend)\n        )\n\n    def create_symmetric_encryption_ctx(self, algorithm, mode):\n        for b in self._filtered_backends(CipherBackend):\n            try:\n                return b.create_symmetric_encryption_ctx(algorithm, mode)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"cipher {0} in {1} mode is not supported by this backend\".format(\n                algorithm.name, mode.name if mode else mode),\n            _Reasons.UNSUPPORTED_CIPHER\n        )\n\n    def create_symmetric_decryption_ctx(self, algorithm, mode):\n        for b in self._filtered_backends(CipherBackend):\n            try:\n                return b.create_symmetric_decryption_ctx(algorithm, mode)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"cipher {0} in {1} mode is not supported by this backend\".format(\n                algorithm.name, mode.name if mode else mode),\n            _Reasons.UNSUPPORTED_CIPHER\n        )\n\n    def hash_supported(self, algorithm):\n        return any(\n            b.hash_supported(algorithm)\n            for b in self._filtered_backends(HashBackend)\n        )\n\n    def create_hash_ctx(self, algorithm):\n        for b in self._filtered_backends(HashBackend):\n            try:\n                return b.create_hash_ctx(algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def hmac_supported(self, algorithm):\n        return any(\n            b.hmac_supported(algorithm)\n            for b in self._filtered_backends(HMACBackend)\n        )\n\n    def create_hmac_ctx(self, key, algorithm):\n        for b in self._filtered_backends(HMACBackend):\n            try:\n                return b.create_hmac_ctx(key, algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def pbkdf2_hmac_supported(self, algorithm):\n        return any(\n            b.pbkdf2_hmac_supported(algorithm)\n            for b in self._filtered_backends(PBKDF2HMACBackend)\n        )\n\n    def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations,\n                           key_material):\n        for b in self._filtered_backends(PBKDF2HMACBackend):\n            try:\n                return b.derive_pbkdf2_hmac(\n                    algorithm, length, salt, iterations, key_material\n                )\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\n            \"{0} is not a supported hash on this backend\".format(\n                algorithm.name),\n            _Reasons.UNSUPPORTED_HASH\n        )\n\n    def generate_rsa_private_key(self, public_exponent, key_size):\n        for b in self._filtered_backends(RSABackend):\n            return b.generate_rsa_private_key(public_exponent, key_size)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_rsa_signature_ctx(self, private_key, padding, algorithm):\n        for b in self._filtered_backends(RSABackend):\n            return b.create_rsa_signature_ctx(private_key, padding, algorithm)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_rsa_verification_ctx(self, public_key, signature, padding,\n                                    algorithm):\n        for b in self._filtered_backends(RSABackend):\n            return b.create_rsa_verification_ctx(public_key, signature,\n                                                 padding, algorithm)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def mgf1_hash_supported(self, algorithm):\n        for b in self._filtered_backends(RSABackend):\n            return b.mgf1_hash_supported(algorithm)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def decrypt_rsa(self, private_key, ciphertext, padding):\n        for b in self._filtered_backends(RSABackend):\n            return b.decrypt_rsa(private_key, ciphertext, padding)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def encrypt_rsa(self, public_key, plaintext, padding):\n        for b in self._filtered_backends(RSABackend):\n            return b.encrypt_rsa(public_key, plaintext, padding)\n        raise UnsupportedAlgorithm(\"RSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def generate_dsa_parameters(self, key_size):\n        for b in self._filtered_backends(DSABackend):\n            return b.generate_dsa_parameters(key_size)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def generate_dsa_private_key(self, parameters):\n        for b in self._filtered_backends(DSABackend):\n            return b.generate_dsa_private_key(parameters)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_dsa_verification_ctx(self, public_key, signature, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.create_dsa_verification_ctx(public_key, signature,\n                                                 algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def create_dsa_signature_ctx(self, private_key, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.create_dsa_signature_ctx(private_key, algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def dsa_hash_supported(self, algorithm):\n        for b in self._filtered_backends(DSABackend):\n            return b.dsa_hash_supported(algorithm)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def dsa_parameters_supported(self, p, q, g):\n        for b in self._filtered_backends(DSABackend):\n            return b.dsa_parameters_supported(p, q, g)\n        raise UnsupportedAlgorithm(\"DSA is not supported by the backend\",\n                                   _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM)\n\n    def cmac_algorithm_supported(self, algorithm):\n        return any(\n            b.cmac_algorithm_supported(algorithm)\n            for b in self._filtered_backends(CMACBackend)\n        )\n\n    def create_cmac_ctx(self, algorithm):\n        for b in self._filtered_backends(CMACBackend):\n            try:\n                return b.create_cmac_ctx(algorithm)\n            except UnsupportedAlgorithm:\n                pass\n        raise UnsupportedAlgorithm(\"This backend does not support CMAC\",\n                                   _Reasons.UNSUPPORTED_CIPHER)\n", "path": "cryptography/hazmat/backends/multibackend.py"}]}