Microchip® Advanced Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Advanced Encryption Standard (AES)

See Quick start guide for XMEGA AES driver.

This is a driver for the AVR XMEGA AES crypto module. It provides functions for configuring the AES modules, reseting and starting AES encryption and decryption operations.

Note
  1. After the AES has been configured, data and key must be loaded into register before any operations can be done.
  2. The functions for loading configurations/data/key are not protected against interrupts.

Quick start guide

See Quick start guide for XMEGA AES driver

Modules

 
 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the Advanced Encryption Standard (AES).
 

AES Configuration Define

enum  aes_dec {
  AES_ENCRYPT,
  AES_DECRYPT = AES_DECRYPT_bm
}
 AES encryption/decryption direction settings. More...
 
enum  aes_auto {
  AES_MANUAL,
  AES_AUTO = AES_AUTO_bm
}
 AES Auto Start Trigger settings. More...
 
enum  aes_xor {
  AES_XOR_OFF,
  AES_XOR_ON = AES_XOR_bm
}
 AES State XOR Load Enable settings. More...
 
enum  aes_intlvl {
  AES_INTLVL_OFF = AES_INTLVL_OFF_gc,
  AES_INTLVL_LO = AES_INTLVL_LO_gc,
  AES_INTLVL_MED = AES_INTLVL_MED_gc,
  AES_INTLVL_HI = AES_INTLVL_HI_gc
}
 AES Interrupt Enable / Level settings. More...
 
typedef uint8_t t_key [AES_KEY_SIZE]
 AES key block type. More...
 
typedef uint8_t t_data [AES_DATA_SIZE]
 AES data block type. More...
 
typedef void(* aes_callback_t )(void)
 AES interrupt callback function pointer. More...
 
#define AES_KEY_SIZE   16
 Length of one key block. More...
 
#define AES_DATA_SIZE   16
 Length of one data block. More...
 

AES Function Define

static void aes_start (void)
 Start a decryption/encryption operation. More...
 
static void aes_software_reset (void)
 Reset all registers in AES module. More...
 
static bool aes_is_busy (void)
 Check if the AES module is busy. More...
 
static bool aes_is_error (void)
 Check if the AES module has encountered an error. More...
 
static void aes_clear_interrupt_flag (void)
 Clear the AES state ready interrupt flag. More...
 
static void aes_clear_error_flag (void)
 Clear the AES error flag. More...
 
void aes_configure (enum aes_dec decrypt, enum aes_auto auto_start, enum aes_xor xor_mode)
 AES control register settings. More...
 
void aes_set_key (t_key k_in)
 Load key memory. More...
 
void aes_get_key (t_key k_out)
 Get key memory. More...
 
void aes_write_inputdata (t_data d_in)
 Load state memory. More...
 
void aes_read_outputdata (t_data d_out)
 Get state memory. More...
 
void aes_isr_configure (enum aes_intlvl intlvl)
 AES interrupt settings. More...
 
void aes_set_callback (aes_callback_t callback)
 Set AES interrupt callback function. More...
 

#define AES_DATA_SIZE   16

Length of one data block.

Always 128-bits (16 bytes).

Referenced by aes_read_outputdata(), aes_write_inputdata(), and compare_data_block().

#define AES_KEY_SIZE   16

Length of one key block.

Always 128-bits (16 bytes).

Referenced by aes_get_key(), and aes_set_key().

typedef void(* aes_callback_t)(void)

AES interrupt callback function pointer.

typedef uint8_t t_data[AES_DATA_SIZE]

AES data block type.

typedef uint8_t t_key[AES_KEY_SIZE]

AES key block type.

enum aes_auto

AES Auto Start Trigger settings.

Enumerator
AES_MANUAL 

manual start mode.

AES_AUTO 

auto start mode.

enum aes_dec

AES encryption/decryption direction settings.

Enumerator
AES_ENCRYPT 

encryption.

AES_DECRYPT 

decryption.

enum aes_intlvl

AES Interrupt Enable / Level settings.

Enumerator
AES_INTLVL_OFF 

Interrupt Disabled.

AES_INTLVL_LO 

Low Level.

AES_INTLVL_MED 

Medium Level.

AES_INTLVL_HI 

High Level.

enum aes_xor

AES State XOR Load Enable settings.

Enumerator
AES_XOR_OFF 

state direct load.

AES_XOR_ON 

state XOR load.

static void aes_clear_error_flag ( void  )
inlinestatic

Clear the AES error flag.

See Also
aes_software_reset() to reset entire module and all flags.

Referenced by aes_lastsubkey_generate(), and run_aes_state_interface_test().

static void aes_clear_interrupt_flag ( void  )
inlinestatic

Clear the AES state ready interrupt flag.

See Also
aes_software_reset() to reset entire module and all flags.

Referenced by aes_lastsubkey_generate(), and run_aes_state_interface_test().

void aes_configure ( enum aes_dec  decrypt,
enum aes_auto  auto_start,
enum aes_xor  xor_mode 
)

AES control register settings.

Note
Set AES CTRL register. Refer to the device manual for detailed information.
Parameters
decryptencryption/decryption direction.
auto_startAuto Start Trigger.
xor_modeAES State XOR Load Enable.

Referenced by aes_isr_cbc_decrypt_handler(), aes_lastsubkey_generate(), main(), run_aes_decryption_test(), run_aes_encrypt_and_decrypt_test(), run_aes_encryption_test(), and run_aes_state_interface_test().

void aes_get_key ( t_key  key_out)

Get key memory.

Note
The key is a user defined value of 16 bytes in AVR XMEGA Crypto Engine.
Parameters
key_outPointer to AES key output.

References AES_KEY_SIZE.

Referenced by aes_lastsubkey_generate(), and run_aes_set_and_get_key_test().

static bool aes_is_busy ( void  )
inlinestatic

Check if the AES module is busy.

This functions determines whether the AES module is busy by checking if it is currently performing a encryption/decryption operation or an error has occurred. If neither of these cases are true, the module is determined to be busy.

If an error has occurred, the flag must be cleared with the function aes_clear_error_flag().

Referenced by aes_lastsubkey_generate(), main(), run_aes_decryption_test(), run_aes_encryption_test(), and run_aes_state_interface_test().

static bool aes_is_error ( void  )
inlinestatic

Check if the AES module has encountered an error.

Referenced by aes_isr_handler(), aes_lastsubkey_generate(), main(), and run_aes_state_interface_test().

void aes_isr_configure ( enum aes_intlvl  intlvl)

AES interrupt settings.

Note
Resetting AES interrupt and interrupt level.
Parameters
intlvlAES interrupt level.

Referenced by main(), and run_aes_encrypt_and_decrypt_test().

void aes_read_outputdata ( t_data  data_out)

Get state memory.

Note
The state is a user defined value of 16 bytes in AVR XMEGA Crypto Engine.
Parameters
data_outPointer to AES output date.

References AES_DATA_SIZE.

Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_isr_handler(), int_callback_aes(), main(), run_aes_decryption_test(), and run_aes_encryption_test().

void aes_set_callback ( aes_callback_t  callback)

Set AES interrupt callback function.

Note
Sets a new callback function for interrupts on AES.
Parameters
callbackPointer to the callback function to set.

References aes_callback.

Referenced by main().

void aes_set_key ( t_key  key_in)

Load key memory.

Note
The key is a user defined value of 16 bytes in AVR XMEGA Crypto Engine.
Parameters
key_inPointer to AES key input.

References AES_KEY_SIZE.

Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_lastsubkey_generate(), main(), run_aes_decryption_test(), run_aes_encrypt_and_decrypt_test(), run_aes_encryption_test(), run_aes_set_and_get_key_test(), and run_aes_state_interface_test().

static void aes_software_reset ( void  )
inlinestatic
static void aes_start ( void  )
inlinestatic
void aes_write_inputdata ( t_data  data_in)

Load state memory.

Note
The state is a user defined value of 16 bytes in AVR XMEGA Crypto Engine.
Parameters
data_inPointer to AES input date.

References AES_DATA_SIZE.

Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_lastsubkey_generate(), main(), run_aes_decryption_test(), run_aes_encrypt_and_decrypt_test(), run_aes_encryption_test(), and run_aes_state_interface_test().