Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:08

0001 // rc5.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file rc5.h

0004 /// \brief Classes for the RC5 block cipher

0005 
0006 #ifndef CRYPTOPP_RC5_H
0007 #define CRYPTOPP_RC5_H
0008 
0009 #include "seckey.h"
0010 #include "secblock.h"
0011 
0012 NAMESPACE_BEGIN(CryptoPP)
0013 
0014 /// \brief RC5 block cipher information

0015 /// \since Crypto++ 1.0

0016 struct RC5_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 0, 255>, public VariableRounds<16>
0017 {
0018     CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "RC5";}
0019     typedef word32 RC5_WORD;
0020 };
0021 
0022 /// \brief RC5 block cipher

0023 /// \sa <a href="http://www.cryptopp.com/wiki/RC5">RC5</a>

0024 /// \since Crypto++ 1.0

0025 class RC5 : public RC5_Info, public BlockCipherDocumentation
0026 {
0027     class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC5_Info>
0028     {
0029     public:
0030         void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
0031 
0032     protected:
0033         unsigned int r;       // number of rounds

0034         SecBlock<RC5_WORD> sTable;  // expanded key table

0035     };
0036 
0037     class CRYPTOPP_NO_VTABLE Enc : public Base
0038     {
0039     public:
0040         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0041     };
0042 
0043     class CRYPTOPP_NO_VTABLE Dec : public Base
0044     {
0045     public:
0046         void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0047     };
0048 
0049 public:
0050     typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
0051     typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
0052 };
0053 
0054 typedef RC5::Encryption RC5Encryption;
0055 typedef RC5::Decryption RC5Decryption;
0056 
0057 NAMESPACE_END
0058 
0059 #endif