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.

58 lines
1.3 KiB

  1. #ifndef CRYPTOPP_GOST_H
  2. #define CRYPTOPP_GOST_H
  3. /** \file
  4. */
  5. #include "seckey.h"
  6. #include "secblock.h"
  7. NAMESPACE_BEGIN(CryptoPP)
  8. //! _
  9. struct GOST_Info : public FixedBlockSize<8>, public FixedKeyLength<32>
  10. {
  11. static const char *StaticAlgorithmName() {return "GOST";}
  12. };
  13. /// <a href="http://www.weidai.com/scan-mirror/cs.html#GOST">GOST</a>
  14. class GOST : public GOST_Info, public BlockCipherDocumentation
  15. {
  16. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<GOST_Info>
  17. {
  18. public:
  19. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  20. protected:
  21. static void PrecalculateSTable();
  22. static const byte sBox[8][16];
  23. static volatile bool sTableCalculated;
  24. static word32 sTable[4][256];
  25. FixedSizeSecBlock<word32, 8> key;
  26. };
  27. class CRYPTOPP_NO_VTABLE Enc : public Base
  28. {
  29. public:
  30. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  31. };
  32. class CRYPTOPP_NO_VTABLE Dec : public Base
  33. {
  34. public:
  35. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  36. };
  37. public:
  38. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  39. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  40. };
  41. typedef GOST::Encryption GOSTEncryption;
  42. typedef GOST::Decryption GOSTDecryption;
  43. NAMESPACE_END
  44. #endif