diff --git a/libdevcrypto/Common.cpp b/libdevcrypto/Common.cpp index 66f211933..af61a1dd5 100644 --- a/libdevcrypto/Common.cpp +++ b/libdevcrypto/Common.cpp @@ -189,7 +189,7 @@ bytes dev::pbkdf2(string const& _pass, bytes const& _salt, unsigned _iterations, _salt.size(), _iterations ) != _iterations) - BOOST_THROW_EXCEPTION(CryptoException()); + BOOST_THROW_EXCEPTION(CryptoException() << errinfo_comment("Key derivation failed.")); return ret; } @@ -207,7 +207,7 @@ bytes dev::scrypt(std::string const& _pass, bytes const& _salt, uint64_t _n, uin ret.data(), ret.size() ) != 0) - BOOST_THROW_EXCEPTION(CryptoException()); + BOOST_THROW_EXCEPTION(CryptoException() << errinfo_comment("Key derivation failed.")); return ret; } diff --git a/libdevcrypto/SecretStore.cpp b/libdevcrypto/SecretStore.cpp index 6423269f9..aeb06f11b 100644 --- a/libdevcrypto/SecretStore.cpp +++ b/libdevcrypto/SecretStore.cpp @@ -112,8 +112,6 @@ h128 SecretStore::importSecret(bytes const& _s, string const& _pass) { h128 r; EncryptedKey key{encrypt(_s, _pass), string()}; - if (!key.encryptedKey.empty()) - BOOST_THROW_EXCEPTION(crypto::CryptoException()); r = h128::random(); m_cached[r] = _s; m_keys[r] = move(key); @@ -243,10 +241,7 @@ string SecretStore::encrypt(bytes const& _v, string const& _pass, KDF _kdf) bytes derivedKey = deriveNewKey(_pass, _kdf, ret); if (derivedKey.empty()) - { - cwarn << "Key derivation failed."; - return string(); - } + BOOST_THROW_EXCEPTION(crypto::CryptoException() << errinfo_comment("Key derivation failed.")); ret["cipher"] = "aes-128-ctr"; h128 key(derivedKey, h128::AlignLeft); @@ -260,10 +255,7 @@ string SecretStore::encrypt(bytes const& _v, string const& _pass, KDF _kdf) // cipher text bytes cipherText = encryptSymNoAuth(key, iv, &_v); if (cipherText.empty()) - { - cwarn << "Key encryption failed."; - return string(); - } + BOOST_THROW_EXCEPTION(crypto::CryptoException() << errinfo_comment("Key encryption failed.")); ret["ciphertext"] = toHex(cipherText); // and mac.