Crypto++
8.3
Free C++ class library of cryptographic schemes
gf256.cpp
1
// gf256.cpp - originally written and placed in the public domain by Wei Dai
2
3
#include "
pch.h
"
4
#include "
gf256.h
"
5
6
NAMESPACE_BEGIN(
CryptoPP
)
7
8
GF256::Element GF256::Multiply(Element a, Element b)
const
9
{
10
word result = 0, t = b;
11
12
for
(
unsigned
int
i=0; i<8; i++)
13
{
14
result <<= 1;
15
if
(result & 0x100)
16
result ^= m_modulus;
17
18
t <<= 1;
19
if
(t & 0x100)
20
result ^= a;
21
}
22
23
return
(GF256::Element) result;
24
}
25
26
GF256::Element GF256::MultiplicativeInverse(Element a)
const
27
{
28
Element result = a;
29
for
(
int
i=1; i<7; i++)
30
result = Multiply(
Square
(result), a);
31
return
Square
(result);
32
}
33
34
NAMESPACE_END
Square
Square block cipher.
Definition:
square.h:25
pch.h
Precompiled header file.
gf256.h
Classes and functions for schemes over GF(256)
CryptoPP
Crypto++ library namespace.
Generated on Fri Dec 25 2020 17:16:54 for Crypto++ by
1.8.20