示例#1
0
    def test_unsupported_cipher(self):
        @utils.register_interface(BlockCipherAlgorithm)
        class FakeAlgorithm(object):
            block_size = 64

        with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
            backend.create_cmac_ctx(FakeAlgorithm())
示例#2
0
    def test_unsupported_cipher(self):
        @utils.register_interface(BlockCipherAlgorithm)
        class FakeAlgorithm(object):
            block_size = 64

        with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
            backend.create_cmac_ctx(FakeAlgorithm())
示例#3
0
    def __init__(
        self,
        algorithm: ciphers.BlockCipherAlgorithm,
        backend: typing.Any = None,
        ctx: typing.Optional["_CMACContext"] = None,
    ):
        if not isinstance(algorithm, ciphers.BlockCipherAlgorithm):
            raise TypeError("Expected instance of BlockCipherAlgorithm.")
        self._algorithm = algorithm

        if ctx is None:
            from cryptography.hazmat.backends.openssl.backend import (
                backend as ossl, )

            self._ctx = ossl.create_cmac_ctx(self._algorithm)
        else:
            self._ctx = ctx
示例#4
0
 def test_unsupported_cipher(self):
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
         backend.create_cmac_ctx(DummyCipherAlgorithm())
示例#5
0
 def test_unsupported_cipher(self):
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
         backend.create_cmac_ctx(DummyCipherAlgorithm())