Significantly enhance hardware key robustness

* Significantly improve user experience when using hardware keys on databases in both GUI and CLI modes. Prevent locking up the YubiKey USB interface for prolonged periods of time. Allows for other apps to use the key concurrently with KeePassXC.

* Improve messages displayed to user when finding keys and when user interaction is required. Output specific error messages when handling hardware keys during database read/write.

* Only poll for keys when previously used or upon user request. Prevent continuously polling keys when accessing the UI such as switching tabs and minimize/maximize.

* Add support for using multiple hardware keys simultaneously. Keys are identified by their serial number which prevents using the wrong key during open and save operations.

* Fixes #4400
* Fixes #4065
* Fixes #1050
* Fixes #1215
* Fixes #3087
* Fixes #1088
* Fixes #1869
This commit is contained in:
Jonathan White
2020-04-06 08:42:20 -04:00
parent a145bf9119
commit 5142981018
32 changed files with 670 additions and 687 deletions

View File

@@ -16,20 +16,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "core/Global.h"
#include "crypto/Random.h"
#include "YubiKey.h"
YubiKey::YubiKey()
: m_yk_void(NULL)
, m_ykds_void(NULL)
{
}
YubiKey* YubiKey::m_instance(Q_NULLPTR);
YubiKey::~YubiKey()
{
}
YubiKey* YubiKey::m_instance(nullptr);
YubiKey* YubiKey::instance()
{
@@ -40,45 +37,43 @@ YubiKey* YubiKey::instance()
return m_instance;
}
bool YubiKey::init()
bool YubiKey::isInitialized()
{
return false;
}
bool YubiKey::deinit()
{
return false;
}
void YubiKey::detect()
void YubiKey::findValidKeys()
{
}
bool YubiKey::getSerial(unsigned int& serial)
QList<YubiKeySlot> YubiKey::foundKeys()
{
Q_UNUSED(serial);
return false;
return {};
}
QString YubiKey::getVendorName()
{
return "YubiKeyStub";
}
YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByteArray& chal, QByteArray& resp)
QString YubiKey::getDisplayName(YubiKeySlot slot)
{
Q_UNUSED(slot);
return {};
}
QString YubiKey::errorMessage()
{
return {};
}
YubiKey::ChallengeResult YubiKey::challenge(YubiKeySlot slot, const QByteArray& chal, QByteArray& resp)
{
Q_UNUSED(slot);
Q_UNUSED(mayBlock);
Q_UNUSED(chal);
Q_UNUSED(resp);
return ERROR;
}
bool YubiKey::checkSlotIsBlocking(int slot, QString& errorMessage)
bool YubiKey::testChallenge(YubiKeySlot slot, bool* wouldBlock)
{
Q_UNUSED(slot);
Q_UNUSED(errorMessage);
Q_UNUSED(wouldBlock);
return false;
}