diff options
author | lloyd <[email protected]> | 2015-01-23 20:33:09 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-23 20:33:09 +0000 |
commit | b8814d2833741156a5ddc2c758da4e907581c823 (patch) | |
tree | fe0283907803254998e3b3cff4690e909e201b5b /src/lib/modes/aead | |
parent | 94befc816b7cd7067f1d68e8a8e9943c63fa1b88 (diff) |
Avoid needless buffering when handling padding bytes
Diffstat (limited to 'src/lib/modes/aead')
-rw-r--r-- | src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp index 38c2c2813..0961f1dc8 100644 --- a/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp +++ b/src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp @@ -69,8 +69,8 @@ secure_vector<byte> ChaCha20Poly1305_Mode::start_raw(const byte nonce[], size_t if(cfrg_version()) { - for(size_t i = 0; i != 16 - m_ad.size() % 16; ++i) - m_poly1305->update(0); + std::vector<byte> padding(16 - m_ad.size() % 16); + m_poly1305->update(padding); } else { @@ -96,8 +96,8 @@ void ChaCha20Poly1305_Encryption::finish(secure_vector<byte>& buffer, size_t off update(buffer, offset); if(cfrg_version()) { - for(size_t i = 0; i != 16 - m_ctext_len % 16; ++i) - m_poly1305->update(0); + std::vector<byte> padding(16 - m_ctext_len % 16); + m_poly1305->update(padding); update_len(m_ad.size()); } update_len(m_ctext_len); |