mbedtls_cipher_crypt() function
The generic all-in-one encryption/decryption function, for all ciphers except AEAD constructs.
Arguments
ctx
The generic cipher context. This must be initialized.
iv
The IV to use, or NONCE_COUNTER for CTR-mode ciphers. This must be a readable buffer of at least \p iv_len Bytes.
iv_len
The IV length for ciphers with variable-size IV. This parameter is discarded by ciphers with fixed-size IV.
input
The buffer holding the input data. This must be a readable buffer of at least \p ilen Bytes.
ilen
The length of the input data in Bytes.
output
The buffer for the output data. This must be able to hold at least `ilen + block_size`. This must not be the same buffer as \p input.
olen
The length of the output data, to be updated with the actual number of Bytes written. This must not be \c NULL.
Return value
\c 0 on success. #MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA on parameter-verification failure. #MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED on decryption expecting a full block but not receiving one. #MBEDTLS_ERR_CIPHER_INVALID_PADDING on invalid padding while decrypting. A cipher-specific error code on failure.
Notes
Some ciphers do not use IVs nor nonce. For these ciphers, use \p iv = NULL and \p iv_len = 0.