aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-10-13 14:00:18 -0400
committerJack Lloyd <[email protected]>2019-10-13 14:00:18 -0400
commitef22f0773c4e0b43f8f0855fe8f52f673d079aa2 (patch)
tree7dbab4ad62030e94a06f4aaa31d83765c9725a6e /src
parent1c393ac67187deb03e87da8de0b740fb16ffffdf (diff)
Update DLIES in the same way
GH #2050
Diffstat (limited to 'src')
-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(...)