Security Scol plugin
arc4.h
Go to the documentation of this file.
1// arc4.h - originally written and placed in the public domain by Wei Dai
2
6
7#ifndef CRYPTOPP_ARC4_H
8#define CRYPTOPP_ARC4_H
9
10#include "cryptlib.h"
11#include "strciphr.h"
12#include "secblock.h"
13#include "smartptr.h"
14
15NAMESPACE_BEGIN(CryptoPP)
16
17namespace Weak1 {
18
22class CRYPTOPP_NO_VTABLE ARC4_Base : public VariableKeyLength<16, 1, 256>, public RandomNumberGenerator, public SymmetricCipher, public SymmetricCipherDocumentation
23{
24public:
25 ~ARC4_Base();
26
27 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "ARC4";}
28
29 void GenerateBlock(byte *output, size_t size);
30 void DiscardBytes(size_t n);
31
32 void ProcessData(byte *outString, const byte *inString, size_t length);
33
34 bool IsRandomAccess() const {return false;}
35 bool IsSelfInverting() const {return true;}
36 bool IsForwardTransformation() const {return true;}
37
38 typedef SymmetricCipherFinal<ARC4_Base> Encryption;
39 typedef SymmetricCipherFinal<ARC4_Base> Decryption;
40
41protected:
42 void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params);
43 virtual unsigned int GetDefaultDiscardBytes() const {return 0;}
44
46 byte m_x, m_y;
47};
48
52DOCUMENTED_TYPEDEF(SymmetricCipherFinal<ARC4_Base>, ARC4);
53
58class CRYPTOPP_NO_VTABLE MARC4_Base : public ARC4_Base
59{
60public:
61 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "MARC4";}
62
65
66protected:
67 unsigned int GetDefaultDiscardBytes() const {return 256;}
68};
69
73DOCUMENTED_TYPEDEF(SymmetricCipherFinal<MARC4_Base>, MARC4);
74
75}
76#if CRYPTOPP_ENABLE_NAMESPACE_WEAK >= 1
77namespace Weak {using namespace Weak1;} // import Weak1 into CryptoPP::Weak
78#else
79using namespace Weak1; // import Weak1 into CryptoPP with warning
80#ifdef __GNUC__
81#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."
82#else
83#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.")
84#endif
85#endif
86
87NAMESPACE_END
88
89#endif
Fixed size stack-based SecBlock.
Definition secblock.h:1246
Interface for retrieving values given their names.
Definition cryptlib.h:322
Interface for random number generators.
Definition cryptlib.h:1435
SymmetricCipher implementation.
Definition strciphr.h:684
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
Definition cryptlib.h:1291
Inherited by keyed algorithms with variable key length.
Definition seckey.h:166
ARC4 base class.
Definition arc4.h:23
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition arc4.h:34
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition arc4.h:35
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition arc4.h:36
MARC4 base class.
Definition arc4.h:59
Abstract base classes that provide a uniform interface to this library.
Classes and functions for secure memory allocations.
Classes for automatic resource management.
Classes for implementing stream ciphers.
Provides Encryption and Decryption typedefs used by derived classes to implement a symmetric cipher.
Definition seckey.h:414