mbedtls_camellia_crypt_cfb128() function
Perform a CAMELLIA-CFB128 buffer encryption/decryption operation.
Arguments
ctx
The CAMELLIA context to use. This must be initialized and bound to a key.
mode
The mode of operation. This must be either #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT.
length
The length of the input data \p input. Any value is allowed.
iv_off
The current offset in the IV. This must be smaller than \c 16 Bytes. It is updated after this call to allow the aforementioned streaming usage.
iv
The initialization vector. This must be a read/write buffer of length \c 16 Bytes. It is updated after this call to allow the aforementioned streaming usage.
input
The buffer holding the input data. This must be a readable buffer of size \p length Bytes.
output
The buffer to hold the output data. This must be a writable buffer of length \p length Bytes.
Return value
\c 0 if successful. A negative error code on failure.
Notes
Due to the nature of CFB mode, you should use the same key for both encryption and decryption. In particular, calls to this function should be preceded by a key-schedule via mbedtls_camellia_setkey_enc() regardless of whether \p mode is #MBEDTLS_CAMELLIA_ENCRYPT or #MBEDTLS_CAMELLIA_DECRYPT. Upon exit, the content of the IV is updated so that you can call the function same function again on the following block(s) of data and get the same result as if it was encrypted in one call. This allows a "streaming" usage. If on the other hand you need to retain the contents of the IV, you should either save it manually or use the cipher module instead.