aboutsummaryrefslogtreecommitdiffstats
path: root/docs/changelog.rst
blob: 565b0521d0c2cdbfe493d19765b04d5c119fa7eb (plain)
1
.. include:: ../CHANGELOG.rst
light .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
.. hazmat::

MultiBackend
============

.. currentmodule:: cryptography.hazmat.backends.multibackend

.. class:: MultiBackend(backends)

    .. versionadded:: 0.2

    This class allows you to combine multiple backends into a single backend
    that offers the combined features of all of its constituents.

    .. testsetup::

        from cryptography import utils
        from cryptography.exceptions import UnsupportedAlgorithm, _Reasons
        from cryptography.hazmat.backends.interfaces import HashBackend
        from cryptography.hazmat.backends.openssl.backend import backend as backend2

        @utils.register_interface(HashBackend)
        class DummyHashBackend(object):
            def hash_supported(self, algorithm):
                return False

            def create_hash_ctx(self, algorithm):
                raise UnsupportedAlgorithm("", _Reasons.UNSUPPORTED_HASH)

        backend1 = DummyHashBackend()

    .. doctest::

        >>> from cryptography.hazmat.backends.multibackend import MultiBackend
        >>> from cryptography.hazmat.primitives import hashes
        >>> backend1.hash_supported(hashes.SHA256())
        False
        >>> backend2.hash_supported(hashes.SHA256())
        True
        >>> multi_backend = MultiBackend([backend1, backend2])
        >>> multi_backend.hash_supported(hashes.SHA256())
        True

    :param backends: A ``list`` of backend objects. Backends are checked for
                     feature support in the order they appear in this list.