aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/modes/aead
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-01-23 20:33:09 +0000
committerlloyd <[email protected]>2015-01-23 20:33:09 +0000
commitb8814d2833741156a5ddc2c758da4e907581c823 (patch)
treefe0283907803254998e3b3cff4690e909e201b5b /src/lib/modes/aead
parent94befc816b7cd7067f1d68e8a8e9943c63fa1b88 (diff)
Avoid needless buffering when handling padding bytes
Diffstat (limited to 'src/lib/modes/aead')
-rw-r--r--src/lib/modes/aead/chacha20poly1305/chacha20poly1305.cpp8
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);