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.

56 lines
1.4 KiB

  1. // rc6.h - written and placed in the public domain by Wei Dai
  2. //! \file rc6.h
  3. //! \brief Classes for the RC6 block cipher
  4. #ifndef CRYPTOPP_RC6_H
  5. #define CRYPTOPP_RC6_H
  6. #include "seckey.h"
  7. #include "secblock.h"
  8. NAMESPACE_BEGIN(CryptoPP)
  9. //! _
  10. struct RC6_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 255>, public VariableRounds<20>
  11. {
  12. static const char *StaticAlgorithmName() {return "RC6";}
  13. typedef word32 RC6_WORD;
  14. };
  15. /// <a href="http://www.weidai.com/scan-mirror/cs.html#RC6">RC6</a>
  16. class RC6 : public RC6_Info, public BlockCipherDocumentation
  17. {
  18. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC6_Info>
  19. {
  20. public:
  21. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  22. protected:
  23. unsigned int r; // number of rounds
  24. SecBlock<RC6_WORD> sTable; // expanded key table
  25. };
  26. class CRYPTOPP_NO_VTABLE Enc : public Base
  27. {
  28. public:
  29. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  30. };
  31. class CRYPTOPP_NO_VTABLE Dec : public Base
  32. {
  33. public:
  34. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  35. };
  36. public:
  37. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  38. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  39. };
  40. typedef RC6::Encryption RC6Encryption;
  41. typedef RC6::Decryption RC6Decryption;
  42. NAMESPACE_END
  43. #endif