mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Pull out KDFs into their own class hierarchy
In preparation for multiple KDFs in KDBX 4
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#include <QImage>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "crypto/kdf/AesKdf.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Endian.h"
|
||||
#include "core/Entry.h"
|
||||
@@ -159,10 +160,10 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
raiseError("Invalid number of transform rounds");
|
||||
return nullptr;
|
||||
}
|
||||
if (!m_db->setTransformRounds(m_transformRounds)) {
|
||||
raiseError(tr("Unable to calculate master key"));
|
||||
return nullptr;
|
||||
}
|
||||
AesKdf* kdf = new AesKdf();
|
||||
kdf->setRounds(m_transformRounds);
|
||||
kdf->setSeed(m_transformSeed);
|
||||
db->setKdf(kdf);
|
||||
|
||||
qint64 contentPos = m_device->pos();
|
||||
|
||||
@@ -397,12 +398,11 @@ QByteArray KeePass1Reader::key(const QByteArray& password, const QByteArray& key
|
||||
key.setPassword(password);
|
||||
key.setKeyfileData(keyfileData);
|
||||
|
||||
bool ok;
|
||||
QString errorString;
|
||||
QByteArray transformedKey = key.transform(m_transformSeed, m_transformRounds, &ok, &errorString);
|
||||
QByteArray transformedKey;
|
||||
bool result = key.transform(*m_db->kdf(), transformedKey);
|
||||
|
||||
if (!ok) {
|
||||
raiseError(errorString);
|
||||
if (!result) {
|
||||
raiseError("Key transformation failed");
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user