Catch botan exception in password manager and throw higher level exception.

This commit is contained in:
eelke 2022-07-08 19:54:18 +02:00
parent 6d05c6d75a
commit b5ca7099c1

View file

@ -171,10 +171,18 @@ std::string PasswordManager::encrypt(const std::string &name, const std::string
std::string PasswordManager::decrypt(const std::string &id, const std::string_view &encpwd)
{
if (m_cryptoEngine) {
if (m_cryptoEngine)
{
try
{
secure_vector<uint8_t> decoded = m_cryptoEngine->get(id, encpwd);
return std::string(reinterpret_cast<const char*>(decoded.data()), decoded.size());
}
catch (const Botan::Exception &ex)
{
throw PasswordManagerException(ex.what());
}
}
else {
throw PasswordManagerLockedException();
}