Driver for the AES (Advanced Encryption Standard) module.
Provides functions for configuring and initiating ciphering/deciphering with AES algorithms. Several modes(ECB, CBC, OFB, CFB or CTR) and key sizes(128-, 192- or 256-bit) are supported, in addition to manual or DMA-based data input to the AES module.
Data Structures | |
struct | aes_config |
AES Configuration structure. More... | |
struct | aes_dev_inst |
AES driver software instance structure. More... | |
Typedefs | |
typedef void(* | aes_callback_t )(void) |
Interrupt callback function type for AES. More... | |
typedef enum aes_interrupt_source | aes_interrupt_source_t |
AES interrupt source type. More... | |
Enumerations | |
enum | aes_cfb_size { AES_CFB_SIZE_128 = 0, AES_CFB_SIZE_64, AES_CFB_SIZE_32, AES_CFB_SIZE_16, AES_CFB_SIZE_8 } |
AES CFB size. More... | |
enum | aes_countermeature_type { AES_COUNTERMEASURE_TYPE_1 = 0x01, AES_COUNTERMEASURE_TYPE_2 = 0x02, AES_COUNTERMEASURE_TYPE_3 = 0x04, AES_COUNTERMEASURE_TYPE_4 = 0x08, AES_COUNTERMEASURE_TYPE_ALL = 0x0F } |
AES CounterMeasure type. More... | |
enum | aes_dma_mode { AES_MANUAL_MODE = 0, AES_DMA_MODE } |
AES DMA mode. More... | |
enum | aes_encrypt_mode { AES_DECRYPTION = 0, AES_ENCRYPTION } |
AES Processing mode. More... | |
enum | aes_interrupt_source { AES_INTERRUPT_INPUT_BUFFER_READY = AESA_IER_ODATARDY, AES_INTERRUPT_OUTPUT_DATA_READY = AESA_IER_IBUFRDY } |
AES interrupt source type. More... | |
enum | aes_key_size { AES_KEY_SIZE_128 = 0, AES_KEY_SIZE_192, AES_KEY_SIZE_256 } |
AES Cryptographic key size. More... | |
enum | aes_opmode { AES_ECB_MODE = 0, AES_CBC_MODE, AES_OFB_MODE, AES_CFB_MODE, AES_CTR_MODE } |
AES Confidentiality mode. More... | |
Functions | |
static void | aes_decryption_key_generate (struct aes_dev_inst *const dev_inst) |
Starts the computation of the last Nk words of the expanded key. More... | |
void | aes_disable (struct aes_dev_inst *const dev_inst) |
Disable the AES. More... | |
static void | aes_disable_interrupt (struct aes_dev_inst *const dev_inst, aes_interrupt_source_t source) |
Disable the AES interrupt. More... | |
void | aes_enable (struct aes_dev_inst *const dev_inst) |
Enable the AES. More... | |
static void | aes_enable_interrupt (struct aes_dev_inst *const dev_inst, aes_interrupt_source_t source) |
Enable the AES interrupt. More... | |
void | aes_get_config_defaults (struct aes_config *const cfg) |
Initializes a AES configuration structure to defaults. More... | |
bool | aes_init (struct aes_dev_inst *const dev_inst, Aesa *const aes, struct aes_config *const cfg) |
Initialize the AES module. More... | |
static uint32_t | aes_read_input_buffer_pointer (struct aes_dev_inst *const dev_inst) |
Read the input buffer pointer position. More... | |
static uint32_t | aes_read_interrupt_mask (struct aes_dev_inst *const dev_inst) |
Get the AES interrupt mask status. More... | |
static uint32_t | aes_read_output_buffer_pointer (struct aes_dev_inst *const dev_inst) |
Read the output buffer pointer position. More... | |
static uint32_t | aes_read_output_data (struct aes_dev_inst *const dev_inst) |
Read the output data. More... | |
static uint32_t | aes_read_status (struct aes_dev_inst *const dev_inst) |
Get the AES status. More... | |
static void | aes_reset (struct aes_dev_inst *const dev_inst) |
Perform a software reset of the AES. More... | |
void | aes_set_callback (struct aes_dev_inst *const dev_inst, aes_interrupt_source_t source, aes_callback_t callback, uint8_t irq_level) |
Set callback for AES. More... | |
static void | aes_set_config (struct aes_dev_inst *const dev_inst) |
Configure the AES. More... | |
static void | aes_set_new_message (struct aes_dev_inst *const dev_inst) |
Notifies the module that the next input data block is the beginning of a new message. More... | |
static void | aes_write_drng_seed (struct aes_dev_inst *const dev_inst, uint32_t ul_drng_seed) |
Write the DRNG seed. More... | |
void | aes_write_initvector (struct aes_dev_inst *const dev_inst, const uint32_t *p_vector) |
Write the initialization vector (for the CBC, CFB, OFB & CTR cipher modes) More... | |
static void | aes_write_input_buffer_pointer (struct aes_dev_inst *const dev_inst, uint32_t ul_in_position) |
Write the input buffer pointer position. More... | |
static void | aes_write_input_data (struct aes_dev_inst *const dev_inst, uint32_t ul_data) |
Write the input data. More... | |
void | aes_write_key (struct aes_dev_inst *const dev_inst, const uint32_t *p_key) |
Write the 128/192/256bit cryptographic key. More... | |
static void | aes_write_output_buffer_pointer (struct aes_dev_inst *const dev_inst, uint32_t ul_out_position) |
Write the output buffer pointer position. More... | |
typedef void(* aes_callback_t)(void) |
Interrupt callback function type for AES.
The interrupt handler can be configured to do a function callback, the callback function must match the aes_callback_t type.
typedef enum aes_interrupt_source aes_interrupt_source_t |
AES interrupt source type.
enum aes_cfb_size |
enum aes_dma_mode |
enum aes_encrypt_mode |
enum aes_interrupt_source |
enum aes_key_size |
enum aes_opmode |
|
inlinestatic |
Starts the computation of the last Nk words of the expanded key.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
void aes_disable | ( | struct aes_dev_inst *const | dev_inst | ) |
Disable the AES.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev, SLEEPMGR_SLEEP_0, sleepmgr_unlock_mode(), and sysclk_disable_peripheral_clock().
|
inlinestatic |
Disable the AES interrupt.
dev_inst | Device structure pointer. |
source | Interrupt source. |
References aes_dev_inst::hw_dev.
void aes_enable | ( | struct aes_dev_inst *const | dev_inst | ) |
Enable the AES.
dev_inst | Device structure pointer. |
References CONFIG_AESA_GENERIC_DIV, CONFIG_AESA_GENERIC_SRC, genclk_config_defaults(), genclk_config_set_divider(), genclk_config_set_source(), genclk_enable(), genclk_enable_source(), aes_dev_inst::hw_dev, sleepmgr_lock_mode(), SLEEPMGR_SLEEP_0, and sysclk_enable_peripheral_clock().
Referenced by main().
|
inlinestatic |
Enable the AES interrupt.
dev_inst | Device structure pointer. |
source | Interrupt source. |
References aes_dev_inst::hw_dev.
Referenced by aes_set_callback().
void aes_get_config_defaults | ( | struct aes_config *const | cfg | ) |
Initializes a AES configuration structure to defaults.
Initializes a given AES configuration structure to a set of known default values. This function should be called on all new instances of these configuration structures before being modified by the user application.
The default configuration is as follows:
cfg | Configuration structure to initialize to default values. |
References AES_CFB_SIZE_128, AES_COUNTERMEASURE_TYPE_ALL, AES_ECB_MODE, AES_ENCRYPTION, AES_KEY_SIZE_128, AES_MANUAL_MODE, Assert, aes_config::cfb_size, aes_config::countermeasure_mask, aes_config::dma_mode, aes_config::encrypt_mode, aes_config::key_size, and aes_config::opmode.
Referenced by main().
bool aes_init | ( | struct aes_dev_inst *const | dev_inst, |
Aesa *const | aesa, | ||
struct aes_config *const | cfg | ||
) |
Initialize the AES module.
dev_inst | Device structure pointer. |
aesa | Base address of the AESA instance. |
cfg | Pointer to AES configuration. |
true | if the initialization was successful. |
false | if initialization failed. |
References aes_dev_inst::aes_cfg, aes_set_config(), Assert, aes_dev_inst::hw_dev, sysclk_disable_peripheral_clock(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
inlinestatic |
Read the input buffer pointer position.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
|
inlinestatic |
Get the AES interrupt mask status.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
|
inlinestatic |
Read the output buffer pointer position.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
|
inlinestatic |
Read the output data.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
Referenced by aes_callback().
|
inlinestatic |
Get the AES status.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
|
inlinestatic |
Perform a software reset of the AES.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
void aes_set_callback | ( | struct aes_dev_inst *const | dev_inst, |
aes_interrupt_source_t | source, | ||
aes_callback_t | callback, | ||
uint8_t | irq_level | ||
) |
Set callback for AES.
dev_inst | Device structure pointer. |
source | Interrupt source. |
callback | callback function pointer. |
irq_level | interrupt level. |
References aes_callback_pointer, aes_enable_interrupt(), and irq_register_handler.
Referenced by ecb_mode_test_pdca(), and main().
|
inlinestatic |
Configure the AES.
dev_inst | Device structure pointer. |
References aes_dev_inst::aes_cfg, aes_config::cfb_size, aes_config::countermeasure_mask, aes_config::dma_mode, aes_config::encrypt_mode, aes_dev_inst::hw_dev, aes_config::key_size, and aes_config::opmode.
Referenced by aes_init(), cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), ecb_mode_test(), ecb_mode_test_pdca(), and ofb_mode_test().
|
inlinestatic |
Notifies the module that the next input data block is the beginning of a new message.
dev_inst | Device structure pointer. |
References aes_dev_inst::hw_dev.
Referenced by cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), ecb_mode_test(), ecb_mode_test_pdca(), and ofb_mode_test().
|
inlinestatic |
Write the DRNG seed.
dev_inst | Device structure pointer. |
ul_drng_seed | DRNG seed. |
References aes_dev_inst::hw_dev.
void aes_write_initvector | ( | struct aes_dev_inst *const | dev_inst, |
const uint32_t * | p_vector | ||
) |
Write the initialization vector (for the CBC, CFB, OFB & CTR cipher modes)
dev_inst | Device structure pointer. |
*p_vector | Pointer on 4 contiguous 32bit words. |
References aes_dev_inst::hw_dev.
Referenced by cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), and ofb_mode_test().
|
inlinestatic |
Write the input buffer pointer position.
dev_inst | Device structure pointer. |
ul_in_position | Input buffer pointer position. |
References aes_dev_inst::hw_dev.
|
inlinestatic |
Write the input data.
dev_inst | Device structure pointer. |
ul_data | Input data. |
References aes_dev_inst::hw_dev.
Referenced by cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), ecb_mode_test(), and ofb_mode_test().
void aes_write_key | ( | struct aes_dev_inst *const | dev_inst, |
const uint32_t * | p_key | ||
) |
Write the 128/192/256bit cryptographic key.
dev_inst | Device structure pointer. |
*p_key | Pointer on 4/6/8 contiguous 32bit words. |
References aes_dev_inst::hw_dev.
Referenced by cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), ecb_mode_test(), ecb_mode_test_pdca(), and ofb_mode_test().
|
inlinestatic |
Write the output buffer pointer position.
dev_inst | Device structure pointer. |
ul_out_position | Output buffer pointer position. |
References aes_dev_inst::hw_dev.