ChaCha20

class pyflocker.ciphers.backends.cryptodome_.ChaCha20.ChaCha20(encrypting: bool, key: bytes, nonce: bytes)[source]

Bases: NonAEADCipherTemplate

ChaCha20 Cipher class.

This class alone does not provide any authentication. For AEAD purposes, wrap ChaCha20 object with a class that implements BaseAEADCipher or use ChaCha20Poly1305.

class pyflocker.ciphers.backends.cryptodome_.ChaCha20.ChaCha20Poly1305(encrypting: bool, key: bytes, nonce: bytes)[source]

Bases: AEADCipherTemplate

ChaCha20Poly1305 Cipher class.

pyflocker.ciphers.backends.cryptodome_.ChaCha20.new(encrypting: bool, key: bytes, nonce: bytes, *, use_poly1305: bool = True, file: io.BufferedIOBase | None = None) ChaCha20 | ChaCha20Poly1305 | FileCipherWrapper[source]

Instantiate a new ChaCha20-Poly1305 cipher wrapper object.

Parameters:
  • encrypting – True is encryption and False is decryption.

  • key – The key for the cipher.

  • nonce – The Nonce for the cipher. It must not be repeated with the same key.

Keyword Arguments:
  • use_poly1305 – Whether to use Poly1305 MAC with ChaCha20 cipher.

  • file – The source file to read from.

Returns:

ChaCha20(-Poly1305) cipher wrapper object.

Note

Any other error that is raised is from the backend itself.