CC26xx Driver Library
crypto.h File Reference
#include <stdbool.h>
#include <stdint.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_ECB_LENGTH   16
 
#define CRYPTO_DMA_IN_DONE   0x00000002
 
#define CRYPTO_RESULT_RDY   0x00000001
 
#define CRYPTO_DMA_BUS_ERR   0x80000000
 
#define CRYPTO_KEY_ST_WR_ERR   0x40000000
 
#define CRYPTO_KEY_ST_RD_ERR   0x20000000
 
#define CRYPTO_IRQTYPE_LEVEL   0x00000001
 
#define CRYPTO_IRQTYPE_PULSE   0x00000000
 
#define CRYPTO_DMA_CHAN0   0x00000001
 
#define CRYPTO_DMA_CHAN1   0x00000002
 
#define CRYPTO_AES128_ENCRYPT   0x0000000C
 
#define CRYPTO_AES128_DECRYPT   0x00000008
 
#define CRYPTO_DMA_READY   0x00000000
 
#define CRYPTO_DMA_BSY   0x00000003
 
#define CRYPTO_DMA_BUS_ERROR   0x00020000
 
#define AES_SUCCESS   0
 
#define AES_KEYSTORE_READ_ERROR   1
 
#define AES_KEYSTORE_WRITE_ERROR   2
 
#define AES_DMA_BUS_ERROR   3
 
#define CCM_AUTHENTICATION_FAILED   4
 
#define AES_ECB_TEST_ERROR   8
 
#define AES_NULL_ERROR   9
 
#define AES_CCM_TEST_ERROR   10
 
#define AES_DMA_BSY   11
 
#define STATE_BLENGTH   16
 
#define KEY_BLENGTH   16
 
#define KEY_EXP_LENGTH   176
 
#define KEY_STORE_SIZE_128   0x00000001
 
#define KEY_STORE_SIZE_192   0x00000002
 
#define KEY_STORE_SIZE_256   0x00000003
 
#define KEY_STORE_SIZE_BITS   0x00000003
 
#define CRYPTO_KEY_AREA_0   0
 
#define CRYPTO_KEY_AREA_1   1
 
#define CRYPTO_KEY_AREA_2   2
 
#define CRYPTO_KEY_AREA_3   3
 
#define CRYPTO_KEY_AREA_4   4
 
#define CRYPTO_KEY_AREA_5   5
 
#define CRYPTO_KEY_AREA_6   6
 
#define CRYPTO_KEY_AREA_7   7
 
#define CRYPTO_AES_NONE   0
 
#define CRYPTO_AES_KEYL0AD   1
 
#define CRYPTO_AES_ECB   2
 
#define CRYPTO_AES_CCM   3
 
#define CRYPTO_AES_RNG   4
 
#define CRYPTO_AES_CBC   5
 
#define CRYPTO_AES_CTR_32   0x0
 
#define CRYPTO_AES_CTR_64   0x1
 
#define CRYPTO_AES_CTR_96   0x2
 
#define CRYPTO_AES_CTR_128   0x3
 

Functions

uint32_t CRYPTOAesLoadKey (uint32_t *pui32AesKey, uint32_t ui32KeyLocation)
 Write the key into the Key Ram. More...
 
uint32_t CRYPTOAesCbc (uint32_t *pui32MsgIn, uint32_t *pui32MsgOut, uint32_t ui32MsgLength, uint32_t *pui32Nonce, uint32_t ui32KeyLocation, bool bEncrypt, bool bIntEnable)
 Start an AES-CBC operation (encryption or decryption). More...
 
uint32_t CRYPTOAesCbcStatus (void)
 Check the result of an AES CBC operation. More...
 
uint32_t CRYPTOAesEcb (uint32_t *pui32MsgIn, uint32_t *pui32MsgOut, uint32_t ui32KeyLocation, bool bEncrypt, bool bIntEnable)
 Start an AES-ECB operation (encryption or decryption). More...
 
uint32_t CRYPTOAesEcbStatus (void)
 Check the result of an AES ECB operation. More...
 
static void CRYPTOAesEcbFinish (void)
 Finish the encryption operation by resetting the operation mode. More...
 
static void CRYPTOAesCbcFinish (void)
 Finish the encryption operation by resetting the operation mode. More...
 
uint32_t CRYPTOCcmAuthEncrypt (bool bEncrypt, uint32_t ui32AuthLength, uint32_t *pui32Nonce, uint32_t *pui32PlainText, uint32_t ui32PlainTextLength, uint32_t *pui32Header, uint32_t ui32HeaderLength, uint32_t ui32KeyLocation, uint32_t ui32FieldLength, bool bIntEnable)
 Start CCM operation. More...
 
uint32_t CRYPTOCcmAuthEncryptStatus (void)
 Check the result of an AES CCM operation. More...
 
uint32_t CRYPTOCcmAuthEncryptResultGet (uint32_t ui32TagLength, uint32_t *pui32CcmTag)
 Get the result of an AES CCM operation. More...
 
uint32_t CRYPTOCcmInvAuthDecrypt (bool bDecrypt, uint32_t ui32AuthLength, uint32_t *pui32Nonce, uint32_t *pui32CipherText, uint32_t ui32CipherTextLength, uint32_t *pui32Header, uint32_t ui32HeaderLength, uint32_t ui32KeyLocation, uint32_t ui32FieldLength, bool bIntEnable)
 Start a CCM Decryption and Inverse Authentication operation. More...
 
uint32_t CRYPTOCcmInvAuthDecryptStatus (void)
 Checks CCM decrypt and Inverse Authentication result. More...
 
uint32_t CRYPTOCcmInvAuthDecryptResultGet (uint32_t ui32AuthLength, uint32_t *pui32CipherText, uint32_t ui32CipherTextLength, uint32_t *pui32CcmTag)
 Get the result of the CCM operation. More...
 
static uint32_t CRYPTODmaStatus (void)
 Get the current status of the Crypto DMA controller. More...
 
void CRYPTODmaEnable (uint32_t ui32Channels)
 Enable Crypto DMA operation. More...
 
void CRYPTODmaDisable (uint32_t ui32Channels)
 Disable Crypto DMA operation. More...
 
static void CRYPTOIntEnable (uint32_t ui32IntFlags)
 Enables individual Crypto interrupt sources. More...
 
static void CRYPTOIntDisable (uint32_t ui32IntFlags)
 Disables individual CRYPTO interrupt sources. More...
 
static uint32_t CRYPTOIntStatus (bool bMasked)
 Gets the current interrupt status. More...
 
static void CRYPTOIntClear (uint32_t ui32IntFlags)
 Clears Crypto interrupt sources. More...
 
static void CRYPTOIntRegister (void(*pfnHandler)(void))
 Registers an interrupt handler for a Crypto interrupt in the dynamic interrupt table. More...
 
static void CRYPTOIntUnregister (void)
 Unregisters an interrupt handler for a Crypto interrupt in the dynamic interrupt table. More...