Skip to content

AEAD modes: XChaCha20-Poly1305, AES-SIV, AES-CCM, AES-EAX, AES-OCB3, XAES-256-GCM #155

Backlog

Description

@WingZer0o

Summary

cas-lib's AEADs are AES-GCM, AES-GCM-SIV, ChaCha20-Poly1305 and Ascon-AEAD128. RustCrypto's AEADs workspace has several more standard modes. The most useful for cas-lib consumers are the extended-nonce variants (XChaCha20-Poly1305 and XAES-256-GCM), whose 192-bit nonces are safe to draw at random for any number of messages, and AES-SIV, which is deterministic and nonce-misuse resistant (also a common key-wrap construction). AES-CCM, AES-EAX and AES-OCB3 cover interop with IoT, TLS, Bluetooth and other protocols that require them.

Upstream

Scope

  • XChaCha20-Poly1305
  • XAES-256-GCM
  • AES-SIV (AES-128-SIV / AES-256-SIV, RFC 5297)
  • AES-CCM (RFC 3610; pick the tag/nonce sizes to expose, e.g. 16-byte tag / 13-byte nonce, and document them)
  • AES-EAX
  • AES-OCB3 (RFC 7253)

Implementation notes

  • Follow the module pattern: trait in cas_<module>.rs, impl in <algorithm>.rs, declared in src/lib.rs (no top-level re-exports).
  • Return CasResult<T> and never panic (a panic across the FFI boundary is UB); add CasError variants only by appending (stable ABI codes).
  • Zeroize intermediate secret buffers with zeroize::Zeroizing; structs holding secrets get a redacting Debug impl (see src/pqc/cas_pqc.rs).
  • Each mode gets a unit struct in src/symmetric/ implementing CASAeadSeal (nonce drawn internally via OsRng, output nonce || ciphertext || tag, optional AAD). Reuse src/symmetric/aead_helpers.rs.
  • Only add the caller-supplied-nonce encrypt_plaintext / *_with_aad functions if there is an interop need; if added, document the nonce-reuse risk like the existing ones.
  • AES-SIV: document that it is deterministic (equal plaintexts under the same key and AAD give equal ciphertexts) and that a random nonce is still recommended.
  • AES-SIV uses cmac 0.8, which is on digest 0.11: blocked by Move the hash/MAC/PBKDF2 dependencies to the digest 0.11 ecosystem #154 for that item.

Tests

  • Wycheproof (add to tests/wycheproof.rs): xchacha20_poly1305_test.json, aes_siv_cmac_test.json, aead_aes_siv_cmac_test.json, aes_ccm_test.json, aes_eax_test.json.
  • RFC test vectors for OCB3 (RFC 7253 Appendix A) and XAES-256-GCM (C2SP spec) under tests/data/.
  • Seal/open round-trip and tamper tests like the existing AEADs.

Docs

  • Add a complete, runnable fn main() example for each new API to docs/EXAMPLES.md and keep its Table of Contents in sync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions