hu_AESCCMAuthDecrypt()

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

Synopsis:

#include "huaes.h"
 
int hu_AESCCMAuthDecrypt(sb_Params aesParams, sb_Key aesKey, size_t nonceLen, const unsigned char *nonce, size_t addDataLen, const unsigned char *addData, size_t ciphertextLen, const unsigned char *ciphertext, size_t macLen, unsigned char *plaintext, 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.

ciphertextLen

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

ciphertext

Ciphertext buffer. This data will be authenticated and decrypted.

macLen

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

plaintext

The plaintext buffer. The plaintext buffer must be at least ciphertext - 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 ciphertext, nonce, or addData buffer is NULL.

SB_ERR_BAD_LENGTH

The macLen is invalid.

SB_ERR_NULL_OUTPUT_BUF

The plaintext buffer is NULL.

SB_ERR_BAD_INPUT_BUF_LEN

ciphertextLen is not consistent with nonceLen.

SB_ERR_MAC_INVALID

The MAC is invalid.

SB_FAIL_ALLOC

Memory allocation failure.

SB_SUCCESS

Success.