- 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
    00029         protected:
    00030                 FixedSizeSecBlock<word16, 64> K;  // expanded key table
    00031         };
    00032
    00033         class CRYPTOPP_NO_VTABLE Enc : public Base
    00034         {
    00035         public:
    00036                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00037         };
    00038
    00039         class CRYPTOPP_NO_VTABLE Dec : public Base
    00040         {
    00041         public:
    00042                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
    00043         };
    00044
    00045 public:
    00046         class Encryption : public BlockCipherFinal<ENCRYPTION, Enc>
    00047         {
    00048         public:
    00049                 Encryption() {}
    00050                 Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
    00051                         {SetKey(key, keyLen);}
    00052                 Encryption(const byte *key, size_t keyLen, int effectiveKeyLen)
    00053                         {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
    00054         };
    00055
    00056         class Decryption : public BlockCipherFinal<DECRYPTION, Dec>
    00057         {
    00058         public:
    00059                 Decryption() {}
    00060                 Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
    00061                         {SetKey(key, keyLen);}
    00062                 Decryption(const byte *key, size_t keyLen, int effectiveKeyLen)
    00063                         {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
    00064         };
    00065 };
    00066
    00067 typedef RC2::Encryption RC2Encryption;
    00068 typedef RC2::Decryption RC2Decryption;
    00069
    00070 NAMESPACE_END
    00071
    00072 #endif