-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgf2p8.h
75 lines (55 loc) · 853 Bytes
/
gf2p8.h
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Operations on Galois Field GF(2^8)
*/
#ifndef GF2P8_H
#include <stdio.h>
#include <stdlib.h>
#define GF2P8_ELEMENT 256
#define GF2P8_ORDER 255
typedef unsigned char gf2p8_t;
/*
initialize internal tables
*/
void gf2p8_init(void);
/*
addtion
return x + y
*/
gf2p8_t gf2p8_add(gf2p8_t x, gf2p8_t y);
/*
subtraction
return x - y
*/
gf2p8_t gf2p8_sub(gf2p8_t x, gf2p8_t y);
/*
index
return y where a^y = x
*/
gf2p8_t gf2p8_ind(gf2p8_t x);
/*
power
return a^x
*/
gf2p8_t gf2p8_pow(gf2p8_t x);
/*
multiplication
return x * y
*/
gf2p8_t gf2p8_mul(gf2p8_t x, gf2p8_t y);
/*
reciplocal number
return y where x * y = 1
*/
gf2p8_t gf2p8_recip(gf2p8_t x);
/*
dividing
return x / y
*/
gf2p8_t gf2p8_div(gf2p8_t x, gf2p8_t y);
/*
negate
return -x
*/
gf2p8_t gf2p8_neg(gf2p8_t x);
#define GF2P8_H 1
#endif