ATmega644 Smart-Card
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AES Class Reference

Class providing functionality for 128-bit AES decryption. More...

#include <aes.h>

Collaboration diagram for AES:
Collaboration graph

Public Member Functions

 AES (const aes_key_t masterKey)
 Construct a new AES object. More...
 
void decrypt (uint8_t *cipher)
 Decrypt a cipher using the 128-bit AES algorithm. More...
 

Private Member Functions

void createKeySchedule (const aes_key_t masterKey, sub_keys_t subKeys) const
 Create the AES key-schedule & store all subkeys in mSubkeys. More...
 
void addRoundKey (const aes_key_t roundKey, state_t state)
 Add the key for the current round to state. More...
 
void invMixCols (state_t state)
 Inverse MixColumn sublayer. More...
 
void invShiftRows (state_t state)
 Inverse ShiftRows sublayer. More...
 
void invByteSub (state_t state)
 Inverse Byte Substituion layer. More...
 

Private Attributes

sub_keys_t mSubkeys = {}
 Array that contains all subkeys.
 
Logger mLog
 Logger.
 
Masking mMasking
 Masking object.
 
sub_keys_t mOriginalSubKeys
 Array that contains all original subkeys, if masking is enabled.
 
Hiding mHiding
 Hiding object.
 
uint8_t mShuffledSBoxIndices [STATE_BYTES] = {}
 Array of indices of the S-Box, if shuffling is enabled.
 

Static Private Attributes

static uint8_t mRCs [ROUNDS]
 Array of round coefficients that are used in the key schedule.
 

Detailed Description

Class providing functionality for 128-bit AES decryption.

If MASKING is defined, the class also provides functionality for masking and unmasking AES-decryption.

Authors
Philipp Karg (phili.nosp@m.pp.k.nosp@m.arg@t.nosp@m.um.d.nosp@m.e)
Date
23.05.2022

Constructor & Destructor Documentation

◆ AES()

AES::AES ( const aes_key_t  masterKey)

Construct a new AES object.

Parameters
[in]masterKey(const aes_key_t): The master key.

Member Function Documentation

◆ addRoundKey()

void AES::addRoundKey ( const aes_key_t  roundKey,
state_t  state 
)
private

Add the key for the current round to state.

X-OR each byte of state with the corresponding byte in roundKey.

Parameters
[in]roundKey(const aes_key_t): Key for the current round.
[in,out]state( state_t): Current state matrix.

◆ createKeySchedule()

void AES::createKeySchedule ( const aes_key_t  masterKey,
sub_keys_t  subKeys 
) const
private

Create the AES key-schedule & store all subkeys in mSubkeys.

  • The first subkey is masterKey.
  • The remaining subkeys are calculated as defined in the AES standard. See p. 106-108 for reference.
Parameters
[in]masterKey(const aes_key_t): The master key, which is used to create the key schedule.
[out]subKeys( sub_keys_t): Array that contains all subkeys.

◆ decrypt()

void AES::decrypt ( uint8_t *  cipher)

Decrypt a cipher using the 128-bit AES algorithm.

See also
p. 110-112
Parameters
[in,out]cipher(uint8_t *): Cipher to decrypt.

◆ invByteSub()

void AES::invByteSub ( state_t  state)
private

Inverse Byte Substituion layer.

Substitute each byte in state with the corresponding value in #INV_S_BOX.

Parameters
[in,out]state( state_t): Current state matrix.

◆ invMixCols()

void AES::invMixCols ( state_t  state)
private

Inverse MixColumn sublayer.

Do a matrix-matrix multiplication of state & #INV_MIX_COL_MATRIX.

Parameters
[in,out]state( state_t): Current state matrix.

◆ invShiftRows()

void AES::invShiftRows ( state_t  state)
private

Inverse ShiftRows sublayer.

Rotate each row of the state matrix by the row-number to the right.

Parameters
[in,out]state( state_t): Current state matrix.

The documentation for this class was generated from the following file: