![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
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... | |
#define FSL_AES_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
typedef status_t(* aes_lock_func_t)(void) |
typedef void(* aes_unlock_func_t)(void) |
enum aes_mode_t |
enum aes_fifo_t |
enum aes_keysize_t |
enum aes_miclen_t |
enum aes_interrupt_t |
anonymous enum |
void AES_Init | ( | AES_Type * | base | ) |
Initialize the module, reset the module and set the registers to default status.
base | AES peripheral base address. |
void AES_Deinit | ( | AES_Type * | base | ) |
Deinitialize the module and reset the module.
base | AES 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.
base | AES peripheral base address. |
|
inlinestatic |
base | AES peripheral base address. |
mode | AES work mode. |
void AES_SetInputVector | ( | AES_Type * | base, |
const uint8_t | inputVector[AES_VECTOR_SIZE] | ||
) |
base | AES peripheral base address. |
inputVector | Input vector. |
void AES_GetOutputVector | ( | AES_Type * | base, |
uint8_t | outputVector[AES_VECTOR_SIZE] | ||
) |
base | AES peripheral base address. |
outputVector | Array to save the output vector. |
|
inlinestatic |
base | AES peripheral base address. |
msgLen | Length of the input data in byte. |
|
inlinestatic |
base | AES peripheral base address. |
len | Length in byte. |
|
inlinestatic |
base | AES peripheral base address. |
modular | The 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. |
|
inlinestatic |
base | AES peripheral base address. |
enable | Use true to forward output stream to output FIFO, use false to block output stream from output FIFO. |
|
inlinestatic |
base | AES peripheral base address. |
enable | Use true to enable DMA, use false to disable DMA. |
|
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.
base | AES peripheral base address. |
append | Use true to append, otherwise use false. |
|
inlinestatic |
base | AES peripheral base address. |
len | MIC length. |
status_t AES_ReadMIC | ( | AES_Type * | base, |
uint32_t * | micData, | ||
uint8_t | len | ||
) |
base | AES peripheral base address. |
micData | The memory to save the MIC data. |
len | Length of micData in word, the valid range is 1~4. |
kStatus_InvalidArgument | The required length is wrong. |
kStatus_Success | Get MIC successfully. |
void AES_ClearFIFO | ( | AES_Type * | base, |
aes_fifo_t | fifo | ||
) |
base | AES peripheral base address. |
fifo | The FIFO to clear. |
|
inlinestatic |
Start the calculation based on configurations.
base | AES peripheral base address. |
|
inlinestatic |
Stop the calculation.
base | AES peripheral base address. |
|
inlinestatic |
base | AES peripheral base address. |
data | Data written to AES FIFO. |
|
inlinestatic |
base | AES peripheral base address. |
|
inlinestatic |
base | AES peripheral base address. |
|
inlinestatic |
base | AES peripheral base address. |
interrupts | The interrupts to enable, logical OR'ed value of aes_interrupts. |
|
inlinestatic |
base | AES peripheral base address. |
interrupts | The interrupts to disable, logical OR'ed value of aes_interrupts. |
|
inlinestatic |
base | AES peripheral base address. |
|
inlinestatic |
base | AES peripheral base address. |
interrupts | The interrupt pending status to clear, logical OR'ed value of aes_interrupts. |
|
inlinestatic |
This function is similar with AES_GetInterruptStatus, the difference is the raw interrupt status is not affected by interrupt enable status.
base | AES peripheral base address. |
status_t AES_SetKey | ( | AES_Type * | base, |
const uint8_t * | key, | ||
size_t | keySize | ||
) |
Sets AES key.
base | AES peripheral base address |
key | Input key to use for encryption or decryption |
keySize | Size of the input key, in bytes. Must be 16, 24, or 32. |
status_t AES_EncryptEcb | ( | AES_Type * | base, |
const uint8_t * | plaintext, | ||
uint8_t * | ciphertext, | ||
size_t | size | ||
) |
Encrypts AES using the ECB block mode.
base | AES peripheral base address | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. |
status_t AES_DecryptEcb | ( | AES_Type * | base, |
const uint8_t * | ciphertext, | ||
uint8_t * | plaintext, | ||
size_t | size | ||
) |
Decrypts AES using the ECB block mode.
base | AES peripheral base address | |
ciphertext | Input ciphertext to decrypt | |
[out] | plaintext | Output plain text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. |
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] | ||
) |
base | AES peripheral base address | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. | |
iv | Input initial vector to combine with the first input block. | |
[out] | ov | Output vector used for chained operation, could be NULL. |
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] | ||
) |
base | AES peripheral base address | |
ciphertext | Input cipher text to decrypt | |
[out] | plaintext | Output plain text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. | |
iv | Input initial vector to combine with the first input block. | |
[out] | ov | Output vector used for chained operation, could be NULL. |
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.
streamBlock
contains sensitive data, discard it after used.base | AES peripheral base address | |
input | Input data for CTR block mode | |
[out] | output | Output data for CTR block mode |
size | Size of input and output data in bytes | |
[in,out] | nonce | and counter(updates on return) |
[out] | streamBlock | Saved block for chained CTR calls. NULL can be passed if chained calls are not used. |
[out] | offset | Offset in streamBlock . NULL can be passed if chained calls are not used. |
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.
base | AES peripheral base address | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text. |
size | Size of input and output data in bytes | |
iv | Input initial vector | |
ivSize | Size of the iv | |
aad | Input additional authentication data | |
aadSize | Input size in bytes of aad . | |
[out] | tag | Output hash tag. Set to NULL to skip tag processing. |
tagSize | Input size of the tag to generate, in bytes. Must be 0,4,8, or 16. |
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.
base | AES peripheral base address | |
ciphertext | Input cipher text to decrypt | |
[out] | plaintext | Output plain text. |
size | Size of input and output data in bytes | |
iv | Input initial vector | |
ivSize | Size of the iv | |
aad | Input additional authentication data | |
aadSize | Input size in bytes of aad | |
tag | Input hash tag to compare. Set to NULL to skip tag processing. | |
tagSize | Input size of the tag to generate, in bytes. Must be 0,4,8, or 16. |
kStatus_Success | Calculation successed. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_Fail | Tag does not match. |
status_t AES_CalculateMMOHash | ( | AES_Type * | base, |
const uint8_t * | input, | ||
size_t | size, | ||
uint8_t | hash[16] | ||
) |
base | AES peripheral base address | |
input | Input stream. | |
size | Length of the stream in bytes. | |
[out] | hash | Hash value of the input stream. |
void AES_SetLockFunc | ( | aes_lock_func_t | lockFunc, |
aes_unlock_func_t | unlockFunc | ||
) |
lockFunc | Lock function. |
unlockFunc | Unlock 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.
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. |
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.
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
ciphertext | Input ciphertext to decrypt | |
[out] | plaintext | Output plain text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. |
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] | ||
) |
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. | |
iv | Input initial vector to combine with the first input block. | |
[out] | ov | Output vector used for chained operation, could be NULL. |
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] | ||
) |
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
ciphertext | Input cipher text to decrypt | |
[out] | plaintext | Output plain text |
size | Size of input and output data in bytes. Must be multiple of 16 bytes. | |
iv | Input initial vector to combine with the first input block. | |
[out] | ov | Output vector used for chained operation, could be NULL. |
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.
streamBlock
contains sensitive data, discard it after used.base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
input | Input data for CTR block mode | |
[out] | output | Output data for CTR block mode |
size | Size of input and output data in bytes | |
[in,out] | nonce | and counter(updates on return) |
[out] | streamBlock | Saved block for chained CTR calls. NULL can be passed if chained calls are not used. |
[out] | offset | Offset in streamBlock . NULL can be passed if chained calls are not used. |
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.
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
plaintext | Input plain text to encrypt | |
[out] | ciphertext | Output cipher text. |
size | Size of input and output data in bytes | |
iv | Input initial vector | |
ivSize | Size of the iv | |
aad | Input additional authentication data | |
aadSize | Input size in bytes of aad . | |
[out] | tag | Output hash tag. Set to NULL to skip tag processing. |
tagSize | Input size of the tag to generate, in bytes. Must be 0,4,8, or 16. |
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.
base | AES peripheral base address | |
key | Input key to use for encryption or decryption | |
keySize | Size of the input key, in bytes. | |
ciphertext | Input cipher text to decrypt | |
[out] | plaintext | Output plain text. |
size | Size of input and output data in bytes | |
iv | Input initial vector | |
ivSize | Size of the iv | |
aad | Input additional authentication data | |
aadSize | Input size in bytes of aad | |
tag | Input hash tag to compare. Set to NULL to skip tag processing. | |
tagSize | Input size of the tag to generate, in bytes. Must be 0,4,8, or 16. |
kStatus_Success | Calculation successed. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_Fail | Tag does not match. |
status_t AES_CalculateMMOHashWithLock | ( | AES_Type * | base, |
const uint8_t * | input, | ||
size_t | size, | ||
uint8_t | hash[16] | ||
) |
base | AES peripheral base address | |
input | Input stream. | |
size | Length of the stream in bytes. | |
[out] | hash | Hash value of the input stream. |