aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2020-01-23 11:28:44 -0500
committerJack Lloyd <[email protected]>2020-01-23 11:28:44 -0500
commit240b71310baa5fc978f481caae6f7842aa77830b (patch)
tree26bf06b3ca40d802d3b3209f72cbeb832afab702 /src/lib
parent206c18114e7e7336a6f41251979b979bb74223e7 (diff)
Very minor GCM optimization
Improves performance a bit with very small message sizes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/modes/aead/gcm/gcm.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp
index 5dd6408d8..4e4b26f31 100644
--- a/src/lib/modes/aead/gcm/gcm.cpp
+++ b/src/lib/modes/aead/gcm/gcm.cpp
@@ -95,7 +95,10 @@ void GCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
- m_y0.resize(GCM_BS);
+ if(m_y0.size() != GCM_BS)
+ m_y0.resize(GCM_BS);
+
+ clear_mem(m_y0.data(), m_y0.size());
if(nonce_len == 12)
{
@@ -109,11 +112,11 @@ void GCM_Mode::start_msg(const uint8_t nonce[], size_t nonce_len)
m_ctr->set_iv(m_y0.data(), m_y0.size());
- zeroise(m_y0);
+ clear_mem(m_y0.data(), m_y0.size());
m_ctr->encipher(m_y0);
m_ghash->start(m_y0.data(), m_y0.size());
- m_y0.clear();
+ clear_mem(m_y0.data(), m_y0.size());
}
size_t GCM_Encryption::process(uint8_t buf[], size_t sz)