Macros | Functions
AES256

Module to interact with the Advanced Encryption Standard 256 (AES256) hardware accelerator. More...

Macros

#define AES256_CMSIS(x)   ((AES256_Type *) x)
 
#define Key_128BIT   128
 
#define Key_192BIT   192
 
#define Key_256BIT   256
 
#define AES256_KEYLENGTH_128BIT   128
 
#define AES256_KEYLENGTH_192BIT   192
 
#define AES256_KEYLENGTH_256BIT   256
 
#define AES256_ERROR_OCCURRED   AES256_CTL0_ERRFG
 
#define AES256_NO_ERROR   0x00
 
#define AES256_BUSY   AES256_STAT_BUSY
 
#define AES256_NOT_BUSY   0x00
 
#define AES256_READY_INTERRUPT   0x01
 
#define AES256_NOTREADY_INTERRUPT   0x00
 

Functions

bool AES256_setCipherKey (uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
 Loads a 128, 192 or 256 bit cipher key to AES256 module. More...
 
void AES256_encryptData (uint32_t moduleInstance, const uint8_t *data, uint8_t *encryptedData)
 Encrypts a block of data using the AES256 module. More...
 
void AES256_decryptData (uint32_t moduleInstance, const uint8_t *data, uint8_t *decryptedData)
 Decrypts a block of data using the AES256 module. More...
 
bool AES256_setDecipherKey (uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
 Sets the decipher key. More...
 
void AES256_clearInterruptFlag (uint32_t moduleInstance)
 Clears the AES256 ready interrupt flag. More...
 
uint32_t AES256_getInterruptFlagStatus (uint32_t moduleInstance)
 Gets the AES256 ready interrupt flag status. More...
 
void AES256_enableInterrupt (uint32_t moduleInstance)
 Enables AES256 ready interrupt. More...
 
void AES256_disableInterrupt (uint32_t moduleInstance)
 Disables AES256 ready interrupt. More...
 
void AES256_reset (uint32_t moduleInstance)
 Resets AES256 Module immediately. More...
 
void AES256_startEncryptData (uint32_t moduleInstance, const uint8_t *data)
 Starts an encryption process on the AES256 module. More...
 
void AES256_startDecryptData (uint32_t moduleInstance, const uint8_t *data)
 Decypts a block of data using the AES256 module. More...
 
bool AES256_startSetDecipherKey (uint32_t moduleInstance, const uint8_t *cipherKey, uint_fast16_t keyLength)
 Sets the decipher key. More...
 
bool AES256_getDataOut (uint32_t moduleInstance, uint8_t *outputData)
 Reads back the output data from AES256 module. More...
 
bool AES256_isBusy (uint32_t moduleInstance)
 Gets the AES256 module busy status. More...
 
void AES256_clearErrorFlag (uint32_t moduleInstance)
 Clears the AES256 error flag. More...
 
uint32_t AES256_getErrorFlagStatus (uint32_t moduleInstance)
 Gets the AES256 error flag status. More...
 
void AES256_registerInterrupt (uint32_t moduleInstance, void(*intHandler)(void))
 
void AES256_unregisterInterrupt (uint32_t moduleInstance)
 
uint32_t AES256_getInterruptStatus (uint32_t moduleInstance)
 

Detailed Description

Module to interact with the Advanced Encryption Standard 256 (AES256) hardware accelerator.


Module Operation


The AES256 accelerator module performs encryption and decryption of 128-bit data with 128-bit keys according to the advanced encryption standard (AES256) (FIPS PUB 197) in hardware.


Key Features


The key features of the AES256 module include:

The AES256256 accelerator module performs encryption and decryption of 128-bit data with 128-/192-/256-bit keys according to the advanced encryption standard (AES256) (FIPS PUB 197) in hardware.


Encryption/Decryption Cycle Times


The the AES256 accelerator decryption/encryption cycle counts are as follows:

AES256 encryption

AES256 decryption:


Programming Example


The DriverLib package contains a variety of different code examples that demonstrate the usage of the AES256 module. These code examples are accessible under the examples/ folder of the SDK release as well as through TI Resource Explorer if using Code Composer Studio. Below is a simple code example of how to encrypt/decrypt data using a cipher key with the AES256 module

Macro Definition Documentation

#define AES256_CMSIS (   x)    ((AES256_Type *) x)
#define Key_128BIT   128
#define Key_192BIT   192
#define Key_256BIT   256
#define AES256_KEYLENGTH_128BIT   128
#define AES256_KEYLENGTH_192BIT   192
#define AES256_KEYLENGTH_256BIT   256
#define AES256_ERROR_OCCURRED   AES256_CTL0_ERRFG
#define AES256_NO_ERROR   0x00
#define AES256_BUSY   AES256_STAT_BUSY
#define AES256_NOT_BUSY   0x00
#define AES256_READY_INTERRUPT   0x01
#define AES256_NOTREADY_INTERRUPT   0x00

Function Documentation

bool AES256_setCipherKey ( uint32_t  moduleInstance,
const uint8_t *  cipherKey,
uint_fast16_t  keyLength 
)

Loads a 128, 192 or 256 bit cipher key to AES256 module.

Parameters
moduleInstanceis the base address of the AES256 module.
cipherKeyis a pointer to an uint8_t array with a length of 16 bytes that contains a 128 bit cipher key.
keyLengthis the length of the key. Valid values are:
  • AES256_KEYLENGTH_128BIT
  • AES256_KEYLENGTH_192BIT
  • AES256_KEYLENGTH_256BIT
Returns
true if set correctly, false otherwise

References AES256_CMSIS, AES256_KEYLENGTH_128BIT, AES256_KEYLENGTH_192BIT, and AES256_KEYLENGTH_256BIT.

void AES256_encryptData ( uint32_t  moduleInstance,
const uint8_t *  data,
uint8_t *  encryptedData 
)

Encrypts a block of data using the AES256 module.

The cipher key that is used for encryption should be loaded in advance by using function AES256_setCipherKey()

Parameters
moduleInstanceis the base address of the AES256 module.
datais a pointer to an uint8_t array with a length of 16 bytes that contains data to be encrypted.
encryptedDatais a pointer to an uint8_t array with a length of 16 bytes in that the encrypted data will be written.
Returns
None

References AES256_CMSIS.

void AES256_decryptData ( uint32_t  moduleInstance,
const uint8_t *  data,
uint8_t *  decryptedData 
)

Decrypts a block of data using the AES256 module.

This function requires a pregenerated decryption key. A key can be loaded and pregenerated by using function AES256_setDecipherKey() or AES256_startSetDecipherKey(). The decryption takes 167 MCLK.

Parameters
moduleInstanceis the base address of the AES256 module.
datais a pointer to an uint8_t array with a length of 16 bytes that contains encrypted data to be decrypted.
decryptedDatais a pointer to an uint8_t array with a length of 16 bytes in that the decrypted data will be written.
Returns
None

References AES256_CMSIS.

bool AES256_setDecipherKey ( uint32_t  moduleInstance,
const uint8_t *  cipherKey,
uint_fast16_t  keyLength 
)

Sets the decipher key.

The API AES256_startSetDecipherKey or AES256_setDecipherKey must be invoked before invoking AES256_startDecryptData.

Parameters
moduleInstanceis the base address of the AES256 module.
cipherKeyis a pointer to an uint8_t array with a length of 16 bytes that contains a 128 bit cipher key.
keyLengthis the length of the key. Valid values are:
  • AES256_KEYLENGTH_128BIT
  • AES256_KEYLENGTH_192BIT
  • AES256_KEYLENGTH_256BIT
Returns
true if set, false otherwise

References AES256_CMSIS, AES256_KEYLENGTH_128BIT, AES256_KEYLENGTH_192BIT, and AES256_KEYLENGTH_256BIT.

void AES256_clearInterruptFlag ( uint32_t  moduleInstance)

Clears the AES256 ready interrupt flag.

Parameters
moduleInstanceis the base address of the AES256 module.

Modified bits are AESRDYIFG of AESACTL0 register.

Returns
None

References AES256_CMSIS.

uint32_t AES256_getInterruptFlagStatus ( uint32_t  moduleInstance)

Gets the AES256 ready interrupt flag status.

Parameters
moduleInstanceis the base address of the AES256 module.
Returns
One of the following:
  • AES256_READY_INTERRUPT
  • AES256_NOTREADY_INTERRUPT
    indicating the status of the AES256 ready status

References AES256_CMSIS.

Referenced by AES256_getInterruptStatus().

void AES256_enableInterrupt ( uint32_t  moduleInstance)

Enables AES256 ready interrupt.

Parameters
moduleInstanceis the base address of the AES256 module.

Modified bits are AESRDYIE of AESACTL0 register.

Returns
None

References AES256_CMSIS.

void AES256_disableInterrupt ( uint32_t  moduleInstance)

Disables AES256 ready interrupt.

Parameters
moduleInstanceis the base address of the AES256 module.

Modified bits are AESRDYIE of AESACTL0 register.

Returns
None

References AES256_CMSIS.

void AES256_reset ( uint32_t  moduleInstance)

Resets AES256 Module immediately.

Parameters
moduleInstanceis the base address of the AES256 module.

Modified bits are AESSWRST of AESACTL0 register.

Returns
None

References AES256_CMSIS.

void AES256_startEncryptData ( uint32_t  moduleInstance,
const uint8_t *  data 
)

Starts an encryption process on the AES256 module.

The cipher key that is used for decryption should be loaded in advance by using function AES256_setCipherKey(). This is a non-blocking equivalent pf AES256_encryptData(). It is recommended to use the interrupt functionality to check for procedure completion then use the AES256_getDataOut() API to retrieve the encrypted data.

Parameters
moduleInstanceis the base address of the AES256 module.
datais a pointer to an uint8_t array with a length of 16 bytes that contains data to be encrypted.
Returns
None

References AES256_CMSIS.

void AES256_startDecryptData ( uint32_t  moduleInstance,
const uint8_t *  data 
)

Decypts a block of data using the AES256 module.

This is the non-blocking equivalant of AES256_decryptData(). This function requires a pregenerated decryption key. A key can be loaded and pregenerated by using function AES256_setDecipherKey() or AES256_startSetDecipherKey(). The decryption takes 167 MCLK. It is recommended to use interrupt to check for procedure completion then use the AES256_getDataOut() API to retrieve the decrypted data.

Parameters
moduleInstanceis the base address of the AES256 module.
datais a pointer to an uint8_t array with a length of 16 bytes that contains encrypted data to be decrypted.
Returns
None

References AES256_CMSIS.

bool AES256_startSetDecipherKey ( uint32_t  moduleInstance,
const uint8_t *  cipherKey,
uint_fast16_t  keyLength 
)

Sets the decipher key.

The API AES256_startSetDecipherKey() or AES256_setDecipherKey() must be invoked before invoking AES256_startDecryptData.

Parameters
moduleInstanceis the base address of the AES256 module.
cipherKeyis a pointer to an uint8_t array with a length of 16 bytes that contains a 128 bit cipher key.
keyLengthis the length of the key. Valid values are:
  • AES256_KEYLENGTH_128BIT
  • AES256_KEYLENGTH_192BIT
  • AES256_KEYLENGTH_256BIT
Returns
true if set correctly, false otherwise

References AES256_CMSIS, AES256_KEYLENGTH_128BIT, AES256_KEYLENGTH_192BIT, and AES256_KEYLENGTH_256BIT.

bool AES256_getDataOut ( uint32_t  moduleInstance,
uint8_t *  outputData 
)

Reads back the output data from AES256 module.

This function is meant to use after an encryption or decryption process that was started and finished by initiating an interrupt by use of AES256_startEncryptData or AES256_startDecryptData functions.

Parameters
moduleInstanceis the base address of the AES256 module.
outputDatais a pointer to an uint8_t array with a length of 16 bytes in that the data will be written.
Returns
true if data is valid, otherwise false

References AES256_CMSIS.

bool AES256_isBusy ( uint32_t  moduleInstance)

Gets the AES256 module busy status.

Parameters
moduleInstanceis the base address of the AES256 module.
Returns
true if busy, false otherwise

References AES256_CMSIS.

void AES256_clearErrorFlag ( uint32_t  moduleInstance)

Clears the AES256 error flag.

Parameters
moduleInstanceis the base address of the AES256 module.

Modified bits are AESERRFG of AESACTL0 register.

Returns
None

References AES256_CMSIS.

uint32_t AES256_getErrorFlagStatus ( uint32_t  moduleInstance)

Gets the AES256 error flag status.

Parameters
moduleInstanceis the base address of the AES256 module.
Returns
One of the following:
  • AES256_ERROR_OCCURRED
  • AES256_NO_ERROR
    indicating the error flag status

References AES256_CMSIS.

void AES256_registerInterrupt ( uint32_t  moduleInstance,
void(*)(void)  intHandler 
)

Registers an interrupt handler for the AES interrupt.

Parameters
moduleInstanceInstance of the AES256 module
intHandleris a pointer to the function to be called when the AES interrupt occurs.

This function registers the handler to be called when a AES interrupt occurs. This function enables the global interrupt in the interrupt controller; specific AES interrupts must be enabled via AES256_enableInterrupt(). It is the interrupt handler's responsibility to clear the interrupt source via AES256_clearInterrupt().

Returns
None.

References INT_AES256, Interrupt_enableInterrupt(), and Interrupt_registerInterrupt().

void AES256_unregisterInterrupt ( uint32_t  moduleInstance)

Unregisters the interrupt handler for the AES interrupt

Parameters
moduleInstanceInstance of the AES256 module

This function unregisters the handler to be called when AES interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

See Also
Interrupt_registerInterrupt() for important information about registering interrupt handlers.
Returns
None.

References INT_AES256, Interrupt_disableInterrupt(), and Interrupt_unregisterInterrupt().

uint32_t AES256_getInterruptStatus ( uint32_t  moduleInstance)

Returns the current interrupt flag for the peripheral.

Parameters
moduleInstanceInstance of the AES256 module
Returns
The currently triggered interrupt flag for the module.

References AES256_getInterruptFlagStatus().


Copyright 2018, Texas Instruments Incorporated