Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.3 KiB

  1. #ifndef CRYPTOPP_GF2_32_H
  2. #define CRYPTOPP_GF2_32_H
  3. #include "cryptlib.h"
  4. #include "secblock.h"
  5. #include "misc.h"
  6. NAMESPACE_BEGIN(CryptoPP)
  7. //! GF(2^32) with polynomial basis
  8. class GF2_32
  9. {
  10. public:
  11. typedef word32 Element;
  12. typedef int RandomizationParameter;
  13. GF2_32(word32 modulus=0x0000008D) : m_modulus(modulus) {}
  14. Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
  15. {CRYPTOPP_UNUSED(ignored); return rng.GenerateWord32();}
  16. bool Equal(Element a, Element b) const
  17. {return a==b;}
  18. Element Identity() const
  19. {return 0;}
  20. Element Add(Element a, Element b) const
  21. {return a^b;}
  22. Element& Accumulate(Element &a, Element b) const
  23. {return a^=b;}
  24. Element Inverse(Element a) const
  25. {return a;}
  26. Element Subtract(Element a, Element b) const
  27. {return a^b;}
  28. Element& Reduce(Element &a, Element b) const
  29. {return a^=b;}
  30. Element Double(Element a) const
  31. {CRYPTOPP_UNUSED(a); return 0;}
  32. Element MultiplicativeIdentity() const
  33. {return 1;}
  34. Element Multiply(Element a, Element b) const;
  35. Element Square(Element a) const
  36. {return Multiply(a, a);}
  37. bool IsUnit(Element a) const
  38. {return a != 0;}
  39. Element MultiplicativeInverse(Element a) const;
  40. Element Divide(Element a, Element b) const
  41. {return Multiply(a, MultiplicativeInverse(b));}
  42. private:
  43. word32 m_modulus;
  44. };
  45. NAMESPACE_END
  46. #endif