summaryrefslogtreecommitdiff
path: root/hc128.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-10-25 08:24:13 -0400
committerJeffrey Walton <noloader@gmail.com>2018-10-25 08:24:13 -0400
commit352083b1d06f73ea571ff4804d4169630e3eab88 (patch)
tree557829a92452bffb0f34eb2a26705df708952c7c /hc128.cpp
parentba5ca6b8cded2abdf7f082980e6452ffdf322650 (diff)
downloadcryptopp-git-352083b1d06f73ea571ff4804d4169630e3eab88.tar.gz
Cleanup HC128 and HC256 OperateKeystream
Diffstat (limited to 'hc128.cpp')
-rw-r--r--hc128.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/hc128.cpp b/hc128.cpp
index 682344c5..b734d6e5 100644
--- a/hc128.cpp
+++ b/hc128.cpp
@@ -200,8 +200,7 @@ void HC128Policy::CipherSetKey(const NameValuePairs &params, const byte *userKey
void HC128Policy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
{
- size_t msglen = GetBytesPerIteration() * iterationCount;
- while (msglen >= 64)
+ while (iterationCount--)
{
word32 keystream[16];
GenerateKeystream(keystream);
@@ -231,9 +230,12 @@ void HC128Policy::OperateKeystream(KeystreamOperation operation, byte *output, c
// keystream is written to the output buffer. The optional part is
// adding the input buffer and keystream.
if ((operation & INPUT_NULL) != INPUT_NULL)
- xorbuf(output, input, 64);
+ {
+ xorbuf(output, input, BYTES_PER_ITERATION);
+ input += BYTES_PER_ITERATION;
+ }
- msglen -= 64; input += 64; output += 64;
+ output += BYTES_PER_ITERATION;
}
}