Skip to content

aead: marker trait + simpler encryption API for randomized nonces #1666

Open

Description

@tarcieri

We currently require an explicit nonce for all encryption APIs, including ones which automatically encode the nonce as part of the AEAD message.

For some AEADs we can use purely randomized nonces safely: AES-GCM-SIV, the XChaCha* variants, and the new XAES-256-GCM are all examples of AEAD algorithms which are safe to use with nonces derived from a CSPRNG.

For these constructions, it would be nice if we had APIs that completely delegate nonce generation to a CSPRNG so we could more easily avoid nonce reuse.

Activity

  1. tarcieri commented on Nov 20, 2024

    @tarcieri
    MemberAuthor

    As discussed in #1713, the encryption API can also wrap up prepending the random nonce to the message, as is customary.

  2. newpavlov commented on Nov 20, 2024

    @newpavlov
    Member

    Are there any protocols used in practice which append nonces to ciphertext?

    We potentially could add an inout type with reserved header of fixed size. It also could be useful for a more efficient set of prefix encrypt/decrypt methods.

  3. added a commit that references this issue on Apr 14, 2025
  4. added
    aeadAuthenticated Encryption with Associated Data (AEAD) crate
    on Oct 13, 2025
  5. tarcieri commented on May 13, 2026

    @tarcieri
    MemberAuthor

    Are there any protocols used in practice which append nonces to ciphertext?

    I'm not aware of any. It seems generally disadvantageous because the nonce is needed before the tag, so putting it at the end is the reverse order you actually need it in (although we don't provide any APIs that would let you perform computation with the nonce without the tag)

  6. newpavlov commented on May 19, 2026

    @newpavlov
    Member

    putting it at the end is the reverse order you actually need it in

    I guess it matters in the case of online application of an AEAD mode (which we currently do not expose). When you have the whole ciphertext it should be trivial to slice postfix nonce/tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aeadAuthenticated Encryption with Associated Data (AEAD) crate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions