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

Overview

The MCUXpresso SDK provides a peripheral driver for the AES module in MCUXpresso SDK devices.

Macros

#define FSL_AES_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Defines AES driver version. More...
 
#define AES_BLOCK_SIZE   16U
 AES block size in bytes.
 
#define AES_VECTOR_SIZE   16U
 AES Vector size in bytes.
 

Typedefs

typedef status_t(* aes_lock_func_t )(void)
 AES lock function. More...
 
typedef void(* aes_unlock_func_t )(void)
 AES lock function. More...
 

Enumerations

enum  aes_mode_t {
  kAES_ModeEncryptECB = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(0),
  kAES_ModeDecryptECB = AES_CTRL1_DECRYPT(1) | AES_CTRL1_MODE(0),
  kAES_ModeEncryptCBC = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(1),
  kAES_ModeDecryptCBC = AES_CTRL1_DECRYPT(1) | AES_CTRL1_MODE(1),
  kAES_ModeCTR = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(2),
  kAES_ModeEncryptCCM = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(5),
  kAES_ModeDecryptCCM = AES_CTRL1_DECRYPT(1) | AES_CTRL1_MODE(5),
  kAES_ModeMMO = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(6),
  kAES_ModeBYPASS = AES_CTRL1_DECRYPT(0) | AES_CTRL1_MODE(7)
}
 AES work mode definition. More...
 
enum  aes_fifo_t {
  kAES_InputFIFO = AES_CTRL1_IF_CLR_MASK,
  kAES_OutputFIFO = AES_CTRL1_OF_CLR_MASK,
  kAES_AllFIFO = AES_CTRL1_OF_CLR_MASK | AES_CTRL1_IF_CLR_MASK
}
 AES FIFO. More...
 
enum  aes_keysize_t {
  kAES_KeyBytes16 = 0,
  kAES_KeyBytes32 = 1,
  kAES_KeyBytes24 = 2
}
 AES key size type definition. More...
 
enum  aes_miclen_t {
  kAES_MicBytes0 = 0,
  kAES_MicBytes4 = 1,
  kAES_MicBytes8 = 2,
  kAES_MicBytes16 = 3
}
 AES MIC size type definition. More...
 
enum  aes_interrupt_t {
  kAES_InterruptOutputFIFOEmpty,
  kAES_InterruptInputFIFOFull,
  kAES_InterruptDone
}
 AES interrupt type definition. More...
 
enum  {
  kAES_OutputFIFOEmptyFlag = AES_STATUS_OF_EMPTY_MASK,
  kAES_InputFIFOFullFlag = AES_STATUS_IF_FULL_MASK,
  kAES_OutputFIFOReadyFlag = AES_STATUS_OF_RDY_MASK,
  kAES_DoneFlag = AES_STATUS_DONE_MASK,
  kAES_Error0Flag = AES_STATUS_STATUS(1U),
  kAES_Error1Flag = AES_STATUS_STATUS(2U),
  kAES_Error2Flag = AES_STATUS_STATUS(4U)
}
 AES status type definition. More...
 

Initialization Interfaces

void AES_Init (AES_Type *base)
 Initializes AES module. More...
 
void AES_Deinit (AES_Type *base)
 Deinitializes AES module. More...
 
void AES_Reset (AES_Type *base)
 Reset AES module. More...
 

Module configuration

static void AES_SetMode (AES_Type *base, aes_mode_t mode)
 Set AES module work mode. More...
 
void AES_SetInputVector (AES_Type *base, const uint8_t inputVector[AES_VECTOR_SIZE])
 Set the AES input vector. More...
 
void AES_GetOutputVector (AES_Type *base, uint8_t outputVector[AES_VECTOR_SIZE])
 Get the AES output vector. More...
 
static void AES_SetMsgLen (AES_Type *base, uint32_t msgLen)
 Set the input data length. More...
 
static void AES_SetAadLen (AES_Type *base, uint32_t len)
 Set the additional authentication data length in CCM mode. More...
 
static void AES_SetCTRCountModular (AES_Type *base, uint8_t modular)
 Set the CTR mode counter modular. More...
 
static void AES_EnableOutMsg (AES_Type *base, bool enable)
 Enable or disable the output stream to output FIFO. More...
 
static void AES_EnableDma (AES_Type *base, bool enable)
 Enable or disable DMA. More...
 
static void AES_AppendMIC (AES_Type *base, bool append)
 Append MIC/HASH output or not. More...
 
static void AES_SetMICLength (AES_Type *base, aes_miclen_t len)
 Set the MIC length in CCM mode. More...
 
status_t AES_ReadMIC (AES_Type *base, uint32_t *micData, uint8_t len)
 Read AES CCM MIC output value. More...
 
void AES_ClearFIFO (AES_Type *base, aes_fifo_t fifo)
 Clear AES input or output FIFO. More...
 
static void AES_Start (AES_Type *base)
 Start the AES calculation. More...
 
static void AES_Stop (AES_Type *base)
 Stop the AES calculation. More...
 
static void AES_WriteData (AES_Type *base, uint32_t data)
 Write data to AES input FIFO. More...
 
static uint32_t AES_ReadData (AES_Type *base)
 Read data from AES output FIFO. More...
 

Interrupt and status

static uint32_t AES_GetStatus (AES_Type *base)
 Get the AES status. More...
 
static void AES_EnableInterrupts (AES_Type *base, uint32_t interrupts)
 Enable AES interrupts. More...
 
static void AES_DisableInterrupts (AES_Type *base, uint32_t interrupts)
 Disable AES interrupts. More...
 
static uint32_t AES_GetInterruptStatus (AES_Type *base)
 Get AES interrupt status. More...
 
static void AES_ClearInterruptStatus (AES_Type *base, uint32_t interrupts)
 Clear AES interrupt status. More...
 
static uint32_t AES_GetRawInterruptStatus (AES_Type *base)
 Get AES raw interrupt status. More...
 

High level interface

status_t AES_SetKey (AES_Type *base, const uint8_t *key, size_t keySize)
 Sets AES key. More...
 
status_t AES_EncryptEcb (AES_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, size_t size)
 Encrypts AES using the ECB block mode. More...
 
status_t AES_DecryptEcb (AES_Type *base, const uint8_t *ciphertext, uint8_t *plaintext, size_t size)
 Decrypts AES using the ECB block mode. More...
 
status_t AES_EncryptCbc (AES_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[AES_VECTOR_SIZE], uint8_t ov[AES_VECTOR_SIZE])
 Encrypts AES using CBC block mode. More...
 
status_t AES_DecryptCbc (AES_Type *base, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[AES_VECTOR_SIZE], uint8_t ov[AES_VECTOR_SIZE])
 Decrypts AES using CBC block mode. More...
 
status_t AES_CryptCtr (AES_Type *base, const uint8_t *input, uint8_t *output, size_t size, uint8_t nonce[AES_BLOCK_SIZE], uint8_t streamBlock[AES_BLOCK_SIZE], size_t *offset)
 Encrypts or decrypts AES using CTR block mode. More...
 
status_t AES_EncryptTagCcm (AES_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, uint8_t *tag, size_t tagSize)
 Encrypts AES and tags using CCM block mode. More...
 
status_t AES_DecryptTagCcm (AES_Type *base, 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 *tag, size_t tagSize)
 Decrypts AES and authenticates using CCM block mode. More...
 
status_t AES_CalculateMMOHash (AES_Type *base, const uint8_t *input, size_t size, uint8_t hash[16])
 Calculate the input stream MMO HASH value. More...
 

Function with lock

AES module might be used by multiple sofware components, to make sure the on-going proess is not broken by the call from another components, lock is used to protect the operation.

To use the lock, set the lock function with AES_SetLockFunc, then when calling the APIs with suffix WithLock, the lock function will be called by AES driver.

void AES_SetLockFunc (aes_lock_func_t lockFunc, aes_unlock_func_t unlockFunc)
 Set the lock functions. More...
 
status_t AES_EncryptEcbWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *plaintext, uint8_t *ciphertext, size_t size)
 Encrypts AES using the ECB block mode. More...
 
status_t AES_DecryptEcbWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *ciphertext, uint8_t *plaintext, size_t size)
 Decrypts AES using the ECB block mode. More...
 
status_t AES_EncryptCbcWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[AES_VECTOR_SIZE], uint8_t ov[AES_VECTOR_SIZE])
 Encrypts AES using CBC block mode. More...
 
status_t AES_DecryptCbcWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[AES_VECTOR_SIZE], uint8_t ov[AES_VECTOR_SIZE])
 Decrypts AES using CBC block mode. More...
 
status_t AES_CryptCtrWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *input, uint8_t *output, size_t size, uint8_t nonce[AES_BLOCK_SIZE], uint8_t streamBlock[AES_BLOCK_SIZE], size_t *offset)
 Encrypts or decrypts AES using CTR block mode. More...
 
status_t AES_EncryptTagCcmWithLock (AES_Type *base, const uint8_t *key, size_t keySize, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t *iv, size_t ivSize, const uint8_t *aad, size_t aadSize, uint8_t *tag, size_t tagSize)
 Encrypts AES and tags using CCM block mode. More...
 
status_t AES_DecryptTagCcmWithLock (AES_Type *base, const uint8_t *key, size_t keySize, 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 *tag, size_t tagSize)
 Decrypts AES and authenticates using CCM block mode. More...
 
status_t AES_CalculateMMOHashWithLock (AES_Type *base, const uint8_t *input, size_t size, uint8_t hash[16])
 Calculate the input stream MMO HASH value. More...
 

Macro Definition Documentation

#define FSL_AES_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Typedef Documentation

typedef status_t(* aes_lock_func_t)(void)
typedef void(* aes_unlock_func_t)(void)

Enumeration Type Documentation

enum aes_mode_t
Enumerator
kAES_ModeEncryptECB 

ECB encrypt.

kAES_ModeDecryptECB 

ECB decrypt.

kAES_ModeEncryptCBC 

CBC encrypt.

kAES_ModeDecryptCBC 

CBC decrypt.

kAES_ModeCTR 

CTR.

kAES_ModeEncryptCCM 

CCM encrypt.

kAES_ModeDecryptCCM 

CCM decrypt.

kAES_ModeMMO 

AES mode: MMO.

kAES_ModeBYPASS 

AES mode: Bypass.

enum aes_fifo_t
Enumerator
kAES_InputFIFO 

Input FIFO.

kAES_OutputFIFO 

Output FIFO.

kAES_AllFIFO 

Input and output FIFO.

Enumerator
kAES_KeyBytes16 

AES key size select: 16 bytes.

kAES_KeyBytes32 

AES key size select: 32 bytes.

kAES_KeyBytes24 

AES key size select: 24 bytes.

Enumerator
kAES_MicBytes0 

AES MIC length: 0 bytes.

kAES_MicBytes4 

AES MIC length: 4 bytes.

kAES_MicBytes8 

AES MIC length: 8 bytes.

kAES_MicBytes16 

AES MIC length: 16 bytes.

Enumerator
kAES_InterruptOutputFIFOEmpty 

AES output FIFO empty int flag.

kAES_InterruptInputFIFOFull 

AES input FIFO full int flag.

kAES_InterruptDone 

AES done int flag.

anonymous enum

Enumerator
kAES_OutputFIFOEmptyFlag 

AES output FIFO empty flag.

kAES_InputFIFOFullFlag 

AES input FIFO full flag.

kAES_OutputFIFOReadyFlag 

AES output FIFO can be read flag.

kAES_DoneFlag 

AES done flag.

kAES_Error0Flag 

Input stream size is less than 16 bytes in CBC&CTR mode.

kAES_Error1Flag 

Data is more than 2^13-1 bytes in MMO mode Data is not multiple of 16 bytes in ECB mode.

kAES_Error2Flag 

MIC mismatch during decryption in CCM* mode.

Function Documentation

void AES_Init ( AES_Type *  base)

Initialize the module, reset the module and set the registers to default status.

Parameters
baseAES peripheral base address.
void AES_Deinit ( AES_Type *  base)

Deinitialize the module and reset the module.

Parameters
baseAES peripheral base address.
void AES_Reset ( AES_Type *  base)

Reset the module. This function only resets the AES module internal status, but does not reset the register configurations.

Parameters
baseAES peripheral base address.
static void AES_SetMode ( AES_Type *  base,
aes_mode_t  mode 
)
inlinestatic
Parameters
baseAES peripheral base address.
modeAES work mode.
void AES_SetInputVector ( AES_Type *  base,
const uint8_t  inputVector[AES_VECTOR_SIZE] 
)
Parameters
baseAES peripheral base address.
inputVectorInput vector.
void AES_GetOutputVector ( AES_Type *  base,
uint8_t  outputVector[AES_VECTOR_SIZE] 
)
Parameters
baseAES peripheral base address.
outputVectorArray to save the output vector.
static void AES_SetMsgLen ( AES_Type *  base,
uint32_t  msgLen 
)
inlinestatic
Parameters
baseAES peripheral base address.
msgLenLength of the input data in byte.
static void AES_SetAadLen ( AES_Type *  base,
uint32_t  len 
)
inlinestatic
Parameters
baseAES peripheral base address.
lenLength in byte.
static void AES_SetCTRCountModular ( AES_Type *  base,
uint8_t  modular 
)
inlinestatic
Parameters
baseAES peripheral base address.
modularThe modular set to AES register. Valid range is 0~128. When pass in 0~15, the CTR counter modular is 2^128, when pass in other values, the CTR counter modular is 2^input value.
static void AES_EnableOutMsg ( AES_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseAES peripheral base address.
enableUse true to forward output stream to output FIFO, use false to block output stream from output FIFO.
static void AES_EnableDma ( AES_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseAES peripheral base address.
enableUse true to enable DMA, use false to disable DMA.
static void AES_AppendMIC ( AES_Type *  base,
bool  append 
)
inlinestatic

When enabled in CCM mode decryption, the MIC is append at the end of output stream. When enabled in MMO mode, the HASH is append at the end of output stream.

Parameters
baseAES peripheral base address.
appendUse true to append, otherwise use false.
static void AES_SetMICLength ( AES_Type *  base,
aes_miclen_t  len 
)
inlinestatic
Parameters
baseAES peripheral base address.
lenMIC length.
status_t AES_ReadMIC ( AES_Type *  base,
uint32_t *  micData,
uint8_t  len 
)
Parameters
baseAES peripheral base address.
micDataThe memory to save the MIC data.
lenLength of micData in word, the valid range is 1~4.
Return values
kStatus_InvalidArgumentThe required length is wrong.
kStatus_SuccessGet MIC successfully.
void AES_ClearFIFO ( AES_Type *  base,
aes_fifo_t  fifo 
)
Parameters
baseAES peripheral base address.
fifoThe FIFO to clear.
static void AES_Start ( AES_Type *  base)
inlinestatic

Start the calculation based on configurations.

Parameters
baseAES peripheral base address.
static void AES_Stop ( AES_Type *  base)
inlinestatic

Stop the calculation.

Parameters
baseAES peripheral base address.
static void AES_WriteData ( AES_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseAES peripheral base address.
dataData written to AES FIFO.
static uint32_t AES_ReadData ( AES_Type *  base)
inlinestatic
Parameters
baseAES peripheral base address.
static uint32_t AES_GetStatus ( AES_Type *  base)
inlinestatic
Parameters
baseAES peripheral base address.
Returns
AES status, logical OR'ed value of aes_status_flags.
static void AES_EnableInterrupts ( AES_Type *  base,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseAES peripheral base address.
interruptsThe interrupts to enable, logical OR'ed value of aes_interrupts.
static void AES_DisableInterrupts ( AES_Type *  base,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseAES peripheral base address.
interruptsThe interrupts to disable, logical OR'ed value of aes_interrupts.
static uint32_t AES_GetInterruptStatus ( AES_Type *  base)
inlinestatic
Parameters
baseAES peripheral base address.
Returns
The interrupt pending status, logical OR'ed value of aes_interrupts.
static void AES_ClearInterruptStatus ( AES_Type *  base,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseAES peripheral base address.
interruptsThe interrupt pending status to clear, logical OR'ed value of aes_interrupts.
static uint32_t AES_GetRawInterruptStatus ( AES_Type *  base)
inlinestatic

This function is similar with AES_GetInterruptStatus, the difference is the raw interrupt status is not affected by interrupt enable status.

Parameters
baseAES peripheral base address.
Returns
The raw interrupt pending status, logical OR'ed value of aes_interrupts.
status_t AES_SetKey ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize 
)

Sets AES key.

Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes. Must be 16, 24, or 32.
Returns
Status from Set Key operation
status_t AES_EncryptEcb ( AES_Type *  base,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size 
)

Encrypts AES using the ECB block mode.

Parameters
baseAES 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.
Returns
Status from encrypt operation
status_t AES_DecryptEcb ( AES_Type *  base,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size 
)

Decrypts AES using the ECB block mode.

Parameters
baseAES peripheral base address
ciphertextInput ciphertext to decrypt
[out]plaintextOutput plain text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
Returns
Status from decrypt operation
status_t AES_EncryptCbc ( AES_Type *  base,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t  iv[AES_VECTOR_SIZE],
uint8_t  ov[AES_VECTOR_SIZE] 
)
Parameters
baseAES 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.
ivInput initial vector to combine with the first input block.
[out]ovOutput vector used for chained operation, could be NULL.
Returns
Status from encrypt operation
status_t AES_DecryptCbc ( AES_Type *  base,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t  iv[AES_VECTOR_SIZE],
uint8_t  ov[AES_VECTOR_SIZE] 
)
Parameters
baseAES peripheral base address
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.
[out]ovOutput vector used for chained operation, could be NULL.
Returns
Status from decrypt operation
status_t AES_CryptCtr ( AES_Type *  base,
const uint8_t *  input,
uint8_t *  output,
size_t  size,
uint8_t  nonce[AES_BLOCK_SIZE],
uint8_t  streamBlock[AES_BLOCK_SIZE],
size_t *  offset 
)

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.

For chained calls, the internal status are saved in the parameters: nonce, streamBlock, and offset. In this case, initialize nonce to the desired value, and initialize offset to 0 before the first call, in the following calls, the nonce, streamBlock, and offset should be preserved.

Note
The streamBlock contains sensitive data, discard it after used.
Parameters
baseAES peripheral base address
inputInput data for CTR block mode
[out]outputOutput data for CTR block mode
sizeSize of input and output data in bytes
[in,out]nonceand counter(updates on return)
[out]streamBlockSaved block for chained CTR calls. NULL can be passed if chained calls are not used.
[out]offsetOffset in streamBlock. NULL can be passed if chained calls are not used.
Returns
Status from crypt operation
status_t AES_EncryptTagCcm ( AES_Type *  base,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
uint8_t *  tag,
size_t  tagSize 
)

Encrypts AES and optionally tags using CCM block mode.

Parameters
baseAES peripheral base address
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.
[out]tagOutput hash tag. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 0,4,8, or 16.
Returns
Status from encrypt operation
status_t AES_DecryptTagCcm ( AES_Type *  base,
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 *  tag,
size_t  tagSize 
)

Decrypts AES and optionally authenticates using CCM block mode.

Parameters
baseAES peripheral base address
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
tagInput hash tag to compare. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 0,4,8, or 16.
Return values
kStatus_SuccessCalculation successed.
kStatus_InvalidArgumentInvalid argument.
kStatus_FailTag does not match.
status_t AES_CalculateMMOHash ( AES_Type *  base,
const uint8_t *  input,
size_t  size,
uint8_t  hash[16] 
)
Parameters
baseAES peripheral base address
inputInput stream.
sizeLength of the stream in bytes.
[out]hashHash value of the input stream.
Returns
Status from HASH operation
void AES_SetLockFunc ( aes_lock_func_t  lockFunc,
aes_unlock_func_t  unlockFunc 
)
Parameters
lockFuncLock function.
unlockFuncUnlock function.
status_t AES_EncryptEcbWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size 
)

Encrypts AES using the ECB block mode.

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

Decrypts AES using the ECB block mode.

Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
ciphertextInput ciphertext to decrypt
[out]plaintextOutput plain text
sizeSize of input and output data in bytes. Must be multiple of 16 bytes.
Returns
Status from decrypt operation
status_t AES_EncryptCbcWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t  iv[AES_VECTOR_SIZE],
uint8_t  ov[AES_VECTOR_SIZE] 
)
Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
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.
[out]ovOutput vector used for chained operation, could be NULL.
Returns
Status from encrypt operation
status_t AES_DecryptCbcWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  ciphertext,
uint8_t *  plaintext,
size_t  size,
const uint8_t  iv[AES_VECTOR_SIZE],
uint8_t  ov[AES_VECTOR_SIZE] 
)
Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
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.
[out]ovOutput vector used for chained operation, could be NULL.
Returns
Status from decrypt operation
status_t AES_CryptCtrWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  input,
uint8_t *  output,
size_t  size,
uint8_t  nonce[AES_BLOCK_SIZE],
uint8_t  streamBlock[AES_BLOCK_SIZE],
size_t *  offset 
)

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.

For chained calls, the internal status are saved in the parameters: nonce, streamBlock, and offset. In this case, initialize nonce to the desired value, and initialize offset to 0 before the first call, in the following calls, the nonce, streamBlock, and offset should be preserved.

Note
The streamBlock contains sensitive data, discard it after used.
Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
inputInput data for CTR block mode
[out]outputOutput data for CTR block mode
sizeSize of input and output data in bytes
[in,out]nonceand counter(updates on return)
[out]streamBlockSaved block for chained CTR calls. NULL can be passed if chained calls are not used.
[out]offsetOffset in streamBlock. NULL can be passed if chained calls are not used.
Returns
Status from crypt operation
status_t AES_EncryptTagCcmWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
const uint8_t *  plaintext,
uint8_t *  ciphertext,
size_t  size,
const uint8_t *  iv,
size_t  ivSize,
const uint8_t *  aad,
size_t  aadSize,
uint8_t *  tag,
size_t  tagSize 
)

Encrypts AES and optionally tags using CCM block mode.

Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
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.
[out]tagOutput hash tag. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 0,4,8, or 16.
Returns
Status from encrypt operation
status_t AES_DecryptTagCcmWithLock ( AES_Type *  base,
const uint8_t *  key,
size_t  keySize,
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 *  tag,
size_t  tagSize 
)

Decrypts AES and optionally authenticates using CCM block mode.

Parameters
baseAES peripheral base address
keyInput key to use for encryption or decryption
keySizeSize of the input key, in bytes.
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
tagInput hash tag to compare. Set to NULL to skip tag processing.
tagSizeInput size of the tag to generate, in bytes. Must be 0,4,8, or 16.
Return values
kStatus_SuccessCalculation successed.
kStatus_InvalidArgumentInvalid argument.
kStatus_FailTag does not match.
status_t AES_CalculateMMOHashWithLock ( AES_Type *  base,
const uint8_t *  input,
size_t  size,
uint8_t  hash[16] 
)
Parameters
baseAES peripheral base address
inputInput stream.
sizeLength of the stream in bytes.
[out]hashHash value of the input stream.
Returns
Status from HASH operation