blob: 194cd575c19e9edcf42b4a72724726f646b7e76e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <iostream>
#include <cstdint>
//The GF(2^8) field used in AES
class GF28{
int value;
static int reduce(int v,int m);
public:
static const int modulus=0x11b;
static uint8_t multiply(uint8_t x,uint8_t y); //for when the class is overkill
GF28();
explicit GF28(int v);
explicit operator uint8_t() const;
GF28& operator+=(GF28 o);
GF28& operator-=(GF28 o);
GF28& operator<<=(int n); //multiplication by x^n
GF28 operator+(GF28 o) const;
GF28 operator-(GF28 o) const;
GF28 operator*(GF28 o) const;
GF28 operator<<(int n) const; //multiplication by x^n
bool operator==(GF28 o) const;
GF28 inverse() const;
friend std::ostream& operator<<(std::ostream&,GF28);
};
std::ostream& operator<<(std::ostream &os,GF28 p);
|