Module: aead

class doubleratchet.aead.AEAD[source]

Bases: ABC

Authenticated Encryption with Associated Data (AEAD).

abstractmethod async static encrypt(plaintext, key, associated_data)[source]
Parameters:
  • plaintext (bytes) – The plaintext to encrypt.

  • key (bytes) – The encryption key.

  • associated_data (bytes) – Additional data to authenticate without including it in the ciphertext.

Return type:

bytes

Returns:

The ciphertext.

abstractmethod async static decrypt(ciphertext, key, associated_data)[source]
Parameters:
  • ciphertext (bytes) – The ciphertext to decrypt.

  • key (bytes) – The decryption key.

  • associated_data (bytes) – Additional data to authenticate without including it in the ciphertext.

Return type:

bytes

Returns:

The plaintext.

Raises:
exception doubleratchet.aead.AuthenticationFailedException[source]

Bases: Exception

Raised by AEAD.decrypt() in case of authentication failure.

exception doubleratchet.aead.DecryptionFailedException[source]

Bases: Exception

Raised by AEAD.decrypt() in case of decryption failure.