openHiTLS API openHiTLS 0.1.0-Alpha1

◆ CRYPT_EAL_CipherInit()

int32_t CRYPT_EAL_CipherInit ( CRYPT_EAL_CipherCtx ctx,
const uint8_t *  key,
uint32_t  keyLen,
const uint8_t *  iv,
uint32_t  ivLen,
bool  enc 
)

Initialize the symmetric encryption/decryption handle. The key cannot be null. Except the ECB mode, other modes iv cannot be null.

The length of iv must be the same as the block length (this requirement is not required in ECB mode). The block length can be obtained through CRYPT_CTRL_GET_BLOCKSIZE of CRYPT_EAL_CipherCtrl. CRYPT_EAL_CipherInit can be called repeatedly at any stage, resets the key and iv, and clears the cached data.

Attention
If the function is called by an external user and the error stack is concerned, you are advised to call BSL_ERR_ClearError() before calling this function.
Parameters
ctx[IN] Symmetric encryption/decryption handle
key[IN] Key
keyLen[IN] Key length
iv[IN] Initialization vector
ivLen[IN] Initialize the vector length.
enc[IN] True: encryption; False: decryption
Return values
CRYPT_SUCCESS,success.For other error codes, see crypt_errno.h.