ATmega644 Smart-Card
Loading...
Searching...
No Matches
aes.h
1
11#ifndef AES_H
12#define AES_H
13
14#include <string.h>
15
16#include "defs.h"
17#include "lut.h"
18#include "aesMath.h"
19
20// Logger
21#ifdef DEBUG
22#include "logger.h"
23#endif
24
25// Masking
26#ifdef MASKING
27#include "masking.h"
28#endif
29
30// Hiding
31#if defined(SHUFFLING) || defined(DUMMY_OPS)
32#include "hiding.h"
33#endif
34
45class AES
46{
47public:
52 AES(const aes_key_t masterKey);
53
59 void decrypt(uint8_t *cipher);
60
61private:
62 // *******************************************************************************
63 // Private Attributes ************************************************************
64 // *******************************************************************************
65 sub_keys_t mSubkeys = {};
66 static uint8_t mRCs[ROUNDS];
67
68 // Logger
69 #ifdef DEBUG
71 #endif
72
73 // Masking
74 #ifdef MASKING
76 sub_keys_t mOriginalSubKeys;
77 #endif
78
79 // Hiding
80 #if defined(SHUFFLING) || defined(DUMMY_OPS)
82 #endif
83
84 #ifdef SHUFFLING
85 uint8_t mShuffledSBoxIndices[STATE_BYTES] = {};
86 #endif
87
88 // ******************************************************************************
89 // Private Methods **************************************************************
90 // ******************************************************************************
91 // Key Schedule *****************************************************************
103 void createKeySchedule(const aes_key_t masterKey, sub_keys_t subKeys) const;
104
105 // Key Addition Layer ***********************************************************
113 void addRoundKey(const aes_key_t roundKey, state_t state);
114
115 // Diffusion Layer **************************************************************
122 void invMixCols(state_t state);
123
130 void invShiftRows(state_t state);
131
132 // Byte Substitution layer ******************************************************
139 void invByteSub(state_t state);
140};
141
142#endif // AES_H
Class providing functionality for 128-bit AES decryption.
Definition aes.h:46
void invShiftRows(state_t state)
Inverse ShiftRows sublayer.
static uint8_t mRCs[ROUNDS]
Array of round coefficients that are used in the key schedule.
Definition aes.h:66
uint8_t mShuffledSBoxIndices[STATE_BYTES]
Array of indices of the S-Box, if shuffling is enabled.
Definition aes.h:85
void createKeySchedule(const aes_key_t masterKey, sub_keys_t subKeys) const
Create the AES key-schedule & store all subkeys in mSubkeys.
sub_keys_t mOriginalSubKeys
Array that contains all original subkeys, if masking is enabled.
Definition aes.h:76
Masking mMasking
Masking object.
Definition aes.h:75
void addRoundKey(const aes_key_t roundKey, state_t state)
Add the key for the current round to state.
sub_keys_t mSubkeys
Array that contains all subkeys.
Definition aes.h:65
Hiding mHiding
Hiding object.
Definition aes.h:81
void decrypt(uint8_t *cipher)
Decrypt a cipher using the 128-bit AES algorithm.
void invByteSub(state_t state)
Inverse Byte Substituion layer.
void invMixCols(state_t state)
Inverse MixColumn sublayer.
AES(const aes_key_t masterKey)
Construct a new AES object.
Logger mLog
Logger.
Definition aes.h:70
Class that implements 2 hiding techniques: dummy-ops & shuffling.
Definition hiding.h:32
Logger class that outputs logs over USART.
Definition logger.h:27
Masking class that provides functionality for masking and unmasking AES-decryption.
Definition masking.h:37