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