crypto_secretbox_xsalsa20poly1305, a particular
combination of Salsa20 and Poly1305 specified in
Cryptography in NaCl.
This function is conjectured to meet the standard notions of privacy and
authenticity.
| Key | Key for symmetric authenticated encryption
|
| Nonce | Nonce for symmetric authenticated encryption
|
| Tag | Authentication Tag for the detached encryption mode
|
| KEYBYTES | Number of bytes in Key.
|
| MACBYTES | Number of bytes in the authenticator tag of an encrypted message
i.e. the number of bytes by which the ciphertext is larger than the
plaintext.
|
| NONCEBYTES | Number of bytes in a Nonce.
|
| 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 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 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 using a secret key k and a
nonce n. It returns a ciphertext c.
|
| seal_detached | seal_detached() encrypts and authenticates a message m 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.
|