Unit tests for AES driver.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | AES_EXAMPLE_REFBUF_SIZE 4 |
Functions | |
static void | configure_dma_aes_rd (void) |
Configure DMA AES DATA read trigger. More... | |
static void | configure_dma_aes_wr (void) |
Configure DMA AES DATA write trigger. More... | |
static void | configure_usart (void) |
Configure usart. More... | |
int | main (void) |
Run AES driver unit tests. More... | |
static void | run_cbc_mode_test (const struct test_case *test) |
Test CBC mode encryption and decryption. More... | |
static void | run_cfb128_mode_test (const struct test_case *test) |
Test CFB128 mode encryption and decryption. More... | |
static void | run_ctr_mode_test (const struct test_case *test) |
Test CTR mode encryption and decryption. More... | |
static void | run_ecb_mode_test (const struct test_case *test) |
Test ECB mode encryption and decryption. More... | |
static void | run_ecb_mode_test_dma (const struct test_case *test) |
Test ECB mode encryption with DMA. More... | |
static void | run_ofb_mode_test (const struct test_case *test) |
Test OFB mode encryption and decryption. More... | |
Variables | |
struct aes_module | aes_instance |
struct dma_resource | example_resource_rx |
struct dma_resource | example_resource_tx |
volatile bool | flag = false |
struct aes_config | g_aes_cfg |
AES configuration. More... | |
static uint32_t | output_data [AES_EXAMPLE_REFBUF_SIZE] |
DmacDescriptor example_descriptor_tx | SECTION_DMAC_DESCRIPTOR |
struct usart_module | usart_instance |
sample data from NIST-800-38A appendix F | |
uint32_t | ref_plain_text [AES_EXAMPLE_REFBUF_SIZE] |
Reference plain data. More... | |
uint32_t | ref_cipher_text_ecb [AES_EXAMPLE_REFBUF_SIZE] |
Reference ECB cipher data. More... | |
uint32_t | ref_cipher_text_cbc [AES_EXAMPLE_REFBUF_SIZE] |
Reference CBC cipher data. More... | |
uint32_t | ref_cipher_text_cfb128 [AES_EXAMPLE_REFBUF_SIZE] |
Reference CFB128 cipher data. More... | |
uint32_t | ref_cipher_text_ofb [AES_EXAMPLE_REFBUF_SIZE] |
Reference OFB cipher data. More... | |
uint32_t | ref_cipher_text_ctr [AES_EXAMPLE_REFBUF_SIZE] |
Reference CTR cipher data. More... | |
const uint32_t | key128 [4] |
Cipher 128 bits key array. More... | |
const uint32_t | init_vector [4] |
Init vector array for ECB, CBC, CFB128 and OFB mode. More... | |
const uint32_t | init_vector_ctr [4] |
Init vector array for CTR mode. More... | |
#define AES_EXAMPLE_REFBUF_SIZE 4 |
Referenced by configure_dma_aes_rd(), and configure_dma_aes_wr().
|
static |
Configure DMA AES DATA read trigger.
References AES_EXAMPLE_REFBUF_SIZE, dma_descriptor_config::beat_size, dma_descriptor_config::block_transfer_count, dma_descriptor_config::destination_address, dma_add_descriptor(), dma_allocate(), DMA_BEAT_SIZE_WORD, dma_descriptor_create(), dma_descriptor_get_config_defaults(), dma_get_config_defaults(), DMA_TRIGGER_ACTION_BLOCK, example_resource_rx, output_data, dma_resource_config::peripheral_trigger, dma_descriptor_config::source_address, dma_descriptor_config::src_increment_enable, and dma_resource_config::trigger_action.
Referenced by run_ecb_mode_test_dma().
|
static |
Configure DMA AES DATA write trigger.
References AES_EXAMPLE_REFBUF_SIZE, dma_descriptor_config::beat_size, dma_descriptor_config::block_transfer_count, dma_descriptor_config::destination_address, dma_add_descriptor(), dma_allocate(), DMA_BEAT_SIZE_WORD, dma_descriptor_create(), dma_descriptor_get_config_defaults(), dma_get_config_defaults(), DMA_TRIGGER_ACTION_BLOCK, dma_descriptor_config::dst_increment_enable, example_resource_tx, dma_resource_config::peripheral_trigger, ref_plain_text, dma_descriptor_config::source_address, and dma_resource_config::trigger_action.
Referenced by run_ecb_mode_test_dma().
|
static |
Configure usart.
References usart_config::baudrate, EDBG_CDC_MODULE, EDBG_CDC_SERCOM_MUX_SETTING, EDBG_CDC_SERCOM_PINMUX_PAD0, EDBG_CDC_SERCOM_PINMUX_PAD1, EDBG_CDC_SERCOM_PINMUX_PAD2, EDBG_CDC_SERCOM_PINMUX_PAD3, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), usart_get_config_defaults(), and usart_instance.
Referenced by main().
int main | ( | void | ) |
Run AES driver unit tests.
References aes_enable(), aes_get_config_defaults(), aes_init(), aes_instance, configure_usart(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, delay_init(), g_aes_cfg, run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), run_ecb_mode_test_dma(), run_ofb_mode_test(), system_init(), and test_suite_run().
|
static |
Test CBC mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CBC_MODE, AES_CFB_SIZE_128, aes_clear_new_message(), AES_DECRYPTION, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, aes_read_output_data(), aes_set_config(), aes_set_new_message(), aes_write_init_vector(), aes_write_input_data(), aes_write_key(), aes_config::cfb_size, delay_ms, aes_config::encrypt_mode, flag, g_aes_cfg, init_vector, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_cbc, ref_plain_text, aes_config::start_mode, and test_assert_true.
Referenced by main().
|
static |
Test CFB128 mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CFB_MODE, AES_CFB_SIZE_128, aes_clear_new_message(), AES_DECRYPTION, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, aes_read_output_data(), aes_set_config(), aes_set_new_message(), aes_write_init_vector(), aes_write_input_data(), aes_write_key(), aes_config::cfb_size, delay_ms, aes_config::encrypt_mode, flag, g_aes_cfg, init_vector, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_cfb128, ref_plain_text, aes_config::start_mode, and test_assert_true.
Referenced by main().
|
static |
Test CTR mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CFB_SIZE_128, aes_clear_new_message(), AES_CTR_MODE, AES_DECRYPTION, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, aes_read_output_data(), aes_set_config(), aes_set_new_message(), aes_write_init_vector(), aes_write_input_data(), aes_write_key(), aes_config::cfb_size, delay_ms, aes_config::encrypt_mode, flag, g_aes_cfg, init_vector_ctr, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_ctr, ref_plain_text, aes_config::start_mode, and test_assert_true.
Referenced by main().
|
static |
Test ECB mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CFB_SIZE_128, aes_clear_new_message(), AES_DECRYPTION, AES_ECB_MODE, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, aes_read_output_data(), aes_set_config(), aes_set_new_message(), aes_write_input_data(), aes_write_key(), aes_config::cfb_size, delay_ms, aes_config::encrypt_mode, flag, g_aes_cfg, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_ecb, ref_plain_text, aes_config::start_mode, and test_assert_true.
Referenced by main().
|
static |
Test ECB mode encryption with DMA.
test | Current test case. |
References AES_AUTO_START, AES_CFB_SIZE_128, aes_clear_new_message(), AES_ECB_MODE, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, aes_set_config(), aes_set_new_message(), aes_write_key(), aes_config::cfb_size, configure_dma_aes_rd(), configure_dma_aes_wr(), delay_ms, dma_start_transfer_job(), aes_config::encrypt_mode, example_resource_rx, example_resource_tx, flag, g_aes_cfg, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_ecb, aes_config::start_mode, and test_assert_true.
Referenced by main().
|
static |
Test OFB mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CFB_SIZE_128, aes_clear_new_message(), AES_DECRYPTION, AES_ENCRYPTION, aes_instance, AES_KEY_SIZE_128, AES_OFB_MODE, aes_read_output_data(), aes_set_config(), aes_set_new_message(), aes_write_init_vector(), aes_write_input_data(), aes_write_key(), aes_config::cfb_size, delay_ms, aes_config::encrypt_mode, flag, g_aes_cfg, init_vector, key128, aes_config::key_size, aes_config::lod, aes_config::opmode, output_data, ref_cipher_text_ofb, ref_plain_text, aes_config::start_mode, and test_assert_true.
Referenced by main().
struct aes_module aes_instance |
struct dma_resource example_resource_rx |
Referenced by configure_dma_aes_rd(), and run_ecb_mode_test_dma().
struct dma_resource example_resource_tx |
Referenced by configure_dma_aes_wr(), and run_ecb_mode_test_dma().
struct aes_config g_aes_cfg |
AES configuration.
Referenced by main(), run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), run_ecb_mode_test_dma(), and run_ofb_mode_test().
const uint32_t init_vector[4] |
Init vector array for ECB, CBC, CFB128 and OFB mode.
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), and run_ofb_mode_test().
const uint32_t init_vector_ctr[4] |
Init vector array for CTR mode.
Referenced by run_ctr_mode_test().
const uint32_t key128[4] |
Cipher 128 bits key array.
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), run_ecb_mode_test_dma(), and run_ofb_mode_test().
|
static |
uint32_t ref_cipher_text_cbc[AES_EXAMPLE_REFBUF_SIZE] |
Reference CBC cipher data.
Referenced by run_cbc_mode_test().
uint32_t ref_cipher_text_cfb128[AES_EXAMPLE_REFBUF_SIZE] |
Reference CFB128 cipher data.
Referenced by run_cfb128_mode_test().
uint32_t ref_cipher_text_ctr[AES_EXAMPLE_REFBUF_SIZE] |
Reference CTR cipher data.
Referenced by run_ctr_mode_test().
uint32_t ref_cipher_text_ecb[AES_EXAMPLE_REFBUF_SIZE] |
Reference ECB cipher data.
Referenced by run_ecb_mode_test(), and run_ecb_mode_test_dma().
uint32_t ref_cipher_text_ofb[AES_EXAMPLE_REFBUF_SIZE] |
Reference OFB cipher data.
Referenced by run_ofb_mode_test().
uint32_t ref_plain_text[AES_EXAMPLE_REFBUF_SIZE] |
Reference plain data.
Referenced by configure_dma_aes_wr(), run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
DmacDescriptor example_descriptor_rx SECTION_DMAC_DESCRIPTOR |
struct usart_module usart_instance |
Referenced by configure_usart().