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. // rc5.h - written and placed in the public domain by Wei Dai
  2. //! \file rc5.h
  3. //! \brief Classes for the RC5 block cipher
  4. #ifndef CRYPTOPP_RC5_H
  5. #define CRYPTOPP_RC5_H
  6. #include "seckey.h"
  7. #include "secblock.h"
  8. NAMESPACE_BEGIN(CryptoPP)
  9. //! _
  10. struct RC5_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 0, 255>, public VariableRounds<16>
  11. {
  12. static const char *StaticAlgorithmName() {return "RC5";}
  13. typedef word32 RC5_WORD;
  14. };
  15. /// <a href="http://www.weidai.com/scan-mirror/cs.html#RC5">RC5</a>
  16. class RC5 : public RC5_Info, public BlockCipherDocumentation
  17. {
  18. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC5_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<RC5_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 RC5::Encryption RC5Encryption;
  41. typedef RC5::Decryption RC5Decryption;
  42. NAMESPACE_END
  43. #endif