aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/pubkey/ecies/ecies.cpp11
-rw-r--r--src/tests/data/pubkey/ecies.vec2
-rw-r--r--src/tests/test_ecies.cpp7
3 files changed, 7 insertions, 13 deletions
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp
index 1c8ca45b6..cda3a8f55 100644
--- a/src/lib/pubkey/ecies/ecies.cpp
+++ b/src/lib/pubkey/ecies/ecies.cpp
@@ -287,10 +287,8 @@ 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->start(m_iv.bits_of());
- }
+ m_cipher->start(m_iv.bits_of());
+
secure_vector<uint8_t> encrypted_data(data, data + length);
m_cipher->finish(encrypted_data);
@@ -391,10 +389,7 @@ 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->start(m_iv.bits_of());
- }
+ m_cipher->start(m_iv.bits_of());
try
{
diff --git a/src/tests/data/pubkey/ecies.vec b/src/tests/data/pubkey/ecies.vec
index 9b22924c3..61bf1463e 100644
--- a/src/tests/data/pubkey/ecies.vec
+++ b/src/tests/data/pubkey/ecies.vec
@@ -58,7 +58,6 @@ OtherPrivateKey = 1255825134563225934367124570783723166851629196761
Kdf = KDF2(SHA-1)
Dem = AES-256/CBC
DemKeyLen = 32
-Iv = 00000000000000000000000000000000
Mac = HMAC(SHA-256)
MacKeyLen = 20
Format = compressed
@@ -76,7 +75,6 @@ OtherPrivateKey = 1255825134563225934367124570783723166851629196761
Kdf = KDF1-18033(SHA-1)
Dem = AES-256/CBC
DemKeyLen = 32
-Iv = 00000000000000000000000000000000
Mac = HMAC(SHA-256)
MacKeyLen = 20
Format = compressed
diff --git a/src/tests/test_ecies.cpp b/src/tests/test_ecies.cpp
index 534a2719e..97f6d2606 100644
--- a/src/tests/test_ecies.cpp
+++ b/src/tests/test_ecies.cpp
@@ -196,8 +196,9 @@ class ECIES_Tests final : public Text_Based_Test
ECIES_Tests()
: Text_Based_Test(
"pubkey/ecies.vec",
- "Curve,PrivateKey,OtherPrivateKey,Kdf,Dem,DemKeyLen,Iv,Mac,MacKeyLen,Format,"
- "CofactorMode,OldCofactorMode,CheckMode,SingleHashMode,Label,Plaintext,Ciphertext") {}
+ "Curve,PrivateKey,OtherPrivateKey,Kdf,Dem,DemKeyLen,Mac,MacKeyLen,Format,"
+ "CofactorMode,OldCofactorMode,CheckMode,SingleHashMode,Label,Plaintext,Ciphertext",
+ "Iv") {}
Test::Result run_one_test(const std::string&, const VarMap& vars) override
{
@@ -209,7 +210,7 @@ class ECIES_Tests final : public Text_Based_Test
const std::string kdf = vars.get_req_str("Kdf");
const std::string dem = vars.get_req_str("Dem");
const size_t dem_key_len = vars.get_req_sz("DemKeyLen");
- const std::vector<uint8_t> iv = vars.get_req_bin("Iv");
+ const std::vector<uint8_t> iv = vars.get_opt_bin("Iv");
const std::string mac = vars.get_req_str("Mac");
const size_t mac_key_len = vars.get_req_sz("MacKeyLen");
const Botan::PointGFp::Compression_Type compression_type = get_compression_type(vars.get_req_str("Format"));