6 #ifndef CRYPTOPP_SIMPLE_H
7 #define CRYPTOPP_SIMPLE_H
12 NAMESPACE_BEGIN(CryptoPP)
15 template <class DERIVED, class BASE>
19 Clonable * Clone()
const {
return new DERIVED(*static_cast<const DERIVED *>(
this));}
23 template <
class BASE,
class ALGORITHM_INFO=BASE>
27 static std::string CRYPTOPP_API StaticAlgorithmName() {
return ALGORITHM_INFO::StaticAlgorithmName();}
28 std::string AlgorithmName()
const {
return ALGORITHM_INFO::StaticAlgorithmName();}
35 explicit InvalidKeyLength(
const std::string &algorithm,
size_t length) :
InvalidArgument(algorithm +
": " + IntToString(length) +
" is not a valid key length") {}
42 explicit InvalidRounds(
const std::string &algorithm,
unsigned int rounds) :
InvalidArgument(algorithm +
": " + IntToString(rounds) +
" is not a valid number of rounds") {}
52 bool IsolatedFlush(
bool hardFlush,
bool blocking) {
return false;}
60 bool Flush(
bool completeFlush,
int propagation=-1,
bool blocking=
true)
61 {
return ChannelFlush(DEFAULT_CHANNEL, completeFlush, propagation, blocking);}
62 bool IsolatedFlush(
bool hardFlush,
bool blocking)
63 {assert(
false);
return false;}
64 bool ChannelFlush(
const std::string &channel,
bool hardFlush,
int propagation=-1,
bool blocking=
true)
66 if (hardFlush && !InputBufferIsEmpty())
67 throw CannotFlush(
"Unflushable<T>: this object has buffered input that cannot be flushed");
71 return attached && propagation ? attached->ChannelFlush(channel, hardFlush, propagation-1, blocking) :
false;
76 virtual bool InputBufferIsEmpty()
const {
return false;}
88 size_t Put2(
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
90 bool IsolatedFlush(
bool,
bool) {
return false;}
91 bool IsolatedMessageSeriesEnd(
bool) {
throw InputRejected();}
93 size_t ChannelPut2(
const std::string &channel,
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
94 {
throw InputRejected();}
95 bool ChannelMessageSeriesEnd(
const std::string &,
int,
bool) {
throw InputRejected();}
103 virtual bool Flush(
bool hardFlush,
int propagation=-1,
bool blocking=
true) =0;
106 bool IsolatedFlush(
bool hardFlush,
bool blocking) {assert(
false);
return false;}
114 virtual void Initialize(
const NameValuePairs ¶meters=g_nullNameValuePairs,
int propagation=-1) =0;
117 void IsolatedInitialize(
const NameValuePairs ¶meters) {assert(
false);}
125 bool Flush(
bool hardFlush,
int propagation=-1,
bool blocking=
true)
126 {
return this->ChannelFlush(DEFAULT_CHANNEL, hardFlush, propagation, blocking);}
127 bool MessageSeriesEnd(
int propagation=-1,
bool blocking=
true)
128 {
return this->ChannelMessageSeriesEnd(DEFAULT_CHANNEL, propagation, blocking);}
129 byte * CreatePutSpace(
size_t &size)
130 {
return this->ChannelCreatePutSpace(DEFAULT_CHANNEL, size);}
131 size_t Put2(
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
132 {
return this->ChannelPut2(DEFAULT_CHANNEL, begin, length, messageEnd, blocking);}
133 size_t PutModifiable2(byte *inString,
size_t length,
int messageEnd,
bool blocking)
134 {
return this->ChannelPutModifiable2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);}
138 byte * ChannelCreatePutSpace(
const std::string &channel,
size_t &size)
139 {size = 0;
return NULL;}
140 bool ChannelPutModifiable(
const std::string &channel, byte *inString,
size_t length)
141 {this->ChannelPut(channel, inString, length);
return false;}
143 virtual size_t ChannelPut2(
const std::string &channel,
const byte *begin,
size_t length,
int messageEnd,
bool blocking) =0;
144 size_t ChannelPutModifiable2(
const std::string &channel, byte *begin,
size_t length,
int messageEnd,
bool blocking)
145 {
return ChannelPut2(channel, begin, length, messageEnd, blocking);}
147 virtual bool ChannelFlush(
const std::string &channel,
bool hardFlush,
int propagation=-1,
bool blocking=
true) =0;
155 AutoSignaling(
int propagation=-1) : m_autoSignalPropagation(propagation) {}
157 void SetAutoSignalPropagation(
int propagation)
158 {m_autoSignalPropagation = propagation;}
159 int GetAutoSignalPropagation()
const
160 {
return m_autoSignalPropagation;}
163 int m_autoSignalPropagation;
167 class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE
Store :
public AutoSignaling<InputRejecting<BufferedTransformation> >
170 Store() : m_messageEnd(
false) {}
174 m_messageEnd =
false;
175 StoreInitialize(parameters);
179 bool GetNextMessage();
180 unsigned int CopyMessagesTo(
BufferedTransformation &target,
unsigned int count=UINT_MAX,
const std::string &channel=DEFAULT_CHANNEL)
const;
183 virtual void StoreInitialize(
const NameValuePairs ¶meters) =0;
193 {transferBytes = 0;
return 0;}
203 size_t Put2(
const byte *begin,
size_t length,
int messageEnd,
bool blocking)