File indexing completed on 2025-01-18 09:55:03
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_GF2_32_H
0007 #define CRYPTOPP_GF2_32_H
0008
0009 #include "cryptlib.h"
0010 #include "secblock.h"
0011 #include "misc.h"
0012
0013 NAMESPACE_BEGIN(CryptoPP)
0014
0015
0016 class GF2_32
0017 {
0018 public:
0019 typedef word32 Element;
0020 typedef int RandomizationParameter;
0021
0022 GF2_32(word32 modulus=0x0000008D) : m_modulus(modulus) {}
0023
0024 Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
0025 {CRYPTOPP_UNUSED(ignored); return rng.GenerateWord32();}
0026
0027 bool Equal(Element a, Element b) const
0028 {return a==b;}
0029
0030 Element Identity() const
0031 {return 0;}
0032
0033 Element Add(Element a, Element b) const
0034 {return a^b;}
0035
0036 Element& Accumulate(Element &a, Element b) const
0037 {return a^=b;}
0038
0039 Element Inverse(Element a) const
0040 {return a;}
0041
0042 Element Subtract(Element a, Element b) const
0043 {return a^b;}
0044
0045 Element& Reduce(Element &a, Element b) const
0046 {return a^=b;}
0047
0048 Element Double(Element a) const
0049 {CRYPTOPP_UNUSED(a); return 0;}
0050
0051 Element MultiplicativeIdentity() const
0052 {return 1;}
0053
0054 Element Multiply(Element a, Element b) const;
0055
0056 Element Square(Element a) const
0057 {return Multiply(a, a);}
0058
0059 bool IsUnit(Element a) const
0060 {return a != 0;}
0061
0062 Element MultiplicativeInverse(Element a) const;
0063
0064 Element Divide(Element a, Element b) const
0065 {return Multiply(a, MultiplicativeInverse(b));}
0066
0067 private:
0068 word32 m_modulus;
0069 };
0070
0071 NAMESPACE_END
0072
0073 #endif