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

@@ -146,23 +146,27 @@ QByteArray CompositeKey::transformKeyRaw(const QByteArray& key, const QByteArray
return result;
}
QByteArray CompositeKey::challenge(const QByteArray& seed) const
bool CompositeKey::challenge(const QByteArray& seed, QByteArray& result) const
{
/* If no challenge response was requested, return nothing to
* maintain backwards compatability with regular databases.
*/
if (m_challengeResponseKeys.length() == 0) {
return QByteArray();
return true;
}
CryptoHash cryptoHash(CryptoHash::Sha256);
Q_FOREACH (ChallengeResponseKey* key, m_challengeResponseKeys) {
key->challenge(seed);
/* If the device isn't present or fails, return an error */
if (key->challenge(seed) == false) {
return false;
}
cryptoHash.addData(key->rawKey());
}
return cryptoHash.result();
result = cryptoHash.result();
return true;
}
void CompositeKey::addKey(const Key& key)