rc5.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // rc5.h - originally 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. /// \brief RC5 block cipher information
  10. /// \since Crypto++ 1.0
  11. struct RC5_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 0, 255>, public VariableRounds<16>
  12. {
  13. CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "RC5";}
  14. typedef word32 RC5_WORD;
  15. };
  16. /// \brief RC5 block cipher
  17. /// \sa <a href="http://www.cryptopp.com/wiki/RC5">RC5</a>
  18. /// \since Crypto++ 1.0
  19. class RC5 : public RC5_Info, public BlockCipherDocumentation
  20. {
  21. class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC5_Info>
  22. {
  23. public:
  24. void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
  25. protected:
  26. unsigned int r; // number of rounds
  27. SecBlock<RC5_WORD> sTable; // expanded key table
  28. };
  29. class CRYPTOPP_NO_VTABLE Enc : public Base
  30. {
  31. public:
  32. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  33. };
  34. class CRYPTOPP_NO_VTABLE Dec : public Base
  35. {
  36. public:
  37. void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
  38. };
  39. public:
  40. typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
  41. typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
  42. };
  43. typedef RC5::Encryption RC5Encryption;
  44. typedef RC5::Decryption RC5Decryption;
  45. NAMESPACE_END
  46. #endif