CC26xx Driver Library
aes.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "../inc/hw_types.h"
#include "../inc/hw_memmap.h"
#include "../inc/hw_ints.h"
#include "../inc/hw_crypto.h"
#include "debug.h"
#include "interrupt.h"
#include "cpu.h"

Macros

#define AES_DMA_IN_DONE   CRYPTO_IRQEN_DMA_IN_DONE_M
 
#define AES_RESULT_RDY   CRYPTO_IRQEN_RESULT_AVAIL_M
 
#define AES_DMA_BUS_ERR   CRYPTO_IRQCLR_DMA_BUS_ERR_M
 
#define AES_KEY_ST_WR_ERR   CRYPTO_IRQCLR_KEY_ST_WR_ERR_M
 
#define AES_KEY_ST_RD_ERR   CRYPTO_IRQCLR_KEY_ST_RD_ERR_M
 
#define AES_SUCCESS   0
 
#define AES_KEYSTORE_ERROR   1
 
#define AES_KEYSTORE_AREA_INVALID   2
 
#define AES_DMA_BUSY   3
 
#define AES_DMA_ERROR   4
 
#define AES_TAG_NOT_READY   5
 
#define AES_TAG_VERIFICATION_FAILED   6
 
#define AES_IV_LENGTH_BYTES   16
 
#define AES_TAG_LENGTH_BYTES   16
 
#define AES_128_KEY_LENGTH_BYTES   (128 / 8)
 
#define AES_192_KEY_LENGTH_BYTES   (192 / 8)
 
#define AES_256_KEY_LENGTH_BYTES   (256 / 8)
 
#define AES_BLOCK_SIZE   16
 
#define AES_DMA_CHANNEL0_ACTIVE   CRYPTO_DMASTAT_CH0_ACT_M
 
#define AES_DMA_CHANNEL1_ACTIVE   CRYPTO_DMASTAT_CH1_ACT_M
 
#define AES_DMA_PORT_ERROR   CRYPTO_DMASTAT_PORT_ERR_M
 
#define AES_ALGSEL_AES   CRYPTO_ALGSEL_AES_M
 
#define AES_ALGSEL_KEY_STORE   CRYPTO_ALGSEL_KEY_STORE_M
 
#define AES_ALGSEL_TAG   CRYPTO_ALGSEL_TAG_M
 
#define AES_KEY_AREA_0   0
 
#define AES_KEY_AREA_1   1
 
#define AES_KEY_AREA_2   2
 
#define AES_KEY_AREA_3   3
 
#define AES_KEY_AREA_4   4
 
#define AES_KEY_AREA_5   5
 
#define AES_KEY_AREA_6   6
 
#define AES_KEY_AREA_7   7
 
#define AES_CTR_WIDTH_32   0x0
 
#define AES_CTR_WIDTH_64   0x1
 
#define AES_CTR_WIDTH_96   0x2
 
#define AES_CTR_WIDTH_128   0x3
 

Functions

void AESStartDMAOperation (const uint8_t *channel0Addr, uint32_t channel0Length, uint8_t *channel1Addr, uint32_t channel1Length)
 Start a crypto DMA operation. More...
 
void AESSetInitializationVector (const uint32_t *initializationVector)
 Write the initialization vector (IV) to the crypto module. More...
 
void AESReadNonAuthenticationModeIV (uint32_t *iv)
 Read the initialization vector (IV) out from the crypto module for Non-Authenticated Modes (CBC or CTR). More...
 
void AESReadAuthenticationModeIV (uint32_t *iv)
 Read the initialization vector (IV) out from the crypto module for Authenticated Modes (CCM or GCM). More...
 
void AESWriteCCMInitializationVector (const uint8_t *nonce, uint32_t nonceLength)
 Generate and load the initialization vector for a CCM operation. More...
 
uint32_t AESReadTag (uint8_t *tag, uint32_t tagLength)
 Read the tag out from the crypto module. More...
 
uint32_t AESVerifyTag (const uint8_t *tag, uint32_t tagLength)
 Verifies the provided tag against calculated one. More...
 
uint32_t AESWriteToKeyStore (const uint8_t *aesKey, uint32_t aesKeyLength, uint32_t keyStoreArea)
 Transfer a key from main memory to a key area within the key store. More...
 
uint32_t AESReadFromKeyStore (uint32_t keyStoreArea)
 Transfer a key from key store area to the internal buffers within the hardware module. More...
 
uint32_t AESWaitForIRQFlags (uint32_t irqFlags)
 Poll the interrupt status register and clear when done. More...
 
void AESConfigureCCMCtrl (uint32_t nonceLength, uint32_t macLength, bool encrypt)
 Configure AES engine for CCM operation. More...
 
static void AESInvalidateKey (uint32_t keyStoreArea)
 Invalidate a key in the key store. More...
 
static void AESSelectAlgorithm (uint32_t algorithm)
 Select type of operation. More...
 
static void AESSetCtrl (uint32_t ctrlMask)
 Set up the next crypto module operation. More...
 
static void AESSetDataLength (uint32_t length)
 Specify length of the crypto operation. More...
 
static void AESSetAuthLength (uint32_t length)
 Specify the length of the additional authentication data (AAD). More...
 
void AESReset (void)
 Reset the accelerator and cancel ongoing operations. More...
 
void AESDMAReset (void)
 Reset the accelerator DMA. More...
 
static void AESIntEnable (uint32_t intFlags)
 Enable individual crypto interrupt sources. More...
 
static void AESIntDisable (uint32_t intFlags)
 Disable individual crypto interrupt sources. More...
 
static uint32_t AESIntStatusMasked (void)
 Get the current masked interrupt status. More...
 
static uint32_t AESIntStatusRaw (void)
 Get the current raw interrupt status. More...
 
static void AESIntClear (uint32_t intFlags)
 Clear crypto interrupt sources. More...
 
static void AESIntRegister (void(*handlerFxn)(void))
 Register an interrupt handler for a crypto interrupt. More...
 
static void AESIntUnregister (void)
 Unregister an interrupt handler for a crypto interrupt. More...
 
static uint32_t AESGetCtrl (void)
 Read the Crypto module control and mode register value. More...
 
void AESWriteKey2 (const uint32_t *key2)
 Write the crypto module KEY2 registers. More...
 
void AESWriteKey3 (const uint32_t *key3)
 Write the crypto module KEY3 registers. More...
 
void AESClearDataIn (void)
 Clear the crypto module DATA_IN registers. More...
 
void AESWriteDataIn (const uint32_t *dataInBuffer)
 Write the crypto module DATA_IN registers. More...
 
void AESReadDataOut (uint32_t *dataOutBuffer)
 Read the crypto module DATA_OUT registers. More...
 
void AESClearKey2 (void)
 Clear the crypto module KEY2 registers. More...
 
void AESClearKey3 (void)
 Clear the crypto module KEY3 registers. More...
 
static void AESCBCMACClearKeys (void)
 Clear key registers as required for AES CBC-MAC. More...
 
static void AESCCMSetTag (const uint32_t *tag)
 Write the AES CCM intermediate tag to the crypto module. More...
 
static void AESCMACWriteSubKey1 (const uint32_t *subKey1)
 Write AES CMAC SubKey1. More...
 
static void AESCMACWriteSubKey2 (const uint32_t *subKey2)
 Write AES CMAC SubKey2. More...
 
static void AESCMACClearSubKey1 (void)
 Clear AES CMAC SubKey1. More...
 
static void AESCMACClearSubKey2 (void)
 Clear AES CMAC SubKey2. More...
 
static void AESSetBlockCounter (uint32_t blockCount)
 Write the crypto module block counter. More...
 
static uint32_t AESGetBlockCounter (void)
 Read the block counter from the crypto module. More...
 
static void AESSetCCMAlignWord (uint32_t alignmentInfo)
 Restore AAD alignment data for resuming CCM operations. More...
 
static uint32_t AESGetCCMAlignWord (void)
 Read the AES CCM AAD alignment word from the crypto module. More...