3.8.3.1.3 Workflow
- Define sample data from NIST-800-38A appendix F for ECB mode.
#define AES_EXAMPLE_REFBUF_SIZE 4uint32_t ref_plain_text[AES_EXAMPLE_REFBUF_SIZE] = {0xe2bec16b,0x969f402e,0x117e3de9,0x2a179373};uint32_t ref_cipher_text_ecb[AES_EXAMPLE_REFBUF_SIZE] = {0xb47bd73a,0x60367a0d,0xf3ca9ea8,0x97ef6624};constuint32_t key128[4] = {0x16157e2b,0xa6d2ae28,0x8815f7ab,0x3c4fcf09}; - Create related module variable and software instance structure.
/* Output data array */staticuint32_t output_data[AES_EXAMPLE_REFBUF_SIZE];/* State indicate */volatileboolstate =false;structaes_config g_aes_cfg;structaes_module aes_instance;structusart_module usart_instance; - Create DMA resource struct and descriptor.
structdma_resource example_resource_tx;structdma_resource example_resource_rx;COMPILER_ALIGNED(16)DmacDescriptor example_descriptor_tx SECTION_DMAC_DESCRIPTOR;DmacDescriptor example_descriptor_rx SECTION_DMAC_DESCRIPTOR; - Configure, initialize, and enable AES module.
- Configuration AES DMA module, which can be used for AES.
/* Configure AES DMA and enable callback */configure_dma_aes_wr();configure_dma_aes_rd();dma_register_callback(&example_resource_tx, transfer_tx_rx_done,DMA_CALLBACK_TRANSFER_DONE);dma_enable_callback(&example_resource_tx, DMA_CALLBACK_TRANSFER_DONE);dma_register_callback(&example_resource_rx, transfer_tx_rx_done,DMA_CALLBACK_TRANSFER_DONE);dma_enable_callback(&example_resource_rx, DMA_CALLBACK_TRANSFER_DONE); - Configuration AES struct, which can be filled out to adjust the configuration of a physical AES peripheral.
aes_get_config_defaults(&g_aes_cfg); - Initialize the AES configuration struct with the module's default values.
aes_init(&aes_instance,AES, &g_aes_cfg); - Enable the AES module.
aes_enable(&aes_instance);
