File indexing completed on 2025-01-18 09:54:53
0001
0002
0003
0004
0005
0006
0007 #ifndef CRYPTOPP_ARC4_H
0008 #define CRYPTOPP_ARC4_H
0009
0010 #include "cryptlib.h"
0011 #include "strciphr.h"
0012 #include "secblock.h"
0013 #include "smartptr.h"
0014
0015 NAMESPACE_BEGIN(CryptoPP)
0016
0017 namespace Weak1 {
0018
0019
0020
0021
0022 class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
0023 {
0024 public:
0025 ~ARC4_Base();
0026
0027 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARC4";}
0028
0029 void GenerateBlock(byte *output, size_t size);
0030 void DiscardBytes(size_t n);
0031
0032 void ProcessData(byte *outString, const byte *inString, size_t length);
0033
0034 bool IsRandomAccess() const {return false;}
0035 bool IsSelfInverting() const {return true;}
0036 bool IsForwardTransformation() const {return true;}
0037
0038 typedef SymmetricCipherFinal<ARC4_Base> Encryption;
0039 typedef SymmetricCipherFinal<ARC4_Base> Decryption;
0040
0041 protected:
0042 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms);
0043 virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
0044
0045 FixedSizeSecBlock<byte, 256> m_state;
0046 byte m_x, m_y;
0047 };
0048
0049
0050
0051
0052 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4);
0053
0054
0055
0056
0057
0058 class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
0059 {
0060 public:
0061 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MARC4";}
0062
0063 typedef SymmetricCipherFinal<MARC4_Base> Encryption;
0064 typedef SymmetricCipherFinal<MARC4_Base> Decryption;
0065
0066 protected:
0067 unsigned int GetDefaultDiscardBytes() const {return 256;}
0068 };
0069
0070
0071
0072
0073 DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4);
0074
0075 }
0076 #if CRYPTOPP_ENABLE_NAMESPACE_WEAK >= 1
0077 namespace Weak {using namespace Weak1;}
0078 #else
0079 using namespace Weak1;
0080 #ifdef __GNUC__
0081 #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."
0082 #else
0083 #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.")
0084 #endif
0085 #endif
0086
0087 NAMESPACE_END
0088
0089 #endif