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

@ -113,9 +113,15 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
return nullptr;
}
QByteArray challengeResult;
if (m_db->challengeMasterSeed(m_masterSeed, challengeResult) == false) {
raiseError(tr("Unable to issue challenge-response."));
return Q_NULLPTR;
}
CryptoHash hash(CryptoHash::Sha256);
hash.addData(m_masterSeed);
hash.addData(m_db->challengeMasterSeed(m_masterSeed));
hash.addData(challengeResult);
hash.addData(m_db->transformedMasterKey());
QByteArray finalKey = hash.result();