![]() |
Kinetis SDK v.2.0 API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the AES module in MCUXpresso SDK devices.
The driver provides blocking synchronous APIs. The AES operations are complete (and results are made availabe for further usage) when a function returns. When called, these functions do not return until an AES operation is complete. These functions use main CPU for simple polling loops to determine operation complete or error status, as well as plaintext or ciphertext data movements. The driver functions are not re-entrant. These functions provide typical interface to upper layer or application software.
Clock to the AES module has to be enabled before using the driver API. The function AES_SetKey() has to be used to store encryption key into device registers prior to using other API.
AES operations provided by this driver are not re-entrant. Because of this, the application software should ensure the AES module operation is not requested from different tasks or interrupt service routines while an operation is in progress.
Encrypt plaintext and decrypt it back by AES engine Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/aes Encrypts AES using CTR block mode. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/aes Generation of GCM tag only Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/aes
Files | |
file | fsl_aes.h |
Driver version | |
#define | FSL_AES_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
Defines LPC AES driver version 2.0.1. More... | |
AES Functional Operation | |
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_IV_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_IV_SIZE]) |
Decrypts AES using CBC block mode. More... | |
status_t | AES_EncryptCfb (AES_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[AES_IV_SIZE]) |
Encrypts AES using CFB block mode. More... | |
status_t | AES_DecryptCfb (AES_Type *base, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[AES_IV_SIZE]) |
Decrypts AES using CFB block mode. More... | |
status_t | AES_EncryptOfb (AES_Type *base, const uint8_t *plaintext, uint8_t *ciphertext, size_t size, const uint8_t iv[AES_IV_SIZE]) |
Encrypts AES using OFB block mode. More... | |
status_t | AES_DecryptOfb (AES_Type *base, const uint8_t *ciphertext, uint8_t *plaintext, size_t size, const uint8_t iv[AES_IV_SIZE]) |
Decrypts AES using OFB block mode. More... | |
status_t | AES_CryptCtr (AES_Type *base, const uint8_t *input, uint8_t *output, size_t size, uint8_t counter[AES_BLOCK_SIZE], uint8_t counterlast[AES_BLOCK_SIZE], size_t *szLeft) |
Encrypts or decrypts AES using CTR block mode. More... | |
status_t | AES_EncryptTagGcm (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 GCM block mode. More... | |
status_t | AES_DecryptTagGcm (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 GCM block mode. More... | |
void | AES_Init (AES_Type *base) |
void | AES_Deinit (AES_Type *base) |
#define | AES_BLOCK_SIZE 16 |
AES block size in bytes. | |
#define | AES_IV_SIZE 16 |
AES Input Vector size in bytes. | |
#define FSL_AES_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
Change log:
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_IV_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. |
status_t AES_DecryptCbc | ( | AES_Type * | base, |
const uint8_t * | ciphertext, | ||
uint8_t * | plaintext, | ||
size_t | size, | ||
const uint8_t | iv[AES_IV_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. |
status_t AES_EncryptCfb | ( | AES_Type * | base, |
const uint8_t * | plaintext, | ||
uint8_t * | ciphertext, | ||
size_t | size, | ||
const uint8_t | iv[AES_IV_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 be used as the first input block. |
status_t AES_DecryptCfb | ( | AES_Type * | base, |
const uint8_t * | ciphertext, | ||
uint8_t * | plaintext, | ||
size_t | size, | ||
const uint8_t | iv[AES_IV_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 be used as the first input block. |
status_t AES_EncryptOfb | ( | AES_Type * | base, |
const uint8_t * | plaintext, | ||
uint8_t * | ciphertext, | ||
size_t | size, | ||
const uint8_t | iv[AES_IV_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. | |
iv | Input Initial vector to be used as the first input block. |
status_t AES_DecryptOfb | ( | AES_Type * | base, |
const uint8_t * | ciphertext, | ||
uint8_t * | plaintext, | ||
size_t | size, | ||
const uint8_t | iv[AES_IV_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. | |
iv | Input Initial vector to be used as the first input block. |
status_t AES_CryptCtr | ( | AES_Type * | base, |
const uint8_t * | input, | ||
uint8_t * | output, | ||
size_t | size, | ||
uint8_t | counter[AES_BLOCK_SIZE], | ||
uint8_t | counterlast[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.
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] | counter | Input counter (updates on return) |
[out] | counterlast | Output cipher of last counter, for chained CTR calls. NULL can be passed if chained calls are not used. |
[out] | szLeft | Output number of bytes in left unused in counterlast block. NULL can be passed if chained calls are not used. |
status_t AES_EncryptTagGcm | ( | 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 GCM block mode. If plaintext is NULL, only the GHASH is calculated and output in the 'tag' field.
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 4,8,12,13,14,15 or 16. |
status_t AES_DecryptTagGcm | ( | 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 GCM block mode. If ciphertext is NULL, only the GHASH is calculated and compared with the received GHASH in 'tag' field.
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, in bytes. Must be 4, 8, 12, 13, 14, 15, or 16. |