mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-21 13:52:36 +00:00
Crypto: fix ChaCha partial block continuation
Count consumed input bytes so short updates don't skip unused keystream. Reset the saved offset when the block is exhausted. Reported by @router0mail.
This commit is contained in:
@@ -151,12 +151,14 @@ static VC_INLINE void do_encrypt(const unsigned char* in, size_t len, unsigned c
|
||||
size_t i = 0, pos = *posPtr;
|
||||
if (pos)
|
||||
{
|
||||
while (pos < len && pos < 64)
|
||||
while (i < len && pos < 64)
|
||||
{
|
||||
out[i] = in[i] ^ ((unsigned char*)block)[pos++];
|
||||
++i;
|
||||
}
|
||||
len -= i;
|
||||
if (pos == 64)
|
||||
pos = 0;
|
||||
}
|
||||
if (len)
|
||||
pos = 0;
|
||||
|
||||
Reference in New Issue
Block a user