• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

rc2.h

Go to the documentation of this file.
00001 #ifndef CRYPTOPP_RC2_H
00002 #define CRYPTOPP_RC2_H
00003 
00004 /** \file
00005 */
00006 
00007 #include "seckey.h"
00008 #include "secblock.h"
00009 #include "algparam.h"
00010 
00011 NAMESPACE_BEGIN(CryptoPP)
00012 
00013 //! _
00014 struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
00015 {
00016         CRYPTOPP_CONSTANT(DEFAULT_EFFECTIVE_KEYLENGTH = 1024)
00017         CRYPTOPP_CONSTANT(MAX_EFFECTIVE_KEYLENGTH = 1024)
00018         static const char *StaticAlgorithmName() {return "RC2";}
00019 };
00020 
00021 /// <a href="http://www.weidai.com/scan-mirror/cs.html#RC2">RC2</a>
00022 class RC2 : public RC2_Info, public BlockCipherDocumentation
00023 {
00024         class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC2_Info>
00025         {
00026         public:
00027                 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
00028                 unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();}
00029 
00030         protected:
00031                 FixedSizeSecBlock<word16, 64> K;  // expanded key table
00032         };
00033 
00034         class CRYPTOPP_NO_VTABLE Enc : public Base
00035         {
00036         public:
00037                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00038         };
00039 
00040         class CRYPTOPP_NO_VTABLE Dec : public Base
00041         {
00042         public:
00043                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00044         };
00045 
00046 public:
00047         class Encryption : public BlockCipherFinal<ENCRYPTION, Enc>
00048         {
00049         public:
00050                 Encryption() {}
00051                 Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
00052                         {SetKey(key, keyLen);}
00053                 Encryption(const byte *key, size_t keyLen, int effectiveKeyLen)
00054                         {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
00055         };
00056 
00057         class Decryption : public BlockCipherFinal<DECRYPTION, Dec>
00058         {
00059         public:
00060                 Decryption() {}
00061                 Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
00062                         {SetKey(key, keyLen);}
00063                 Decryption(const byte *key, size_t keyLen, int effectiveKeyLen)
00064                         {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
00065         };
00066 };
00067 
00068 typedef RC2::Encryption RC2Encryption;
00069 typedef RC2::Decryption RC2Decryption;
00070 
00071 NAMESPACE_END
00072 
00073 #endif

Generated on Mon Aug 9 2010 15:56:35 for Crypto++ by  doxygen 1.7.1