Example #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())
Example #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())
Example #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
Example #4
0
 def test_unsupported_cipher(self):
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
         backend.create_cmac_ctx(DummyCipherAlgorithm())
Example #5
0
 def test_unsupported_cipher(self):
     with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_CIPHER):
         backend.create_cmac_ctx(DummyCipherAlgorithm())