hu_AESKeyGen()

Creates an AES key object of the specified length from random data that can later be used for encryption and/or decryption.

Synopsis:

#include "huaes.h"
 
int hu_AESKeyGen(sb_Params aesParams, size_t keyLen, sb_Key *aesKey, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

aesParams

The AES parameters object.

keyLen

The length (in bits) of the AES key value. The acceptable values are SB_AES_128_KEY_BITS, SB_AES_192_KEY_BITS, SB_AES_256_KEY_BITS, SB_AES_128_XTS_KEY_BITS and SB_AES_256_XTS_KEY_BITS.

aesKey

The AES key object pointer.

sbCtx

A global context.

Library:

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

Description:

The AES parameter object must have been created with an RNG context.

If the key will be used only for encryption, then you should use hu_AESEncryptKeyGen() as it uses fewer resources.

In XTS mode, two AES keys are used. Therefore, the key size for XTS mode is twice as large as an AES key.

Returns:

SB_ERR_NULL_PARAMS

The aesParams object is NULL.

SB_ERR_BAD_PARAMS

The tag for the params object is not of the expected type.

SB_ERR_BAD_KEY_LEN

keyLen is an invalid key length.

SB_ERR_NULL_KEY_PTR

The aesKey object pointer is NULL.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.