ATmega644 Smart-Card
aesMath.h
1 
11 #ifndef AES_MATH_H
12 #define AES_MATH_H
13 
14 #include "defs.h"
15 
24 class AESMath
25 {
26 public:
33  static void reverseArray(uint8_t arr[], uint8_t low, uint8_t high);
34 
40  static void swap(uint8_t &a, uint8_t &b);
41 
48  static void rightRotateArray(uint8_t arr[], uint8_t n, uint8_t k);
49 
57  static uint8_t ffMul(uint8_t x, uint8_t y);
58 private:
59  static constexpr uint8_t IRREDUCIBLE_POLYNOMIAL = 0x1B;
60 
64  AESMath() = default;
65 };
66 
67 #endif // AES_MATH_H
AESMath
Class providing some mathematical functions needed for AES.
Definition: aesMath.h:24
AESMath::AESMath
AESMath()=default
Construct a new AESMath object.
AESMath::rightRotateArray
static void rightRotateArray(uint8_t arr[], uint8_t n, uint8_t k)
Rotate an array arr of length n by k to the right.
AESMath::swap
static void swap(uint8_t &a, uint8_t &b)
Swap the values of 2 integers.
AESMath::IRREDUCIBLE_POLYNOMIAL
static constexpr uint8_t IRREDUCIBLE_POLYNOMIAL
Irreducible polynomial: x^8 + x^4 + x^3 + x + 1.
Definition: aesMath.h:59
AESMath::reverseArray
static void reverseArray(uint8_t arr[], uint8_t low, uint8_t high)
Reverse an array by swapping the lowest and highest element.
AESMath::ffMul
static uint8_t ffMul(uint8_t x, uint8_t y)
Multiply x and y in GF(2^8) Implemented after https://en.wikipedia.org/wiki/Finite_field_arithmetic.