diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-09-29 22:34:33 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-09-29 22:34:33 -0400 |
commit | e92eb316906c41b349f6c86a8186fd18b0b3b580 (patch) | |
tree | 93342c71e707564ae64d46bb60df16353762159f /cryptlib.cpp | |
parent | bebdc8b91723f9155c22e5e4543ea02f4870c954 (diff) | |
download | cryptopp-git-e92eb316906c41b349f6c86a8186fd18b0b3b580.tar.gz |
Update StreamTransformation and ProcessLastBlock
Some authenticated encryption modes have needs that are not expressed well with MandatoryBlockSize() and MinLastBlockSize(). When IsLastBlockSpecial() returns true three things happen. First, standard block cipher padding is not applied. Second, the ProcessLastBlock() is used that provides inString and outString lengths. Third, outString is larger than inString by 2*MandatoryBlockSize(). That is, there's a reserve available when processing the last block.
The return value of ProcessLastBlock() indicates how many bytes were written to outString. A filter driving data will send outString and returned length to an AttachedTransformation() for additional processing.
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r-- | cryptlib.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp index 162a9b81..41461c61 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -213,6 +213,7 @@ unsigned int HashTransformation::OptimalDataAlignment() const return GetAlignmentOf<word32>();
}
+#if 0
void StreamTransformation::ProcessLastBlock(byte *outString, const byte *inString, size_t length)
{
CRYPTOPP_ASSERT(MinLastBlockSize() == 0); // this function should be overridden otherwise
@@ -222,6 +223,22 @@ void StreamTransformation::ProcessLastBlock(byte *outString, const byte *inStrin else if (length != 0)
throw NotImplemented(AlgorithmName() + ": this object doesn't support a special last block");
}
+#endif
+
+size_t StreamTransformation::ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength)
+{
+ // this function should be overridden otherwise
+ CRYPTOPP_ASSERT(MinLastBlockSize() == 0);
+
+ if (inLength == MandatoryBlockSize())
+ {
+ ProcessData(outString, inString, inLength);
+ return inLength;
+ }
+ else if (inLength != 0)
+ throw NotImplemented(AlgorithmName() + ": this object doesn't support a special last block");
+ return 0;
+}
void AuthenticatedSymmetricCipher::SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
{
|