hu_AESCCMAuthEncrypt()

Does an authenticated encryption according to the AES CCM algorithm with the given AES parameters and key objects.

Synopsis:

#include "huaes.h"
 
int hu_AESCCMAuthEncrypt(sb_Params aesParams, sb_Key aesKey, size_t nonceLen, const unsigned char *nonce, size_t addDataLen, const unsigned char *addData, size_t plaintextLen, const unsigned char *plaintext, size_t macLen, unsigned char *ciphertext, sb_GlobalCtx sbCtx)

Since:

BlackBerry 10.0.0

Arguments:

aesParams

The AES parameters object.

aesKey

The AES key object. The key must be a valid encryption key.

nonceLen

The length (in bytes) of nonce. Acceptable values are 7, 8, 9, 10, 11, 12 and 13.

nonce

Nonce buffer.

addDataLen

The length (in bytes) of additional data. If addDataLen is not 0, then addData cannot be NULL.

addData

Additional data buffer. This data will be authenticated, but will not be encrypted.

plaintextLen

The length (in bytes) of plaintext. If plaintextLen is not 0, then plaintext cannot be NULL.

plaintext

Plaintext buffer. This data will be authenticated and encrypted.

macLen

The length of the CBC-MAC used for authentication. Acceptable values are 4, 6, 8, 10, 12, 14 and 16.

ciphertext

The ciphertext buffer. The ciphertext buffer must be at least plaintext + macLen bytes in length.

sbCtx

A global context.

Library:

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

Description:

CCM is described in NIST Special Publication 800-38C.

The plaintext and ciphertext buffers may overlap in memory subject to the constraints described in the API Reference section on overlapping buffers.

The adapter registered for AES must support SB_AES_ECB and SB_AES_CBC.

This function should only be called for buffers of plaintext and ciphertext that can be stored entirely in memory.

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_BAD_MODE

aesParams uses an invalid mode of operation.

SB_ERR_NULL_INPUT_BUF

The plaintext, nonce, or addData buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

The nonceLen is invalid.

SB_ERR_BAD_LENGTH

The macLen is invalid.

SB_ERR_NULL_OUTPUT_BUF

The ciphertext buffer is NULL.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.