@@ -45,51 +45,31 @@ QByteArray YkChallengeResponseKey::rawKey() const
45
45
return m_key;
46
46
}
47
47
48
- /* *
49
- * Assumes yubikey()->init() was called
50
- */
51
48
bool YkChallengeResponseKey::challenge (const QByteArray& challenge)
52
49
{
53
- return this ->challenge (challenge, 1 );
54
- }
55
-
56
- bool YkChallengeResponseKey::challenge (const QByteArray& challenge, unsigned retries)
57
- {
58
- Q_ASSERT (retries > 0 );
59
-
60
- do {
61
- --retries;
62
-
63
- if (m_blocking) {
64
- emit userInteractionRequired ();
65
- }
66
-
67
- QFuture<YubiKey::ChallengeResult> future = QtConcurrent::run ([this , challenge]() {
68
- return YubiKey::instance ()->challenge (m_slot, true , challenge, m_key);
69
- });
70
-
71
- QEventLoop loop;
72
- QFutureWatcher<YubiKey::ChallengeResult> watcher;
73
- watcher.setFuture (future);
74
- connect (&watcher, SIGNAL (finished ()), &loop, SLOT (quit ()));
75
- loop.exec ();
50
+ if (!YubiKey::instance ()->init ()) {
51
+ return false ;
52
+ }
76
53
77
- if (m_blocking) {
78
- emit userConfirmed ();
79
- }
54
+ if (m_blocking) {
55
+ emit userInteractionRequired ();
56
+ }
80
57
81
- if ( future. result () != YubiKey::ERROR ) {
82
- return true ;
83
- }
58
+ QFuture<YubiKey::ChallengeResult> future = QtConcurrent::run ([ this , challenge]( ) {
59
+ return YubiKey::instance ()-> challenge (m_slot, true , challenge, m_key) ;
60
+ });
84
61
85
- // if challenge failed, retry to detect YubiKeys in the event the YubiKey was un-plugged and re-plugged
86
- if (retries > 0 && YubiKey::instance ()->init () != true ) {
87
- continue ;
88
- }
62
+ QEventLoop loop;
63
+ QFutureWatcher<YubiKey::ChallengeResult> watcher;
64
+ watcher.setFuture (future);
65
+ connect (&watcher, SIGNAL (finished ()), &loop, SLOT (quit ()));
66
+ loop.exec ();
89
67
90
- } while (retries > 0 );
68
+ if (m_blocking) {
69
+ emit userConfirmed ();
70
+ }
91
71
92
- return false ;
72
+ return future. result () != YubiKey::ERROR ;
93
73
}
94
74
95
75
QString YkChallengeResponseKey::getName () const
0 commit comments