Tools related to symmetric ciphers¶
Cryptography backend specific templates and tools for symmetric ciphers.
- class pyflocker.ciphers.backends.cryptography_.symmetric.NonAEADCipherTemplate[source]¶
Bases:
BaseNonAEADCipher
Template class to provide the default behavior if BaseNonAEADCipher.
- Subclasses need to provide:
_encrypting
_ctx
- is_encrypting() bool [source]¶
Whether the cipher is encrypting or not.
- Returns:
True
if encrypting, elseFalse
.
- update(data: bytes) bytes [source]¶
Takes bytes-like object and returns encrypted/decrypted bytes object.
- Parameters:
data – The bytes-like object to pass to the cipher.
- Returns:
Encrypted/decrypted data as bytes.
- update_into(data: bytes, out: bytearray | memoryview) None [source]¶
Encrypt or decrypt the
data
and store it in a preallocated bufferout
.- Parameters:
data – The bytes-like object to pass to the cipher.
out – The buffer interface where the encrypted/decrypted data must be written into.
- finalize() None [source]¶
Finalizes and closes the cipher.
- Raises:
AlreadyFinalized – If the cipher was already finalized.
- class pyflocker.ciphers.backends.cryptography_.symmetric.AuthenticationMixin[source]¶
Bases:
object
Mixin class to provide authentication behavior to ciphers.
Classes inheriting this must provide these attributes:
- _ctx¶
A cipher context from cryptography package that has
finalize()
method.- Type:
Any
- class pyflocker.ciphers.backends.cryptography_.symmetric.AEADCipherTemplate[source]¶
Bases:
AuthenticationMixin
,BaseAEADCipher
Template class to provide the default behavior of BaseAEADCipher.
- Subclasses need to provide the following attributes:
_encrypting
_ctx
- is_encrypting() bool [source]¶
Whether the cipher is encrypting or not.
- Returns:
True
if encrypting, elseFalse
.