Microchip® Advanced Software Framework

aes.h File Reference

SAM Advanced Encryption Standard driver.

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

#include <compiler.h>
#include <system.h>

Data Structures

struct  aes_config
 AES Configuration structure. More...
 

Macros

Module Status Flags

AES status flags, returned by aes_get_status() and cleared by aes_clear_status().

#define AES_ENCRYPTION_COMPLETE   (1UL << 0)
 AES encryption complete. More...
 
#define AES_GF_MULTI_COMPLETE   (1UL << 1)
 AES GF multiplication complete. More...
 

Enumerations

enum  aes_cfb_size {
  AES_CFB_SIZE_128 = 0,
  AES_CFB_SIZE_64,
  AES_CFB_SIZE_32,
  AES_CFB_SIZE_16,
  AES_CFB_SIZE_8
}
 AES Cipher FeedBack (CFB) size. More...
 
enum  aes_countermeature_type {
  AES_COUNTERMEASURE_TYPE_disabled = 0x0,
  AES_COUNTERMEASURE_TYPE_1 = 0x01,
  AES_COUNTERMEASURE_TYPE_2 = 0x02,
  AES_COUNTERMEASURE_TYPE_3 = 0x04,
  AES_COUNTERMEASURE_TYPE_4 = 0x08,
  AES_COUNTERMEASURE_TYPE_ALL = 0x0F
}
 AES countermeasure type. More...
 
enum  aes_encrypt_mode {
  AES_DECRYPTION = 0,
  AES_ENCRYPTION
}
 AES processing mode. More...
 
enum  aes_key_size {
  AES_KEY_SIZE_128 = 0,
  AES_KEY_SIZE_192,
  AES_KEY_SIZE_256
}
 AES cryptographic key size. More...
 
enum  aes_operation_mode {
  AES_ECB_MODE = 0,
  AES_CBC_MODE,
  AES_OFB_MODE,
  AES_CFB_MODE,
  AES_CTR_MODE,
  AES_CCM_MODE,
  AES_GCM_MODE
}
 AES operation mode. More...
 
enum  aes_start_mode {
  AES_MANUAL_START = 0,
  AES_AUTO_START
}
 AES start mode. More...
 

Functions

Configuration and Initialization
void aes_get_config_defaults (struct aes_config *const config)
 Initializes an AES configuration structure to defaults. More...
 
void aes_set_config (struct aes_module *const module, Aes *const hw, struct aes_config *const config)
 Configure the AES module. More...
 
void aes_init (struct aes_module *const module, Aes *const hw, struct aes_config *const config)
 Initialize the AES module. More...
 
Start, Enable, and Write
static void aes_start (struct aes_module *const module)
 Start a manual encryption/decryption process. More...
 
static void aes_set_new_message (struct aes_module *const module)
 Notifies the module that the next input data block is the beginning of a new message. More...
 
static void aes_clear_new_message (struct aes_module *const module)
 Clear the indication of the beginning for a new message. More...
 
void aes_enable (struct aes_module *const module)
 Enable the AES module. More...
 
void aes_disable (struct aes_module *const module)
 Disable the AES module. More...
 
void aes_write_key (struct aes_module *const module, const uint32_t *key)
 Write the 128/192/256-bit cryptographic key. More...
 
void aes_write_init_vector (struct aes_module *const module, const uint32_t *vector)
 Write the initialization vector (for the CBC, CFB, OFB, CTR, and GCM cipher modes). More...
 
void aes_write_input_data (struct aes_module *const module, const uint32_t *p_input_data_buffer)
 Write the input data (four consecutive 32-bit words). More...
 
void aes_read_output_data (struct aes_module *const module, uint32_t *p_output_data_buffer)
 Read the output data. More...
 
static void aes_write_random_seed (struct aes_module *const module, uint32_t seed)
 Write AES random seed. More...
 
Status Management
static uint32_t aes_get_status (struct aes_module *const module)
 Retrieves the current module status. More...
 
static void aes_clear_status (struct aes_module *const module, const uint32_t status_flags)
 Clears a module status flag. More...
 
Galois Counter Mode
static uint32_t aes_gcm_read_ghash (struct aes_module *const module, uint32_t id)
 Get the AES GCM Hash Value. More...
 
static void aes_gcm_write_ghash (struct aes_module *const module, uint32_t id, uint32_t ghash)
 Set the AES GCM Hash Value. More...
 
static uint32_t aes_gcm_read_hash_key (struct aes_module *const module, uint32_t id)
 Get AES GCM Hash key. More...
 
static void aes_gcm_write_hash_key (struct aes_module *const module, uint32_t id, uint32_t key)
 Set the AES GCM Hash key. More...
 
static uint32_t aes_gcm_read_cipher_len (struct aes_module *const module)
 Get the AES GCM cipher length. More...
 
static void aes_gcm_write_cipher_len (struct aes_module *const module, uint32_t len)
 Set the AES GCM cipher length. More...
 
static void aes_gcm_set_end_message_status (struct aes_module *const module)
 Set GCM end of input message status. More...
 
static void aes_gcm_clear_end_message_status (struct aes_module *const module)
 Clear GCM end of input message status. More...
 
static void aes_gcm_set_gf_multiplication (struct aes_module *const module)
 Set GF multiplication of GCM mode. More...