Module sodiumoxide::crypto::aead::chacha20poly1305_ietf[][src]

Expand description

The IETF variant of the ChaCha20-Poly1305 construction can safely encrypt a practically unlimited number of messages, but individual messages cannot exceed 64*(2^32)-64 bytes (approximatively 256 GB).

Structs

Key

Key for symmetric authenticated encryption with additional data.

Nonce

Nonce for symmetric authenticated encryption with additional data.

Tag

Authentication Tag for symmetric authenticated encryption with additional data in detached mode.

Constants

KEYBYTES

Number of bytes in a Key.

NONCEBYTES

Number of bytes in a Nonce.

TAGBYTES

Number of bytes in an authentication Tag.

Functions

gen_key

gen_key() randomly generates a secret key

open

open() verifies and decrypts a ciphertext c together with optional plaintext data ad using a secret key k and a nonce n. It returns a plaintext Ok(m). If the ciphertext fails verification, open() returns Err(()).

open_detached

open_detached() verifies and decrypts a ciphertext c toghether with optional plaintext data ad and and authentication tag tag, using a secret key k and a nonce n. c is decrypted in place, so if this function is successful it will contain the plaintext. If the ciphertext fails verification, open_detached() returns Err(()), and the ciphertext is not modified.

seal

seal() encrypts and authenticates a message m together with optional plaintext data ad using a secret key k and a nonce n. It returns a ciphertext c.

seal_detached

seal_detached() encrypts and authenticates a message m together with optional plaintext data ad using a secret key k and a nonce n. m is encrypted in place, so after this function returns it will contain the ciphertext. The detached authentication tag is returned by value.