00001 #ifndef CRYPTOPP_ARC4_H
00002 #define CRYPTOPP_ARC4_H
00003
00004 #include "strciphr.h"
00005
00006 NAMESPACE_BEGIN(CryptoPP)
00007
00008
00009
00010 class ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher
00011 {
00012 public:
00013 ~ARC4_Base();
00014
00015 static const char *StaticAlgorithmName() {return "ARC4";}
00016
00017 byte GenerateByte();
00018 void DiscardBytes(unsigned int n);
00019
00020 void ProcessData(byte *outString, const byte *inString, unsigned int length);
00021
00022 bool IsRandomAccess() const {return false;}
00023 bool IsSelfInverting() const {return true;}
00024 bool IsForwardTransformation() const {return true;}
00025
00026 typedef SymmetricCipherFinalTemplate<ARC4_Base> Encryption;
00027 typedef SymmetricCipherFinalTemplate<ARC4_Base> Decryption;
00028
00029 protected:
00030 void UncheckedSetKey(const NameValuePairs ¶ms, const byte *key, unsigned int length);
00031 virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
00032
00033 FixedSizeSecBlock<byte, 256> m_state;
00034 byte m_x, m_y;
00035 };
00036
00037
00038 typedef SymmetricCipherFinalTemplate<ARC4_Base> ARC4;
00039
00040
00041
00042 class MARC4_Base : public ARC4_Base
00043 {
00044 public:
00045 static const char *StaticAlgorithmName() {return "MARC4";}
00046
00047 typedef SymmetricCipherFinalTemplate<MARC4_Base> Encryption;
00048 typedef SymmetricCipherFinalTemplate<MARC4_Base> Decryption;
00049
00050 protected:
00051 unsigned int GetDefaultDiscardBytes() const {return 256;}
00052 };
00053
00054
00055 typedef SymmetricCipherFinalTemplate<MARC4_Base> MARC4;
00056
00057 NAMESPACE_END
00058
00059 #endif