monotone

monotone Mtn Source Tree

Root/cryptopp/arc4.h

1#ifndef CRYPTOPP_ARC4_H
2#define CRYPTOPP_ARC4_H
3
4#include "strciphr.h"
5
6NAMESPACE_BEGIN(CryptoPP)
7
8//! <a href="http://www.weidai.com/scan-mirror/cs.html#RC4">Alleged RC4</a>
9/*! You can #ARC4 typedef rather than this class directly. */
10class ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher
11{
12public:
13~ARC4_Base();
14
15static const char *StaticAlgorithmName() {return "ARC4";}
16
17 byte GenerateByte();
18void DiscardBytes(unsigned int n);
19
20 void ProcessData(byte *outString, const byte *inString, unsigned int length);
21
22bool IsRandomAccess() const {return false;}
23bool IsSelfInverting() const {return true;}
24bool IsForwardTransformation() const {return true;}
25
26typedef SymmetricCipherFinalTemplate<ARC4_Base> Encryption;
27typedef SymmetricCipherFinalTemplate<ARC4_Base> Decryption;
28
29protected:
30void UncheckedSetKey(const NameValuePairs &params, const byte *key, unsigned int length);
31virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
32
33 FixedSizeSecBlock<byte, 256> m_state;
34 byte m_x, m_y;
35};
36
37//! .
38typedef SymmetricCipherFinalTemplate<ARC4_Base> ARC4;
39
40//! Modified ARC4: it discards the first 256 bytes of keystream which may be weaker than the rest
41/*! You can #MARC4 typedef rather than this class directly. */
42class MARC4_Base : public ARC4_Base
43{
44public:
45static const char *StaticAlgorithmName() {return "MARC4";}
46
47typedef SymmetricCipherFinalTemplate<MARC4_Base> Encryption;
48typedef SymmetricCipherFinalTemplate<MARC4_Base> Decryption;
49
50protected:
51unsigned int GetDefaultDiscardBytes() const {return 256;}
52};
53
54//! .
55typedef SymmetricCipherFinalTemplate<MARC4_Base> MARC4;
56
57NAMESPACE_END
58
59#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status