hu_AESParamsCreate()

Creates an AES parameters object.

Synopsis:

#include "huaes.h"
 
int hu_AESParamsCreate(int mode, size_t blockLen, sb_RNGCtx rngContext, sb_YieldCtx yieldCtx, sb_Params *aesParams, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

mode

The mode of operation. The acceptable values are 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. 0 is also acceptable since some adapters support hu_AESBeginV2(). 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 platforms where int is 4 bytes, only up to 2^24 - 16 (=0xFFFFF0) can be specified.

blockLen

The length (in bits) of an encryption block. If mode is SB_AES_KEYWRAP, the length must be SB_AES_KEYWRAP_BLOCK_BITS; otherwise, the length must be SB_AES_128_BLOCK_BITS.

rngContext

An RNG context. (Optional - set to NULL if key generation will not be performed.)

yieldCtx

A yield context. (Optional - set to NULL if yielding is not required.)

aesParams

The AES parameters object pointer.

sbCtx

A global context.

Library:

libhuapi (For the qcc command, use the -l huapi option to link against this library)

Description:

The mode of operation and block length must be specified. An RNG context and/or yielding context must be supplied if key generation and/or yielding will be performed, respectively.

If XTS mode is used, the mode must be specified in this function in order to have correct keys are generated or set by the key functions.

Returns:

SB_ERR_BAD_MODE

mode is an invalid mode of operation.

SB_ERR_BAD_BLOCK_LEN

blockLen is an invalid block length.

SB_ERR_NULL_PARAMS_PTR

The aesParams object is NULL.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.