format: Add challenge response result to final key hash

* The challengeMasterSeed() function return empty if not present
  maintaining backwards compatability.
* This commit is where the challenge response result is computed into
  the final key  used to encrypt or decrypt the database.

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
This commit is contained in:
Kyle Manna 2014-05-26 00:29:41 -07:00
parent e354a0ee0e
commit add4846d79
2 changed files with 2 additions and 0 deletions

View File

@ -115,6 +115,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
CryptoHash hash(CryptoHash::Sha256); CryptoHash hash(CryptoHash::Sha256);
hash.addData(m_masterSeed); hash.addData(m_masterSeed);
hash.addData(m_db->challengeMasterSeed(m_masterSeed));
hash.addData(m_db->transformedMasterKey()); hash.addData(m_db->transformedMasterKey());
QByteArray finalKey = hash.result(); QByteArray finalKey = hash.result();

View File

@ -53,6 +53,7 @@ void KeePass2Writer::writeDatabase(QIODevice* device, Database* db)
CryptoHash hash(CryptoHash::Sha256); CryptoHash hash(CryptoHash::Sha256);
hash.addData(masterSeed); hash.addData(masterSeed);
hash.addData(db->challengeMasterSeed(masterSeed));
Q_ASSERT(!db->transformedMasterKey().isEmpty()); Q_ASSERT(!db->transformedMasterKey().isEmpty());
hash.addData(db->transformedMasterKey()); hash.addData(db->transformedMasterKey());
QByteArray finalKey = hash.result(); QByteArray finalKey = hash.result();