Function esp_idf_sys::mbedtls_chacha20_crypt
source ยท pub unsafe extern "C" fn mbedtls_chacha20_crypt(
key: *const c_uchar,
nonce: *const c_uchar,
counter: u32,
size: usize,
input: *const c_uchar,
output: *mut c_uchar,
) -> c_int
Expand description
\brief This function encrypts or decrypts data with ChaCha20 and the given key and nonce.
Since ChaCha20 is a stream cipher, the same operation is
used for encrypting and decrypting data.
\warning You must never use the same (key, nonce) pair more than once. This would void any confidentiality guarantees for the messages encrypted with the same nonce and key.
\note The \p input and \p output pointers must either be equal or point to non-overlapping buffers.
\param key The encryption/decryption key.
This must be \c 32 Bytes in length.
\param nonce The nonce. This must be \c 12 Bytes in size.
\param counter The initial counter value. This is usually \c 0.
\param size The length of the input data in Bytes.
\param input The buffer holding the input data.
This pointer can be \c NULL if size == 0
.
\param output The buffer holding the output data.
This must be able to hold \p size Bytes.
This pointer can be \c NULL if size == 0
.
\return \c 0 on success. \return A negative error code on failure.