From b8814d2833741156a5ddc2c758da4e907581c823 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 23 Jan 2015 20:33:09 +0000 Subject: Avoid needless buffering when handling padding bytes --- src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/modes/aead') 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 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 padding(16 - m_ad.size() % 16); + m_poly1305->update(padding); } else { @@ -96,8 +96,8 @@ void ChaCha20Poly1305_Encryption::finish(secure_vector& 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 padding(16 - m_ctext_len % 16); + m_poly1305->update(padding); update_len(m_ad.size()); } update_len(m_ctext_len); -- cgit v1.2.3