Unit tests for AES driver.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | AES_EXAMPLE_REFBUF_SIZE 4 |
Functions | |
static void | aes_callback (void) |
The AES interrupt call back function. 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_ofb_mode_test (const struct test_case *test) |
Test OFB mode encryption and decryption. More... | |
Variables | |
volatile bool | flag = false |
struct aes_config | g_aes_cfg |
AES configuration. More... | |
static uint32_t | output_data [AES_EXAMPLE_REFBUF_SIZE] |
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 |
|
static |
The AES interrupt call back function.
References aes_read_output_data(), and output_data.
Referenced by main().
int main | ( | void | ) |
Run AES driver unit tests.
References aes_callback(), aes_enable(), aes_get_config_defaults(), aes_init(), AES_INTERRUPT_DATA_READY, aes_set_callback(), uart_rs232_options::baudrate, board_init(), CONF_TEST_BAUDRATE, CONF_TEST_CHAR_LENGTH, CONF_TEST_PARITY, CONF_TEST_STOP_BITS, CONF_TEST_USART, DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, g_aes_cfg, run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), run_ofb_mode_test(), stdio_serial_init(), sysclk_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_DECRYPTION, AES_ENCRYPTION, AES_KEY_SIZE_128, aes_set_config(), aes_write_initvector(), 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_DECRYPTION, AES_ENCRYPTION, AES_KEY_SIZE_128, aes_set_config(), aes_write_initvector(), 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_CTR_MODE, AES_DECRYPTION, AES_ENCRYPTION, AES_KEY_SIZE_128, aes_set_config(), aes_write_initvector(), 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_DECRYPTION, AES_ECB_MODE, AES_ENCRYPTION, AES_KEY_SIZE_128, aes_set_config(), 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 OFB mode encryption and decryption.
test | Current test case. |
References AES_AUTO_START, AES_CFB_SIZE_128, AES_DECRYPTION, AES_ENCRYPTION, AES_KEY_SIZE_128, AES_OFB_MODE, aes_set_config(), aes_write_initvector(), 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().
Referenced by run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
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(), 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(), and run_ofb_mode_test().
|
static |
Referenced by aes_callback(), run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
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().
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 run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().