#include "aes.h"
Functions | |
void | AddRoundKey (uint8_t *state, uint8_t round) |
Performs Add RoundKey operation. More... | |
aes_ret_status_t | aes_cipher (uint8_t *plainText, uint8_t *state) |
Performs AES-128 Encryption. More... | |
void | aes_init (uint8_t *key) |
Performs Key Expansion. More... | |
aes_ret_status_t | aes_inverse_cipher (uint8_t *cipherText, uint8_t *state) |
Performs AES-128 Decryption. More... | |
void | Inv_AddRoundKey (uint8_t *state, uint8_t round) |
Performs AddRound Key. More... | |
void | Inv_MixColumns (uint8_t *state, uint8_t round) |
Performs Inverse Mix Columns operation. More... | |
void | Inv_ShiftRows_SubBytes (uint8_t *state) |
Performs Inverse of sub bytes (from inverse sub-box) and shift rows operation. More... | |
void | KeyExpansion (uint8_t *round_key, uint8_t *key) |
Performs key expansion to generate key schedule from initial set of Key of 4 words. More... | |
void | MixColumnns (uint8_t *state) |
Performs Mix Columns Operation. More... | |
void | SubBytes_ShiftRows (uint8_t *state) |
Performs Sub Byte (from sbox array) and Shift rows operation. More... | |
uint8_t | xtime (uint8_t value) |
xtime calculation The value is multiplied by 0x02. This is implemented at the byte level as a left shift and XOR with 0x1b if the MSB of the value (before) shifting is 1. More... | |
Variables | |
bool | aes_key_ready = false |
uint8_t | inv_sbox [256] |
uint8_t | key_schedule [AES_KEY_SCHEDULE_SIZE] |
uint8_t | RCon [11] |
uint8_t | sbox [256] |
Support and FAQ: visit Microchip Support More... | |
void AddRoundKey | ( | uint8_t * | state, |
uint8_t | round | ||
) |
Performs Add RoundKey operation.
state | variable to store the intermediate result of the algorithm |
References key_schedule.
Referenced by aes_cipher().
aes_ret_status_t aes_cipher | ( | uint8_t * | plainText, |
uint8_t * | state | ||
) |
Performs AES-128 Encryption.
plainText | Input plain text block |
state | Variable to store the intermediate result |
ERR_NO_KEY | if key expansion is not done via aes_init() |
STATUS_OKAY | if aes_init() is called before this function. |
References AddRoundKey(), AES_BLOCK_SIZE, aes_key_ready, ERR_NO_KEY, key_schedule, MixColumnns(), STATUS_OKAY, and SubBytes_ShiftRows().
Referenced by cbc_encrypt(), cfb_decrypt(), cfb_encrypt(), ctr_encrypt_decrypt(), ecb_encrypt(), ofb_decrypt(), and ofb_encrypt().
void aes_init | ( | uint8_t * | key | ) |
Performs Key Expansion.
key | Initial Key vectors received from user |
References aes_key_ready, key_schedule, and KeyExpansion().
Referenced by main().
aes_ret_status_t aes_inverse_cipher | ( | uint8_t * | cipherText, |
uint8_t * | state | ||
) |
Performs AES-128 Decryption.
cipherText | Input cipher text block |
state | Variable to store the intermediate result |
ERR_NO_KEY | if key expansion is not done vis aes_init() |
STATUS_OKAY | if aes_init() is called before this function. |
References AES_BLOCK_SIZE, aes_key_ready, ERR_NO_KEY, Inv_AddRoundKey(), Inv_MixColumns(), Inv_ShiftRows_SubBytes(), key_schedule, and STATUS_OKAY.
Referenced by cbc_decrypt(), and ecb_decrypt().
void Inv_AddRoundKey | ( | uint8_t * | state, |
uint8_t | round | ||
) |
Performs AddRound Key.
state | variable to store the intermediate result of the algorithm |
References key_schedule.
Referenced by aes_inverse_cipher().
void Inv_MixColumns | ( | uint8_t * | state, |
uint8_t | round | ||
) |
Performs Inverse Mix Columns operation.
state | variable to store the intermediate result of the algorithm |
Number | of current ongoing round in AES algorithm |
References xtime().
Referenced by aes_inverse_cipher().
void Inv_ShiftRows_SubBytes | ( | uint8_t * | state | ) |
Performs Inverse of sub bytes (from inverse sub-box) and shift rows operation.
Performs Inverse of sub bytes and shift rows operation.
state | variable to store the intermediate result of the algorithm |
References inv_sbox.
Referenced by aes_inverse_cipher().
void KeyExpansion | ( | uint8_t * | round_key, |
uint8_t * | key | ||
) |
Performs key expansion to generate key schedule from initial set of Key of 4 words.
round_key | Holds the pointer to store key schedule |
key | Initial Key received from the user |
References AES_NUM_OF_ROUNDS, RCon, and sbox.
Referenced by aes_init().
void MixColumnns | ( | uint8_t * | state | ) |
Performs Mix Columns Operation.
state | variable to store the intermediate result of the algorithm |
References xtime().
Referenced by aes_cipher().
void SubBytes_ShiftRows | ( | uint8_t * | state | ) |
Performs Sub Byte (from sbox array) and Shift rows operation.
Performs Sub Byte and Shift rows operation.
state | variable to store the intermediate result of the algorithm |
References sbox.
Referenced by aes_cipher().
uint8_t xtime | ( | uint8_t | value | ) |
xtime calculation The value is multiplied by 0x02. This is implemented at the byte level as a left shift and XOR with 0x1b if the MSB of the value (before) shifting is 1.
value | Value for which multiplication to be done |
Referenced by Inv_MixColumns(), and MixColumnns().
Referenced by aes_cipher(), aes_init(), and aes_inverse_cipher().
uint8_t inv_sbox[256] |
Referenced by Inv_ShiftRows_SubBytes().
uint8_t key_schedule[AES_KEY_SCHEDULE_SIZE] |
Referenced by AddRoundKey(), aes_cipher(), aes_init(), aes_inverse_cipher(), and Inv_AddRoundKey().
uint8_t RCon[11] |
Referenced by KeyExpansion().
uint8_t sbox[256] |
Support and FAQ: visit Microchip Support
Referenced by KeyExpansion(), and SubBytes_ShiftRows().