nrfxlib API 0.1.0
|
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. | |
n_len | Length of n . 0 <= n_len <= ocrypto_chacha20_poly1305_NONCE_BYTES_MAX . | |
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.