AVR XMEGA Advanced Encryption Standard (AES) example.
Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
Macros | |
#define | BLOCK_COUNT 9 |
AES data block count. More... | |
#define | BLOCK_LENGTH 16 |
AES data, key block length. More... | |
Functions | |
static void | aes_isr_cbc_decrypt_handler (void) |
AES interrupt handler. More... | |
static void | aes_isr_cbc_encrypt_handler (void) |
AES interrupt handler. More... | |
static void | aes_isr_handler (void) |
AES interrupt handler. More... | |
static bool | aes_lastsubkey_generate (t_key key, t_key last_sub_key) |
Generate AES sub key. More... | |
int | main (void) |
Variables | |
uint8_t | byte_count |
AES block byte count. More... | |
uint8_t | cipher_block_ans [BLOCK_LENGTH *BLOCK_COUNT] |
Variable used to store encryption result from Cipher Block Chaining. More... | |
uint8_t | cipher_text [BLOCK_LENGTH] |
Cipher result from FIPS-197 = 69c4e0d8 6a7b0430 d8cdb780 70b4c55a. More... | |
uint8_t | data_block [BLOCK_LENGTH *BLOCK_COUNT] |
Plain text used during Cipher Block Chaining. More... | |
uint8_t | init [BLOCK_LENGTH] |
Initialization vector used during Cipher Block Chaining (CBC). More... | |
volatile uint8_t | int_end |
Variable used to check AES interrupt. More... | |
uint8_t | key [BLOCK_LENGTH] |
Key from FIPS-197 = 00010203 04050607 08090A0B 0C0D0E0. More... | |
uint8_t | lastsubkey [BLOCK_LENGTH] |
Key used when the AES shall decrypt. More... | |
uint8_t | plain_block_ans [BLOCK_LENGTH *BLOCK_COUNT] |
Variable used to store decryption result from Cipher Block Chaining. More... | |
uint8_t | plain_text [BLOCK_LENGTH] |
Plaintext from FIPS-197 = 00112233 44556677 8899AABB CCDDEEFF. More... | |
uint8_t | single_ans [BLOCK_LENGTH] |
Variable used to store the result from a single AES encryption/decryption. More... | |
bool | success |
Variable used to check AES results. More... | |
#define BLOCK_COUNT 9 |
AES data block count.
Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), and main().
#define BLOCK_LENGTH 16 |
AES data, key block length.
Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_isr_handler(), aes_lastsubkey_generate(), and main().
|
static |
AES interrupt handler.
References AES_AUTO, aes_configure(), AES_DECRYPT, AES_MANUAL, aes_read_outputdata(), aes_set_key(), aes_write_inputdata(), AES_XOR_OFF, AES_XOR_ON, BLOCK_COUNT, BLOCK_LENGTH, byte_count, cipher_block_ans, init, int_end, lastsubkey, and plain_block_ans.
Referenced by main().
|
static |
AES interrupt handler.
References aes_read_outputdata(), aes_set_key(), aes_write_inputdata(), BLOCK_COUNT, BLOCK_LENGTH, byte_count, cipher_block_ans, data_block, int_end, and key.
Referenced by main().
|
static |
AES interrupt handler.
References aes_is_error(), aes_read_outputdata(), BLOCK_LENGTH, int_end, plain_text, single_ans, and success.
Referenced by main().
Generate AES sub key.
key | Pointer to AES key input. |
last_sub_key | Pointer to AES sub key output. |
References aes_clear_error_flag(), aes_clear_interrupt_flag(), aes_configure(), AES_ENCRYPT, aes_get_key(), aes_is_busy(), aes_is_error(), AES_MANUAL, aes_set_key(), aes_software_reset(), aes_start(), AES_XOR_OFF, and BLOCK_LENGTH.
Referenced by main().
int main | ( | void | ) |
References AES_AUTO, aes_configure(), AES_DECRYPT, AES_ENCRYPT, AES_INTLVL_LO, aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_isr_configure(), aes_isr_handler(), aes_lastsubkey_generate(), AES_MANUAL, aes_set_callback(), aes_set_key(), aes_software_reset(), aes_start(), aes_write_inputdata(), AES_XOR_OFF, AES_XOR_ON, BLOCK_COUNT, BLOCK_LENGTH, board_init(), byte_count, cipher_block_ans, cipher_text, cpu_irq_enable, data_block, init, int_end, ioport_set_pin_low(), key, lastsubkey, plain_block_ans, pmic_init(), sleepmgr_enter_sleep(), sleepmgr_init(), success, SYSCLK_AES, sysclk_disable_module(), sysclk_enable_module(), sysclk_init(), and SYSCLK_PORT_GEN.
uint8_t byte_count |
AES block byte count.
Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), hx8347a_copy_pixels_to_screen(), hx8347a_copy_progmem_pixels_to_screen(), and main().
uint8_t cipher_block_ans[BLOCK_LENGTH *BLOCK_COUNT] |
Variable used to store encryption result from Cipher Block Chaining.
Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), and main().
uint8_t cipher_text[BLOCK_LENGTH] |
Cipher result from FIPS-197 = 69c4e0d8 6a7b0430 d8cdb780 70b4c55a.
Referenced by main().
uint8_t data_block[BLOCK_LENGTH *BLOCK_COUNT] |
Plain text used during Cipher Block Chaining.
This data block need to be exactly [BLOCK_LENGTH * BLOCK_COUNT] bytes.
Referenced by aes_isr_cbc_encrypt_handler(), and main().
uint8_t init[BLOCK_LENGTH] |
Initialization vector used during Cipher Block Chaining (CBC).
Referenced by aes_isr_cbc_decrypt_handler(), main(), run_3des_cbc_decryption_test(), run_3des_cbc_encryption_test(), run_des_cbc_decryption_test(), and run_des_cbc_encryption_test().
volatile uint8_t int_end |
Variable used to check AES interrupt.
Referenced by aes_isr_cbc_decrypt_handler(), aes_isr_cbc_encrypt_handler(), aes_isr_handler(), and main().
uint8_t key[BLOCK_LENGTH] |
Key from FIPS-197 = 00010203 04050607 08090A0B 0C0D0E0.
Referenced by aes_dma_input(), aes_isr_cbc_encrypt_handler(), and main().
uint8_t lastsubkey[BLOCK_LENGTH] |
Key used when the AES shall decrypt.
This last subkey is a modified version of the key.
Referenced by aes_isr_cbc_decrypt_handler(), main(), run_aes_decryption_test(), and run_aes_encrypt_and_decrypt_test().
uint8_t plain_block_ans[BLOCK_LENGTH *BLOCK_COUNT] |
Variable used to store decryption result from Cipher Block Chaining.
Referenced by aes_isr_cbc_decrypt_handler(), and main().
uint8_t plain_text[BLOCK_LENGTH] |
Plaintext from FIPS-197 = 00112233 44556677 8899AABB CCDDEEFF.
Referenced by aes_dma_input(), aes_isr_handler(), and main().
uint8_t single_ans[BLOCK_LENGTH] |
Variable used to store the result from a single AES encryption/decryption.
Referenced by aes_dma_output(), aes_isr_handler(), and main().
bool success |
Variable used to check AES results.
Referenced by aes_isr_handler(), main(), run_3des_cbc_decryption_test(), run_3des_cbc_encryption_test(), run_3des_decryption(), run_3des_encryption(), run_3des_encryption_and_decryption_test(), run_aes_decryption_test(), run_aes_encrypt_and_decrypt_test(), run_aes_encryption_test(), run_aes_set_and_get_key_test(), run_des_cbc_decryption_test(), run_des_cbc_encryption_test(), run_des_decryption(), run_des_encryption(), run_des_encryption_and_decryption_test(), run_dma_direction_test(), run_dma_double_buffering_test(), run_dma_memory_copy_burst_length_test(), run_dma_triggered_with_callback(), run_eeprom_atomic_write_test(), run_eeprom_erase_byte_test(), run_eeprom_erase_test(), run_eeprom_read_buffer_test(), run_eeprom_split_write_test(), run_eeprom_write_buffer_test(), run_eeprom_write_test(), test_all_devices(), test_initialization(), test_periodic_timeout(), test_sha204_wakeup(), and test_singleshot_timeout().