Skip to content

Commit

Permalink
Remove Lithuanian G2 Card support
Browse files Browse the repository at this point in the history
IB-7696

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Jun 30, 2023
1 parent 608feee commit c7478e2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions client/QPKCS11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
template<class Container>
QString toQString(const Container &c)
{
return QString::fromLatin1(QByteArray::fromRawData((const char*)std::data(c), std::size(c)).toUpper());
return QString::fromLatin1((const char*)std::data(c), std::size(c));
}

QByteArray QPKCS11::Private::attribute(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE obj, CK_ATTRIBUTE_TYPE type) const
Expand Down Expand Up @@ -123,22 +123,21 @@ QByteArray QPKCS11::deriveConcatKDF(const QByteArray &publicKey, QCryptographicH

QByteArray QPKCS11::decrypt( const QByteArray &data ) const
{
QByteArray result;
std::vector<CK_OBJECT_HANDLE> key = d->findObject(d->session, CKO_PRIVATE_KEY, d->id);
if(key.size() != 1)
return result;
return {};

CK_MECHANISM mech { CKM_RSA_PKCS, nullptr, 0 };
if(d->f->C_DecryptInit(d->session, &mech, key.front()) != CKR_OK)
return result;
return {};

CK_ULONG size = 0;
if(d->f->C_Decrypt(d->session, CK_BYTE_PTR(data.constData()), CK_ULONG(data.size()), nullptr, &size) != CKR_OK)
return result;
return {};

result.resize(int(size));
QByteArray result(int(size), 0);
if(d->f->C_Decrypt(d->session, CK_BYTE_PTR(data.constData()), CK_ULONG(data.size()), CK_BYTE_PTR(result.data()), &size) != CKR_OK)
result.clear();
return {};
return result;
}

Expand Down Expand Up @@ -177,7 +176,7 @@ bool QPKCS11::load( const QString &driver )
<< QStringLiteral("%1 (%2.%3)").arg(toQString(info.libraryDescription))
.arg(info.libraryVersion.major).arg(info.libraryVersion.minor) << '\n'
<< "Flags:" << info.flags;
d->isFinDriver = toQString(info.libraryDescription).contains(QLatin1String("MPOLLUX"));
d->isFinDriver = toQString(info.libraryDescription).contains(QLatin1String("MPOLLUX"), Qt::CaseInsensitive);
return true;
}

Expand Down Expand Up @@ -320,7 +319,6 @@ bool QPKCS11::reload()
{ "/Library/latvia-eid/lib/eidlv-pkcs11.bundle/Contents/MacOS/eidlv-pkcs11", "3BDD18008131FE45904C41545649412D65494490008C" }, // LV-G1
{ "/Library/latvia-eid/lib/eidlv-pkcs11.bundle/Contents/MacOS/eidlv-pkcs11", "3BDB960080B1FE451F830012428F536549440F900020" }, // LV-G2
{ "/Library/mCard/lib/mcard-pkcs11.so", "3B9D188131FC358031C0694D54434F5373020505D3" }, // LT-G3
{ "/Library/PWPW-Card/lib/pwpw-card-pkcs11.so", "3BF81300008131FE45536D617274417070F8" }, // LT-G2
{ "/Library/mPolluxDigiSign/libcryptoki.dylib", "3B7F9600008031B865B0850300EF1200F6829000" }, // FI-G3
{ "/Library/mPolluxDigiSign/libcryptoki.dylib", "3B7F9600008031B865B08504021B1200F6829000" }, // FI-G3.1
{ "/Library/mPolluxDigiSign/libcryptoki.dylib", "3B7F9600008031B865B085050011122460829000" }, // FI-G4
Expand All @@ -338,12 +336,10 @@ bool QPKCS11::reload()
{ "/opt/latvia-eid/lib/eidlv-pkcs11.so", "3BDB960080B1FE451F830012428F536549440F900020" }, // LV-G2
{ "mcard-pkcs11.so", "3B9D188131FC358031C0694D54434F5373020505D3" }, // LT-G3
#if Q_PROCESSOR_WORDSIZE == 8
{ "/usr/lib64/pwpw-card-pkcs11.so", "3BF81300008131FE45536D617274417070F8" }, // LT-G2
{ "/usr/lib64/libcryptoki.so", "3B7F9600008031B865B0850300EF1200F6829000" }, // FI-G3
{ "/usr/lib64/libcryptoki.so", "3B7F9600008031B865B08504021B1200F6829000" }, // FI-G3.1
{ "/usr/lib64/libcryptoki.so", "3B7F9600008031B865B085050011122460829000" }, // FI-G4
#else
{ "pwpw-card-pkcs11.so", "3BF81300008131FE45536D617274417070F8" }, // LT-G2
{ "libcryptoki.so", "3B7F9600008031B865B0850300EF1200F6829000" }, // FI-G3
{ "libcryptoki.so", "3B7F9600008031B865B08504021B1200F6829000" }, // FI-G3.1
{ "libcryptoki.so", "3B7F9600008031B865B085050011122460829000" }, // FI-G4
Expand Down

0 comments on commit c7478e2

Please sign in to comment.