![]() |
nrfxlib API 3.3.99
|
| void ocrypto_chacha20_poly1305_encrypt | ( | uint8_t | tag[(16)], |
| uint8_t * | c, | ||
| const uint8_t * | m, | ||
| size_t | m_len, | ||
| const uint8_t * | a, | ||
| size_t | a_len, | ||
| const uint8_t * | n, | ||
| size_t | n_len, | ||
| const uint8_t | k[(32)] ) |
#include <crypto/nrf_oberon/include/ocrypto_chacha20_poly1305.h>
AEAD ChaCha20-Poly1305 encrypt.
The message m is encrypted using a ChaCha20 cipher stream derived from the encryption key k and the nonce n. The resulting ciphertext has the same length m_len as the input message m and is put into c.
Additionally, the ciphertext c, as well as the additional authenticated data a, is authenticated with a tag that is generated with Poly1305 using a unique subkey derived from k and n, and then put into tag.
| [out] | tag | Generated authentication tag. |
| [out] | c | Generated ciphertext. Same length as input message. |
| m | Input message. | |
| m_len | Length of m and c. | |
| a | Additional authenticated data. | |
| a_len | Length of a. May be 0. | |
| n | Nonce (or IV). | |
| n_len | Length of n. n_len = 8, 12, or 24. | |
| k | Encryption key. |
c may be same as m.k for a different message m or different additional authenticated data a, a different nonce n must be used.n_len = 24, the XChaCha20-Poly1305 algorithm is used.