00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_RC2_H
00007 #define CRYPTOPP_RC2_H
00008
00009 #include "seckey.h"
00010 #include "secblock.h"
00011 #include "algparam.h"
00012
00013 NAMESPACE_BEGIN(CryptoPP)
00014
00015
00016
00017 struct RC2_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 128>
00018 {
00019 CRYPTOPP_CONSTANT(DEFAULT_EFFECTIVE_KEYLENGTH = 1024)
00020 CRYPTOPP_CONSTANT(MAX_EFFECTIVE_KEYLENGTH = 1024)
00021 static const char *StaticAlgorithmName() {return "RC2";}
00022 };
00023
00024
00025
00026
00027 class RC2 : public RC2_Info, public BlockCipherDocumentation
00028 {
00029
00030
00031
00032 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<RC2_Info>
00033 {
00034 public:
00035 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
00036 unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word16>();}
00037
00038 protected:
00039 FixedSizeSecBlock<word16, 64> K;
00040 };
00041
00042
00043
00044
00045 class CRYPTOPP_NO_VTABLE Enc : public Base
00046 {
00047 public:
00048 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00049 };
00050
00051
00052
00053
00054 class CRYPTOPP_NO_VTABLE Dec : public Base
00055 {
00056 public:
00057 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00058 };
00059
00060 public:
00061
00062
00063
00064
00065 class Encryption : public BlockCipherFinal<ENCRYPTION, Enc>
00066 {
00067 public:
00068 Encryption() {}
00069 Encryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
00070 {SetKey(key, keyLen);}
00071 Encryption(const byte *key, size_t keyLen, int effectiveKeyLen)
00072 {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
00073 };
00074
00075
00076
00077
00078 class Decryption : public BlockCipherFinal<DECRYPTION, Dec>
00079 {
00080 public:
00081 Decryption() {}
00082 Decryption(const byte *key, size_t keyLen=DEFAULT_KEYLENGTH)
00083 {SetKey(key, keyLen);}
00084 Decryption(const byte *key, size_t keyLen, int effectiveKeyLen)
00085 {SetKey(key, keyLen, MakeParameters("EffectiveKeyLength", effectiveKeyLen));}
00086 };
00087 };
00088
00089 typedef RC2::Encryption RC2Encryption;
00090 typedef RC2::Decryption RC2Decryption;
00091
00092 NAMESPACE_END
00093
00094 #endif
00095