Creates an AES context initialized with the given parameters (with the ability to override the mode in the parameters) and key.
#include "huaes.h"
int hu_AESBeginV2(sb_Params aesParams, sb_Key aesKey, int mode, size_t ivLen, const unsigned char *iv, sb_Context *aesContext, sb_GlobalCtx sbCtx)
BlackBerry 10.0.0
The AES parameters object.
The AES key object.
The mode of operation. The acceptable values are 0, SB_AES_ECB, SB_AES_CBC, SB_AES_CFB128, SB_AES_CFB8, SB_AES_OFB128, SB_AES_KEYWRAP, SB_AES_CTR(ctrBits) and SB_AES_XTS(unitBytes). For SB_AES_CTR(ctrBits), ctrBits is the number of bits that will be used for the counter. ctrBits must be less than or equal to SB_AES_128_BLOCK_BITS. Specifying 0 will use the mode from the parameters object. For SB_AES_XTS(unitBytes), unitBytes is the number of bytes in a data unit. The number of bytes in a data unit must be a multiple of 16. By NIST SP 800-38E, the minimum number of bytes in a data unit is 16, and the maximum number of bytes allowed in a data unit is 2^24 = (0x1000000). Note that on the platforms where int is 4 bytes, only up to 2^24 - 16 (=0xFFFFF0) can be specified.
The length (in bytes) of initial vector. The only acceptable value is SB_AES_128_BLOCK_BYTES.
The initial vector.
The AES context object pointer.
A global context.
An initial vector is required for the SB_AES_CBC, SB_AES_CFB128, SB_AES_CFB8, SB_AES_OFB128, and SB_AES_CTR(ctrBits) modes of operation. For SB_AES_CTR(ctrBits), iv will be used as the initial counter block, where the initial counter value must be set in the most significant (higher index) ctrBits/8 bytes of the initial counter, and the counter value must be represented in big-endian. The counter is incremented by 1. iv is ignored for SB_AES_ECB, as an initial vector is not required for that mode.
If XTS mode is used and XTS mode was not specified in the hu_AESParamsCreate function, SB_ERR_BAD_KEY will be returned.
The aesParams object is NULL.
The aesParams object is invalid.
The aesKey object is NULL.
The aesKey object is invalid.
iv, the initial vector, is NULL.
ivLen is an invalid vector length.
The value iv is invalid.
The context object pointer is NULL.
No mode has been specified.
Memory allocation failure.
Success.