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.

46 lines
1.2 KiB

  1. #ifndef CRYPTOPP_BLOWFISH_H
  2. #define CRYPTOPP_BLOWFISH_H
  3. /** \file */
  4. #include "seckey.h"
  5. #include "secblock.h"
  6. NAMESPACE_BEGIN(CryptoPP)
  7. //! _
  8. struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 56>, public FixedRounds<16>
  9. {
  10. static const char *StaticAlgorithmName() {return "Blowfish";}
  11. };
  12. //! <a href="http://www.weidai.com/scan-mirror/cs.html#Blowfish">Blowfish</a>
  13. class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
  14. {
  15. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
  16. {
  17. public:
  18. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  19. void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs &params);
  20. private:
  21. void crypt_block(const word32 in[2], word32 out[2]) const;
  22. static const word32 p_init[ROUNDS+2];
  23. static const word32 s_init[4*256];
  24. FixedSizeSecBlock<word32, ROUNDS+2> pbox;
  25. FixedSizeSecBlock<word32, 4*256> sbox;
  26. };
  27. public:
  28. typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
  29. typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
  30. };
  31. typedef Blowfish::Encryption BlowfishEncryption;
  32. typedef Blowfish::Decryption BlowfishDecryption;
  33. NAMESPACE_END
  34. #endif