correct chacha20 for multiple messages

This commit is contained in:
orignal 2018-11-30 16:21:11 -05:00
parent e68f1dbc99
commit ef6db64e9f
4 changed files with 81 additions and 58 deletions

View file

@ -1182,12 +1182,12 @@ namespace crypto
chacha20 ((uint8_t *)polyKey, 64, nonce, key, 0);
Poly1305 polyHash (polyKey);
// encrypt buffers
Chacha20State state;
Chacha20Init (state, nonce, key, 1);
chacha::Chacha20State state;
chacha::Chacha20Init (state, nonce, key, 1);
size_t size = 0;
for (auto& it: bufs)
{
Chacha20Encrypt (state, (uint8_t *)it.first, it.second);
chacha::Chacha20Encrypt (state, (uint8_t *)it.first, it.second);
polyHash.Update ((uint8_t *)it.first, it.second); // after encryption
size += it.second;
}