Microchip® Advanced Software Framework

gcm_example.c File Reference

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
#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

static void aes_read_gcm_auth_tag ( Aes *const  p_aes,
uint32_t *  p_auth_tag_buffer 
)
static

Read the GCM Authentication Tag "T" generated in AES_TAGRx registers.

Parameters
p_aesBase address of the AES instance.
p_auth_tag_bufferPointer to output buffer of 4 contiguous 32-bit words.

References aes_read_tag().

Referenced by gcm_mode_encryption_test().

static void configure_console ( void  )
static

Configure serial console.

References uart_rs232_options::baudrate, and stdio_serial_init().

Referenced by main().

static void display_menu ( void  )
static

Display the user menu on the terminal.

Referenced by main().

uint32_t aes_aad[AES_AAD_SIZE]
Initial value:
= {
0xa259d87b,
0x211a9647,
0x0e383b82,
0x50b6e89f,
0xd361ba82
}

Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().

uint32_t aes_cipher_text[AES_PDATA_SIZE]
Initial value:
= {
0xb42720ce,
0x5232847a,
0x83653401,
0x0ffd754d,
0x2e752907
}

Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().

uint32_t aes_iv[AES_IV_SIZE]
Initial value:
= {
0x63a3d1db,
0xb4b72460,
0x6f7dda02
}

Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().

uint32_t aes_key[AES_KEY_SIZE]
Initial value:
= {
0xcf76d4f8,
0x6cea46d6,
0x1ccb8423,
0x5d19d627,
0xf3a9f1fe,
0x218d9c7b,
0xf8219ca7,
0x89d290cb
}

Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().

uint32_t aes_plain_text[AES_PDATA_SIZE]
Initial value:
= {
0xcf61ae90,
0x4cbdae7b,
0xc594e4ad,
0x70ae294a,
0x71ec9a26
}

Referenced by gcm_mode_decryption_test(), and gcm_mode_encryption_test().

uint32_t aes_tag[AES_TAG_SIZE]
Initial value:
= {
0x3883d8ac,
0xde0eab37,
0x8d74f484,
0x159c89a8
}

Referenced by gcm_mode_encryption_test().

struct gcm_input gcm_input_data
uint32_t output_data[AES_PDATA_SIZE]
static
uint32_t tag_data[AES_TAG_SIZE]
static