summaryrefslogtreecommitdiff
path: root/filters.cpp
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-03 03:28:39 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2009-03-03 03:28:39 +0000
commitf1b1bf3d0dea2032f9ce5f9b3d29b7ed5d22a32a (patch)
treebbbd178df43bdc71503320cd87f5ec0c84c9d494 /filters.cpp
parent94ee86bbf6d35476281a7012136e7c74c1693231 (diff)
downloadcryptopp-f1b1bf3d0dea2032f9ce5f9b3d29b7ed5d22a32a.tar.gz
tweaks/fixes for 5.6
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@435 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'filters.cpp')
-rw-r--r--filters.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/filters.cpp b/filters.cpp
index e9ca428..86bd616 100644
--- a/filters.cpp
+++ b/filters.cpp
@@ -540,6 +540,18 @@ size_t ArrayXorSink::Put2(const byte *begin, size_t length, int messageEnd, bool
// *************************************************************
+StreamTransformationFilter::StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment, BlockPaddingScheme padding, bool allowAuthenticatedSymmetricCipher)
+ : FilterWithBufferedInput(attachment)
+ , m_cipher(c)
+{
+ assert(c.MinLastBlockSize() == 0 || c.MinLastBlockSize() > c.MandatoryBlockSize());
+
+ if (!allowAuthenticatedSymmetricCipher && dynamic_cast<AuthenticatedSymmetricCipher *>(&c) != 0)
+ throw InvalidArgument("StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher");
+
+ IsolatedInitialize(MakeParameters(Name::BlockPaddingScheme(), padding));
+}
+
size_t StreamTransformationFilter::LastBlockSize(StreamTransformation &c, BlockPaddingScheme padding)
{
if (c.MinLastBlockSize() > 0)
@@ -550,15 +562,6 @@ size_t StreamTransformationFilter::LastBlockSize(StreamTransformation &c, BlockP
return 0;
}
-StreamTransformationFilter::StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment, BlockPaddingScheme padding)
- : FilterWithBufferedInput(attachment)
- , m_cipher(c)
-{
- assert(c.MinLastBlockSize() == 0 || c.MinLastBlockSize() > c.MandatoryBlockSize());
-
- IsolatedInitialize(MakeParameters(Name::BlockPaddingScheme(), padding));
-}
-
void StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize)
{
BlockPaddingScheme padding = parameters.GetValueWithDefault(Name::BlockPaddingScheme(), DEFAULT_PADDING);
@@ -804,8 +807,8 @@ void HashVerificationFilter::LastPut(const byte *inString, size_t length)
// *************************************************************
AuthenticatedEncryptionFilter::AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment,
- BlockPaddingScheme padding, bool putMessage, int truncatedDigestSize, const std::string &macChannel)
- : StreamTransformationFilter(c, attachment, padding)
+ bool putMessage, int truncatedDigestSize, const std::string &macChannel, BlockPaddingScheme padding)
+ : StreamTransformationFilter(c, attachment, padding, true)
, m_hf(c, new OutputProxy(*this, false), putMessage, truncatedDigestSize, "AAD", macChannel)
{
assert(c.IsForwardTransformation());
@@ -847,10 +850,10 @@ void AuthenticatedEncryptionFilter::LastPut(const byte *inString, size_t length)
// *************************************************************
-AuthenticatedDecryptionFilter::AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment, BlockPaddingScheme padding, word32 flags, int truncatedDigestSize)
+AuthenticatedDecryptionFilter::AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment, word32 flags, int truncatedDigestSize, BlockPaddingScheme padding)
: FilterWithBufferedInput(attachment)
, m_hashVerifier(c, new OutputProxy(*this, false))
- , m_streamFilter(c, new OutputProxy(*this, false))
+ , m_streamFilter(c, new OutputProxy(*this, false), padding, true)
{
assert(!c.IsForwardTransformation() || c.IsSelfInverting());
IsolatedInitialize(MakeParameters(Name::BlockPaddingScheme(), padding)(Name::AuthenticatedDecryptionFilterFlags(), flags)(Name::TruncatedDigestSize(), truncatedDigestSize));