diff options
author | Jeffrey Walton <noloader@gmail.com> | 2021-03-17 12:25:40 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2021-03-17 12:25:40 -0400 |
commit | bbc45ddfd7fca9b8d967657628da6b363fae0b1b (patch) | |
tree | 1764d30ed452497259e32f44ebdb9544d35f9c2c /strciphr.h | |
parent | 71a812ed9e7cdaa9b93cdd1285930d459e8d4900 (diff) | |
download | cryptopp-git-bbc45ddfd7fca9b8d967657628da6b363fae0b1b.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 'strciphr.h')
-rw-r--r-- | strciphr.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -388,7 +388,8 @@ protected: inline byte * KeystreamBufferBegin() {return this->m_buffer.data();}
inline byte * KeystreamBufferEnd() {return (PtrAdd(this->m_buffer.data(), this->m_buffer.size()));}
- AlignedSecByteBlock m_buffer;
+ // m_tempOutString added due to GH #1010
+ AlignedSecByteBlock m_buffer, m_tempOutString;
size_t m_leftOver;
};
@@ -633,6 +634,8 @@ protected: void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms);
+ // m_tempOutString added due to GH #1010
+ AlignedSecByteBlock m_tempOutString;
size_t m_leftOver;
};
|