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.

34 lines
592 B

  1. // gf256.cpp - written and placed in the public domain by Wei Dai
  2. #include "pch.h"
  3. #include "gf256.h"
  4. NAMESPACE_BEGIN(CryptoPP)
  5. GF256::Element GF256::Multiply(Element a, Element b) const
  6. {
  7. word result = 0, t = b;
  8. for (unsigned int i=0; i<8; i++)
  9. {
  10. result <<= 1;
  11. if (result & 0x100)
  12. result ^= m_modulus;
  13. t <<= 1;
  14. if (t & 0x100)
  15. result ^= a;
  16. }
  17. return (GF256::Element) result;
  18. }
  19. GF256::Element GF256::MultiplicativeInverse(Element a) const
  20. {
  21. Element result = a;
  22. for (int i=1; i<7; i++)
  23. result = Multiply(Square(result), a);
  24. return Square(result);
  25. }
  26. NAMESPACE_END