CC26xx Driver Library
[crypto] Crypto

Functions

uint32_t CRYPTOAesLoadKey (uint32_t *pui32AesKey, uint32_t ui32KeyLocation)
 Write the key into the Key Ram. 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...
 
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. More...
 
static void CRYPTOIntUnregister (void)
 Unregisters an interrupt handler for a Crypto interrupt. More...
 

Detailed Description

Function Documentation

uint32_t CRYPTOAesEcb ( uint32_t *  pui32MsgIn,
uint32_t *  pui32MsgOut,
uint32_t  ui32KeyLocation,
bool  bEncrypt,
bool  bIntEnable 
)

Start an AES-ECB operation (encryption or decryption).

The ui32KeyLocation parameter is an enumerated type which specifies the Key Ram location in which the key is stored.

Parameters
pui32MsgInis a pointer to the input data.
pui32MsgOutis a pointer to the output data.
ui32KeyLocationis the location of the key in Key RAM. This parameter can have any of the following values:
bEncryptis set true to encrypt or set false to decrypt.
bIntEnableis set true to enable Crypto interrupts or false to disable Crypto interrupt.
Returns
Returns status of the AES-ECB operation:
See also
CRYPTOAesEcbStatus()

Definition at line 202 of file crypto.c.

Here is the call graph for this function:

static void CRYPTOAesEcbFinish ( void  )
inlinestatic

Finish the encryption operation by resetting the operation mode.

This function should be called after CRYPTOAesEcbStatus() has reported that the operation is finished successfully.

Returns
None
See also
CRYPTOAesEcbStatus()

Definition at line 294 of file crypto.h.

uint32_t CRYPTOAesEcbStatus ( void  )

Check the result of an AES ECB operation.

This function should be called after CRYPTOAesEcb() function to check if the AES ECB operation was successful.

Returns
Returns the status of the AES ECB operation:
See also
CRYPTOAesEcb()

Definition at line 317 of file crypto.c.

Here is the call graph for this function:

uint32_t CRYPTOAesLoadKey ( uint32_t *  pui32AesKey,
uint32_t  ui32KeyLocation 
)

Write the key into the Key Ram.

The ui32KeyLocation parameter is an enumerated type which specifies the Key Ram location in which the key is stored.

The pointer pui8AesKey has the address where the Key is stored.

Parameters
pui32AesKeyis a pointer to an AES Key.
ui32KeyLocationis the location of the key in Key RAM. This parameter can have any of the following values:
Returns
Returns status of the function:

Definition at line 85 of file crypto.c.

Here is the call graph for this function:

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.

The ui32KeyLocation is an enumerated type which specifies the Key Ram location in which the key is stored.

Parameters
bEncryptdetermines whether to run encryption or not.
ui32AuthLengthis the the length of the authentication field - 0, 2, 4, 6, 8, 10, 12, 14 or 16 octets.
pui32Nonceis a pointer to 13-byte or 12-byte Nonce (Number used once).
pui32PlainTextis a pointer to the octet string input message.
ui32PlainTextLengthis the length of the message.
pui32Headeris the length of the header (Additional Authentication Data or AAD).
ui32HeaderLengthis the length of the header in octets.
ui32KeyLocationis the location in Key RAM where the key is stored. This parameter can have any of the following values:
ui32FieldLengthis the size of the length field (2 or 3).
bIntEnableenables interrupts.
Returns
Returns the status of the CCM operation
See also
CRYPTOCcmAuthEncryptStatus()

Definition at line 357 of file crypto.c.

Here is the call graph for this function:

uint32_t CRYPTOCcmAuthEncryptResultGet ( uint32_t  ui32TagLength,
uint32_t *  pui32CcmTag 
)

Get the result of an AES CCM operation.

This function should be called after CRYPTOCcmAuthEncryptStatus().

Parameters
ui32TagLengthis length of the Tag.
pui32CcmTagis the location of the authentication Tag.
Returns
Returns AES_SUCCESS if successful.
See also
CRYPTOCcmAuthEncryptStatus()

Get the result of an AES CCM operation.

Definition at line 629 of file crypto.c.

Here is the call graph for this function:

uint32_t CRYPTOCcmAuthEncryptStatus ( void  )

Check the result of an AES CCM operation.

This function should be called after CRYPTOCcmAuthEncrypt() function to check if the AES CCM operation was successful.

Returns
Returns the status of the AES CCM operation:
See also
CRYPTOCcmAuthEncrypt()

Definition at line 590 of file crypto.c.

Here is the call graph for this function:

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.

The ui32KeyLocation is an enumerated type which specifies the Key Ram location in which the key is stored.

Parameters
bDecryptdetermines whether to run decryption or not.
ui32AuthLengthis the the length of the authentication field - 0, 2, 4, 6, 8, 10, 12, 14 or 16 octets.
pui32Nonceis a pointer to 13-byte or 12-byte Nonce (Number used once).
pui32CipherTextis a pointer to the octet string encrypted message.
ui32CipherTextLengthis the length of the encrypted message.
pui32Headeris the length of the header (Additional Authentication Data or AAD).
ui32HeaderLengthis the length of the header in octets.
ui32KeyLocationis the location in Key RAM where the key is stored. This parameter can have any of the following values:
ui32FieldLengthis the size of the length field (2 or 3).
bIntEnableenables interrupts.
Returns
Returns the status of the operation:

Definition at line 678 of file crypto.c.

Here is the call graph for this function:

uint32_t CRYPTOCcmInvAuthDecryptResultGet ( uint32_t  ui32AuthLength,
uint32_t *  pui32CipherText,
uint32_t  ui32CipherTextLength,
uint32_t *  pui32CcmTag 
)

Get the result of the CCM operation.

Parameters
ui32AuthLengthis the the length of the authentication field - 0, 2, 4, 6, 8, 10, 12, 14 or 16 octets.
pui32CipherTextis a pointer to the octet string encrypted message.
ui32CipherTextLengthis the length of the encrypted message.
pui32CcmTagis the location of the authentication Tag.
Returns
Returns AES_SUCCESS if successful.

Definition at line 952 of file crypto.c.

Here is the call graph for this function:

uint32_t CRYPTOCcmInvAuthDecryptStatus ( void  )

Checks CCM decrypt and Inverse Authentication result.

Returns
Returns status of operation:

Definition at line 913 of file crypto.c.

Here is the call graph for this function:

void CRYPTODmaDisable ( uint32_t  ui32Channels)

Disable Crypto DMA operation.

The specified Crypto DMA channels are disabled.

Parameters
ui32Channelsis a bitwise OR of the channels to disable.
Returns
None

Definition at line 1048 of file crypto.c.

void CRYPTODmaEnable ( uint32_t  ui32Channels)

Enable Crypto DMA operation.

The specified Crypto DMA channels are enabled.

Parameters
ui32Channelsis a bitwise OR of the channels to enable.
Returns
None

Definition at line 1021 of file crypto.c.

static uint32_t CRYPTODmaStatus ( void  )
inlinestatic

Get the current status of the Crypto DMA controller.

This function is used to poll the Crypto DMA controller to check if it is ready for a new operation or if an error has occurred.

The CRYPTO_DMA_BUS_ERROR can also be caught using the crypto event handler.

Returns
Returns the current status of the DMA controller:

Definition at line 477 of file crypto.h.

static void CRYPTOIntClear ( uint32_t  ui32IntFlags)
inlinestatic

Clears Crypto interrupt sources.

The specified Crypto interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being recognized again immediately upon exit.

Note
Because there is a write buffer in the System CPU, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source is cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately re-entered (because the interrupt controller still sees the interrupt source asserted).
Parameters
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.
Returns
None

Definition at line 642 of file crypto.h.

static void CRYPTOIntDisable ( uint32_t  ui32IntFlags)
inlinestatic

Disables individual CRYPTO interrupt sources.

This function disables the indicated Crypto interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.

Parameters
ui32IntFlagsis the bitwise OR of the interrupt sources to be enabled.
Returns
None

Definition at line 566 of file crypto.h.

static void CRYPTOIntEnable ( uint32_t  ui32IntFlags)
inlinestatic

Enables individual Crypto interrupt sources.

This function enables the indicated Crypto interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.

Parameters
ui32IntFlagsis the bitwise OR of the interrupt sources to be enabled.
Returns
None

Definition at line 531 of file crypto.h.

static void CRYPTOIntRegister ( void(*)(void)  pfnHandler)
inlinestatic

Registers an interrupt handler for a Crypto interrupt.

This function does the actual registering of the interrupt handler. This function enables the global interrupt in the interrupt controller; specific UART interrupts must be enabled via CRYPTOIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source.

Parameters
pfnHandleris a pointer to the function to be called when the UART interrupt occurs.
Returns
None
See also
IntRegister() for important information about registering interrupt handlers.

Definition at line 675 of file crypto.h.

Here is the call graph for this function:

static uint32_t CRYPTOIntStatus ( bool  bMasked)
inlinestatic

Gets the current interrupt status.

This function returns the interrupt status for the specified Crypto. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Parameters
bMaskedwhether to use raw or masked interrupt status:
  • false : Raw interrupt status is required.
  • true : Masked interrupt status is required.
Returns
Returns the current interrupt status:

Definition at line 598 of file crypto.h.

static void CRYPTOIntUnregister ( void  )
inlinestatic

Unregisters an interrupt handler for a Crypto interrupt.

This function does the actual unregistering of the interrupt handler. It clears the handler to be called when a Crypto interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

Returns
None
See also
IntRegister() for important information about registering interrupt handlers.

Definition at line 704 of file crypto.h.

Here is the call graph for this function:

Macro Definition Documentation

#define AES_CCM_TEST_ERROR   10

Definition at line 145 of file crypto.h.

#define AES_DMA_BSY   11
#define AES_DMA_BUS_ERROR   3
#define AES_ECB_LENGTH   16

Definition at line 104 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define AES_ECB_TEST_ERROR   8

Definition at line 143 of file crypto.h.

#define AES_KEYSTORE_READ_ERROR   1
#define AES_KEYSTORE_WRITE_ERROR   2

Definition at line 140 of file crypto.h.

#define AES_NULL_ERROR   9

Definition at line 144 of file crypto.h.

#define CCM_AUTHENTICATION_FAILED   4

Definition at line 142 of file crypto.h.

Referenced by CRYPTOCcmInvAuthDecryptResultGet().

#define CRYPTO_AES128_DECRYPT   0x00000008

Definition at line 125 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define CRYPTO_AES128_ENCRYPT   0x0000000C

Definition at line 124 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define CRYPTO_AES_CCM   3

Definition at line 182 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_AES_CTR_128   0x3

Definition at line 193 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_AES_CTR_32   0x0

Definition at line 190 of file crypto.h.

#define CRYPTO_AES_CTR_64   0x1

Definition at line 191 of file crypto.h.

#define CRYPTO_AES_CTR_96   0x2

Definition at line 192 of file crypto.h.

#define CRYPTO_AES_ECB   2

Definition at line 181 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define CRYPTO_AES_KEYL0AD   1

Definition at line 180 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_AES_RNG   4

Definition at line 183 of file crypto.h.

#define CRYPTO_DMA_BSY   0x00000003
#define CRYPTO_DMA_BUS_ERR   0x80000000

Definition at line 114 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_DMA_BUS_ERROR   0x00020000
#define CRYPTO_DMA_CHAN0   0x00000001

Definition at line 121 of file crypto.h.

Referenced by CRYPTODmaDisable(), and CRYPTODmaEnable().

#define CRYPTO_DMA_CHAN1   0x00000002

Definition at line 122 of file crypto.h.

Referenced by CRYPTODmaDisable(), and CRYPTODmaEnable().

#define CRYPTO_DMA_IN_DONE   0x00000002
#define CRYPTO_DMA_READY   0x00000000

Definition at line 127 of file crypto.h.

#define CRYPTO_INT_LEVEL   0x00000001
#define CRYPTO_INT_PULSE   0x00000000

Definition at line 119 of file crypto.h.

#define CRYPTO_KEY_AREA_0   0

Definition at line 165 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_1   1

Definition at line 166 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_2   2

Definition at line 167 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_3   3

Definition at line 168 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_4   4

Definition at line 169 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_5   5

Definition at line 170 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_6   6

Definition at line 171 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_7   7

Definition at line 172 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_ST_RD_ERR   0x20000000

Definition at line 116 of file crypto.h.

Referenced by CRYPTOAesEcb(), CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_KEY_ST_WR_ERR   0x40000000

Definition at line 115 of file crypto.h.

#define CRYPTO_RESULT_RDY   0x00000001

Definition at line 113 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), CRYPTOIntClear(), CRYPTOIntDisable(), and CRYPTOIntEnable().

#define KEY_BLENGTH   16

Definition at line 150 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define KEY_EXP_LENGTH   176

Definition at line 151 of file crypto.h.

#define KEY_STORE_SIZE_128   0x00000001

Definition at line 153 of file crypto.h.

Referenced by CRYPTOAesLoadKey(), CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define KEY_STORE_SIZE_192   0x00000002

Definition at line 154 of file crypto.h.

#define KEY_STORE_SIZE_256   0x00000003

Definition at line 155 of file crypto.h.

#define KEY_STORE_SIZE_BITS   0x00000003

Definition at line 156 of file crypto.h.

#define STATE_BLENGTH   16

Definition at line 149 of file crypto.h.