rokdocs
v0.1

rok::core::crypto::aead

Authenticated encryption with associated data: AES-GCM (NIST SP 800-38D, 96-bit nonces) and ChaCha20-Poly1305 (RFC 8439). Tags are 16 bytes, appended to the ciphertext. The key material is in secret storage; per-message state is in locals.

Structs

Aead

pub struct Aead

A key ready for seal / open.

  • pub fn new(alg: AeadAlgorithm, key: Bytes) throws (ValueError) -> Aead
  • pub const fn algorithm(self) -> AeadAlgorithm
  • pub fn wipe(self)

    Overwrite the key material with zeros now (every copy shares it); seal and open are meaningless afterwards.

  • pub fn seal(self, nonce: Bytes, aad: Bytes, plaintext: Bytes) throws (ValueError) -> List<u8>

    plaintext encrypted, then the tag.

  • pub fn open(self, nonce: Bytes, aad: Bytes, ciphertext_and_tag: Bytes) throws (ValueError) -> List<u8> | none

    The plaintext, or none when the tag does not match (nothing is decrypted then).

Trait implementations 1
  • impl Drop for Aead

Enums

AeadAlgorithm

pub enum AeadAlgorithm
  • Aes128Gcm
  • Aes256Gcm
  • ChaCha20Poly1305
  • pub const fn key_len(self) -> usize
  • pub const fn nonce_len(self) -> usize
  • pub const fn tag_len(self) -> usize