mirror of
https://github.com/QuasarApp/qca.git
synced 2025-05-09 17:29:33 +00:00
botan: Fix crash if asking for something botan doesn't provide
Fixes crash in KDFUnitTest with my botan installation
This commit is contained in:
parent
1b061d63a8
commit
b9d80939c6
@ -179,7 +179,12 @@ class BotanPBKDFContext: public QCA::KDFContext
|
||||
public:
|
||||
BotanPBKDFContext( const QString &kdfName, QCA::Provider *p, const QString &type) : QCA::KDFContext(p, type)
|
||||
{
|
||||
m_s2k = Botan::get_s2k(kdfName.toStdString());
|
||||
try {
|
||||
m_s2k = Botan::get_s2k(kdfName.toStdString());
|
||||
} catch (Botan::Exception& e) {
|
||||
m_s2k = nullptr;
|
||||
std::cout << "caught: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
~BotanPBKDFContext()
|
||||
@ -195,6 +200,9 @@ public:
|
||||
QCA::SymmetricKey makeKey(const QCA::SecureArray &secret, const QCA::InitializationVector &salt,
|
||||
unsigned int keyLength, unsigned int iterationCount) override
|
||||
{
|
||||
if (!m_s2k)
|
||||
return {};
|
||||
|
||||
std::string secretString(secret.data(), secret.size() );
|
||||
Botan::OctetString key = m_s2k->derive_key(keyLength, secretString, (const Botan::byte*)salt.data(), salt.size(), iterationCount);
|
||||
QCA::SecureArray retval(QByteArray((const char*)key.begin(), key.length()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user