Documentation

Cryptlib.Primitives.Cipher.AEAD

Authenticated encryption with associated data #

Confidentiality and authenticity are computational and are not stated as laws. The laws are correctness (decrypt_encrypt), fixed tag expansion (size_encrypt), and soundness (decrypt_sound): decrypt only accepts ciphertexts that encrypt produces. Together they make decrypt the partial inverse of encrypt (decrypt_eq_some_iff).

The nonce is an explicit argument; choosing unique nonces is the caller's responsibility. Failure is Option so that no failure reason is reported.

Instances For
    theorem Cryptlib.Primitives.Cipher.AEAD.AEAD.decrypt_eq_some_iff (A : AEAD) (k : A.Key) (n : Vector UInt8 A.nonceSize) (ad ct pt : ByteArray) :
    A.decrypt k n ad ct = some pt ↔ A.encrypt k n ad pt = ct

    A ciphertext decrypts to a plaintext exactly when it is that plaintext's encryption.

    Nothing shorter than a tag is accepted.

    theorem Cryptlib.Primitives.Cipher.AEAD.AEAD.size_of_decrypt (A : AEAD) (k : A.Key) (n : Vector UInt8 A.nonceSize) (ad ct pt : ByteArray) (h : A.decrypt k n ad ct = some pt) :
    ct.size = pt.size + A.tagSize

    A ciphertext's length determines its plaintext's length.

    theorem Cryptlib.Primitives.Cipher.AEAD.AEAD.decrypt_inj (A : AEAD) (k : A.Key) (n : Vector UInt8 A.nonceSize) (ad ct₁ ct₂ pt : ByteArray) (h₁ : A.decrypt k n ad ct₁ = some pt) (h₂ : A.decrypt k n ad ct₂ = some pt) :
    ct₁ = ct₂

    Distinct ciphertexts cannot decrypt to the same plaintext under one key, nonce and associated data.

    @[instance_reducible]

    The identity cipher, showing the laws are satisfiable. Provides no security.

    Equations
    • One or more equations did not get rendered due to their size.