MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
CAAM AES driver

Overview

This section describes the programming interface of the CAAM AES driver.

Macros

#define CAAM_AES_BLOCK_SIZE   16
 AES block size in bytes.
 

Functions

status_t CAAM_AES_EncryptEcb (CAAM_Type *base, caam_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t *key, size_t keySize)
 Encrypts AES using the ECB block mode. More...
 
status_t CAAM_AES_DecryptEcb (CAAM_Type *base, caam_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t *key, size_t keySize)
 Decrypts AES using ECB block mode. More...
 
status_t CAAM_AES_EncryptCbc (CAAM_Type *base, caam_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[CAAM_AES_BLOCK_SIZE], const uint8_t *key, size_t keySize)
 Encrypts AES using CBC block mode. More...
 
status_t CAAM_AES_DecryptCbc (CAAM_Type *base, caam_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[CAAM_AES_BLOCK_SIZE], const uint8_t *key, size_t keySize)
 Decrypts AES using CBC block mode. More...
 
status_t CAAM_AES_CryptCtr (CAAM_Type *base, caam_handle_t *handle, const uint8_t *input, uint8_t *output, size_t size, uint8_t counter[CAAM_AES_BLOCK_SIZE], const uint8_t *key, size_t keySize, uint8_t counterlast[CAAM_AES_BLOCK_SIZE], size_t *szLeft)
 Encrypts or decrypts AES using CTR block mode. More...
 
status_t CAAM_AES_EncryptTagCcm (CAAM_Type *base, caam_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, const uint8_t *key, size_t keySize, uint8_t *tag, size_t tagSize)
 Encrypts AES and tags using CCM block mode. More...
 
status_t CAAM_AES_DecryptTagCcm (CAAM_Type *base, caam_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, const uint8_t *key, size_t keySize, const uint8_t *tag, size_t tagSize)
 Decrypts AES and authenticates using CCM block mode. More...
 
status_t CAAM_AES_EncryptTagGcm (CAAM_Type *base, caam_handle_t *handle, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, const uint8_t *key, size_t keySize, uint8_t *tag, size_t tagSize)
 Encrypts AES and tags using GCM block mode. More...
 
status_t CAAM_AES_DecryptTagGcm (CAAM_Type *base, caam_handle_t *handle, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, const uint8_t *key, size_t keySize, const uint8_t *tag, size_t tagSize)
 Decrypts AES and authenticates using GCM block mode. More...
 

Function Documentation

status_t CAAM_AES_EncryptEcb ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t *  key,
size_t  keySize 
)

Encrypts AES using the ECB block mode.

Parameters
baseCAAM peripheral base address
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
keyInput key to use for encryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
Returns
Status from encrypt operation
status_t CAAM_AES_DecryptEcb ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t *  key,
size_t  keySize 
)

Decrypts AES using ECB block mode.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
ciphertextInput cipher text to decrypt
[out]plaintextOutput plain text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
keyInput key.
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
Returns
Status from decrypt operation
status_t CAAM_AES_EncryptCbc ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t  iv[CAAM_AES_BLOCK_SIZE],
const uint8_t *  key,
size_t  keySize 
)
Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
ivInput initial vector to combine with the first input block.
keyInput key to use for encryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
Returns
Status from encrypt operation
status_t CAAM_AES_DecryptCbc ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t  iv[CAAM_AES_BLOCK_SIZE],
const uint8_t *  key,
size_t  keySize 
)
Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
ciphertextInput cipher text to decrypt
[out]plaintextOutput plain text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
ivInput initial vector to combine with the first input block.
keyInput key to use for decryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
Returns
Status from decrypt operation
status_t CAAM_AES_CryptCtr ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  input,
uint8_t *  output,
size_t  size,
uint8_t  counter[CAAM_AES_BLOCK_SIZE],
const uint8_t *  key,
size_t  keySize,
uint8_t  counterlast[CAAM_AES_BLOCK_SIZE],
size_t *  szLeft 
)

Encrypts or decrypts AES using CTR block mode. AES CTR mode uses only forward AES cipher and same algorithm for encryption and decryption. The only difference between encryption and decryption is that, for encryption, the input argument is plain text and the output argument is cipher text. For decryption, the input argument is cipher text and the output argument is plain text.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
inputInput data for CTR block mode
[out]outputOutput data for CTR block mode
sizeSize of input and output data in bytes
[in,out]counterInput counter (updates on return)
keyInput key to use for forward AES cipher
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
[out]counterlastOutput cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are not used.
[out]szLeftOutput number of bytes in left unused in counterlast block. NULL can be passed if chained calls are not used.
Returns
Status from encrypt operation
status_t CAAM_AES_EncryptTagCcm ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
const uint8_t *  key,
size_t  keySize,
uint8_t *  tag,
size_t  tagSize 
)

Encrypts AES and optionally tags using CCM block mode.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text.
sizeSize of input and output data in bytes. Zero means authentication only.
ivNonce
ivSizeLength of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
aadInput additional authentication data. Can be NULL if aadSize is zero.
aadSizeInput size in bytes of AAD. Zero means data mode only (authentication skipped).
keyInput key to use for encryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
[out]tagGenerated output tag. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16.
Returns
Status from encrypt operation
status_t CAAM_AES_DecryptTagCcm ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  tag,
size_t  tagSize 
)

Decrypts AES and optionally authenticates using CCM block mode.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
ciphertextInput cipher text to decrypt
[out]plaintextOutput plain text.
sizeSize of input and output data in bytes. Zero means authentication data only.
ivNonce
ivSizeLength of the Nonce in bytes. Must be 7, 8, 9, 10, 11, 12, or 13.
aadInput additional authentication data. Can be NULL if aadSize is zero.
aadSizeInput size in bytes of AAD. Zero means data mode only (authentication data skipped).
keyInput key to use for decryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
tagReceived tag. Set to NULL to skip tag processing.
tagSizeInput size of the received tag to compare with the computed tag, in bytes. Must be 4, 6, 8, 10, 12, 14, or 16.
Returns
Status from decrypt operation
status_t CAAM_AES_EncryptTagGcm ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
const uint8_t *  key,
size_t  keySize,
uint8_t *  tag,
size_t  tagSize 
)

Encrypts AES and optionally tags using GCM block mode. If plaintext is NULL, only the GHASH is calculated and output in the 'tag' field.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
plaintextInput plain text to encrypt
[out]ciphertextOutput cipher text.
sizeSize of input and output data in bytes
ivInput initial vector
ivSizeSize of the IV
aadInput additional authentication data
aadSizeInput size in bytes of AAD
keyInput key to use for encryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
[out]tagOutput hash tag. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 4,8,12,13,14,15 or 16.
Returns
Status from encrypt operation
status_t CAAM_AES_DecryptTagGcm ( CAAM_Type *  base,
caam_handle_t handle,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  tag,
size_t  tagSize 
)

Decrypts AES and optionally authenticates using GCM block mode. If ciphertext is NULL, only the GHASH is calculated and compared with the received GHASH in 'tag' field.

Parameters
baseCAAM peripheral base address
handleHandle used for this request. Specifies jobRing.
ciphertextInput cipher text to decrypt
[out]plaintextOutput plain text.
sizeSize of input and output data in bytes
ivInput initial vector
ivSizeSize of the IV
aadInput additional authentication data
aadSizeInput size in bytes of AAD
keyInput key to use for encryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
tagInput hash tag to compare. Set to NULL to skip tag processing.
tagSizeInput size of the tag, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16.
Returns
Status from decrypt operation