Function nrfxlib_sys::ocrypto_chacha20_poly1305_encrypt
source · pub unsafe extern "C" fn ocrypto_chacha20_poly1305_encrypt(
tag: *mut u8,
c: *mut u8,
m: *const u8,
m_len: usize,
a: *const u8,
a_len: usize,
n: *const u8,
n_len: usize,
k: *const u8
)
Expand description
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
- .
tag
- Generated authentication tag.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.
@remark * c
- may be same as * m
- .
@remark When reusing an encryption key * k
- for a different message * m
- or
different additional authenticated data * a
- , a different nonce * n
-
must be used.