nrfxlib API 2.8.99
Loading...
Searching...
No Matches

◆ ocrypto_chacha20_poly1305_encrypt()

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.

Parameters
[out]tagGenerated authentication tag.
[out]cGenerated ciphertext. Same length as input message.
mInput message.
m_lenLength of m and c.
aAdditional authenticated data.
a_lenLength of a. May be 0.
nNonce.
n_lenLength of n. 0 <= n_len <= ocrypto_chacha20_poly1305_NONCE_BYTES_MAX.
kEncryption key.
Remarks
c may be same as m.
When reusing an encryption key k for a different message m or different additional authenticated data a, a different nonce n must be used.