AM64x MCU+ SDK  08.01.00
CRYPTO AES

Advanced Encryption Standard (AES) is widely adopted symmetric Encrypt/Decrypt algorithm provides information security such as confidentiality ..

Features Supported

  • Supports Aes_cbc_256, Aes_cbc_128 and Aes_cbc_192 operations
  • Encryption and Decryption
  • Symmetric key symmetric block cipher

SysConfig Features

Features NOT Supported

Usage Overview

API Sequence

To use the AES driver to do Encryption and decryption. Use the following APIs:

Initializing the AES Driver context buffer

  • Crypto_aesOpen() must be called before any other AES APIs. This function Initializes a AES context and iterates through the elements of the gCryptoAesConfig[] array. Please note that initializing AES driver is taken care by the SysConfig generated code.

AES_CBC Encryption and Decryption

Clearing the AES Driver context buffer

Important Usage Guidelines

Example Usage

Include the below file to access the APIs

#include <stdio.h>
#include <string.h>
#define APP_AES_OUTPUT_LENGTH (16)
uint8_t gCryptoAesTestBuf[16]={0x81,0xEA,0x5B,0xA4,0x69,0x45,0xC1,0x70,0x5F,0x6F,0x89,0x77,0x88,0x68,0xCC,0x67};
uint8_t gCryptoAesTestKey[32]={0x33,0xA3,0x66,0x46,0xFE,0x56,0xF7,0x0D,0xC0,0xC5,0x1A,0x31,0x17,0xE6,0x39,0xF1,0x82,0xDE,0xF8,0xCA,0xB5,0xC0,0x66,0x71,0xEE,0xA0,0x40,0x7C,0x48,0xA9,0xC7,0x57};
uint8_t gCryptoAesTestIv[16]={0x7C,0xE2,0xAB,0xAF,0x8B,0xEF,0x23,0xC4,0x81,0x6D,0xC8,0xCE,0x84,0x20,0x48,0xA7};

Aes Example

Crypto_AesHandle aesHandle;
uint8_t aesResultBuf[APP_AES_OUTPUT_LENGTH];
int32_t status;
/* Context memory */
static Crypto_AesContext gCryptoAesContext;
/* Aes encryption */
memcpy(&params.iv, gCryptoAesTestIv, CRYPTO_AES_IV_LENGTH);
memcpy(&params.key, gCryptoAesTestKey, CRYPTO_AES_KEY_LENGTH);
params.keySizeInBits = 256;
params.type = CRYPTO_TYPE_SW;
aesHandle = Crypto_aesOpen(&gCryptoAesContext, &params);
status = Crypto_aesSetKeyEnc(aesHandle);
status = Crypto_aesCbc(aesHandle, gCryptoAesTestBuf, sizeof(gCryptoAesTestBuf), aesResultBuf );
status = Crypto_aesClose(aesHandle);
/* Aes Decryption */
memcpy(&params.iv, gCryptoAesTestIv, CRYPTO_AES_IV_LENGTH);
memcpy(&params.key, gCryptoAesTestKey, CRYPTO_AES_KEY_LENGTH);
params.keySizeInBits = 256;
params.type = CRYPTO_TYPE_SW;
aesHandle = Crypto_aesOpen(&gCryptoAesContext, &params);
status = Crypto_aesSetKeyDec(aesHandle);
status = Crypto_aesCbc(aesHandle, gCryptoAesTestBuf, sizeof(gCryptoAesTestBuf), aesResultBuf );
status = Crypto_aesClose(aesHandle);

API

APIs for CRYPTO AES

CRYPTO_AES_IV_LENGTH
#define CRYPTO_AES_IV_LENGTH
IV buffer length should be 16 bytes.
Definition: crypto_aes.h:92
Crypto_aesSetKeyEnc
int32_t Crypto_aesSetKeyEnc(Crypto_AesHandle handle)
This function sets the Advance Encryption Standard (AES) encryption key.
Crypto_AesParams::algoType
uint32_t algoType
Definition: crypto_aes.h:114
Crypto_AesParams::key
uint8_t key[CRYPTO_AES_KEY_LENGTH]
Definition: crypto_aes.h:118
Crypto_AesParams::type
uint32_t type
Definition: crypto_aes.h:122
Crypto_AesParams::iv
uint8_t iv[CRYPTO_AES_IV_LENGTH]
Definition: crypto_aes.h:116
Crypto_aesCbc
int32_t Crypto_aesCbc(Crypto_AesHandle handle, const uint8_t *input, uint32_t ilen, uint8_t *output)
This function finishes the Advance Encryption Standard (AES) operation, and writes the result to the ...
Crypto_aesOpen
Crypto_AesHandle Crypto_aesOpen(Crypto_AesContext *ctx, const Crypto_AesParams *params)
This function gives the configuration based on type.
CRYPTO_AES_ENCRYPT
#define CRYPTO_AES_ENCRYPT
AES encryption algorithm.
Definition: crypto_aes.h:67
Crypto_AesHandle
void * Crypto_AesHandle
Handle to the Crypto AES driver returned by Crypto_aesOpen()
Definition: crypto_aes.h:98
Crypto_AesParams
Parameters passed during Crypto_aesOpen()
Definition: crypto_aes.h:111
Crypto_aesClose
int32_t Crypto_aesClose(Crypto_AesHandle handle)
This function clears a Advance Encryption Standard (AES) context.
CRYPTO_AES_DECRYPT
#define CRYPTO_AES_DECRYPT
AES decryption algorithm.
Definition: crypto_aes.h:65
Crypto_aesSetKeyDec
int32_t Crypto_aesSetKeyDec(Crypto_AesHandle handle)
This function sets the Advance Encryption Standard (AES) decryption key.
Crypto_AesParams::keySizeInBits
uint32_t keySizeInBits
Definition: crypto_aes.h:120
crypto_aes.h
CRYPTO_AES_KEY_LENGTH
#define CRYPTO_AES_KEY_LENGTH
key buffer length, min 16 bytes and max 32 bytes
Definition: crypto_aes.h:95