mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-10 16:04:31 -04:00
Adding OnlyKey support
This adds support for OnlyKey and requires yubikey-personalization library 1.20.0 or newer. The function yk_open_key_vid_pid was added to yubikey-personalization in version 1.20.0.
This commit is contained in:
parent
c669ecb4dd
commit
2a8b52a014
3 changed files with 29 additions and 3 deletions
|
@ -106,12 +106,14 @@ bool YkChallengeResponseKey::challenge(const QByteArray& challenge, unsigned int
|
||||||
QString YkChallengeResponseKey::getName() const
|
QString YkChallengeResponseKey::getName() const
|
||||||
{
|
{
|
||||||
unsigned int serial;
|
unsigned int serial;
|
||||||
QString fmt(QObject::tr("YubiKey[%1] Challenge Response - Slot %2 - %3"));
|
QString fmt(QObject::tr("%1[%2] Challenge Response - Slot %3 - %4"));
|
||||||
|
|
||||||
YubiKey::instance()->getSerial(serial);
|
YubiKey::instance()->getSerial(serial);
|
||||||
|
|
||||||
return fmt.arg(
|
return fmt.arg(YubiKey::instance()->getVendorName(),
|
||||||
QString::number(serial), QString::number(m_slot), (m_blocking) ? QObject::tr("Press") : QObject::tr("Passive"));
|
QString::number(serial),
|
||||||
|
QString::number(m_slot),
|
||||||
|
(m_blocking) ? QObject::tr("Press") : QObject::tr("Passive"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YkChallengeResponseKey::isBlocking() const
|
bool YkChallengeResponseKey::isBlocking() const
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include <ykcore.h>
|
#include <ykcore.h>
|
||||||
#include <ykdef.h>
|
#include <ykdef.h>
|
||||||
|
#include <ykpers-version.h>
|
||||||
#include <ykstatus.h>
|
#include <ykstatus.h>
|
||||||
#include <yubikey.h>
|
#include <yubikey.h>
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
YubiKey::YubiKey()
|
YubiKey::YubiKey()
|
||||||
: m_yk_void(nullptr)
|
: m_yk_void(nullptr)
|
||||||
, m_ykds_void(nullptr)
|
, m_ykds_void(nullptr)
|
||||||
|
, m_onlyKey(false)
|
||||||
, m_mutex(QMutex::Recursive)
|
, m_mutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -75,7 +77,17 @@ bool YubiKey::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: handle multiple attached hardware devices
|
// TODO: handle multiple attached hardware devices
|
||||||
|
m_onlyKey = false;
|
||||||
m_yk_void = static_cast<void*>(yk_open_first_key());
|
m_yk_void = static_cast<void*>(yk_open_first_key());
|
||||||
|
#if YKPERS_VERSION_NUMBER >= 0x011400
|
||||||
|
// New fuction available in yubikey-personalization version >= 1.20.0 that allows
|
||||||
|
// selecting device VID/PID (yk_open_key_vid_pid)
|
||||||
|
if (m_yk == nullptr) {
|
||||||
|
static const int device_pids[] = {0x60fc}; // OnlyKey PID
|
||||||
|
m_yk_void = static_cast<void*>(yk_open_key_vid_pid(0x1d50, device_pids, 1, 0));
|
||||||
|
m_onlyKey = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (m_yk == nullptr) {
|
if (m_yk == nullptr) {
|
||||||
yk_release();
|
yk_release();
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
@ -163,6 +175,11 @@ bool YubiKey::getSerial(unsigned int& serial)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString YubiKey::getVendorName()
|
||||||
|
{
|
||||||
|
return m_onlyKey ? "OnlyKey" : "YubiKey";
|
||||||
|
}
|
||||||
|
|
||||||
YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByteArray& challenge, QByteArray& response)
|
YubiKey::ChallengeResult YubiKey::challenge(int slot, bool mayBlock, const QByteArray& challenge, QByteArray& response)
|
||||||
{
|
{
|
||||||
// ensure that YubiKey::init() succeeded
|
// ensure that YubiKey::init() succeeded
|
||||||
|
|
|
@ -79,6 +79,12 @@ public:
|
||||||
*/
|
*/
|
||||||
bool getSerial(unsigned int& serial);
|
bool getSerial(unsigned int& serial);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief YubiKey::getVendorName - vendor name of token
|
||||||
|
* @return vendor name
|
||||||
|
*/
|
||||||
|
QString getVendorName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief YubiKey::detect - probe for attached YubiKeys
|
* @brief YubiKey::detect - probe for attached YubiKeys
|
||||||
*/
|
*/
|
||||||
|
@ -110,6 +116,7 @@ private:
|
||||||
// Create void ptr here to avoid ifdef header include mess
|
// Create void ptr here to avoid ifdef header include mess
|
||||||
void* m_yk_void;
|
void* m_yk_void;
|
||||||
void* m_ykds_void;
|
void* m_ykds_void;
|
||||||
|
bool m_onlyKey;
|
||||||
|
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue