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