Skip to main content

mbedtls_cipher_reset

Function mbedtls_cipher_reset 

Source
pub unsafe extern "C" fn mbedtls_cipher_reset(
    ctx: *mut mbedtls_cipher_context_t,
) -> c_int
Expand description

\brief This function resets the cipher state.

\note With non-AEAD ciphers, the order of calls for each message is as follows: 1. mbedtls_cipher_set_iv() if the mode uses an IV/nonce; 2. mbedtls_cipher_reset(); 3. mbedtls_cipher_update() zero, one or more times; 4. mbedtls_cipher_finish_padded() (recommended for decryption if the mode uses padding) or mbedtls_cipher_finish(). . This sequence can be repeated to encrypt or decrypt multiple messages with the same key.

\note With AEAD ciphers, the order of calls for each message is as follows: 1. mbedtls_cipher_set_iv() if the mode uses an IV/nonce; 2. mbedtls_cipher_reset(); 3. mbedtls_cipher_update_ad(); 4. mbedtls_cipher_update() zero, one or more times; 5. mbedtls_cipher_finish() (or mbedtls_cipher_finish_padded()); 6. mbedtls_cipher_check_tag() (for decryption) or mbedtls_cipher_write_tag() (for encryption). . This sequence can be repeated to encrypt or decrypt multiple messages with the same key.

\param ctx The generic cipher context. This must be bound to a key.

\return \c 0 on success. \return #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter-verification failure.