diff --git a/client/src/cipurse/cipursecore.c b/client/src/cipurse/cipursecore.c index abe8a6bc2..563fda14f 100644 --- a/client/src/cipurse/cipursecore.c +++ b/client/src/cipurse/cipursecore.c @@ -17,17 +17,17 @@ //----------------------------------------------------------------------------- #include "cipursecore.h" -#include // memcpy memset - -#include "commonutil.h" // ARRAYLEN -#include "comms.h" // DropField -#include "util_posix.h" // msleep +#include // memcpy memset +#include "commonutil.h" // ARRAYLEN +#include "comms.h" // DropField +#include "util_posix.h" // msleep #include "cmdhf14a.h" #include "../emv/emvcore.h" #include "../emv/emvjson.h" -#include "../iso7816/apduinfo.h" // sAPDU_t +#include "../iso7816/apduinfo.h" // sAPDU_t #include "ui.h" #include "util.h" +#include "protocols.h" // ISO7816 APDU return codes // context for secure channel CipurseContext_t cipurseContext; @@ -112,7 +112,7 @@ static int CIPURSEExchangeEx(bool activate_field, bool leave_field_on, sAPDU_t a *sw = isw; } - if (isw != 0x9000) { + if (isw != ISO7816_OK) { if (GetAPDULogging()) { if (*sw >> 8 == 0x61) { PrintAndLogEx(ERR, "APDU chaining len:%02x -->", *sw & 0xff); @@ -255,7 +255,7 @@ bool CIPURSEChannelAuthenticate(uint8_t keyindex, uint8_t *key, bool verbose) { // authenticate res = CIPURSEMutualAuthenticate(keyindex, authparams, sizeof(authparams), buf, sizeof(buf), &len, &sw); - if (res != 0 || sw != 0x9000 || len != 16) { + if (res != 0 || sw != ISO7816_OK || len != 16) { if (sw == 0x6988) { if (verbose) { PrintAndLogEx(WARNING, "Authentication ( " _RED_("fail") " ). Wrong key"); diff --git a/client/src/cmdhfksx6924.c b/client/src/cmdhfksx6924.c index 6064a7611..7616ca766 100644 --- a/client/src/cmdhfksx6924.c +++ b/client/src/cmdhfksx6924.c @@ -46,6 +46,7 @@ #include "emv/tlv.h" #include "iso7816/apduinfo.h" #include "cmdhf14a.h" +#include "protocols.h" // ISO7816 APDU return codes static int CmdHelp(const char *Cmd); @@ -126,7 +127,7 @@ static int CmdHFKSX6924Info(const char *Cmd) { return res; } - if (sw != 0x9000) { + if (sw != ISO7816_OK) { if (sw) { PrintAndLogEx(INFO, "Not a KS X 6924 card! APDU response: %04x - %s", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); diff --git a/client/src/cmdhfseos.c b/client/src/cmdhfseos.c index 350df87f5..896157be4 100644 --- a/client/src/cmdhfseos.c +++ b/client/src/cmdhfseos.c @@ -30,6 +30,7 @@ #include "iso7816/apduinfo.h" // GetAPDUCodeDescription #include "crypto/asn1utils.h" // ASN1 decode / print #include "commonutil.h" // get_sw +#include "protocols.h" // ISO7816 APDU return codes static int CmdHelp(const char *Cmd); @@ -55,7 +56,7 @@ static int seos_select(void) { } uint16_t sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting SEOS applet aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -75,7 +76,7 @@ static int seos_select(void) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting ADF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; diff --git a/client/src/cmdhfst25ta.c b/client/src/cmdhfst25ta.c index 0ccccd5d6..86dfe0584 100644 --- a/client/src/cmdhfst25ta.c +++ b/client/src/cmdhfst25ta.c @@ -31,6 +31,7 @@ #include "nfc/ndef.h" // NDEFRecordsDecodeAndPrint #include "cmdnfc.h" // print_type4_cc_info #include "commonutil.h" // get_sw +#include "protocols.h" // ISO7816 APDU return codes #define TIMEOUT 2000 @@ -136,7 +137,7 @@ static int infoHFST25TA(void) { } uint16_t sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -156,7 +157,7 @@ static int infoHFST25TA(void) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting CC file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -172,7 +173,7 @@ static int infoHFST25TA(void) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "reading CC file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -192,7 +193,7 @@ static int infoHFST25TA(void) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting system file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -210,7 +211,7 @@ static int infoHFST25TA(void) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "reading system file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -329,7 +330,7 @@ int CmdHFST25TANdefRead(const char *Cmd) { } uint16_t sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -349,7 +350,7 @@ int CmdHFST25TANdefRead(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -378,7 +379,7 @@ int CmdHFST25TANdefRead(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Verify password failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -397,7 +398,7 @@ int CmdHFST25TANdefRead(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "reading NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -495,7 +496,7 @@ static int CmdHFST25TAProtect(const char *Cmd) { } uint16_t sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -515,7 +516,7 @@ static int CmdHFST25TAProtect(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -534,7 +535,7 @@ static int CmdHFST25TAProtect(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Verify password failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -553,7 +554,7 @@ static int CmdHFST25TAProtect(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "changing protection failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -639,7 +640,7 @@ static int CmdHFST25TAPwd(const char *Cmd) { } uint16_t sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF aid failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -659,7 +660,7 @@ static int CmdHFST25TAPwd(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Selecting NDEF file failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -678,7 +679,7 @@ static int CmdHFST25TAPwd(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "Verify password failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; @@ -699,7 +700,7 @@ static int CmdHFST25TAPwd(const char *Cmd) { } sw = get_sw(response, resplen); - if (sw != 0x9000) { + if (sw != ISO7816_OK) { PrintAndLogEx(ERR, "password change failed (%04x - %s).", sw, GetAPDUCodeDescription(sw >> 8, sw & 0xff)); DropField(); return PM3_ESOFT; diff --git a/client/src/emv/cmdemv.c b/client/src/emv/cmdemv.c index bf1cde60d..71277d87b 100644 --- a/client/src/emv/cmdemv.c +++ b/client/src/emv/cmdemv.c @@ -17,11 +17,9 @@ //----------------------------------------------------------------------------- #include "cmdemv.h" - #include - -#include "comms.h" // DropField -#include "cmdsmartcard.h" // smart_select +#include "comms.h" // DropField +#include "cmdsmartcard.h" // smart_select #include "cmdtrace.h" #include "emvjson.h" #include "test/cryptotest.h" @@ -35,6 +33,7 @@ #include "ui.h" #include "emv_tags.h" #include "fileutils.h" +#include "protocols.h" // ISO7816 APDU return codes static int CmdHelp(const char *Cmd); @@ -1564,7 +1563,7 @@ static int CmdEMVScan(const char *Cmd) { PrintAndLogEx(INFO, "PPSE"); res = EMVSelectPSE(channel, true, true, 2, buf, sizeof(buf), &len, &sw); - if (!res && sw == 0x9000) { + if (!res && sw == ISO7816_OK) { if (decodeTLV) TLVPrintFromBuffer(buf, len);