6#ifndef CRYPTOPP_SIMPLE_H
7#define CRYPTOPP_SIMPLE_H
11#if CRYPTOPP_MSC_VERSION
13# pragma warning(disable: 4127 4189)
19NAMESPACE_BEGIN(CryptoPP)
24template <
class DERIVED,
class BASE>
31 Clonable *
Clone()
const {
return new DERIVED(*
static_cast<const DERIVED *
>(
this));}
38template <
class BASE,
class ALGORITHM_INFO=BASE>
51 std::string
AlgorithmName()
const {
return ALGORITHM_INFO::StaticAlgorithmName();}
127 {CRYPTOPP_UNUSED(hardFlush); CRYPTOPP_UNUSED(blocking);
return false;}
155 bool Flush(
bool completeFlush,
int propagation=-1,
bool blocking=
true)
156 {
return ChannelFlush(DEFAULT_CHANNEL, completeFlush, propagation, blocking);}
163 {CRYPTOPP_UNUSED(hardFlush); CRYPTOPP_UNUSED(blocking); CRYPTOPP_ASSERT(
false);
return false;}
175 bool ChannelFlush(
const std::string &channel,
bool hardFlush,
int propagation=-1,
bool blocking=
true)
177 if (hardFlush && !InputBufferIsEmpty())
178 throw CannotFlush(
"Unflushable<T>: this object has buffered input that cannot be flushed");
182 return attached && propagation ? attached->
ChannelFlush(channel, hardFlush, propagation-1, blocking) :
false;
187 virtual bool InputBufferIsEmpty()
const {
return false;}
211 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
212 {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
throw InputRejected();}
223 {CRYPTOPP_UNUSED(hardFlush); CRYPTOPP_UNUSED(blocking);
return false;}
239 size_t ChannelPut2(
const std::string &channel,
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
240 {CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length);
241 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
throw InputRejected();}
254 {CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
throw InputRejected();}
281 virtual bool Flush(
bool hardFlush,
int propagation=-1,
bool blocking=
true) =0;
286 bool IsolatedFlush(
bool hardFlush,
bool blocking)
287 {CRYPTOPP_UNUSED(hardFlush); CRYPTOPP_UNUSED(blocking); CRYPTOPP_ASSERT(
false);
return false;}
308 {CRYPTOPP_UNUSED(parameters); CRYPTOPP_ASSERT(
false);}
318 bool Flush(
bool hardFlush,
int propagation=-1,
bool blocking=
true)
319 {
return this->ChannelFlush(DEFAULT_CHANNEL, hardFlush, propagation, blocking);}
330 {
return this->ChannelMessageSeriesEnd(DEFAULT_CHANNEL, propagation, blocking);}
342 {
return this->ChannelCreatePutSpace(DEFAULT_CHANNEL, size);}
351 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
352 {
return this->ChannelPut2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);}
361 size_t PutModifiable2(
byte *inString,
size_t length,
int messageEnd,
bool blocking)
362 {
return this->ChannelPutModifiable2(DEFAULT_CHANNEL, inString, length, messageEnd, blocking);}
379 {CRYPTOPP_UNUSED(channel); size = 0;
return NULLPTR;}
387 {this->ChannelPut(channel, inString, length);
return false;}
396 virtual size_t ChannelPut2(
const std::string &channel,
const byte *begin,
size_t length,
int messageEnd,
bool blocking) =0;
406 {
return ChannelPut2(channel, begin, length, messageEnd, blocking);}
416 virtual bool ChannelFlush(
const std::string &channel,
bool hardFlush,
int propagation=-1,
bool blocking=
true) =0;
434 {m_autoSignalPropagation = propagation;}
440 {
return m_autoSignalPropagation;}
443 int m_autoSignalPropagation;
447class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE
Store :
public AutoSignaling<InputRejecting<BufferedTransformation> >
455 m_messageEnd =
false;
456 StoreInitialize(parameters);
460 bool GetNextMessage();
461 unsigned int CopyMessagesTo(
BufferedTransformation &target,
unsigned int count=UINT_MAX,
const std::string &channel=DEFAULT_CHANNEL)
const;
464 virtual void StoreInitialize(
const NameValuePairs ¶meters) =0;
482 {CRYPTOPP_UNUSED(target); CRYPTOPP_UNUSED(transferBytes); CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(blocking); transferBytes = 0;
return 0;}
484 {CRYPTOPP_UNUSED(target); CRYPTOPP_UNUSED(begin); CRYPTOPP_UNUSED(end); CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(blocking);
return 0;}
495 {CRYPTOPP_UNUSED(params);}
496 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
497 {CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
return 0;}
502#if CRYPTOPP_MSC_VERSION
static std::string CRYPTOPP_API StaticAlgorithmName()
The algorithm name.
std::string AlgorithmName() const
The algorithm name.
Provides auto signaling support.
int GetAutoSignalPropagation() const
Retrieve automatic signal propagation value.
AutoSignaling(int propagation=-1)
Construct an AutoSignaling.
void SetAutoSignalPropagation(int propagation)
Set propagation of automatically generated and transferred signals.
Acts as an input discarding Filter or Sink.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
void IsolatedInitialize(const NameValuePairs ¶ms)
Initialize or reinitialize this object, without signal propagation.
std::string AlgorithmName() const
Provides the name of this algorithm.
Base class for bufferless filters.
bool IsolatedFlush(bool hardFlush, bool blocking)
Flushes data buffered by this object, without signal propagation.
Flush(true) was called but it can't completely flush its buffers.
Namespace containing NaCl library functions.
Base class for identifying algorithm.
Clonable * Clone() const
Create a copy of this object.
Interface for custom flush signals propagation.
virtual bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)=0
Flush buffered input and/or output, with signal propagation.
Interface for custom flush signals.
virtual void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1)=0
Initialize or reinitialize this object, with signal propagation.
An invalid argument was detected.
Exception thrown when an invalid block size is encountered.
InvalidBlockSize(const std::string &algorithm, size_t length)
Construct an InvalidBlockSize.
Exception thrown when an invalid derived key length is encountered.
InvalidDerivedKeyLength(const std::string &algorithm, size_t length)
Construct an InvalidDerivedKeyLength.
Exception thrown when an invalid key length is encountered.
InvalidKeyLength(const std::string &algorithm, size_t length)
Construct an InvalidKeyLength.
Exception thrown when an invalid personalization string length is encountered.
InvalidPersonalizationLength(const std::string &algorithm, size_t length)
Construct an InvalidPersonalizationLength.
Exception thrown when an invalid number of rounds is encountered.
InvalidRounds(const std::string &algorithm, unsigned int rounds)
Construct an InvalidRounds.
Exception thrown when an invalid salt length is encountered.
InvalidSaltLength(const std::string &algorithm, size_t length)
Construct an InvalidSaltLength.
Multiple channels support for custom signal processing.
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
virtual bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true)=0
Flush buffered input and/or output on a channel.
bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
Marks the end of a series of messages, with signal propagation.
size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee on a channel.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
virtual size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)=0
Input multiple bytes for processing on a channel.
byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
bool ChannelPutModifiable(const std::string &channel, byte *inString, size_t length)
Input multiple bytes that may be modified by callee on a channel.
size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee.
Interface for retrieving values given their names.
A method was called which was not implemented.
Implementation of BufferedTransformation's attachment interface.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const
Copy bytes from this object to another BufferedTransformation.
Acts as a Source for pre-existing, static data.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Store()
Construct a Store.
unsigned int NumberOfMessages() const
Provides the number of meesages processed by this object.
Base class for unflushable filters.
bool IsolatedFlush(bool hardFlush, bool blocking)
Flushes data buffered by this object, without signal propagation.
bool ChannelFlush(const std::string &channel, bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output on a channel.
bool Flush(bool completeFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
Library configuration file.
const lword LWORD_MAX
Large word type max value.
word64 lword
Large word type.
Abstract base classes that provide a uniform interface to this library.
Utility functions for the Crypto++ library.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.