Microchip® Advanced Software Framework

drivers/aes/unit_test/unit_test.c File Reference

Unit tests for AES driver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <stdio_serial.h>
#include <string.h>

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
 [module_inst] More...
 
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

struct aes_module aes_instance
struct dma_resource example_resource_rx
struct dma_resource example_resource_tx
volatile bool flag = false

To send values once per button press

struct aes_config g_aes_cfg

AES configuration.

const uint32_t init_vector[4]
Initial value:
= {
0x03020100,
0x07060504,
0x0b0a0908,
0x0f0e0d0c
}

Init vector array for ECB, CBC, CFB128 and OFB mode.

const uint32_t init_vector_ctr[4]
Initial value:
= {
0xf3f2f1f0,
0xf7f6f5f4,
0xfbfaf9f8,
0xfffefdfc
}

Init vector array for CTR mode.

const uint32_t key128[4]
Initial value:
= {
0x16157e2b,
0xa6d2ae28,
0x8815f7ab,
0x3c4fcf09
}

Cipher 128 bits key array.

uint32_t ref_cipher_text_cbc[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0xacab4976,
0x46b21981,
0x9b8ee9ce,
0x7d19e912
}

Reference CBC cipher data.

uint32_t ref_cipher_text_cfb128[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0x2ed93f3b,
0x20ad2db7,
0xf8493433,
0x4afb3ce8
}

Reference CFB128 cipher data.

uint32_t ref_cipher_text_ctr[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0x91614d87,
0x26e320b6,
0x6468ef1b,
0xceb60d99
}

Reference CTR cipher data.

uint32_t ref_cipher_text_ecb[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0xb47bd73a,
0x60367a0d,
0xf3ca9ea8,
0x97ef6624
}

Reference ECB cipher data.

uint32_t ref_cipher_text_ofb[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0x2ed93f3b,
0x20ad2db7,
0xf8493433,
0x4afb3ce8
}

Reference OFB cipher data.

uint32_t ref_plain_text[AES_EXAMPLE_REFBUF_SIZE]
Initial value:
= {
0xe2bec16b,
0x969f402e,
0x117e3de9,
0x2a179373
}

Reference plain data.

DmacDescriptor example_descriptor_rx SECTION_DMAC_DESCRIPTOR
struct usart_module usart_instance

[module_inst]