aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r--src/lib/pubkey/dlies/dlies.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/pubkey/dlies/dlies.cpp b/src/lib/pubkey/dlies/dlies.cpp
index d24542d0e..4aee3ffb3 100644
--- a/src/lib/pubkey/dlies/dlies.cpp
+++ b/src/lib/pubkey/dlies/dlies.cpp
@@ -69,11 +69,9 @@ std::vector<uint8_t> DLIES_Encryptor::enc(const uint8_t in[], size_t length,
SymmetricKey enc_key(secret_keys.data(), cipher_key_len);
m_cipher->set_key(enc_key);
- if(m_iv.size())
- {
- m_cipher->start(m_iv.bits_of());
- }
-
+ if(m_iv.size() == 0 && !m_cipher->valid_nonce_length(m_iv.size()))
+ throw Invalid_Argument("DLIES with " + m_cipher->name() + " requires an IV be set");
+ m_cipher->start(m_iv.bits_of());
m_cipher->finish(ciphertext);
}
else
@@ -194,11 +192,9 @@ secure_vector<uint8_t> DLIES_Decryptor::do_decrypt(uint8_t& valid_mask,
// the decryption can fail:
// e.g. Invalid_Authentication_Tag is thrown if GCM is used and the message does not have a valid tag
- if(m_iv.size())
- {
- m_cipher->start(m_iv.bits_of());
- }
-
+ if(m_iv.size() == 0 && !m_cipher->valid_nonce_length(m_iv.size()))
+ throw Invalid_Argument("DLIES with " + m_cipher->name() + " requires an IV be set");
+ m_cipher->start(m_iv.bits_of());
m_cipher->finish(ciphertext);
}
catch(...)