00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_ARC4_H
00007 #define CRYPTOPP_ARC4_H
00008
00009 #include "cryptlib.h"
00010 #include "strciphr.h"
00011 #include "secblock.h"
00012 #include "smartptr.h"
00013
00014 NAMESPACE_BEGIN(CryptoPP)
00015
00016 namespace Weak1 {
00017
00018
00019
00020
00021 class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
00022 {
00023 public:
00024 ~ARC4_Base();
00025
00026 static const char *StaticAlgorithmName() {return "ARC4";}
00027
00028 void GenerateBlock(byte *output, size_t size);
00029 void DiscardBytes(size_t n);
00030
00031 void ProcessData(byte *outString, const byte *inString, size_t length);
00032
00033 bool IsRandomAccess() const {return false;}
00034 bool IsSelfInverting() const {return true;}
00035 bool IsForwardTransformation() const {return true;}
00036
00037 typedef SymmetricCipherFinal<ARC4_Base> Encryption;
00038 typedef SymmetricCipherFinal<ARC4_Base> Decryption;
00039
00040 protected:
00041 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms);
00042 virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
00043
00044 FixedSizeSecBlock<byte, 256> m_state;
00045 byte m_x, m_y;
00046 };
00047
00048
00049 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4)
00050
00051
00052
00053
00054
00055 class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
00056 {
00057 public:
00058 static const char *StaticAlgorithmName() {return "MARC4";}
00059
00060 typedef SymmetricCipherFinal<MARC4_Base> Encryption;
00061 typedef SymmetricCipherFinal<MARC4_Base> Decryption;
00062
00063 protected:
00064 unsigned int GetDefaultDiscardBytes() const {return 256;}
00065 };
00066
00067 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4)
00068
00069 }
00070 #if CRYPTOPP_ENABLE_NAMESPACE_WEAK >= 1
00071 namespace Weak {using namespace Weak1;}
00072 #else
00073 using namespace Weak1;
00074 #ifdef __GNUC__
00075 #warning "You may be using a weak algorithm that has been retained for backwards compatibility. Please '#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1' before including this .h file and prepend the class name with 'Weak::' to remove this warning."
00076 #else
00077 #pragma message("You may be using a weak algorithm that has been retained for backwards compatibility. Please '#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1' before including this .h file and prepend the class name with 'Weak::' to remove this warning.")
00078 #endif
00079 #endif
00080
00081 NAMESPACE_END
00082
00083 #endif