This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's Advanced Encryption Standard functionality.
The Advanced Encryption Standard module supports all five confidentiality modes of operation for symmetrical key block cipher algorithms (as specified in the NIST Special Publication 800-38A Recommendation):
Devices from the following series can use this module:
The outline of this documentation is as follows:
There are no prerequisites for this module.
The Advanced Encryption Standard (AES) module is compliant with the American FIPS (Federal Information Processing Standard) Publication 197 specification.
The AES supports all five confidentiality modes of operation for symmetrical key block cipher algorithms (as specified in the NIST Special Publication 800-38A Recommendation) :
Data transfers both to and from the AES module can occur using the Peripheral DMA Controller (PDC) channels (thus minimizing processor intervention for large data buffer transfers).
As soon as the initialization vector, the input data, and the key are configured, the encryption/decryption process may be started. Once the process has completed the encrypted/decrypted data can be read out via registers or through DMA channels.
The AES module may be clocked through the Power Management Controller (PMC), in which case the user application must first configure the PMC to enable the AES clock.
When using the AES module's interrupt, the configuration of the device's Nested Vectored Interrupt Controller (NVIC) needs to be carried out before the AES module is configured.
For extra information, see Extra Information for Advanced Encryption Standard. This includes:
For a list of examples related to this driver, see Examples for Advanced Encryption Standard.
Data Structures | |
struct | aes_config |
AES Configuration structure. More... | |
Typedefs | |
typedef void(* | aes_callback_t )(void) |
AES interrupt callback function type. 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 Cipher FeedBack (CFB) size. More... | |
enum | aes_encrypt_mode { AES_DECRYPTION = 0, AES_ENCRYPTION } |
AES processing mode. More... | |
enum | aes_interrupt_source { AES_INTERRUPT_DATA_READY = AES_IER_DATRDY, AES_INTERRUPT_UNSPECIFIED_REGISTER_ACCESS = AES_IER_URAD } |
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_GCM_MODE } |
AES cipher block mode. More... | |
enum | aes_start_mode { AES_MANUAL_START = 0, AES_AUTO_START, AES_IDATAR0_START } |
AES start mode. More... | |
Functions | |
void | aes_disable (void) |
Disable the AES module. More... | |
static void | aes_disable_interrupt (Aes *const p_aes, aes_interrupt_source_t source) |
Disable an AES interrupt. More... | |
void | aes_enable (void) |
Enable the AES module. More... | |
static void | aes_enable_interrupt (Aes *const p_aes, aes_interrupt_source_t source) |
Enable an AES interrupt. More... | |
void | aes_get_config_defaults (struct aes_config *const p_cfg) |
Initializes an AES configuration structure to defaults. More... | |
void | aes_init (Aes *const p_aes, struct aes_config *const p_cfg) |
Initialize the AES module. More... | |
static uint32_t | aes_read_interrupt_mask (Aes *const p_aes) |
Get the AES interrupt mask status. More... | |
static uint32_t | aes_read_interrupt_status (Aes *const p_aes) |
Get the AES interrupt status. More... | |
void | aes_read_output_data (Aes *const p_aes, uint32_t *p_output_data_buffer) |
Read the output data. More... | |
static void | aes_reset (Aes *const p_aes) |
Perform an AES software reset. More... | |
void | aes_set_callback (Aes *const p_aes, aes_interrupt_source_t source, aes_callback_t callback, uint8_t irq_level) |
Set the AES interrupt callback. More... | |
void | aes_set_config (Aes *const p_aes, struct aes_config *const p_cfg) |
Configure the AES module. More... | |
static void | aes_start (Aes *const p_aes) |
Start a manual encryption/decryption process. More... | |
void | aes_write_initvector (Aes *const p_aes, const uint32_t *p_vector) |
Write the initialization vector (for the CBC, CFB, OFB, CTR & GCM cipher modes). More... | |
void | aes_write_input_data (Aes *const p_aes, const uint32_t *p_input_data_buffer) |
Write the input data (four consecutive 32-bit words). More... | |
void | aes_write_key (Aes *const p_aes, const uint32_t *p_key) |
Write the 128/192/256-bit cryptographic key. More... | |
typedef void(* aes_callback_t)(void) |
AES interrupt callback function type.
typedef enum aes_interrupt_source aes_interrupt_source_t |
AES interrupt source type.
enum aes_cfb_size |
AES Cipher FeedBack (CFB) size.
enum aes_encrypt_mode |
enum aes_interrupt_source |
enum aes_key_size |
enum aes_opmode |
enum aes_start_mode |
void aes_disable | ( | void | ) |
Disable the AES module.
References SLEEPMGR_SLEEP_WFI, sleepmgr_unlock_mode(), and sysclk_disable_peripheral_clock().
|
inlinestatic |
Disable an AES interrupt.
[out] | p_aes | Module hardware register base address pointer |
[in] | source | Interrupt source |
void aes_enable | ( | void | ) |
Enable the AES module.
References sleepmgr_lock_mode(), SLEEPMGR_SLEEP_WFI, and sysclk_enable_peripheral_clock().
Referenced by main().
|
inlinestatic |
Enable an AES interrupt.
[out] | p_aes | Module hardware register base address pointer |
[in] | source | Interrupt source |
Referenced by aes_set_callback().
void aes_get_config_defaults | ( | struct aes_config *const | p_cfg | ) |
Initializes an AES configuration structure to defaults.
Initializes the specified AES configuration structure to a set of known default values.
The default configuration is as follows:
[out] | p_cfg | Pointer to an AES configuration structure |
References AES_CFB_SIZE_128, AES_ECB_MODE, AES_ENCRYPTION, AES_KEY_SIZE_128, AES_MANUAL_START, Assert, aes_config::cfb_size, aes_config::encrypt_mode, aes_config::gtag_en, aes_config::key_size, aes_config::lod, aes_config::opmode, aes_config::processing_delay, and aes_config::start_mode.
Referenced by main().
void aes_init | ( | Aes *const | p_aes, |
struct aes_config *const | p_cfg | ||
) |
Initialize the AES module.
[out] | p_aes | Module hardware register base address pointer |
[in] | p_cfg | Pointer to an AES configuration structure |
References aes_reset(), aes_set_config(), Assert, sysclk_disable_peripheral_clock(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
inlinestatic |
Get the AES interrupt mask status.
[in] | p_aes | Module hardware register base address pointer |
Referenced by AES_Handler().
|
inlinestatic |
Get the AES interrupt status.
[in] | p_aes | Module hardware register base address pointer |
Referenced by AES_Handler().
void aes_read_output_data | ( | Aes *const | p_aes, |
uint32_t * | p_output_data_buffer | ||
) |
Read the output data.
[in] | p_aes | Module hardware register base address pointer |
[in] | *p_output_data_buffer | Pointer to an output buffer |
References Assert.
Referenced by aes_callback().
|
inlinestatic |
Perform an AES software reset.
[out] | p_aes | Module hardware register base address pointer |
Referenced by aes_init().
void aes_set_callback | ( | Aes *const | p_aes, |
aes_interrupt_source_t | source, | ||
aes_callback_t | callback, | ||
uint8_t | irq_level | ||
) |
Set the AES interrupt callback.
[out] | p_aes | Module hardware register base address pointer |
[in] | source | Interrupt source |
[in] | callback | Interrupt callback function pointer |
[in] | irq_level | Interrupt priority level |
References aes_callback_pointer, aes_enable_interrupt(), AES_INTERRUPT_DATA_READY, AES_INTERRUPT_UNSPECIFIED_REGISTER_ACCESS, Assert, and irq_register_handler.
Referenced by main().
void aes_set_config | ( | Aes *const | p_aes, |
struct aes_config *const | p_cfg | ||
) |
Configure the AES module.
[out] | p_aes | Module hardware register base address pointer |
[in] | p_cfg | Pointer to an AES configuration structure |
References AES_GCM_MODE, AES_IDATAR0_START, Assert, aes_config::cfb_size, aes_config::encrypt_mode, aes_config::gtag_en, aes_config::key_size, aes_config::lod, aes_config::opmode, aes_config::processing_delay, and aes_config::start_mode.
Referenced by aes_init(), run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
|
inlinestatic |
Start a manual encryption/decryption process.
[out] | p_aes | Module hardware register base address pointer |
void aes_write_initvector | ( | Aes *const | p_aes, |
const uint32_t * | p_vector | ||
) |
Write the initialization vector (for the CBC, CFB, OFB, CTR & GCM cipher modes).
[out] | p_aes | Module hardware register base address pointer |
[in] | p_vector | Pointer to four contiguous 32-bit words |
References Assert.
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), and run_ofb_mode_test().
void aes_write_input_data | ( | Aes *const | p_aes, |
const uint32_t * | p_input_data_buffer | ||
) |
Write the input data (four consecutive 32-bit words).
[out] | p_aes | Module hardware register base address pointer |
[in] | p_input_data_buffer | Pointer to an input data buffer |
References Assert.
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
void aes_write_key | ( | Aes *const | p_aes, |
const uint32_t * | p_key | ||
) |
Write the 128/192/256-bit cryptographic key.
[out] | p_aes | Module hardware register base address pointer |
[in] | p_key | Pointer to 4/6/8 contiguous 32-bit words |
References Assert.
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().