diff options
author | Jack Lloyd <[email protected]> | 2019-10-13 13:10:47 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-10-13 13:10:47 -0400 |
commit | 1c393ac67187deb03e87da8de0b740fb16ffffdf (patch) | |
tree | d31bb8e5a69a3e1517b38b0438f8d24a51d6b438 | |
parent | bce33087defad65769f4666c8f1a95013684116a (diff) |
Add a more explicit exception to catch cases where app doesn't set IV
-rw-r--r-- | src/lib/pubkey/ecies/ecies.cpp | 5 |
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 |