mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-04-05 21:47:38 +03:00
Refactor Kdf class, remove fields concept
This commit is contained in:
parent
d00ccd2eb5
commit
15648991fc
17 changed files with 282 additions and 474 deletions
|
@ -318,36 +318,33 @@ void Kdbx3Reader::setTransformSeed(const QByteArray& data)
|
|||
{
|
||||
if (data.size() != 32) {
|
||||
raiseError("Invalid transform seed size");
|
||||
} else {
|
||||
AesKdf* aesKdf;
|
||||
if (m_db->kdf()->type() == Kdf::Type::AES) {
|
||||
aesKdf = static_cast<AesKdf*>(m_db->kdf());
|
||||
} else {
|
||||
aesKdf = new AesKdf();
|
||||
m_db->setKdf(aesKdf);
|
||||
}
|
||||
|
||||
aesKdf->setSeed(data);
|
||||
return;
|
||||
}
|
||||
|
||||
auto kdf = m_db->kdf();
|
||||
if (!kdf) {
|
||||
kdf = QSharedPointer<AesKdf>::create();
|
||||
m_db->setKdf(kdf);
|
||||
}
|
||||
|
||||
kdf->setSeed(data);
|
||||
}
|
||||
|
||||
void Kdbx3Reader::setTransformRounds(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 8) {
|
||||
raiseError("Invalid transform rounds size");
|
||||
} else {
|
||||
quint64 rounds = Endian::bytesToSizedInt<quint64>(data, KeePass2::BYTEORDER);
|
||||
|
||||
AesKdf* aesKdf;
|
||||
if (m_db->kdf()->type() == Kdf::Type::AES) {
|
||||
aesKdf = static_cast<AesKdf*>(m_db->kdf());
|
||||
} else {
|
||||
aesKdf = new AesKdf();
|
||||
m_db->setKdf(aesKdf);
|
||||
}
|
||||
|
||||
aesKdf->setRounds(rounds);
|
||||
return;
|
||||
}
|
||||
|
||||
auto rounds = Endian::bytesToSizedInt<quint64>(data, KeePass2::BYTEORDER);
|
||||
auto kdf = m_db->kdf();
|
||||
if (!kdf) {
|
||||
kdf = QSharedPointer<AesKdf>::create();
|
||||
m_db->setKdf(kdf);
|
||||
}
|
||||
|
||||
kdf->setRounds(rounds);
|
||||
}
|
||||
|
||||
void Kdbx3Reader::setEncryptionIV(const QByteArray& data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue