Skip to content

Commit

Permalink
Simplify APDU SW usage (open-eid#1292)
Browse files Browse the repository at this point in the history
IB-8231

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Nov 8, 2024
1 parent cd8d216 commit b331f52
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
14 changes: 10 additions & 4 deletions client/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include <QtCore/QTextStream>
#include <QtNetwork/QSslCertificate>

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
namespace Qt {
using ::hex;
}
#endif

void Diagnostics::generalInfo(QTextStream &s)
{
s << "<b>" << tr("Arguments:") << "</b> " << Application::arguments().join(' ') << "<br />"
Expand Down Expand Up @@ -122,10 +128,10 @@ void Diagnostics::generalInfo(QTextStream &s)
{
constexpr auto APDU = &QByteArray::fromHex;
QPCSCReader::Result r = reader.transfer(apdu);
s << label << ": " << r.SW.toHex();
if (r.SW == APDU("9000")) s << " (OK)";
if (r.SW == APDU("6A81")) s << " (Locked)";
if (r.SW == APDU("6A82")) s << " (Not found)";
s << label << ": " << Qt::hex << r.SW;
if (r.SW == 0x9000) s << " (OK)";
if (r.SW == 0x6A81) s << " (Locked)";
if (r.SW == 0x6A82) s << " (Not found)";
s << "<br />";
return r;
};
Expand Down
5 changes: 2 additions & 3 deletions client/QSmartCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,9 @@ bool IDEMIACard::loadPerso(QPCSCReader *reader, QSmartCardDataPrivate *d) const
readFailed = true;
return QSslCertificate();
}
int size = quint8(fci[0x80][0]) << 8 | quint8(fci[0x80][1]);
QByteArray cert;
QByteArray cmd = READBINARY;
while(cert.size() < size)
for(int size = quint8(fci[0x80][0]) << 8 | quint8(fci[0x80][1]); cert.size() < size; )
{
cmd[2] = char(cert.size() >> 8);
cmd[3] = char(cert.size());
Expand Down Expand Up @@ -312,7 +311,7 @@ QSmartCard::ErrorType QSmartCard::Private::handlePinResult(QPCSCReader *reader,
{
if(!response || forceUpdate)
card->updateCounters(reader, t.d);
switch((quint8(response.SW[0]) << 8) + quint8(response.SW[1]))
switch(response.SW)
{
case 0x9000: return QSmartCard::NoError;
case 0x63C0: return QSmartCard::BlockedError;//pin retry count 0
Expand Down
2 changes: 1 addition & 1 deletion common
Submodule common updated 3 files
+22 −17 QPCSC.cpp
+2 −7 QPCSC.h
+8 −14 QPCSC_p.h

0 comments on commit b331f52

Please sign in to comment.