- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# arc4.h

    00001 #ifndef CRYPTOPP_ARC4_H
    00002 #define CRYPTOPP_ARC4_H
    00003
    00004 #include "strciphr.h"
    00005
    00006 NAMESPACE_BEGIN(CryptoPP)
    00007
    00008 //! _
    00009 class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
    00010 {
    00011 public:
    00012         ~ARC4_Base();
    00013
    00014         static const char *StaticAlgorithmName() {return "ARC4";}
    00015
    00016     byte GenerateByte();
    00017         void DiscardBytes(size_t n);
    00018
    00019     void ProcessData(byte *outString, const byte *inString, size_t length);
    00020
    00021         bool IsRandomAccess() const {return false;}
    00022         bool IsSelfInverting() const {return true;}
    00023         bool IsForwardTransformation() const {return true;}
    00024
    00025         typedef SymmetricCipherFinal<ARC4_Base> Encryption;
    00026         typedef SymmetricCipherFinal<ARC4_Base> Decryption;
    00027
    00028 protected:
    00029         void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length, const byte *iv);
    00030         virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
    00031
    00032     FixedSizeSecBlock<byte, 256> m_state;
    00033     byte m_x, m_y;
    00034 };
    00035
    00036 //! <a href="http://www.weidai.com/scan-mirror/cs.html#RC4">Alleged RC4</a>
    00037 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4)
    00038
    00039 //! _
    00040 class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
    00041 {
    00042 public:
    00043         static const char *StaticAlgorithmName() {return "MARC4";}
    00044
    00045         typedef SymmetricCipherFinal<MARC4_Base> Encryption;
    00046         typedef SymmetricCipherFinal<MARC4_Base> Decryption;
    00047
    00048 protected:
    00049         unsigned int GetDefaultDiscardBytes() const {return 256;}
    00050 };
    00051
    00052 //! Modified ARC4: it discards the first 256 bytes of keystream which may be weaker than the rest
    00053 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4)
    00054
    00055 NAMESPACE_END
    00056
    00057 #endif