Counter Strike : Global Offensive Source Code
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.

66 lines
1.2 KiB

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