rc6.h 1.5 KB

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