Do not assert KDF UUID and improve error message

This commit is contained in:
Janek Bevendorff 2018-01-11 00:20:37 +01:00 committed by Jonathan White
parent b04c8c2b6e
commit 6df54cfe8d
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
3 changed files with 3 additions and 4 deletions

View File

@ -203,7 +203,7 @@ bool Kdbx4Reader::readHeaderField(StoreDataStream& device)
QVariantMap kdfParams = readVariantMap(&bufIoDevice); QVariantMap kdfParams = readVariantMap(&bufIoDevice);
QSharedPointer<Kdf> kdf = KeePass2::kdfFromParameters(kdfParams); QSharedPointer<Kdf> kdf = KeePass2::kdfFromParameters(kdfParams);
if (!kdf) { if (!kdf) {
raiseError(tr("Invalid KDF parameters")); raiseError(tr("Unsupported key derivation function (KDF) or invalid parameters"));
return false; return false;
} }
m_db->setKdf(kdf); m_db->setKdf(kdf);

View File

@ -70,7 +70,7 @@ QByteArray KeePass2::hmacKey(QByteArray masterSeed, QByteArray transformedMaster
* @param p variant map containing parameters * @param p variant map containing parameters
* @return initialized KDF * @return initialized KDF
*/ */
QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap &p) QSharedPointer<Kdf> KeePass2::kdfFromParameters(const QVariantMap& p)
{ {
QByteArray uuidBytes = p.value(KDFPARAM_UUID).toByteArray(); QByteArray uuidBytes = p.value(KDFPARAM_UUID).toByteArray();
if (uuidBytes.size() != Uuid::Length) { if (uuidBytes.size() != Uuid::Length) {
@ -111,7 +111,6 @@ QSharedPointer<Kdf> KeePass2::uuidToKdf(const Uuid& uuid)
return QSharedPointer<Argon2Kdf>::create(); return QSharedPointer<Argon2Kdf>::create();
} }
Q_ASSERT_X(false, "uuidToKdf", "Invalid UUID");
return {}; return {};
} }

View File

@ -122,7 +122,7 @@ namespace KeePass2
}; };
QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey); QByteArray hmacKey(QByteArray masterSeed, QByteArray transformedMasterKey);
QSharedPointer<Kdf> kdfFromParameters(const QVariantMap &p); QSharedPointer<Kdf> kdfFromParameters(const QVariantMap& p);
QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf); QVariantMap kdfToParameters(QSharedPointer<Kdf> kdf);
QSharedPointer<Kdf> uuidToKdf(const Uuid& uuid); QSharedPointer<Kdf> uuidToKdf(const Uuid& uuid);
Uuid kdfToUuid(QSharedPointer<Kdf> kdf); Uuid kdfToUuid(QSharedPointer<Kdf> kdf);