00001 #ifndef CRYPTOPP_GF256_H
00002 #define CRYPTOPP_GF256_H
00003
00004 #include "cryptlib.h"
00005 #include "misc.h"
00006
00007 NAMESPACE_BEGIN(CryptoPP)
00008
00009
00010 class GF256
00011 {
00012 public:
00013 typedef byte Element;
00014 typedef int RandomizationParameter;
00015
00016 GF256(byte modulus) : m_modulus(modulus) {}
00017
00018 Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
00019 {CRYPTOPP_UNUSED(ignored); return rng.GenerateByte();}
00020
00021 bool Equal(Element a, Element b) const
00022 {return a==b;}
00023
00024 Element Zero() const
00025 {return 0;}
00026
00027 Element Add(Element a, Element b) const
00028 {return a^b;}
00029
00030 Element& Accumulate(Element &a, Element b) const
00031 {return a^=b;}
00032
00033 Element Inverse(Element a) const
00034 {return a;}
00035
00036 Element Subtract(Element a, Element b) const
00037 {return a^b;}
00038
00039 Element& Reduce(Element &a, Element b) const
00040 {return a^=b;}
00041
00042 Element Double(Element a) const
00043 {CRYPTOPP_UNUSED(a); return 0;}
00044
00045 Element One() const
00046 {return 1;}
00047
00048 Element Multiply(Element a, Element b) const;
00049
00050 Element Square(Element a) const
00051 {return Multiply(a, a);}
00052
00053 bool IsUnit(Element a) const
00054 {return a != 0;}
00055
00056 Element MultiplicativeInverse(Element a) const;
00057
00058 Element Divide(Element a, Element b) const
00059 {return Multiply(a, MultiplicativeInverse(b));}
00060
00061 private:
00062 word m_modulus;
00063 };
00064
00065 NAMESPACE_END
00066
00067 #endif