[][src]Module rust_sodium::crypto::aead::chacha20poly1305

The original ChaCha20-Poly1305 construction can safely encrypt a pratically unlimited number of messages with the same key, without any practical limit to the size of a message (up to ~ 2^64 bytes).

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

gen_nonce

gen_nonce() randomly generates a nonce

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.