challenge: Propagate failed challenge to caller

* If a removed Yubikey is to blame, re-inserting the Yubikey won't
  resolve the issue.  Hot plug isn't supported at this point.
* The caller should detect the error and cancel the database write.

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
This commit is contained in:
Kyle Manna
2014-09-06 17:49:39 -07:00
parent ba8fd25604
commit faa055010f
6 changed files with 26 additions and 10 deletions

View File

@@ -51,9 +51,15 @@ void KeePass2Writer::writeDatabase(QIODevice* device, Database* db)
QByteArray startBytes = randomGen()->randomArray(32);
QByteArray endOfHeader = "\r\n\r\n";
QByteArray challengeResult;
if (db->challengeMasterSeed(masterSeed, challengeResult) == false) {
raiseError("Unable to issue challenge-response.");
return;
}
CryptoHash hash(CryptoHash::Sha256);
hash.addData(masterSeed);
hash.addData(db->challengeMasterSeed(masterSeed));
hash.addData(challengeResult);
Q_ASSERT(!db->transformedMasterKey().isEmpty());
hash.addData(db->transformedMasterKey());
QByteArray finalKey = hash.result();