chacha: fix discarding

although it's not needed here.
This commit is contained in:
Mirek Kratochvil 2014-03-30 19:15:43 +02:00
parent 7d1d95784a
commit d44ae939d5

View file

@ -109,13 +109,15 @@ void chacha20::gen (size_t n, byte*out)
{
//empty the block buffer first
while (n && blockpos < 64) {
* (out++) = block[blockpos++];
if (out) * (out++) = block[blockpos++];
else blockpos++;
--n;
}
//fill in whole blocks
while (n >= 64) {
chacha_gen (key, counter, (uint32_t*) &out);
if (out) chacha_gen (key, counter, (uint32_t*) &out);
chacha_incr_counter (counter);
out += 64;
n -= 64;
@ -129,7 +131,8 @@ void chacha20::gen (size_t n, byte*out)
chacha_incr_counter (counter);
while (n) {
* (out++) = block[blockpos++];
if (out) * (out++) = block[blockpos++];
else blockpos++;
--n;
}
}