AES-GCM example for SAM.
This file defines a useful set of functions for the AES-GCM mode on SAM devices.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <string.h>
Data Structures | |
struct | gcm_input |
Macros | |
#define | AES_AAD_EFFECTIVE_SIZE 20 |
#define | AES_AAD_SIZE 8 |
#define | AES_IV_SIZE 3 |
#define | AES_KEY_SIZE 8 |
#define | AES_PDATA_EFFECTIVE_SIZE 20 |
#define | AES_PDATA_SIZE 8 |
#define | AES_TAG_SIZE 4 |
Functions | |
static void | aes_read_gcm_auth_tag (Aes *const p_aes, uint32_t *p_auth_tag_buffer) |
Read the GCM Authentication Tag "T" generated in AES_TAGRx registers. More... | |
static void | configure_console (void) |
Configure serial console. More... | |
static void | display_menu (void) |
Display the user menu on the terminal. More... | |
static void | gcm_mode_decryption_test (void) |
GCM mode decryption test. More... | |
static void | gcm_mode_encryption_test (void) |
GCM mode encryption and generate tag automatically. More... | |
int | main (void) |
The main function. More... | |
Variables | |
struct aes_config | g_aes_cfg |
AES configuration. More... | |
struct gcm_input | gcm_input_data |
GCM Input. More... | |
static uint32_t | output_data [AES_PDATA_SIZE] |
static uint32_t | tag_data [AES_TAG_SIZE] |
reference data for AES-GCM mode | |
uint32_t | aes_key [AES_KEY_SIZE] |
uint32_t | aes_iv [AES_IV_SIZE] |
uint32_t | aes_plain_text [AES_PDATA_SIZE] |
uint32_t | aes_aad [AES_AAD_SIZE] |
uint32_t | aes_cipher_text [AES_PDATA_SIZE] |
uint32_t | aes_tag [AES_TAG_SIZE] |
#define AES_AAD_EFFECTIVE_SIZE 20 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_AAD_SIZE 8 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_IV_SIZE 3 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_KEY_SIZE 8 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_PDATA_EFFECTIVE_SIZE 20 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_PDATA_SIZE 8 |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
#define AES_TAG_SIZE 4 |
Referenced by gcm_mode_encryption_test().
|
static |
Read the GCM Authentication Tag "T" generated in AES_TAGRx registers.
p_aes | Base address of the AES instance. |
p_auth_tag_buffer | Pointer to output buffer of 4 contiguous 32-bit words. |
References aes_read_tag().
Referenced by gcm_mode_encryption_test().
|
static |
Configure serial console.
References uart_rs232_options::baudrate, and stdio_serial_init().
Referenced by main().
|
static |
Display the user menu on the terminal.
Referenced by main().
|
static |
GCM mode decryption test.
References gcm_input::aad, gcm_input::aad_len, aes_aad, AES_AAD_EFFECTIVE_SIZE, AES_AAD_SIZE, AES_AUTO_START, AES_CFB_SIZE_128, aes_cipher_text, AES_DECRYPTION, AES_GCM_MODE, aes_iv, AES_IV_SIZE, aes_key, AES_KEY_SIZE, AES_KEY_SIZE_256, AES_PDATA_EFFECTIVE_SIZE, AES_PDATA_SIZE, aes_plain_text, aes_read_interrupt_status(), aes_read_output_data(), aes_set_config(), aes_write_authen_datalength(), aes_write_initvector(), aes_write_input_data(), aes_write_key(), aes_write_pctext_length(), aes_config::cfb_size, aes_config::encrypt_mode, g_aes_cfg, gcm_input_data, aes_config::gtag_en, gcm_input::input, gcm_input::iv, gcm_input::iv_len, gcm_input::key, gcm_input::key_len, aes_config::key_size, aes_config::lod, aes_config::opmode, gcm_input::output, output_data, aes_config::start_mode, gcm_input::tag, tag_data, and gcm_input::text_len.
Referenced by main().
|
static |
GCM mode encryption and generate tag automatically.
References gcm_input::aad, gcm_input::aad_len, aes_aad, AES_AAD_EFFECTIVE_SIZE, AES_AAD_SIZE, AES_AUTO_START, AES_CFB_SIZE_128, aes_cipher_text, AES_ENCRYPTION, AES_GCM_MODE, aes_iv, AES_IV_SIZE, aes_key, AES_KEY_SIZE, AES_KEY_SIZE_256, AES_PDATA_EFFECTIVE_SIZE, AES_PDATA_SIZE, aes_plain_text, aes_read_gcm_auth_tag(), aes_read_interrupt_status(), aes_read_output_data(), aes_set_config(), aes_tag, AES_TAG_SIZE, aes_write_authen_datalength(), aes_write_initvector(), aes_write_input_data(), aes_write_key(), aes_write_pctext_length(), aes_config::cfb_size, aes_config::encrypt_mode, g_aes_cfg, gcm_input_data, aes_config::gtag_en, gcm_input::input, gcm_input::iv, gcm_input::iv_len, gcm_input::key, gcm_input::key_len, aes_config::key_size, aes_config::lod, aes_config::opmode, gcm_input::output, output_data, aes_config::start_mode, gcm_input::tag, tag_data, and gcm_input::text_len.
Referenced by main().
int main | ( | void | ) |
The main function.
References aes_enable(), aes_enable_interrupt(), aes_get_config_defaults(), aes_init(), AES_INTERRUPT_DATA_READY, board_init(), BOARD_NAME, configure_console(), display_menu(), g_aes_cfg, gcm_mode_decryption_test(), gcm_mode_encryption_test(), gcm_input::key, and sysclk_init().
uint32_t aes_aad[AES_AAD_SIZE] |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
uint32_t aes_cipher_text[AES_PDATA_SIZE] |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
uint32_t aes_iv[AES_IV_SIZE] |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
uint32_t aes_key[AES_KEY_SIZE] |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
uint32_t aes_plain_text[AES_PDATA_SIZE] |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
uint32_t aes_tag[AES_TAG_SIZE] |
Referenced by gcm_mode_encryption_test().
struct aes_config g_aes_cfg |
AES configuration.
Referenced by cbc_mode_test(), cfb128_mode_test(), ctr_mode_test(), ecb_mode_test(), gcm_mode_decryption_test(), gcm_mode_encryption_test(), main(), ofb_mode_test(), run_cbc_mode_test(), run_cfb128_mode_test(), run_ctr_mode_test(), run_ecb_mode_test(), and run_ofb_mode_test().
struct gcm_input gcm_input_data |
GCM Input.
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
|
static |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().
|
static |
Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().