aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/ecies/ecies.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/pubkey/ecies/ecies.cpp')
-rw-r--r--src/lib/pubkey/ecies/ecies.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp
index cda3a8f55..a8c277b3a 100644
--- a/src/lib/pubkey/ecies/ecies.cpp
+++ b/src/lib/pubkey/ecies/ecies.cpp
@@ -287,6 +287,9 @@ std::vector<uint8_t> ECIES_Encryptor::enc(const uint8_t data[], size_t length, R
// encryption
m_cipher->set_key(SymmetricKey(secret_key.begin(), m_params.dem_keylen()));
+ if(m_iv.size() == 0 && !m_cipher->valid_nonce_length(m_iv.size()))
+ throw Invalid_Argument("ECIES with " + m_cipher->name() + " requires an IV be set");
+
m_cipher->start(m_iv.bits_of());
secure_vector<uint8_t> encrypted_data(data, data + length);
@@ -389,6 +392,8 @@ secure_vector<uint8_t> ECIES_Decryptor::do_decrypt(uint8_t& valid_mask, const ui
// decrypt data
m_cipher->set_key(SymmetricKey(secret_key.begin(), m_params.dem_keylen()));
+ if(m_iv.size() == 0 && !m_cipher->valid_nonce_length(m_iv.size()))
+ throw Invalid_Argument("ECIES with " + m_cipher->name() + " requires an IV be set");
m_cipher->start(m_iv.bits_of());
try