Function esp_idf_svc::hal::sys::mbedtls_chacha20_crypt
source ยท pub unsafe extern "C" fn mbedtls_chacha20_crypt(
key: *const u8,
nonce: *const u8,
counter: u32,
size: usize,
input: *const u8,
output: *mut u8,
) -> i32
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.