hu_AESKeyGet()

Retrieves the key value and its length from an AES key object.

Synopsis:

#include "huaes.h"
 
int hu_AESKeyGet(sb_Params aesParams, sb_Key aesKey, size_t *keyLen, unsigned char *keyValue, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

aesParams

The AES parameters object.

aesKey

The AES key object.

keyLen

The length (in bits) of the AES key value.

keyValue

The key value.

sbCtx

A global context.

Library:

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

Description:

If the length of the key value is known, a pointer to a buffer large enough to hold the key value should be passed in keyValue and its length in keyLen. This function will copy the key value into keyValue and set the actual length of the key value in keyLen.

If keyValue is NULL, then this function will set the correct length of the key value in keyLen. If keyValue is not NULL but keyLen is too small, this function will return an error and also will set the correct length of the key value in keyLen.

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_NULL_KEY

The aesKey object is NULL.

SB_ERR_BAD_KEY

The aesKey object is invalid.

SB_ERR_NULL_KEY_LEN

keyLen is NULL.

SB_ERR_BAD_OUTPUT_BUF_LEN

The keyValue buffer length is invalid.

SB_ERR_SYM_KEY_NOT_EXPORTABLE

The key value cannot be exported from the aesKey object.

SB_SUCCESS

Success.