summaryrefslogtreecommitdiff
path: root/modes.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-03-17 12:17:27 -0400
committerJeffrey Walton <noloader@gmail.com>2021-03-17 12:17:27 -0400
commit71a812ed9e7cdaa9b93cdd1285930d459e8d4900 (patch)
tree582e162f5f0b73063c249e1c39e90fec325524ec /modes.cpp
parent4eac79fad8e40e978e05fb82abe7208de406936e (diff)
downloadcryptopp-git-71a812ed9e7cdaa9b93cdd1285930d459e8d4900.tar.gz
Fix CTR mode when using FileSource (GH #683, GH #1010)
We think this is another instance problem that surfaced under GH #683 when inString==outString. It violates aliasing rules and the compiler begins removing code. The ultimate workaround was to add a member variable m_tempOutString as scratch space when inString==outString. We did not loose much in the way of perforamce for some reason. It looks like AES/CTR lost about 0.03-0.05 cpb. When combined with the updated xorbuf from GH #1020, the net result was a speedup of 0.1-0.6 cpb. In fact, some ciphers like RC6, gained almost 5 cpb.
Diffstat (limited to 'modes.cpp')
-rw-r--r--modes.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/modes.cpp b/modes.cpp
index f307b353..a95e7a95 100644
--- a/modes.cpp
+++ b/modes.cpp
@@ -253,7 +253,7 @@ void CBC_Decryption::ProcessData(byte *outString, const byte *inString, size_t l
// save copy now in case of in-place decryption
const unsigned int blockSize = BlockSize();
- memcpy(m_temp, PtrAdd(inString,length-blockSize), blockSize);
+ memcpy(m_temp, PtrAdd(inString, length-blockSize), blockSize);
if (length > blockSize)
m_cipher->AdvancedProcessBlocks(PtrAdd(inString,blockSize), inString, PtrAdd(outString,blockSize), length-blockSize, BlockTransformation::BT_ReverseDirection|BlockTransformation::BT_AllowParallel);
m_cipher->ProcessAndXorBlock(inString, m_register, outString);