Source code for pyflocker.ciphers.backends.cryptodome_.symmetric
"""Cryptodome backend specific templates and tools for symmetric ciphers."""from__future__importannotationsimporttypingfrompyflocker.ciphersimportbase,exc
[docs]classNonAEADCipherTemplate(base.BaseNonAEADCipher):""" Template class to provide the default behavior of BaseNonAEADCipher. Subclasses need to provide: - ``_encrypting`` - ``_update_func`` """# these are *not* class variables_encrypting:bool_update_func:typing.Callable|None
[docs]classAuthenticationMixin:"""Mixin class to provide authentication behavior to ciphers. Classes inheriting this must provide these attributes: Attributes: _updated: A boolean indicating whether ``update()`` method of ``_cipher`` was called. _cipher: A cipher from Cryptodome package that has ``update()`` and ``verify()`` methods. _update_func: A method of ``_cipher`` that encrypts/decrypts data. It is generally ``_cipher.encrypt()`` or ``_cipher.decrypt()``. _tag: A byte sequence denoting the MAC tag generated by the cipher after encryption. """_updated:bool_cipher:typing.Any_update_func:typing.Callable_tag:bytes|None
[docs]classAEADCipherTemplate(AuthenticationMixin,base.BaseAEADCipher):""" Template class to provide the default behavior of BaseAEADCipher. Subclasses need to provide the following attributes: - ``_encrypting`` - ``_update_func`` - ``_cipher`` """_encrypting:bool