mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-12-04 07:42:35 -08:00
YubiKey: Retry to recover hotplugging
* Attempt one retry in the event the event the device was removed and re-inserted. Signed-off-by: Kyle Manna <[email protected]>
This commit is contained in:
1 parent
faa055010f
commit
f7ee528d41
3 files changed
+29
-1
No files matched your search
@@ -26,6 +26,8 @@
|
||||
#include "keys/YkChallengeResponseKey.h"
|
||||
#include "keys/drivers/YubiKey.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
YkChallengeResponseKey::YkChallengeResponseKey(int slot,
|
||||
bool blocking)
|
||||
: m_slot(slot),
|
||||
@@ -46,11 +48,31 @@ YkChallengeResponseKey* YkChallengeResponseKey::clone() const
|
||||
|
||||
/** Assumes yubikey()->init() was called */
|
||||
bool YkChallengeResponseKey::challenge(const QByteArray& chal)
|
||||
{
|
||||
return challenge(chal, 1);
|
||||
}
|
||||
|
||||
bool YkChallengeResponseKey::challenge(const QByteArray& chal, int retries)
|
||||
{
|
||||
if (YubiKey::instance()->challenge(m_slot, true, chal, m_key) != YubiKey::ERROR) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If challenge failed, retry to detect YubiKeys int the event the YubiKey
|
||||
* was un-plugged and re-plugged */
|
||||
while (retries > 0) {
|
||||
qDebug() << "Attempt" << retries << "to re-detect YubiKey(s)";
|
||||
retries--;
|
||||
|
||||
if (YubiKey::instance()->init() != true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (YubiKey::instance()->challenge(m_slot, true, chal, m_key) != YubiKey::ERROR) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user