CC13xx Driver Library
[crypto] Crypto

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. More...
 
static void CRYPTOIntUnregister (void)
 Unregisters an interrupt handler for a Crypto interrupt. More...
 

Detailed Description

Function Documentation

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).

The function starts an AES CBC mode encypt or decrypt operation. End operation can be deteced by enabling interrupt or by polling CRYPTOAesCbcStatus(). Result of operation is returned by CRYPTOAesCbcStatus().

Parameters
pui32MsgInis a pointer to the input data.
pui32MsgOutis a pointer to the output data.
ui32MsgLengthis the length in bytes of the input data.
pui32Nonceis a pointer to 16-byte Nonce.
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-CBC operation:
See also
CRYPTOAesCbcStatus()

Definition at line 207 of file crypto.c.

Here is the call graph for this function:

static void CRYPTOAesCbcFinish ( void  )
inlinestatic

Finish the encryption operation by resetting the operation mode.

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

Returns
None
See also
CRYPTOAesCbcStatus()

Definition at line 375 of file crypto.h.

uint32_t CRYPTOAesCbcStatus ( void  )

Check the result of an AES CBC operation.

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

Returns
Returns the status of the AES CBC operation:
See also
CRYPTOAesCbc()

Definition at line 340 of file crypto.c.

Here is the call graph for this function:

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 351 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 352 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 471 of file crypto.c.

Referenced by CRYPTOAesCbcStatus().

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 90 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 511 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 793 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 754 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 842 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 1127 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 1088 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 1223 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 1196 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 558 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
Due to write buffers and synchronizers in the system it may take several clock cycles from a register write clearing an event in a module and until the event is actually cleared in the NVIC of the system CPU. It is recommended to clear the event source early in the interrupt service routine (ISR) to allow the event clear to propagate to the NVIC before returning from the ISR. At the same time, an early event clear allows new events of the same type to be pended instead of ignored if the event is cleared later in the ISR. It is the responsibility of the programmer to make sure that enough time has passed before returning from the ISR to avoid false re-triggering of the cleared event. A simple, although not necessarily optimal, way of clearing an event before returning from the ISR is:
  1. Write to clear event (interrupt source). (buffered write)
  2. Dummy read from the event source module. (making sure the write has propagated)
  3. Wait two system CPU clock cycles (user code or two NOPs). (allowing cleared event to propagate through any synchronizers)
Parameters
ui32IntFlagsis a bit mask of the interrupt sources to be cleared.
Returns
None

Definition at line 729 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 647 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 612 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 762 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 679 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 791 of file crypto.h.

Here is the call graph for this function:

Macro Definition Documentation

#define AES_CCM_TEST_ERROR   10

Definition at line 147 of file crypto.h.

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

Definition at line 106 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define AES_ECB_TEST_ERROR   8

Definition at line 145 of file crypto.h.

#define AES_KEYSTORE_READ_ERROR   1
#define AES_KEYSTORE_WRITE_ERROR   2

Definition at line 142 of file crypto.h.

#define AES_NULL_ERROR   9

Definition at line 146 of file crypto.h.

#define CCM_AUTHENTICATION_FAILED   4

Definition at line 144 of file crypto.h.

Referenced by CRYPTOCcmInvAuthDecryptResultGet().

#define CRYPTO_AES128_DECRYPT   0x00000008

Definition at line 127 of file crypto.h.

Referenced by CRYPTOAesCbc(), and CRYPTOAesEcb().

#define CRYPTO_AES128_ENCRYPT   0x0000000C

Definition at line 126 of file crypto.h.

Referenced by CRYPTOAesCbc(), and CRYPTOAesEcb().

#define CRYPTO_AES_CBC   5

Definition at line 186 of file crypto.h.

Referenced by CRYPTOAesCbc().

#define CRYPTO_AES_CCM   3

Definition at line 184 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_AES_CTR_128   0x3

Definition at line 196 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_AES_CTR_32   0x0

Definition at line 193 of file crypto.h.

#define CRYPTO_AES_CTR_64   0x1

Definition at line 194 of file crypto.h.

#define CRYPTO_AES_CTR_96   0x2

Definition at line 195 of file crypto.h.

#define CRYPTO_AES_ECB   2

Definition at line 183 of file crypto.h.

Referenced by CRYPTOAesEcb().

#define CRYPTO_AES_KEYL0AD   1

Definition at line 182 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_AES_RNG   4

Definition at line 185 of file crypto.h.

#define CRYPTO_DMA_BSY   0x00000003
#define CRYPTO_DMA_BUS_ERR   0x80000000

Definition at line 116 of file crypto.h.

Referenced by CRYPTOCcmAuthEncrypt(), and CRYPTOCcmInvAuthDecrypt().

#define CRYPTO_DMA_BUS_ERROR   0x00020000
#define CRYPTO_DMA_CHAN0   0x00000001

Definition at line 123 of file crypto.h.

Referenced by CRYPTODmaDisable(), and CRYPTODmaEnable().

#define CRYPTO_DMA_CHAN1   0x00000002

Definition at line 124 of file crypto.h.

Referenced by CRYPTODmaDisable(), and CRYPTODmaEnable().

#define CRYPTO_DMA_IN_DONE   0x00000002

Definition at line 114 of file crypto.h.

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

#define CRYPTO_DMA_READY   0x00000000

Definition at line 129 of file crypto.h.

#define CRYPTO_IRQTYPE_PULSE   0x00000000

Definition at line 121 of file crypto.h.

#define CRYPTO_KEY_AREA_0   0

Definition at line 167 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_1   1

Definition at line 168 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_2   2

Definition at line 169 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_3   3

Definition at line 170 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_4   4

Definition at line 171 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_5   5

Definition at line 172 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_6   6

Definition at line 173 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_AREA_7   7

Definition at line 174 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define CRYPTO_KEY_ST_RD_ERR   0x20000000
#define CRYPTO_KEY_ST_WR_ERR   0x40000000

Definition at line 117 of file crypto.h.

#define CRYPTO_RESULT_RDY   0x00000001

Definition at line 115 of file crypto.h.

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

#define KEY_BLENGTH   16

Definition at line 152 of file crypto.h.

Referenced by CRYPTOAesLoadKey().

#define KEY_EXP_LENGTH   176

Definition at line 153 of file crypto.h.

#define KEY_STORE_SIZE_128   0x00000001

Definition at line 155 of file crypto.h.

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

#define KEY_STORE_SIZE_192   0x00000002

Definition at line 156 of file crypto.h.

#define KEY_STORE_SIZE_256   0x00000003

Definition at line 157 of file crypto.h.

#define KEY_STORE_SIZE_BITS   0x00000003

Definition at line 158 of file crypto.h.

#define STATE_BLENGTH   16

Definition at line 151 of file crypto.h.