6 #if CRYPTOPP_MSC_VERSION 7 # pragma warning(disable: 4100 4189 4355) 10 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE 11 # pragma GCC diagnostic ignored "-Wunused-value" 14 #ifndef CRYPTOPP_IMPORTS 27 : m_attachment(attachment), m_inputPosition(0), m_continueAt(0)
38 if (m_attachment.get() == NULLPTR)
39 m_attachment.reset(NewDefaultAttachment());
40 return m_attachment.get();
45 if (m_attachment.get() == NULLPTR)
46 const_cast<Filter *>(
this)->m_attachment.reset(NewDefaultAttachment());
47 return m_attachment.get();
52 m_attachment.reset(newOut);
55 void Filter::Insert(
Filter *filter)
57 filter->m_attachment.reset(m_attachment.release());
58 m_attachment.reset(filter);
73 m_inputPosition = m_continueAt = 0;
75 PropagateInitialize(parameters, propagation);
87 if (OutputFlush(1, hardFlush, propagation, blocking))
104 if (ShouldPropagateMessageSeriesEnd() && OutputMessageSeriesEnd(1, propagation, blocking))
112 void Filter::PropagateInitialize(
const NameValuePairs ¶meters,
int propagation)
118 size_t Filter::OutputModifiable(
int outputSite, byte *inString,
size_t length,
int messageEnd,
bool blocking,
const std::string &channel)
123 m_continueAt = result ? outputSite : 0;
127 size_t Filter::Output(
int outputSite,
const byte *inString,
size_t length,
int messageEnd,
bool blocking,
const std::string &channel)
132 m_continueAt = result ? outputSite : 0;
136 bool Filter::OutputFlush(
int outputSite,
bool hardFlush,
int propagation,
bool blocking,
const std::string &channel)
140 m_continueAt = outputSite;
147 bool Filter::OutputMessageSeriesEnd(
int outputSite,
int propagation,
bool blocking,
const std::string &channel)
151 m_continueAt = outputSite;
162 m_currentMessageBytes = m_totalBytes = m_currentSeriesMessages = m_totalMessages = m_totalMessageSeries = 0;
163 m_rangesToSkip.clear();
168 MessageRange r = {message, position, size};
169 m_rangesToSkip.push_back(r);
171 std::sort(m_rangesToSkip.begin(), m_rangesToSkip.end());
174 size_t MeterFilter::PutMaybeModifiable(byte *begin,
size_t length,
int messageEnd,
bool blocking,
bool modifiable)
185 while (m_length > 0 || messageEnd)
187 if (m_length > 0 && !m_rangesToSkip.empty() && m_rangesToSkip.front().message == m_totalMessages && m_currentMessageBytes + m_length > m_rangesToSkip.front().position)
189 FILTER_OUTPUT_MAYBE_MODIFIABLE(1, m_begin, t = (
size_t)
SaturatingSubtract(m_rangesToSkip.front().position, m_currentMessageBytes),
false, modifiable);
194 m_currentMessageBytes += t;
197 if (m_currentMessageBytes + m_length < m_rangesToSkip.front().position + m_rangesToSkip.front().size)
201 t = (size_t)
SaturatingSubtract(m_rangesToSkip.front().position + m_rangesToSkip.front().size, m_currentMessageBytes);
203 m_rangesToSkip.pop_front();
208 m_currentMessageBytes += t;
213 FILTER_OUTPUT_MAYBE_MODIFIABLE(2, m_begin, m_length, messageEnd, modifiable);
215 m_currentMessageBytes += m_length;
216 m_totalBytes += m_length;
221 m_currentMessageBytes = 0;
222 m_currentSeriesMessages++;
229 FILTER_END_NO_MESSAGE_END;
234 return PutMaybeModifiable(const_cast<byte *>(begin), length, messageEnd, blocking,
false);
239 return PutMaybeModifiable(begin, length, messageEnd, blocking,
true);
244 CRYPTOPP_UNUSED(blocking);
245 m_currentMessageBytes = 0;
246 m_currentSeriesMessages = 0;
247 m_totalMessageSeries++;
253 void FilterWithBufferedInput::BlockQueue::ResetQueue(
size_t blockSize,
size_t maxBlocks)
255 m_buffer.New(blockSize * maxBlocks);
256 m_blockSize = blockSize;
257 m_maxBlocks = maxBlocks;
262 byte *FilterWithBufferedInput::BlockQueue::GetBlock()
264 if (m_size >= m_blockSize)
267 if ((m_begin+=m_blockSize) == m_buffer.end())
269 m_size -= m_blockSize;
276 byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(
size_t &numberOfBytes)
278 numberOfBytes =
STDMIN(numberOfBytes,
STDMIN(
size_t(m_buffer.end()-m_begin), m_size));
280 m_begin += numberOfBytes;
281 m_size -= numberOfBytes;
282 if (m_size == 0 || m_begin == m_buffer.end())
287 size_t FilterWithBufferedInput::BlockQueue::GetAll(byte *outString)
290 if (!outString)
return 0;
292 size_t size = m_size;
293 size_t numberOfBytes = m_maxBlocks*m_blockSize;
294 const byte *ptr = GetContigousBlocks(numberOfBytes);
295 memcpy(outString, ptr, numberOfBytes);
296 memcpy(outString+numberOfBytes, m_begin, m_size);
301 void FilterWithBufferedInput::BlockQueue::Put(
const byte *inString,
size_t length)
304 if (!inString || !length)
return;
307 byte *end = (m_size < size_t(m_buffer.end()-m_begin)) ? m_begin + m_size : m_begin + m_size - m_buffer.size();
308 size_t len =
STDMIN(length,
size_t(m_buffer.end()-end));
309 memcpy(end, inString, len);
311 memcpy(m_buffer, inString+len, length-len);
316 :
Filter(attachment), m_firstSize(
SIZE_MAX), m_blockSize(0), m_lastSize(
SIZE_MAX), m_firstInputDone(false)
321 :
Filter(attachment), m_firstSize(firstSize), m_blockSize(blockSize), m_lastSize(lastSize), m_firstInputDone(false)
326 m_queue.ResetQueue(1, m_firstSize);
331 InitializeDerivedAndReturnNewSizes(parameters, m_firstSize, m_blockSize, m_lastSize);
334 m_queue.ResetQueue(1, m_firstSize);
335 m_firstInputDone =
false;
350 size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString,
size_t length,
int messageEnd,
bool blocking,
bool modifiable)
357 size_t newLength = m_queue.CurrentSize() + length;
359 if (!m_firstInputDone && newLength >= m_firstSize)
361 size_t len = m_firstSize - m_queue.CurrentSize();
362 m_queue.Put(inString, len);
363 FirstPut(m_queue.GetContigousBlocks(m_firstSize));
365 m_queue.ResetQueue(m_blockSize, (2*m_blockSize+m_lastSize-2)/m_blockSize);
368 newLength -= m_firstSize;
369 m_firstInputDone =
true;
372 if (m_firstInputDone)
374 if (m_blockSize == 1)
376 while (newLength > m_lastSize && m_queue.CurrentSize() > 0)
378 size_t len = newLength - m_lastSize;
379 byte *ptr = m_queue.GetContigousBlocks(len);
380 NextPutModifiable(ptr, len);
384 if (newLength > m_lastSize)
386 size_t len = newLength - m_lastSize;
387 NextPutMaybeModifiable(inString, len, modifiable);
394 while (newLength >= m_blockSize + m_lastSize && m_queue.CurrentSize() >= m_blockSize)
396 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
397 newLength -= m_blockSize;
400 if (newLength >= m_blockSize + m_lastSize && m_queue.CurrentSize() > 0)
403 size_t len = m_blockSize - m_queue.CurrentSize();
404 m_queue.Put(inString, len);
406 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
407 newLength -= m_blockSize;
410 if (newLength >= m_blockSize + m_lastSize)
413 NextPutMaybeModifiable(inString, len, modifiable);
420 m_queue.Put(inString, newLength - m_queue.CurrentSize());
425 if (!m_firstInputDone && m_firstSize==0)
429 m_queue.GetAll(temp);
430 LastPut(temp, temp.size());
432 m_firstInputDone =
false;
433 m_queue.ResetQueue(1, m_firstSize);
436 (void)Output(1, NULLPTR, 0, messageEnd, blocking);
443 if (!m_firstInputDone)
448 while (m_queue.CurrentSize() >= m_blockSize)
449 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
454 while ((len = m_queue.CurrentSize()) > 0)
455 NextPutModifiable(m_queue.GetContigousBlocks(len), len);
459 void FilterWithBufferedInput::NextPutMultiple(
const byte *inString,
size_t length)
465 NextPutSingle(inString);
466 inString += m_blockSize;
467 length -= m_blockSize;
478 if (m_target && GetPassSignals())
479 m_target->Initialize(parameters, propagation);
493 return m_filter.get() ? m_filter->
Flush(hardFlush, -1, blocking) :
false;
498 m_filter.reset(filter);
504 m_filter->
Attach(temp.release());
508 void ProxyFilter::NextPutMultiple(
const byte *s,
size_t len)
511 m_filter->
Put(s, len);
514 void ProxyFilter::NextPutModifiable(byte *s,
size_t len)
529 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
530 m_rng->IncorporateEntropy(begin, length);
534 size_t ArraySink::Put2(
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
536 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
544 memmove(m_buf+m_total, begin, copied);
547 return length - copied;
553 return m_buf + m_total;
561 m_buf = array.
begin();
562 m_size = array.
size();
567 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
574 xorbuf(m_buf+m_total, begin, copied);
577 return length - copied;
588 if (authenticatedFilter)
589 throw InvalidArgument(
"StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher");
595 m_reservedBufferSize =
STDMAX(2*m_mandatoryBlockSize, m_optimalBufferSize);
604 if (!authenticatedFilter)
609 if (authenticatedFilter && !authenticated)
610 throw InvalidArgument(
"StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher");
616 m_reservedBufferSize =
STDMAX(2*m_mandatoryBlockSize, m_optimalBufferSize);
631 void StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
634 bool isBlockCipher = (m_mandatoryBlockSize > 1 && m_cipher.
MinLastBlockSize() == 0);
652 blockSize = m_mandatoryBlockSize;
653 lastSize = LastBlockSize(m_cipher, m_padding);
656 void StreamTransformationFilter::FirstPut(
const byte* inString)
658 CRYPTOPP_UNUSED(inString);
659 m_optimalBufferSize = STDMAX<unsigned int>(m_optimalBufferSize,
RoundDownToMultipleOf(4096U, m_optimalBufferSize));
662 void StreamTransformationFilter::NextPutMultiple(
const byte *inString,
size_t length)
670 size_t len = m_optimalBufferSize;
674 if (len == m_optimalBufferSize)
688 void StreamTransformationFilter::NextPutModifiable(byte *inString,
size_t length)
694 void StreamTransformationFilter::LastPut(
const byte *inString,
size_t length)
696 byte *space = NULLPTR;
720 const size_t leftOver = length % m_mandatoryBlockSize;
735 length = m_cipher.
ProcessLastBlock(space, m_reservedBufferSize, inString, leftOver);
741 length = m_cipher.
ProcessLastBlock(space, m_reservedBufferSize, NULLPTR, 0);
758 if (isForwardTransformation && m_padding ==
ZEROS_PADDING && (minLastBlockSize == 0 || length < minLastBlockSize))
761 size_t blockSize =
STDMAX(minLastBlockSize, (
size_t)m_mandatoryBlockSize);
763 if (inString) {memcpy(space, inString, length);}
764 memset(space + length, 0, blockSize - length);
765 size_t used = m_cipher.
ProcessLastBlock(space, blockSize, space, blockSize);
770 if (minLastBlockSize == 0)
772 if (isForwardTransformation)
773 throw InvalidDataFormat(
"StreamTransformationFilter: plaintext length is not a multiple of block size and NO_PADDING is specified");
775 throw InvalidCiphertext(
"StreamTransformationFilter: ciphertext length is not a multiple of block size");
789 s = m_mandatoryBlockSize;
795 if (inString) {memcpy(space, inString, length);}
799 byte pad =
static_cast<byte
>(s-length);
800 memset(space+length, pad, s-length);
805 memset(space+length, 0, s-length-1);
806 space[s-1] =
static_cast<byte
>(s-length);
810 space[length] = 0x80;
811 memset(space+length+1, 0, s-length-1);
819 throw InvalidCiphertext(
"StreamTransformationFilter: ciphertext length is not a multiple of block size");
823 byte pad = space[s-1];
824 if (pad < 1 || pad > s ||
FindIfNot(space+s-pad, space+s, pad) != space+s)
825 throw InvalidCiphertext(
"StreamTransformationFilter: invalid PKCS #7 block padding found");
830 byte pad = space[s - 1];
831 if (pad < 1 || pad > s)
832 throw InvalidCiphertext(
"StreamTransformationFilter: invalid W3C block padding found");
837 while (length > 1 && space[length-1] == 0)
839 if (space[--length] != 0x80)
840 throw InvalidCiphertext(
"StreamTransformationFilter: invalid ones-and-zeros padding found");
854 : m_hashModule(hm), m_putMessage(putMessage), m_digestSize(0), m_space(NULLPTR)
855 , m_messagePutChannel(messagePutChannel), m_hashPutChannel(hashPutChannel)
857 m_digestSize = truncatedDigestSize < 0 ? m_hashModule.
DigestSize() : truncatedDigestSize;
865 m_digestSize = s < 0 ? m_hashModule.
DigestSize() : s;
868 size_t HashFilter::Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
872 FILTER_OUTPUT3(1, 0, inString, length, 0, m_messagePutChannel);
873 if (inString && length)
874 m_hashModule.
Update(inString, length);
882 FILTER_OUTPUT3(2, 0, m_space, m_digestSize, messageEnd, m_hashPutChannel);
884 FILTER_END_NO_MESSAGE_END;
891 , m_hashModule(hm), m_flags(0), m_digestSize(0), m_verified(false)
896 void HashVerificationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
900 m_digestSize = s < 0 ? m_hashModule.
DigestSize() : s;
907 void HashVerificationFilter::FirstPut(
const byte *inString)
911 m_expectedHash.
New(m_digestSize);
912 if (inString) {memcpy(m_expectedHash, inString, m_expectedHash.
size());}
918 void HashVerificationFilter::NextPutMultiple(
const byte *inString,
size_t length)
920 m_hashModule.
Update(inString, length);
925 void HashVerificationFilter::LastPut(
const byte *inString,
size_t length)
930 m_verified = m_hashModule.
TruncatedVerify(m_expectedHash, m_digestSize);
934 m_verified = (length==m_digestSize && m_hashModule.
TruncatedVerify(inString, length));
949 bool putAAD,
int truncatedDigestSize,
const std::string &macChannel,
BlockPaddingScheme padding)
979 return m_hf.
Put2(begin, length, 0, blocking);
986 StreamTransformationFilter::LastPut(inString, length);
995 , m_streamFilter(c, new
OutputProxy(*this, false), padding, true)
1001 void AuthenticatedDecryptionFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
1008 firstSize = m_hashVerifier.m_firstSize;
1010 lastSize = m_hashVerifier.m_lastSize;
1015 if (channel.empty())
1026 if (channel.empty())
1034 return m_hashVerifier.
Put2(begin, length, 0, blocking);
1039 void AuthenticatedDecryptionFilter::FirstPut(
const byte *inString)
1041 m_hashVerifier.
Put(inString, m_firstSize);
1044 void AuthenticatedDecryptionFilter::NextPutMultiple(
const byte *inString,
size_t length)
1046 m_streamFilter.
Put(inString, length);
1049 void AuthenticatedDecryptionFilter::LastPut(
const byte *inString,
size_t length)
1060 m_messageAccumulator.reset(m_signer.NewSignatureAccumulator(m_rng));
1066 m_messageAccumulator->Update(inString, length);
1068 FILTER_OUTPUT(1, inString, length, 0);
1071 m_buf.New(m_signer.SignatureLength());
1072 m_signer.Sign(m_rng, m_messageAccumulator.release(), m_buf);
1073 FILTER_OUTPUT(2, m_buf, m_buf.size(), messageEnd);
1074 m_messageAccumulator.reset(m_signer.NewSignatureAccumulator(m_rng));
1076 FILTER_END_NO_MESSAGE_END;
1081 , m_verifier(verifier), m_flags(0), m_verified(0)
1086 void SignatureVerificationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
1098 void SignatureVerificationFilter::FirstPut(
const byte *inString)
1107 if (inString) {memcpy(m_signature, inString, m_signature.
size());}
1119 void SignatureVerificationFilter::NextPutMultiple(
const byte *inString,
size_t length)
1121 m_messageAccumulator->
Update(inString, length);
1126 void SignatureVerificationFilter::LastPut(
const byte *inString,
size_t length)
1136 m_verifier.
InputSignature(*m_messageAccumulator, inString, length);
1153 unsigned int messageCount = UINT_MAX;
1155 RETURN_IF_NONZERO(PumpMessages2(messageCount, blocking));
1156 }
while(messageCount == UINT_MAX);
1172 unsigned int Store::CopyMessagesTo(
BufferedTransformation &target,
unsigned int count,
const std::string &channel)
const 1174 if (m_messageEnd || count == 0)
1178 CopyTo(target, ULONG_MAX, channel);
1185 void StringStore::StoreInitialize(
const NameValuePairs ¶meters)
1190 m_store = array.
begin();
1191 m_length = array.
size();
1198 size_t blockedBytes =
CopyRangeTo2(target, position, transferBytes, channel, blocking);
1199 m_count += (size_t)position;
1200 transferBytes = position;
1201 return blockedBytes;
1208 size_t blockedBytes = target.
ChannelPut2(channel, m_store+i, len, 0, blocking);
1211 return blockedBytes;
1214 void RandomNumberStore::StoreInitialize(
const NameValuePairs ¶meters)
1225 throw NotImplemented(
"RandomNumberStore: nonblocking transfer is not implemented by this object");
1227 transferBytes =
UnsignedMin(transferBytes, m_length - m_count);
1228 m_rng->GenerateIntoBufferedTransformation(target, channel, transferBytes);
1229 m_count += transferBytes;
1236 static const byte nullBytes[128] = {0};
1239 size_t len = (size_t)
STDMIN(end-begin, lword(128));
1240 size_t blockedBytes = target.
ChannelPut2(channel, nullBytes, len, 0, blocking);
1242 return blockedBytes;
1252 transferBytes = begin;
1254 return blockedBytes;
Used to pass byte array input as part of a NameValuePairs object.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Standard names for retrieving values by name when working with NameValuePairs.
InputIt FindIfNot(InputIt first, InputIt last, const T &value)
Finds first element not in a range.
An invalid argument was detected.
Indicates the hash is at the beginning of the message (i.e., concatenation of hash+message) ...
HashFilter(HashTransformation &hm, BufferedTransformation *attachment=NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL)
Construct a HashFilter.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
void AddRangeToSkip(unsigned int message, lword position, lword size, bool sortNow=true)
Adds a range to skip during processing.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Utility functions for the Crypto++ library.
size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing on a channel.
virtual size_t PumpAll2(bool blocking=true)
Pump all data to attached transformation.
BlockPaddingScheme
Padding schemes used for block ciphers.
Interface for authenticated encryption modes of operation.
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
size_t size() const
Length of the memory block.
Indicates the filter should throw a HashVerificationFailed if a failure is encountered.
size_t size() const
Length of the memory block.
Indicates the result of the verification should be passed to an attached transformation.
const char * HashVerificationFilterFlags()
word32
Filter class that is a proxy for a sink.
const char * AuthenticatedDecryptionFilterFlags()
word32
const char * SignatureVerificationFilterFlags()
word32
const char * BlockPaddingScheme()
StreamTransformationFilter::BlockPaddingScheme.
bool MessageSeriesEnd(int propagation=-1, bool blocking=true)
Marks the end of a series of messages, with signal propagation.
AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment=NULL, word32 flags=DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding=DEFAULT_PADDING)
Construct a AuthenticatedDecryptionFilter.
void ResetMeter()
Resets the meter.
Indicates the filter should throw a HashVerificationFailed if a failure is encountered.
Classes for automatic resource management.
Indicates the message should be passed to an attached transformation.
Library configuration file.
byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
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.
bool GetNextMessage()
Start retrieving the next message.
void New(size_type newSize)
Change size without preserving contents.
Combines two sets of NameValuePairs.
virtual bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const =0
Check whether messageAccumulator contains a valid signature and message, and restart messageAccumulat...
virtual size_t SignatureLength() const =0
Provides the signature length if it only depends on the key.
Used to pass byte array input as part of a NameValuePairs object.
Exception thrown when an invalid signature is encountered.
SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment=NULL, word32 flags=DEFAULT_FLAGS)
Construct a SignatureVerificationFilter.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Pointer that overloads operator ->
Default flags using THROW_EXCEPTION.
void LastPut(const byte *inString, size_t length)
Input the last block of data.
Exception thrown when a data integrity check failure is encountered.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
1 and 0's padding added to a block
HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment=NULL, word32 flags=DEFAULT_FLAGS, int truncatedDigestSize=-1)
Construct a HashVerificationFilter.
A method was called which was not implemented.
const byte * begin() const
Pointer to the first byte in the memory block.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
void Detach(BufferedTransformation *newAttachment=NULL)
Replace an attached transformation.
const std::string DEFAULT_CHANNEL
Default channel for BufferedTransformation.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
BufferedTransformation * AttachedTransformation()
Retrieve attached transformation.
const char * PutMessage()
bool
size_t PutModifiable2(byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes that may be modified by callee.
Indicates the message should be passed to an attached transformation.
size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
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.
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.
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
const char * InputBuffer()
ConstByteArrayParameter.
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
const T1 UnsignedMin(const T1 &a, const T2 &b)
Safe comparison of values that could be neagtive and incorrectly promoted.
Indicates the hash should be passed to an attached transformation.
bool IsolatedMessageSeriesEnd(bool blocking)
Marks the end of a series of messages, without signal propagation.
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.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
virtual std::string AlgorithmName() const
Provides the name of this algorithm.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
virtual PK_MessageAccumulator * NewVerificationAccumulator() const =0
Create a new HashTransformation to accumulate the message to be verified.
void GetRequiredParameter(const char *className, const char *name, T &value) const
Retrieves a required name/value pair.
Implementation of BufferedTransformation's attachment interface.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
A decryption filter encountered invalid ciphertext.
const char * OutputBuffer()
ByteArrayParameter.
W3C padding added to a block.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
byte * CreatePutSpace(size_t &size)
Request space which can be written into by the caller.
Interface for public-key signature verifiers.
Indicates the result of the verification should be passed to an attached transformation.
byte * begin() const
Pointer to the first byte in the memory block.
ProxyFilter(BufferedTransformation *filter, size_t firstSize, size_t lastSize, BufferedTransformation *attachment)
Construct a ProxyFilter.
void xorbuf(byte *buf, const byte *mask, size_t count)
Performs an XOR of a buffer with a mask.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
bool IsolatedFlush(bool hardFlush, bool blocking)
Flushes data buffered by this object, without signal propagation.
0's padding added to a block
const char * TruncatedDigestSize()
int
Implementation of BufferedTransformation's attachment interface.
const T & STDMAX(const T &a, const T &b)
Replacement function for std::max.
No padding added to a block.
void Initialize(const NameValuePairs ¶meters=g_nullNameValuePairs, int propagation=-1)
Initialize or reinitialize this object, with signal propagation.
Crypto++ library namespace.
void Initialize(const NameValuePairs ¶meters, int propagation)
Initialize or reinitialize this object, with signal propagation.
size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true)
Transfer bytes from this object to another BufferedTransformation.
PKCS #5 padding added to a block.
Indicates the signature is at the beginning of the message (i.e., concatenation of signature+message)...
bool GetValue(const char *name, T &value) const
Get a named value.
Indicates the signature should be passed to an attached transformation.
AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment=NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding=DEFAULT_PADDING)
Construct a AuthenticatedEncryptionFilter.
virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0
Input signature into a message accumulator.
Default flags using SIGNATURE_AT_BEGIN and PUT_RESULT.
const std::string AAD_CHANNEL
Channel for additional authenticated data.
byte * HelpCreatePutSpace(BufferedTransformation &target, const std::string &channel, size_t minSize, size_t desiredSize, size_t &bufferSize)
Create a working space in a BufferedTransformation.
void SetFilter(Filter *filter)
Sets the OutputProxy filter.
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
size_type size() const
Provides the count of elements in the SecBlock.
void GetRequiredIntParameter(const char *className, const char *name, int &value) const
Retrieves a required name/value pair.
T1 RoundDownToMultipleOf(const T1 &n, const T2 &m)
Rounds a value down to a multiple of a second value.
Default flags using HASH_AT_BEGIN and PUT_RESULT.
virtual bool SignatureUpfront() const
Determines whether the signature must be input before the message.
#define SIZE_MAX
The maximum value of a machine word.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Interface for retrieving values given their names.