diff options
author | Ayrx <terrycwk1994@gmail.com> | 2014-04-22 17:01:31 +0800 |
---|---|---|
committer | Ayrx <terrycwk1994@gmail.com> | 2014-04-22 23:32:52 +0800 |
commit | 26d959668ff0a651b7637d0bad11854cc6788ee2 (patch) | |
tree | 710ba5e05e9542bef68888470b3df0da0e7fb2bd | |
parent | 8a312c2ccc99351f1a05dc607a574669944ea4cd (diff) | |
download | cryptography-26d959668ff0a651b7637d0bad11854cc6788ee2.tar.gz cryptography-26d959668ff0a651b7637d0bad11854cc6788ee2.tar.bz2 cryptography-26d959668ff0a651b7637d0bad11854cc6788ee2.zip |
Added CMACBackend to multibackend
-rw-r--r-- | cryptography/hazmat/backends/multibackend.py | 13 | ||||
-rw-r--r-- | docs/hazmat/primitives/mac/cmac.rst | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py index 86cded85..b9388346 100644 --- a/cryptography/hazmat/backends/multibackend.py +++ b/cryptography/hazmat/backends/multibackend.py @@ -16,11 +16,12 @@ from __future__ import absolute_import, division, print_function from cryptography import utils from cryptography.exceptions import UnsupportedAlgorithm, _Reasons from cryptography.hazmat.backends.interfaces import ( - CipherBackend, DSABackend, HMACBackend, HashBackend, PBKDF2HMACBackend, - RSABackend + CMACBackend, CipherBackend, DSABackend, HMACBackend, HashBackend, + PBKDF2HMACBackend, RSABackend ) +@utils.register_interface(CMACBackend) @utils.register_interface(CipherBackend) @utils.register_interface(HashBackend) @utils.register_interface(HMACBackend) @@ -156,3 +157,11 @@ class MultiBackend(object): return b.generate_dsa_private_key(parameters) raise UnsupportedAlgorithm("DSA is not supported by the backend", _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM) + + def cmac_algorithm_supported(self, algorithm): + for b in self._filtered_backends(CMACBackend): + return b.cmac_algorithm_supported(algorithm) + + def create_cmac_ctx(self, algorithm): + for b in self._filtered_backends(CMACBackend): + return b.create_cmac_ctx(algorithm) diff --git a/docs/hazmat/primitives/mac/cmac.rst b/docs/hazmat/primitives/mac/cmac.rst index 8b88a3ce..69706bb7 100644 --- a/docs/hazmat/primitives/mac/cmac.rst +++ b/docs/hazmat/primitives/mac/cmac.rst @@ -22,7 +22,7 @@ A subset of CMAC with the AES-128 algorithm is described in :rfc:`4493`. CMAC objects take a :class:`~cryptography.hazmat.primitives.interfaces.BlockCipherAlgorithm` provider. - .. code-block:: pycon + .. doctest:: >>> from cryptography.hazmat.backends import default_backend >>> from cryptography.hazmat.primitives import cmac |