Microchip® Advanced Software Framework

aes_example1.c File Reference

AVR XMEGA Advanced Encryption Standard (AES) example.

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

#include <asf.h>

Macros

#define BLOCK_LENGTH   16
 AES data, key block length. More...
 

Functions

static bool aes_lastsubkey_generate (t_key key, t_key last_sub_key)
 Generate AES sub key. More...
 
int main (void)
 

Variables

uint8_t cipher_text [BLOCK_LENGTH]
 Cipher result from FIPS-197 = 69c4e0d8 6a7b0430 d8cdb780 70b4c55a. More...
 
uint8_t key [BLOCK_LENGTH]
 Key from FIPS-197 = 00010203 04050607 08090A0B 0C0D0E0. More...
 
uint8_t lastsubkey [BLOCK_LENGTH]
 Key used when the AES shall decrypt. More...
 
uint8_t plain_text [BLOCK_LENGTH]
 Plaintext from FIPS-197 = 00112233 44556677 8899AABB CCDDEEFF. More...
 
uint8_t single_ans [BLOCK_LENGTH]
 Variable used to store the result from a single AES encryption/decryption. More...
 
bool success
 Variable used to check AES results. More...
 

#define BLOCK_LENGTH   16

AES data, key block length.

Referenced by aes_lastsubkey_generate(), and main().

static bool aes_lastsubkey_generate ( t_key  key,
t_key  last_sub_key 
)
static

Generate AES sub key.

Note
Get AES sub key by encryption of dummy data.
Parameters
keyPointer to AES key input.
last_sub_keyPointer to AES sub key output.

References aes_clear_error_flag(), aes_clear_interrupt_flag(), aes_configure(), AES_ENCRYPT, aes_get_key(), aes_is_busy(), aes_is_error(), AES_MANUAL, aes_set_key(), aes_software_reset(), aes_start(), AES_XOR_OFF, and BLOCK_LENGTH.

Referenced by main().

uint8_t cipher_text[BLOCK_LENGTH]
Initial value:
= {
0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a}

Cipher result from FIPS-197 = 69c4e0d8 6a7b0430 d8cdb780 70b4c55a.

uint8_t key[BLOCK_LENGTH]
Initial value:
= {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}

Key from FIPS-197 = 00010203 04050607 08090A0B 0C0D0E0.

uint8_t lastsubkey[BLOCK_LENGTH]

Key used when the AES shall decrypt.

This last subkey is a modified version of the key.

uint8_t plain_text[BLOCK_LENGTH]
Initial value:
= {
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}

Plaintext from FIPS-197 = 00112233 44556677 8899AABB CCDDEEFF.

uint8_t single_ans[BLOCK_LENGTH]

Variable used to store the result from a single AES encryption/decryption.

bool success

Variable used to check AES results.