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.

67 lines
1.2 KiB

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