diff options
-rw-r--r-- | src/aead/eax/eax.cpp | 3 | ||||
-rw-r--r-- | src/aead/gcm/gcm.cpp | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/aead/eax/eax.cpp b/src/aead/eax/eax.cpp index fa0496f42..725a473f4 100644 --- a/src/aead/eax/eax.cpp +++ b/src/aead/eax/eax.cpp @@ -94,6 +94,9 @@ void EAX_Mode::set_associated_data(const byte ad[], size_t length) secure_vector<byte> EAX_Mode::start(const byte nonce[], size_t nonce_len) { + if(!valid_nonce_length(nonce_len)) + throw Invalid_IV_Length(name(), nonce_len); + m_nonce_mac = eax_prf(0, block_size(), *m_cmac, nonce, nonce_len); m_ctr->set_iv(&m_nonce_mac[0], m_nonce_mac.size()); diff --git a/src/aead/gcm/gcm.cpp b/src/aead/gcm/gcm.cpp index a067d162e..a5ccee927 100644 --- a/src/aead/gcm/gcm.cpp +++ b/src/aead/gcm/gcm.cpp @@ -155,6 +155,9 @@ void GCM_Mode::set_associated_data(const byte ad[], size_t ad_len) secure_vector<byte> GCM_Mode::start(const byte nonce[], size_t nonce_len) { + if(!valid_nonce_length(nonce_len)) + throw Invalid_IV_Length(name(), nonce_len); + secure_vector<byte> y0(BS); if(nonce_len == 12) |