6 #if CRYPTOPP_MSC_VERSION 7 # pragma warning(disable: 4100 4189) 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() == NULL)
39 m_attachment.reset(NewDefaultAttachment());
40 return m_attachment.get();
45 if (m_attachment.get() == NULL)
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;
160 void MeterFilter::ResetMeter()
162 m_currentMessageBytes = m_totalBytes = m_currentSeriesMessages = m_totalMessages = m_totalMessageSeries = 0;
163 m_rangesToSkip.clear();
166 void MeterFilter::AddRangeToSkip(
unsigned int message, lword position, lword size,
bool sortNow)
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);
191 assert(t < m_length);
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);
202 assert(t <= m_length);
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;
306 assert(m_size + length <= m_buffer.size());
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);
315 #if !defined(CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562) 323 :
Filter(attachment), m_firstSize(
SIZE_MAX), m_blockSize(0), m_lastSize(
SIZE_MAX), m_firstInputDone(false)
328 :
Filter(attachment), m_firstSize(firstSize), m_blockSize(blockSize), m_lastSize(lastSize), m_firstInputDone(false)
333 m_queue.ResetQueue(1, m_firstSize);
338 InitializeDerivedAndReturnNewSizes(parameters, m_firstSize, m_blockSize, m_lastSize);
341 m_queue.ResetQueue(1, m_firstSize);
342 m_firstInputDone =
false;
357 size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString,
size_t length,
int messageEnd,
bool blocking,
bool modifiable)
364 size_t newLength = m_queue.CurrentSize() + length;
366 if (!m_firstInputDone && newLength >= m_firstSize)
368 size_t len = m_firstSize - m_queue.CurrentSize();
369 m_queue.Put(inString, len);
370 FirstPut(m_queue.GetContigousBlocks(m_firstSize));
371 assert(m_queue.CurrentSize() == 0);
372 m_queue.ResetQueue(m_blockSize, (2*m_blockSize+m_lastSize-2)/m_blockSize);
375 newLength -= m_firstSize;
376 m_firstInputDone =
true;
379 if (m_firstInputDone)
381 if (m_blockSize == 1)
383 while (newLength > m_lastSize && m_queue.CurrentSize() > 0)
385 size_t len = newLength - m_lastSize;
386 byte *ptr = m_queue.GetContigousBlocks(len);
387 NextPutModifiable(ptr, len);
391 if (newLength > m_lastSize)
393 size_t len = newLength - m_lastSize;
394 NextPutMaybeModifiable(inString, len, modifiable);
401 while (newLength >= m_blockSize + m_lastSize && m_queue.CurrentSize() >= m_blockSize)
403 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
404 newLength -= m_blockSize;
407 if (newLength >= m_blockSize + m_lastSize && m_queue.CurrentSize() > 0)
409 assert(m_queue.CurrentSize() < m_blockSize);
410 size_t len = m_blockSize - m_queue.CurrentSize();
411 m_queue.Put(inString, len);
413 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
414 newLength -= m_blockSize;
417 if (newLength >= m_blockSize + m_lastSize)
420 NextPutMaybeModifiable(inString, len, modifiable);
427 m_queue.Put(inString, newLength - m_queue.CurrentSize());
432 if (!m_firstInputDone && m_firstSize==0)
436 m_queue.GetAll(temp);
437 LastPut(temp, temp.size());
439 m_firstInputDone =
false;
440 m_queue.ResetQueue(1, m_firstSize);
443 (
void)Output(1, NULL, 0, messageEnd, blocking);
450 if (!m_firstInputDone)
455 while (m_queue.CurrentSize() >= m_blockSize)
456 NextPutModifiable(m_queue.GetBlock(), m_blockSize);
461 while ((len = m_queue.CurrentSize()) > 0)
462 NextPutModifiable(m_queue.GetContigousBlocks(len), len);
466 void FilterWithBufferedInput::NextPutMultiple(
const byte *inString,
size_t length)
468 assert(m_blockSize > 1);
471 assert(length >= m_blockSize);
472 NextPutSingle(inString);
473 inString += m_blockSize;
474 length -= m_blockSize;
485 if (m_target && GetPassSignals())
486 m_target->Initialize(parameters, propagation);
500 return m_filter.get() ? m_filter->Flush(hardFlush, -1, blocking) :
false;
503 void ProxyFilter::SetFilter(
Filter *filter)
505 m_filter.reset(filter);
510 m_filter->TransferAllTo(*proxy);
511 m_filter->Attach(temp.release());
515 void ProxyFilter::NextPutMultiple(
const byte *s,
size_t len)
518 m_filter->Put(s, len);
521 void ProxyFilter::NextPutModifiable(byte *s,
size_t len)
524 m_filter->PutModifiable(s, len);
536 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
537 m_rng->IncorporateEntropy(begin, length);
541 size_t ArraySink::Put2(
const byte *begin,
size_t length,
int messageEnd,
bool blocking)
543 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
551 memmove(m_buf+m_total, begin, copied);
554 return length - copied;
560 return m_buf + m_total;
568 m_buf = array.begin();
569 m_size = array.size();
574 CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking);
581 xorbuf(m_buf+m_total, begin, copied);
584 return length - copied;
591 , m_cipher(c), m_padding(DEFAULT_PADDING), m_optimalBufferSize(0)
595 if (!allowAuthenticatedSymmetricCipher && dynamic_cast<AuthenticatedSymmetricCipher *>(&c) != 0)
596 throw InvalidArgument(
"StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher");
611 void StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
614 bool isBlockCipher = (m_cipher.MandatoryBlockSize() > 1 && m_cipher.MinLastBlockSize() == 0);
616 if (padding == DEFAULT_PADDING)
617 m_padding = isBlockCipher ? PKCS_PADDING : NO_PADDING;
621 if (!isBlockCipher && (m_padding == PKCS_PADDING || m_padding == ONE_AND_ZEROS_PADDING))
622 throw InvalidArgument(
"StreamTransformationFilter: PKCS_PADDING and ONE_AND_ZEROS_PADDING cannot be used with " + m_cipher.AlgorithmName());
625 blockSize = m_cipher.MandatoryBlockSize();
626 lastSize = LastBlockSize(m_cipher, m_padding);
629 void StreamTransformationFilter::FirstPut(
const byte* inString)
631 CRYPTOPP_UNUSED(inString);
632 m_optimalBufferSize = m_cipher.OptimalBlockSize();
636 void StreamTransformationFilter::NextPutMultiple(
const byte *inString,
size_t length)
641 size_t s = m_cipher.MandatoryBlockSize();
645 size_t len = m_optimalBufferSize;
649 if (len == m_optimalBufferSize)
650 len -= m_cipher.GetOptimalBlockSizeUsed();
655 m_cipher.ProcessString(space, inString, len);
663 void StreamTransformationFilter::NextPutModifiable(byte *inString,
size_t length)
665 m_cipher.ProcessString(inString, length);
669 void StreamTransformationFilter::LastPut(
const byte *inString,
size_t length)
679 size_t minLastBlockSize = m_cipher.MinLastBlockSize();
680 bool isForwardTransformation = m_cipher.IsForwardTransformation();
682 if (isForwardTransformation && m_padding == ZEROS_PADDING && (minLastBlockSize == 0 || length < minLastBlockSize))
685 size_t blockSize =
STDMAX(minLastBlockSize, (
size_t)m_cipher.MandatoryBlockSize());
687 if (inString) {memcpy(space, inString, length);}
688 memset(space + length, 0, blockSize - length);
689 m_cipher.ProcessLastBlock(space, space, blockSize);
694 if (minLastBlockSize == 0)
696 if (isForwardTransformation)
697 throw InvalidDataFormat(
"StreamTransformationFilter: plaintext length is not a multiple of block size and NO_PADDING is specified");
699 throw InvalidCiphertext(
"StreamTransformationFilter: ciphertext length is not a multiple of block size");
703 m_cipher.ProcessLastBlock(space, inString, length);
710 case ONE_AND_ZEROS_PADDING:
712 s = m_cipher.MandatoryBlockSize();
715 if (m_cipher.IsForwardTransformation())
718 if (inString) {memcpy(space, inString, length);}
719 if (m_padding == PKCS_PADDING)
722 byte pad = byte(s-length);
723 memset(space+length, pad, s-length);
727 space[length] = 0x80;
728 memset(space+length+1, 0, s-length-1);
730 m_cipher.ProcessData(space, space, s);
736 throw InvalidCiphertext(
"StreamTransformationFilter: ciphertext length is not a multiple of block size");
737 m_cipher.ProcessData(space, inString, s);
738 if (m_padding == PKCS_PADDING)
740 byte pad = space[s-1];
741 if (pad < 1 || pad > s || std::find_if(space+s-pad, space+s, std::bind2nd(std::not_equal_to<byte>(), pad)) != space+s)
742 throw InvalidCiphertext(
"StreamTransformationFilter: invalid PKCS #7 block padding found");
747 while (length > 1 && space[length-1] == 0)
749 if (space[--length] != 0x80)
750 throw InvalidCiphertext(
"StreamTransformationFilter: invalid ones-and-zeros padding found");
763 HashFilter::HashFilter(
HashTransformation &hm,
BufferedTransformation *attachment,
bool putMessage,
int truncatedDigestSize,
const std::string &messagePutChannel,
const std::string &hashPutChannel)
764 : m_hashModule(hm), m_putMessage(putMessage), m_digestSize(0), m_space(NULL)
765 , m_messagePutChannel(messagePutChannel), m_hashPutChannel(hashPutChannel)
767 m_digestSize = truncatedDigestSize < 0 ? m_hashModule.DigestSize() : truncatedDigestSize;
775 m_digestSize = s < 0 ? m_hashModule.DigestSize() : s;
778 size_t HashFilter::Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking)
782 FILTER_OUTPUT3(1, 0, inString, length, 0, m_messagePutChannel);
783 m_hashModule.Update(inString, length);
788 m_space = HelpCreatePutSpace(*
AttachedTransformation(), m_hashPutChannel, m_digestSize, m_digestSize, size = m_digestSize);
789 m_hashModule.TruncatedFinal(m_space, m_digestSize);
791 FILTER_OUTPUT3(2, 0, m_space, m_digestSize, messageEnd, m_hashPutChannel);
793 FILTER_END_NO_MESSAGE_END;
800 , m_hashModule(hm), m_flags(0), m_digestSize(0), m_verified(
false)
805 void HashVerificationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
809 m_digestSize = s < 0 ? m_hashModule.DigestSize() : s;
811 firstSize = m_flags & HASH_AT_BEGIN ? m_digestSize : 0;
813 lastSize = m_flags & HASH_AT_BEGIN ? 0 : m_digestSize;
816 void HashVerificationFilter::FirstPut(
const byte *inString)
818 if (m_flags & HASH_AT_BEGIN)
820 m_expectedHash.New(m_digestSize);
821 if (inString) {memcpy(m_expectedHash, inString, m_expectedHash.size());}
822 if (m_flags & PUT_HASH)
827 void HashVerificationFilter::NextPutMultiple(
const byte *inString,
size_t length)
829 m_hashModule.Update(inString, length);
830 if (m_flags & PUT_MESSAGE)
834 void HashVerificationFilter::LastPut(
const byte *inString,
size_t length)
836 if (m_flags & HASH_AT_BEGIN)
839 m_verified = m_hashModule.TruncatedVerify(m_expectedHash, m_digestSize);
843 m_verified = (length==m_digestSize && m_hashModule.TruncatedVerify(inString, length));
844 if (m_flags & PUT_HASH)
848 if (m_flags & PUT_RESULT)
851 if ((m_flags & THROW_EXCEPTION) && !m_verified)
852 throw HashVerificationFailed();
858 bool putAAD,
int truncatedDigestSize,
const std::string &macChannel,
BlockPaddingScheme padding)
888 return m_hf.
Put2(begin, length, 0, blocking);
893 void AuthenticatedEncryptionFilter::LastPut(
const byte *inString,
size_t length)
895 StreamTransformationFilter::LastPut(inString, length);
904 , m_streamFilter(c, new
OutputProxy(*this, false), padding, true)
910 void AuthenticatedDecryptionFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
917 firstSize = m_hashVerifier.m_firstSize;
919 lastSize = m_hashVerifier.m_lastSize;
943 return m_hashVerifier.
Put2(begin, length, 0, blocking);
948 void AuthenticatedDecryptionFilter::FirstPut(
const byte *inString)
950 m_hashVerifier.
Put(inString, m_firstSize);
953 void AuthenticatedDecryptionFilter::NextPutMultiple(
const byte *inString,
size_t length)
955 m_streamFilter.
Put(inString, length);
958 void AuthenticatedDecryptionFilter::LastPut(
const byte *inString,
size_t length)
969 m_messageAccumulator.reset(m_signer.NewSignatureAccumulator(m_rng));
975 m_messageAccumulator->Update(inString, length);
977 FILTER_OUTPUT(1, inString, length, 0);
980 m_buf.New(m_signer.SignatureLength());
981 m_signer.Sign(m_rng, m_messageAccumulator.release(), m_buf);
982 FILTER_OUTPUT(2, m_buf, m_buf.size(), messageEnd);
983 m_messageAccumulator.reset(m_signer.NewSignatureAccumulator(m_rng));
985 FILTER_END_NO_MESSAGE_END;
990 , m_verifier(verifier), m_flags(0), m_verified(0)
995 void SignatureVerificationFilter::InitializeDerivedAndReturnNewSizes(
const NameValuePairs ¶meters,
size_t &firstSize,
size_t &blockSize,
size_t &lastSize)
998 m_messageAccumulator.reset(m_verifier.NewVerificationAccumulator());
999 size_t size = m_verifier.SignatureLength();
1002 firstSize = m_flags & SIGNATURE_AT_BEGIN ? size : 0;
1004 lastSize = m_flags & SIGNATURE_AT_BEGIN ? 0 : size;
1007 void SignatureVerificationFilter::FirstPut(
const byte *inString)
1009 if (m_flags & SIGNATURE_AT_BEGIN)
1011 if (m_verifier.SignatureUpfront())
1012 m_verifier.InputSignature(*m_messageAccumulator, inString, m_verifier.SignatureLength());
1015 m_signature.New(m_verifier.SignatureLength());
1016 if (inString) {memcpy(m_signature, inString, m_signature.size());}
1019 if (m_flags & PUT_SIGNATURE)
1024 assert(!m_verifier.SignatureUpfront());
1028 void SignatureVerificationFilter::NextPutMultiple(
const byte *inString,
size_t length)
1030 m_messageAccumulator->Update(inString, length);
1031 if (m_flags & PUT_MESSAGE)
1035 void SignatureVerificationFilter::LastPut(
const byte *inString,
size_t length)
1037 if (m_flags & SIGNATURE_AT_BEGIN)
1039 assert(length == 0);
1040 m_verifier.InputSignature(*m_messageAccumulator, m_signature, m_signature.size());
1041 m_verified = m_verifier.VerifyAndRestart(*m_messageAccumulator);
1045 m_verifier.InputSignature(*m_messageAccumulator, inString, length);
1046 m_verified = m_verifier.VerifyAndRestart(*m_messageAccumulator);
1047 if (m_flags & PUT_SIGNATURE)
1051 if (m_flags & PUT_RESULT)
1054 if ((m_flags & THROW_EXCEPTION) && !m_verified)
1055 throw SignatureVerificationFailed();
1060 size_t Source::PumpAll2(
bool blocking)
1062 unsigned int messageCount = UINT_MAX;
1064 RETURN_IF_NONZERO(PumpMessages2(messageCount, blocking));
1065 }
while(messageCount == UINT_MAX);
1081 unsigned int Store::CopyMessagesTo(
BufferedTransformation &target,
unsigned int count,
const std::string &channel)
const 1083 if (m_messageEnd || count == 0)
1087 CopyTo(target, ULONG_MAX, channel);
1094 void StringStore::StoreInitialize(
const NameValuePairs ¶meters)
1099 m_store = array.begin();
1100 m_length = array.size();
1107 size_t blockedBytes =
CopyRangeTo2(target, position, transferBytes, channel, blocking);
1108 m_count += (size_t)position;
1109 transferBytes = position;
1110 return blockedBytes;
1117 size_t blockedBytes = target.
ChannelPut2(channel, m_store+i, len, 0, blocking);
1120 return blockedBytes;
1123 void RandomNumberStore::StoreInitialize(
const NameValuePairs ¶meters)
1134 throw NotImplemented(
"RandomNumberStore: nonblocking transfer is not implemented by this object");
1136 transferBytes =
UnsignedMin(transferBytes, m_length - m_count);
1137 m_rng->GenerateIntoBufferedTransformation(target, channel, transferBytes);
1138 m_count += transferBytes;
1145 static const byte nullBytes[128] = {0};
1148 size_t len = (size_t)
STDMIN(end-begin, lword(128));
1149 size_t blockedBytes = target.
ChannelPut2(channel, nullBytes, len, 0, blocking);
1151 return blockedBytes;
1161 transferBytes = begin;
1163 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.
Standard names for retrieving values by name when working with NameValuePairs.
An invalid argument was detected.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Filter(BufferedTransformation *attachment=NULL)
Construct a Filter.
void GetRequiredParameter(const char *className, const char *name, T &value) const
Retrieves a required name/value pair.
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.
Interface for one direction (encryption or decryption) of a stream cipher or block cipher mode with a...
T GetValueWithDefault(const char *name, T defaultValue) const
Get a named value.
const char * HashVerificationFilterFlags()
word32
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)
Classes for automatic resource management.
Library configuration file.
byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)
Request space which can be written into by the caller.
bool GetNextMessage()
Start retrieving the next message.
SecByteBlock is a SecBlock<byte> typedef.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Pointer that overloads operator→
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, 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.
bool GetValue(const char *name, T &value) const
Get a named value.
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
A method was called which was not implemented.
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.
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.
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.
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.
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.
bool IsolatedMessageSeriesEnd(bool blocking)
Marks the end of a series of messages, without signal propagation.
void GetRequiredIntParameter(const char *className, const char *name, int &value) const
Retrieves a required name/value pair.
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.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
Implementation of BufferedTransformation's attachment interface in cryptlib.h.
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.
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.
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.
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 IsolatedFlush(bool hardFlush, bool blocking)
const char * TruncatedDigestSize()
int
Implementation of BufferedTransformation's attachment interface.
const T & STDMAX(const T &a, const T &b)
Replacement function for std::max.
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.
AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment=NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding=DEFAULT_PADDING)
const std::string AAD_CHANNEL
Channel for additional authenticated data.
bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)
Flush buffered input and/or output, with signal propagation.
T1 RoundDownToMultipleOf(const T1 &n, const T2 &m)
Rounds a value down to a multiple of a second value.
#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.