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