From 117f0df72901ad4a36f8e58b1f21e9225d375649 Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Wed, 17 Oct 2018 18:19:04 +0300 Subject: [PATCH] some improvements in APDU response checking --- client/cmdhffido.c | 7 ++++--- client/emv/emvcore.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/client/cmdhffido.c b/client/cmdhffido.c index a89dca30..9097dd76 100644 --- a/client/cmdhffido.c +++ b/client/cmdhffido.c @@ -134,7 +134,7 @@ int CmdHFFidoRegister(const char *cmd) { } res = FIDORegister(data, buf, sizeof(buf), &len, &sw); -/* if (res) { + if (res) { PrintAndLog("Can't execute register command. res=%x. Exit...", res); return res; } @@ -142,9 +142,10 @@ int CmdHFFidoRegister(const char *cmd) { if (sw != 0x9000) { PrintAndLog("Can't execute register command. APDU response status: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); return 3; - }*/ + } - //PrintAndLog("data: %s", sprint_hex(buf, len)); + PrintAndLog("---------------------------------------------------------------"); + PrintAndLog("data len: %d", len); if (buf[0] != 0x05) { PrintAndLog("ERROR: First byte must be 0x05, but it %2x", buf[0]); diff --git a/client/emv/emvcore.c b/client/emv/emvcore.c index 36f6f8eb..7ec5a67c 100644 --- a/client/emv/emvcore.c +++ b/client/emv/emvcore.c @@ -255,9 +255,14 @@ int EMVExchangeEx(bool ActivateField, bool LeaveFieldON, sAPDU apdu, bool Includ *sw = isw; if (isw != 0x9000) { - if (APDULogging) - PrintAndLog("APDU(%02x%02x) ERROR: [%4X] %s", apdu.CLA, apdu.INS, isw, GetAPDUCodeDescription(*sw >> 8, *sw & 0xff)); - return 5; + if (APDULogging) { + if (*sw >> 8 == 0x61) { + PrintAndLog("APDU chaining len:%02x -->", *sw & 0xff); + } else { + PrintAndLog("APDU(%02x%02x) ERROR: [%4X] %s", apdu.CLA, apdu.INS, isw, GetAPDUCodeDescription(*sw >> 8, *sw & 0xff)); + return 5; + } + } } // add to tlv tree