mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Move key transform() call into Database.
This commit is contained in:
parent
fd9685037b
commit
6afda908bc
@ -21,6 +21,7 @@
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
|
||||
#include "Metadata.h"
|
||||
#include "crypto/Random.h"
|
||||
|
||||
Database::Database()
|
||||
{
|
||||
@ -142,21 +143,18 @@ void Database::setCompressionAlgo(Database::CompressionAlgorithm algo)
|
||||
m_compressionAlgo = algo;
|
||||
}
|
||||
|
||||
void Database::setTransformSeed(const QByteArray& seed)
|
||||
{
|
||||
Q_ASSERT(seed.size() == 32);
|
||||
|
||||
m_transformSeed = seed;
|
||||
}
|
||||
|
||||
void Database::setTransformRounds(quint64 rounds)
|
||||
{
|
||||
m_transformRounds = rounds;
|
||||
}
|
||||
|
||||
void Database::setTransformedMasterKey(QByteArray& key)
|
||||
void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed)
|
||||
{
|
||||
Q_ASSERT(key.size() == 32);
|
||||
|
||||
m_transformedMasterKey = key;
|
||||
m_transformSeed = transformSeed;
|
||||
m_transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||
}
|
||||
|
||||
void Database::setKey(const CompositeKey& key)
|
||||
{
|
||||
setKey(key, Random::randomArray(32));
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <QtCore/QHash>
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
#include "keys/CompositeKey.h"
|
||||
|
||||
class Metadata;
|
||||
|
||||
struct DeletedObject
|
||||
@ -62,9 +64,9 @@ public:
|
||||
|
||||
void setCipher(const Uuid& cipher);
|
||||
void setCompressionAlgo(Database::CompressionAlgorithm algo);
|
||||
void setTransformSeed(const QByteArray& seed);
|
||||
void setTransformRounds(quint64 rounds);
|
||||
void setTransformedMasterKey(QByteArray& key);
|
||||
void setKey(const CompositeKey& key, const QByteArray& transformSeed);
|
||||
void setKey(const CompositeKey& key);
|
||||
|
||||
Q_SIGNALS:
|
||||
void groupDataChanged(Group* group);
|
||||
|
@ -64,12 +64,11 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
||||
|
||||
// TODO check if all header fields have been parsed
|
||||
|
||||
QByteArray transformedMasterKey = key.transform(m_db->transformSeed(), m_db->transformRounds());
|
||||
m_db->setTransformedMasterKey(transformedMasterKey);
|
||||
m_db->setKey(key, m_transformSeed);
|
||||
|
||||
CryptoHash hash(CryptoHash::Sha256);
|
||||
hash.addData(m_masterSeed);
|
||||
hash.addData(transformedMasterKey);
|
||||
hash.addData(m_db->transformedMasterKey());
|
||||
QByteArray finalKey = hash.result();
|
||||
|
||||
SymmetricCipherStream cipherStream(device, SymmetricCipher::Aes256, SymmetricCipher::Cbc, SymmetricCipher::Decrypt, finalKey, m_encryptionIV);
|
||||
@ -261,7 +260,7 @@ void KeePass2Reader::setTransformSeed(const QByteArray& data)
|
||||
raiseError("");
|
||||
}
|
||||
else {
|
||||
m_db->setTransformSeed(data);
|
||||
m_transformSeed = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
|
||||
Database* m_db;
|
||||
QByteArray m_masterSeed;
|
||||
QByteArray m_transformSeed;
|
||||
QByteArray m_encryptionIV;
|
||||
QByteArray m_streamStartBytes;
|
||||
QByteArray m_protectedStreamKey;
|
||||
|
Loading…
Reference in New Issue
Block a user