Skip to content

Commit

Permalink
Do not trigger update when token has multiple similar certificates (o…
Browse files Browse the repository at this point in the history
…pen-eid#1185)

IB-7572

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Jun 1, 2023
1 parent d592d34 commit d9d381c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions client/QSigner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class QSigner::Private final
ECDSA_SIG* QSigner::Private::ecdsa_do_sign(const unsigned char *dgst, int dgst_len,
const BIGNUM * /*inv*/, const BIGNUM * /*rp*/, EC_KEY *eckey)
{
QCryptoBackend *backend = (QCryptoBackend*)EC_KEY_get_ex_data(eckey, 0);
auto *backend = (QCryptoBackend*)EC_KEY_get_ex_data(eckey, 0);
QByteArray result = backend->sign(QCryptographicHash::Sha512, QByteArray::fromRawData((const char*)dgst, dgst_len));
if(result.isEmpty())
return nullptr;
Expand Down Expand Up @@ -299,7 +299,7 @@ void QSigner::run()
{
if(QCardLock::instance().readTryLock())
{
QPKCS11 *pkcs11 = qobject_cast<QPKCS11*>(d->backend);
auto *pkcs11 = qobject_cast<QPKCS11*>(d->backend);
if(pkcs11 && !pkcs11->reload())
{
Q_EMIT error(tr("Failed to load PKCS#11 module"));
Expand All @@ -321,9 +321,9 @@ void QSigner::run()
SslCertificate c(t.cert());
if(c.keyUsage().contains(SslCertificate::KeyEncipherment) ||
c.keyUsage().contains(SslCertificate::KeyAgreement))
acards << t;
acards.append(t);
if(c.keyUsage().contains(SslCertificate::NonRepudiation))
scards << t;
scards.append(t);
}

// check if selected card is still in slot
Expand Down Expand Up @@ -370,7 +370,9 @@ void QSigner::selectCard(const TokenData &token)
Q_EMIT authDataChanged(d->auth = token);
for(const TokenData &other: cache())
{
if(other == token || other.card() != token.card())
if(other == token ||
other.card() != token.card() ||
isSign == SslCertificate(other.cert()).keyUsage().contains(SslCertificate::NonRepudiation))
continue;
if(isSign) // Select other cert if they are on same card
Q_EMIT authDataChanged(d->auth = other);
Expand Down

0 comments on commit d9d381c

Please sign in to comment.