CAT2 Peripheral Driver Library
Symmetric key algorithms (AES)

Functions

cy_en_crypto_status_t Cy_Crypto_Aes_Init (CRYPTO_Type *base, uint8_t const *key, cy_en_crypto_aes_key_length_t keyLength, cy_stc_crypto_aes_context_t *aesContext)
 This function initializes the AES operation by setting the key and key length. More...
 
cy_en_crypto_status_t Cy_Crypto_Aes_Free (CRYPTO_Type *base, cy_stc_crypto_aes_context_t *aesContext)
 This function clears the AES operation context. More...
 
cy_en_crypto_status_t Cy_Crypto_Aes_Ecb (CRYPTO_Type *base, cy_en_crypto_dir_mode_t dirMode, uint8_t *dst, uint8_t const *src, cy_stc_crypto_aes_context_t *aesContext)
 This function performs an AES-ECB (Electronic Code Book) encryption/decryption operation on the input data. More...
 
cy_en_crypto_status_t Cy_Crypto_Aes_Cbc (CRYPTO_Type *base, cy_en_crypto_dir_mode_t dirMode, uint32_t srcSize, uint8_t *ivPtr, uint8_t *dst, uint8_t const *src, cy_stc_crypto_aes_context_t *aesContext)
 This function performs an AES-CBC (Cipher Block Chaining) encryption/decryption operation on the input data. More...
 
cy_en_crypto_status_t Cy_Crypto_Aes_Cfb (CRYPTO_Type *base, cy_en_crypto_dir_mode_t dirMode, uint32_t srcSize, uint8_t *ivOffset, uint8_t *ivPtr, uint8_t *dst, uint8_t const *src, cy_stc_crypto_aes_context_t *aesContext)
 This function performs the AES-CFB (Cipher FeedBack) encrypt/decrypt operation on the input data. More...
 
cy_en_crypto_status_t Cy_Crypto_Aes_Ctr (CRYPTO_Type *base, uint32_t srcSize, uint32_t *ncOffset, uint8_t *nonceCounter, uint8_t *streamBlock, uint8_t *dst, uint8_t const *src, cy_stc_crypto_aes_context_t *aesContext)
 This function performs the AES-CTR (Counter mode) operation on the input data. More...
 

Detailed Description

Function Documentation

◆ Cy_Crypto_Aes_Init()

cy_en_crypto_status_t Cy_Crypto_Aes_Init ( CRYPTO_Type *  base,
uint8_t const *  key,
cy_en_crypto_aes_key_length_t  keyLength,
cy_stc_crypto_aes_context_t aesContext 
)

This function initializes the AES operation by setting the key and key length.

Parameters
baseBase address of the Crypto block registers.
keyPointer to the encryption/decryption key.
keyLengthAES key length cy_en_crypto_aes_key_length_t
aesContextThe pointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. This structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesEcbPlainText[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u
};
uint8_t aesEcbCipherText[CY_CRYPTO_AES_BLOCK_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt one block (16 Bytes) by AES128 */
cryptoStatus = Cy_Crypto_Aes_Ecb(
CRYPTO, /* Base address of the Crypto block registers */
CY_CRYPTO_ENCRYPT, /* Crypto mode */
aesEcbCipherText, /* Destination block */
aesEcbPlainText, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */

◆ Cy_Crypto_Aes_Free()

cy_en_crypto_status_t Cy_Crypto_Aes_Free ( CRYPTO_Type *  base,
cy_stc_crypto_aes_context_t aesContext 
)

This function clears the AES operation context.

Parameters
baseBase address of the Crypto block registers.
aesContextPointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. The structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesEcbPlainText[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u
};
uint8_t aesEcbCipherText[CY_CRYPTO_AES_BLOCK_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt one block (16 Bytes) by AES128 */
cryptoStatus = Cy_Crypto_Aes_Ecb(
CRYPTO, /* Base address of the Crypto block registers */
CY_CRYPTO_ENCRYPT, /* Crypto mode */
aesEcbCipherText, /* Destination block */
aesEcbPlainText, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */

◆ Cy_Crypto_Aes_Ecb()

cy_en_crypto_status_t Cy_Crypto_Aes_Ecb ( CRYPTO_Type *  base,
cy_en_crypto_dir_mode_t  dirMode,
uint8_t *  dst,
uint8_t const *  src,
cy_stc_crypto_aes_context_t aesContext 
)

This function performs an AES-ECB (Electronic Code Book) encryption/decryption operation on the input data.

It performs the AES operation on a single block of size CY_CRYPTO_AES_BLOCK_SIZE.

The AES key must be set before by invoking Cy_Crypto_Aes_Init().

Parameters
baseBase address of the Crypto block registers.
dirModeCan be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t).
dstPointer to a destination buffer to store the output data of the AES operation. The buffer must be at least CY_CRYPTO_AES_BLOCK_SIZE bytes long.
srcPointer to a source block holding the data to be encrypted/decrypted. It must have at least CY_CRYPTO_AES_BLOCK_SIZE bytes of data.
aesContextPointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. The structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesEcbPlainText[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u
};
uint8_t aesEcbCipherText[CY_CRYPTO_AES_BLOCK_SIZE] = {0};
cy_en_crypto_status_t cryptoStatus;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt one block (16 Bytes) by AES128 */
cryptoStatus = Cy_Crypto_Aes_Ecb(
CRYPTO, /* Base address of the Crypto block registers */
CY_CRYPTO_ENCRYPT, /* Crypto mode */
aesEcbCipherText, /* Destination block */
aesEcbPlainText, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */

◆ Cy_Crypto_Aes_Cbc()

cy_en_crypto_status_t Cy_Crypto_Aes_Cbc ( CRYPTO_Type *  base,
cy_en_crypto_dir_mode_t  dirMode,
uint32_t  srcSize,
uint8_t *  ivPtr,
uint8_t *  dst,
uint8_t const *  src,
cy_stc_crypto_aes_context_t aesContext 
)

This function performs an AES-CBC (Cipher Block Chaining) encryption/decryption operation on the input data.

The key must be set before by invoking Cy_Crypto_Aes_Init().

Note
The input size must be a multiple of the AES block size CY_CRYPTO_AES_BLOCK_SIZE. If not, this function returns an error.
On return of this function, the content of the ivPtr is updated so that the user can call the same function again on the next block of data and get the same result as if it was in one call. This allows a "streaming" usage.
Parameters
baseBase address of the Crypto block registers.
dirModeCan be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t)
srcSizeSize of the input data in bytes. It should be a multiple of the AES block size CY_CRYPTO_AES_BLOCK_SIZE.
ivPtrPointer to the initial vector of length CY_CRYPTO_AES_BLOCK_SIZE bytes. On return of this function, the content of the ivPtr is updated. For AES-CBC operation on the next block, the user must provide the updated ivPtr without any modification.
dstPointer to a destination buffer to store the output data of the AES operation. This buffer must be at least as big as the source buffer.
srcPointer to the source buffer holding the data to be encrypted/decrypted.
aesContextPointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. The structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesCbcPlainText[CY_CRYPTO_AES_BLOCK_SIZE * 2] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u,
0x72u, 0x56u, 0xCBu, 0xE9u, 0x3Cu, 0x66u, 0x72u, 0x58u,
0xF2u, 0x23u, 0x35u, 0x2Bu, 0x6Cu, 0x5Du, 0x27u, 0x15u
};
uint8_t initialVector[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x66u, 0x45u, 0xACu, 0xD4u, 0x49u, 0x51u, 0x86u, 0x29u,
0xE4u, 0x45u, 0x14u, 0x1Du, 0x4Fu, 0x59u, 0x72u, 0x74u
};
uint8_t aesCbcCipherText[CY_CRYPTO_AES_BLOCK_SIZE * 2] = {0};
cy_en_crypto_status_t cryptoStatus;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt two blocks (32 Bytes) by AES CBC */
cryptoStatus = Cy_Crypto_Aes_Cbc(
CRYPTO, /* Base address of the Crypto block registers */
CY_CRYPTO_ENCRYPT, /* Crypto mode */
CY_CRYPTO_AES_BLOCK_SIZE * 2, /* Source size */
initialVector, /* Initial vector */
aesCbcCipherText, /* Destination block */
aesCbcPlainText, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */

◆ Cy_Crypto_Aes_Cfb()

cy_en_crypto_status_t Cy_Crypto_Aes_Cfb ( CRYPTO_Type *  base,
cy_en_crypto_dir_mode_t  dirMode,
uint32_t  srcSize,
uint8_t *  ivOffset,
uint8_t *  ivPtr,
uint8_t *  dst,
uint8_t const *  src,
cy_stc_crypto_aes_context_t aesContext 
)

This function performs the AES-CFB (Cipher FeedBack) encrypt/decrypt operation on the input data.

The key must be set before by invoking Cy_Crypto_Aes_Init().

Note
The AES-CFB crypto operation is stream-based, so the input data size doesn't need to be a multiple of CY_CRYPTO_AES_BLOCK_SIZE.
On return of this function, the content of the ivPtr is updated so that the user can call same function again on the next bytes of data and get the same result as if it was in one call. This allows a "streaming" usage.
Parameters
baseBase address of the Crypto block registers.
dirModeCan be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t)
srcSizeSize of the input data in bytes.
ivPtrPointer to the initial vector of length CY_CRYPTO_AES_BLOCK_SIZE bytes. On return of this function, the content of the * ivPtr is updated. For AES-CFB operation on the next bytes of data, the user must provide the updated ivPtr without any modification.
ivOffsetPointer holding the offset value in ivPtr. The pointer value should be 0 at the start of a stream. On return of this function, ivOffset value is updated. For AES-CFB operation on the next bytes in the stream, the user must provide the updated ivOffset without any modification.
dstPointer to a destination buffer to store the output data of the AES operation. This buffer must be at least as big as the source buffer.
srcPointer to the source buffer holding the data to be encrypted/decrypted.
aesContextPointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. The structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesCfbPlainText[CY_CRYPTO_AES_BLOCK_SIZE * 2] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u,
0x72u, 0x56u, 0xCBu, 0xE9u, 0x3Cu, 0x66u, 0x72u, 0x58u,
0xF2u, 0x23u, 0x35u, 0x2Bu, 0x6Cu, 0x5Du, 0x27u, 0x15u
};
uint8_t initialVector[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x66u, 0x45u, 0xACu, 0xD4u, 0x49u, 0x51u, 0x86u, 0x29u,
0xE4u, 0x45u, 0x14u, 0x1Du, 0x4Fu, 0x59u, 0x72u, 0x74u
};
uint8_t aesCfbCipherText[CY_CRYPTO_AES_BLOCK_SIZE * 2] = {0};
cy_en_crypto_status_t cryptoStatus;
uint8_t ivOffset = 0;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt two blocks (32 Bytes) by AES CFB */
cryptoStatus = Cy_Crypto_Aes_Cfb(
CRYPTO, /* Base address of the Crypto block registers */
CY_CRYPTO_ENCRYPT, /* Crypto mode */
CY_CRYPTO_AES_BLOCK_SIZE * 2, /* Source size */
&ivOffset, /* Offset in initialVector */
initialVector, /* Initial vector */
aesCfbCipherText, /* Destination block */
aesCfbPlainText, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */

◆ Cy_Crypto_Aes_Ctr()

cy_en_crypto_status_t Cy_Crypto_Aes_Ctr ( CRYPTO_Type *  base,
uint32_t  srcSize,
uint32_t *  ncOffset,
uint8_t *  nonceCounter,
uint8_t *  streamBlock,
uint8_t *  dst,
uint8_t const *  src,
cy_stc_crypto_aes_context_t aesContext 
)

This function performs the AES-CTR (Counter mode) operation on the input data.

The key must be set before by invoking Cy_Crypto_Aes_Init().

Note
The AES-CTR crypto operation is stream-based, so the input data size doesn't need to be a multiple of CY_CRYPTO_AES_BLOCK_SIZE.
On a new message, the user must set the first 12 bytes of nonceCounter with the chosen nonce value, the last 4 bytes to the counter value (counter value can be zero), and ncOffset to 0. On return, this function updates ncOffset, nonceCounter, and streamBlock buffers. User must preserve these updated values for successive calls of this function with the partial data of the same message.
For AES-CTR crypto operation, each block is encrypted with the unique key and key-stream combination. Key-stream is the AES-encrypted output of the nonce counter. With the 4-bytes counter and incrementing it by one for each block, 232 unique key streams can be generated. Therefore, the the user can encrypt a message with a maximum of 232 blocks with the same key.
Parameters
baseBase address of the Crypto block registers.
srcSizeSize of the input data in bytes.
ncOffsetPointer holding the offset within the streamBlock buffer for resuming within the current cipher stream. The pointer value should be 0 at the start of a stream. If this function is called multiple times with partial data, the user must not modify the ncOffset value.
nonceCounterPointer holding the 128-bit nonce and counter. For a new message, the user should fill the first 12 bytes in this buffer with the per-message nonce, and the last 4 bytes with the initial counter value (initial counter value can be zero). The last 4 bytes are used internally and updated by the driver. For successive calls of this function with the partial data of a same message, the user must preserve the updated values and pass the same without any modification.
streamBlockThe saved stream-block for resuming. This is overwritten by the function. The user must provide the allocated buffer and it must be at least 16 bytes long. If this function is called multiple times with partial data, the user must not modify the contents.
dstPointer to a destination buffer to store the output data of the AES operation.
srcPointer to the source buffer holding the data to be encrypted/decrypted.
aesContextPointer to the context structure cy_stc_crypto_aes_context_t allocated by the user. The structure is used by the Crypto driver for the AES operation. Do not modify the values of this structure.
Returns
cy_en_crypto_status_t
Function Usage
uint8_t aesKey[CY_CRYPTO_AES_128_KEY_SIZE] = {
0x2Bu, 0x7Eu, 0x15u, 0x16u, 0x28u, 0xAEu, 0xD2u, 0xA6u,
0xABu, 0xF7u, 0x15u, 0x88u, 0x09u, 0xCFu, 0x4Fu, 0x3Cu
};
uint8_t aesCtrPlainTextStream1[20] = {
0x6Bu, 0xC0u, 0xBCu, 0xE1u, 0x2Au, 0x45u, 0x99u, 0x91u,
0xE1u, 0x34u, 0x74u, 0x1Au, 0x7Fu, 0x9Eu, 0x19u, 0x25u,
0x72u, 0x56u, 0xCBu, 0xE9u
};
uint8_t aesCtrPlainTextStream2[12] = {
0x3Cu, 0x66u, 0x72u, 0x58u,
0xF2u, 0x23u, 0x35u, 0x2Bu,
0x6Cu, 0x5Du, 0x27u, 0x15u
};
uint8_t initialVector[CY_CRYPTO_AES_BLOCK_SIZE] = {
0x66u, 0x45u, 0xACu, 0xD4u, 0x49u, 0x51u, 0x86u, 0x29u,
0xE4u, 0x45u, 0x14u, 0x1Du, 0x4Fu, 0x59u, 0x72u, 0x74u
};
uint8_t aesCtrCipherText1[20] = {0};
uint8_t aesCtrCipherText2[12] = {0};
uint8_t streamBlock[CY_CRYPTO_AES_BLOCK_SIZE] = {0};
uint32_t ncOffset = 0;
cy_en_crypto_status_t cryptoStatus;
/* Initialize Crypto AES functionality and context */
cryptoStatus = Cy_Crypto_Aes_Init(
CRYPTO, /* Base address of the Crypto block registers */
aesKey, /* Pointer to key */
CY_CRYPTO_KEY_AES_128, /* Key size */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt the first stream of 20 bytes by AES CTR */
cryptoStatus = Cy_Crypto_Aes_Ctr(
CRYPTO, /* Base address of the Crypto block registers */
sizeof(aesCtrPlainTextStream1), /* Source stream size */
&ncOffset, /* Offset within streamBlock */
initialVector, /* Initial vector */
streamBlock, /* Stream block */
aesCtrCipherText1, /* Destination block */
aesCtrPlainTextStream1, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Encrypt the second stream of 12 bytes by AES CTR */
cryptoStatus = Cy_Crypto_Aes_Ctr(
CRYPTO, /* Base address of the Crypto block registers */
sizeof(aesCtrPlainTextStream2), /* Source stream size */
&ncOffset, /* Offset within streamBlock */
initialVector, /* Initial vector */
streamBlock, /* Stream block */
aesCtrCipherText2, /* Destination block */
aesCtrPlainTextStream2, /* Source block */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */
/* Clear the AES operation context */
cryptoStatus = Cy_Crypto_Aes_Free(
CRYPTO, /* Base address of the Crypto block registers */
&aesContext); /* Pointer to AES context structure */
/* ... check for errors... */