diff --git a/client/MainWindow_MyEID.cpp b/client/MainWindow_MyEID.cpp index c53025695..8c4303cac 100644 --- a/client/MainWindow_MyEID.cpp +++ b/client/MainWindow_MyEID.cpp @@ -182,8 +182,7 @@ void MainWindow::updateCardWarnings(const QSmartCardData &data) ui->myEid->invalidIcon(true); warnings->showWarning(WarningText(WarningType::CertExpiredWarning)); } - else if(data.version() >= QSmartCardData::VER_3_5 && data.version() < QSmartCardData::VER_IDEMIA && - data.authCert().publicKey().algorithm() == QSsl::Rsa) + else if(data.authCert().publicKey().algorithm() == QSsl::Rsa) { ui->myEid->invalidIcon(true); warnings->showWarning(WarningText(WarningType::CertRevokedWarning)); diff --git a/client/QSmartCard.cpp b/client/QSmartCard.cpp index d4264b146..8f237a039 100644 --- a/client/QSmartCard.cpp +++ b/client/QSmartCard.cpp @@ -20,7 +20,6 @@ #include "QSmartCard_p.h" #include "QCardLock.h" -#include "IKValidator.h" #include "Settings.h" #include "Utils.h" #include "dialogs/PinPopup.h" @@ -47,8 +46,7 @@ bool QSmartCardData::operator ==(const QSmartCardData &other) const return d == other.d || ( d->card == other.d->card && d->authCert == other.d->authCert && - d->signCert == other.d->signCert && - d->version == other.d->version); + d->signCert == other.d->signCert); } bool QSmartCardData::operator !=(const QSmartCardData &other) const { return !operator==(other); } @@ -68,7 +66,6 @@ SslCertificate QSmartCardData::authCert() const { return d->authCert; } SslCertificate QSmartCardData::signCert() const { return d->signCert; } quint8 QSmartCardData::retryCount(PinType type) const { return d->retry.value(type); } ulong QSmartCardData::usageCount(PinType type) const { return d->usage.value(type); } -QSmartCardData::CardVersion QSmartCardData::version() const { return d->version; } quint8 QSmartCardData::minPinLen(QSmartCardData::PinType type) { @@ -117,7 +114,6 @@ QPCSCReader::Result Card::transfer(QPCSCReader *reader, bool verify, const QByte -const QByteArray EstEIDCard::AID35 = APDU("00A40400 0F D23300000045737445494420763335"); const QByteArray EstEIDCard::ESTEIDDF = APDU("00A4010C 02 EEEE"); const QByteArray EstEIDCard::PERSONALDATA = APDU("00A4020C 02 5044"); const QTextCodec* EstEIDCard::codec = QTextCodec::codecForName("Windows-1252"); @@ -127,27 +123,16 @@ QPCSCReader::Result EstEIDCard::change(QPCSCReader *reader, QSmartCardData::PinT QByteArray cmd = CHANGE; QByteArray newpin = newpin_.toUtf8(); QByteArray pin = pin_.toUtf8(); - cmd[3] = type == QSmartCardData::PukType ? 0 : type; + cmd[3] = char(type == QSmartCardData::PukType ? 0 : type); cmd[4] = char(pin.size() + newpin.size()); return transfer(reader, false, cmd + pin + newpin, type, quint8(pin.size()), true); } -QSmartCardData::CardVersion EstEIDCard::isSupported(const QByteArray &atr) -{ - static const QHash atrList{ - {"3BFE1800008031FE454573744549442076657220312E30A8", QSmartCardData::VER_3_5}, /*ESTEID_V3_COLD_ATR*/ - {"3BFE1800008031FE45803180664090A4162A00830F9000EF", QSmartCardData::VER_3_5}, /*ESTEID_V3_WARM_ATR / ESTEID_V35_WARM_ATR*/ - {"3BFA1800008031FE45FE654944202F20504B4903", QSmartCardData::VER_3_5}, /*ESTEID_V35_COLD_ATR*/ - }; - return atrList.value(atr, QSmartCardData::VER_INVALID); -} - bool EstEIDCard::loadPerso(QPCSCReader *reader, QSmartCardDataPrivate *d) const { static const QByteArray AUTHCERT = APDU("00A40200 02 AACE"); static const QByteArray SIGNCERT = APDU("00A40200 02 DDCE"); - d->version = isSupported(reader->atr()); if(reader->transfer(MASTER_FILE) && reader->transfer(ESTEIDDF) && d->data.isEmpty() && reader->transfer(PERSONALDATA)) @@ -207,8 +192,6 @@ bool EstEIDCard::loadPerso(QPCSCReader *reader, QSmartCardDataPrivate *d) const d->signCert = readCert(SIGNCERT); if(readFailed) return false; - if(!d->data.contains(QSmartCardData::BirthDate)) - d->data[QSmartCardData::BirthDate] = IKValidator::birthDate(d->authCert.personalCode()); d->data[QSmartCardData::Email] = d->authCert.subjectAlternativeNames().values(QSsl::EmailEntry).value(0); return updateCounters(reader, d); } @@ -302,7 +285,7 @@ QPCSCReader::Result EstEIDCard::verify(QPCSCReader *reader, QSmartCardData::PinT { QByteArray pin = pin_.toUtf8(); QByteArray cmd = VERIFY; - cmd[3] = type == QSmartCardData::PukType ? 0 : type; + cmd[3] = char(type == QSmartCardData::PukType ? 0 : type); cmd[4] = char(pin.size()); return transfer(reader, true, cmd + pin, type, 0, true); } @@ -336,14 +319,13 @@ QPCSCReader::Result IDEMIACard::change(QPCSCReader *reader, QSmartCardData::PinT return transfer(reader, false, cmd + pin + newpin, type, quint8(pin.size()), true); } -QSmartCardData::CardVersion IDEMIACard::isSupported(const QByteArray &atr) +bool IDEMIACard::isSupported(const QByteArray &atr) { - return atr == "3BDB960080B1FE451F830012233F536549440F9000F1" ? QSmartCardData::VER_IDEMIA : QSmartCardData::VER_INVALID; + return atr == "3BDB960080B1FE451F830012233F536549440F9000F1"; } bool IDEMIACard::loadPerso(QPCSCReader *reader, QSmartCardDataPrivate *d) const { - d->version = isSupported(reader->atr()); if(!reader->transfer(AID) || !reader->transfer(MASTER_FILE)) return false; @@ -426,10 +408,6 @@ bool IDEMIACard::loadPerso(QPCSCReader *reader, QSmartCardDataPrivate *d) const if(readFailed) return false; - if(!d->data[QSmartCardData::Expiry].toDate().isValid()) - d->data[QSmartCardData::Expiry] = d->authCert.expiryDate(); - if(!d->data.contains(QSmartCardData::BirthDate)) - d->data[QSmartCardData::BirthDate] = IKValidator::birthDate(d->authCert.personalCode()); d->data[QSmartCardData::Email] = d->authCert.subjectAlternativeNames().values(QSsl::EmailEntry).value(0); return updateCounters(reader, d); } @@ -706,7 +684,7 @@ void QSmartCard::reloadCard(const TokenData &token) t->reader = selectedReader->name(); t->pinpad = selectedReader->isPinPad(); delete d->card; - if(IDEMIACard::isSupported(selectedReader->atr()) == QSmartCardData::VER_IDEMIA) + if(IDEMIACard::isSupported(selectedReader->atr())) d->card = new IDEMIACard(); else d->card = new EstEIDCard(); diff --git a/client/QSmartCard.h b/client/QSmartCard.h index 065f65f35..ed2626f9b 100644 --- a/client/QSmartCard.h +++ b/client/QSmartCard.h @@ -56,12 +56,6 @@ class QSmartCardData Pin2Type, PukType }; - enum CardVersion - { - VER_INVALID = -1, - VER_3_5, - VER_IDEMIA, - }; QSmartCardData(); QSmartCardData( const QSmartCardData &other ); @@ -84,7 +78,6 @@ class QSmartCardData SslCertificate signCert() const; quint8 retryCount( PinType type ) const; ulong usageCount( PinType type ) const; - CardVersion version() const; static quint8 minPinLen(QSmartCardData::PinType type); static QString typeString( PinType type ); diff --git a/client/QSmartCard_p.h b/client/QSmartCard_p.h index 9f242c0e6..cc4416658 100644 --- a/client/QSmartCard_p.h +++ b/client/QSmartCard_p.h @@ -65,10 +65,8 @@ class EstEIDCard: public Card QPCSCReader::Result verify(QPCSCReader *reader, QSmartCardData::PinType type, const QString &pin) const final; static QString cardNR(QPCSCReader *reader); - static QSmartCardData::CardVersion isSupported(const QByteArray &atr); static const QTextCodec *codec; - static const QByteArray AID35; static const QByteArray ESTEIDDF; static const QByteArray PERSONALDATA; }; @@ -84,7 +82,7 @@ class IDEMIACard: public Card QPCSCReader::Result verify(QPCSCReader *reader, QSmartCardData::PinType type, const QString &pin) const final; static QString cardNR(QPCSCReader *reader); - static QSmartCardData::CardVersion isSupported(const QByteArray &atr); + static bool isSupported(const QByteArray &atr); static QByteArray pinTemplate(const QString &pin); static const QByteArray AID, AID_OT, AID_QSCD; @@ -110,6 +108,5 @@ class QSmartCardDataPrivate: public QSharedData SslCertificate authCert, signCert; QHash retry; QHash usage; - QSmartCardData::CardVersion version = QSmartCardData::VER_INVALID; bool pinpad = false; }; diff --git a/client/widgets/VerifyCert.cpp b/client/widgets/VerifyCert.cpp index c42163f76..c5a71b0a3 100644 --- a/client/widgets/VerifyCert.cpp +++ b/client/widgets/VerifyCert.cpp @@ -109,8 +109,6 @@ void VerifyCert::update() bool isBlockedPuk = !cardData.isNull() && cardData.retryCount( QSmartCardData::PukType ) == 0; bool isTempelType = c.type() & SslCertificate::TempelType; bool isRevoked = pinType != QSmartCardData::PukType && - cardData.version() >= QSmartCardData::VER_3_5 && - cardData.version() < QSmartCardData::VER_IDEMIA && cardData.authCert().publicKey().algorithm() == QSsl::Rsa; isValidCert = c.isNull() || (c.isValid() && !isRevoked); @@ -132,12 +130,11 @@ void VerifyCert::update() DateTime(c.expiryDate().toLocalTime()).formatDate(QStringLiteral("dd. MMMM yyyy"))); if(leftDays <= 105 && !c.isNull()) cert << ""; - if(!isTempelType && cardData.version() != QSmartCardData::VER_IDEMIA) + if(auto count = cardData.usageCount(pinType); count > 0) { - if(pinType == QSmartCardData::Pin1Type) - cert << "
" << tr("key has been used %1 times", "pin1").arg(cardData.usageCount(pinType)); - else - cert << "
" << tr("key has been used %1 times", "pin2").arg(cardData.usageCount(pinType)); + cert << "
" << (pinType == QSmartCardData::Pin1Type ? + tr("key has been used %1 times", "pin1").arg(count) : + tr("key has been used %1 times", "pin2").arg(count)); } } switch(pinType)