예제 #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())