mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-11-10 17:49:32 +08:00
swapped to ISO7816 defines
This commit is contained in:
parent
d3b78e0cf2
commit
67b340d838
4 changed files with 25 additions and 26 deletions
|
@ -17,13 +17,11 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "emvcore.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "comms.h" // DropField
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "comms.h" // DropField
|
||||
#include "cmdparser.h"
|
||||
#include "cmdsmartcard.h" // ExchangeAPDUSC
|
||||
#include "cmdsmartcard.h" // ExchangeAPDUSC
|
||||
#include "ui.h"
|
||||
#include "cmdhf14a.h"
|
||||
#include "cmdhf14b.h"
|
||||
|
@ -31,6 +29,7 @@
|
|||
#include "emv_tags.h"
|
||||
#include "emvjson.h"
|
||||
#include "util_posix.h"
|
||||
#include "protocols.h" // ISO7816 APDU return codes
|
||||
|
||||
// Got from here. Thanks!
|
||||
// https://eftlab.co.uk/index.php/site-map/knowledge-base/211-emv-aid-rid-pix
|
||||
|
@ -392,7 +391,7 @@ int EMVSearchPSE(Iso7816CommandChannel channel, bool ActivateField, bool LeaveFi
|
|||
res = EMVSelectPSE(channel, ActivateField, true, PSENum, data, sizeof(data), &datalen, &sw);
|
||||
|
||||
if (!res) {
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
PrintAndLogEx(FAILED, "Select PSE error. APDU error: %04x.", sw);
|
||||
return 1;
|
||||
}
|
||||
|
@ -419,7 +418,7 @@ int EMVSearchPSE(Iso7816CommandChannel channel, bool ActivateField, bool LeaveFi
|
|||
}
|
||||
|
||||
// error catch!
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
sfidatalen[ui] = 0;
|
||||
PrintAndLogEx(FAILED, "PPSE get Error. APDU error: %04x.", sw);
|
||||
break;
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "iso7816core.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "commonutil.h" // ARRAYLEN
|
||||
#include "comms.h" // DropField
|
||||
#include "cmdparser.h"
|
||||
|
@ -29,6 +27,7 @@
|
|||
#include "cmdhf14b.h"
|
||||
#include "iso14b.h" // iso14b_raw_cmd_t
|
||||
#include "util_posix.h"
|
||||
#include "protocols.h" // ISO7816 APDU return codes
|
||||
|
||||
//iceman: this logging setting, should be unified with client debug etc.
|
||||
static bool APDULogging = false;
|
||||
|
@ -170,7 +169,7 @@ int Iso7816ExchangeEx(Iso7816CommandChannel channel, bool activate_field, bool l
|
|||
*sw = isw;
|
||||
}
|
||||
|
||||
if (isw != 0x9000) {
|
||||
if (isw != ISO7816_OK) {
|
||||
if (APDULogging) {
|
||||
if (*sw >> 8 == 0x61) {
|
||||
PrintAndLogEx(ERR, "APDU chaining len %02x", *sw & 0xFF);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "util.h"
|
||||
#include "comms.h" // clearCommandBuffer
|
||||
#include "commonutil.h" // ntohl (pm3 version)
|
||||
#include "protocols.h" // ISO7816 APDU return codes
|
||||
|
||||
// Date type. This is the actual on-card format.
|
||||
typedef struct {
|
||||
|
@ -402,7 +403,7 @@ bool KSX6924TrySelect(void) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
if (sw) {
|
||||
PrintAndLogEx(FAILED,
|
||||
"Not a KS X 6924 card! APDU response: %04x - %s",
|
||||
|
@ -444,7 +445,7 @@ bool KSX6924GetBalance(uint32_t *result) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -476,7 +477,7 @@ bool KSX6924InitializeCard(uint8_t mpda1, uint8_t mpda2, uint8_t mpda3, uint8_t
|
|||
return false;
|
||||
}
|
||||
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -574,7 +575,7 @@ bool KSX6924ProprietaryGetRecord(uint8_t id, uint8_t *result, size_t result_len)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (sw != 0x9000) {
|
||||
if (sw != ISO7816_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
#include "aes.h"
|
||||
#include "ui.h"
|
||||
#include "crc.h"
|
||||
#include "crc16.h" // crc16 ccitt
|
||||
#include "crc16.h" // crc16 ccitt
|
||||
#include "crc32.h"
|
||||
#include "protocols.h"
|
||||
#include "protocols.h" // ISO7816 APDU return codes
|
||||
#include "cmdhf14a.h"
|
||||
#include "iso7816/apduinfo.h" // APDU manipulation / errorcodes
|
||||
#include "iso7816/iso7816core.h" // APDU logging
|
||||
|
@ -470,7 +470,7 @@ static int DESFIRESendApduEx(bool activate_field, sAPDU_t apdu, uint16_t le, uin
|
|||
if (sw)
|
||||
*sw = isw;
|
||||
|
||||
if (isw != 0x9000 &&
|
||||
if (isw != ISO7816_OK &&
|
||||
isw != DESFIRE_GET_ISO_STATUS(MFDES_S_OPERATION_OK) &&
|
||||
isw != DESFIRE_GET_ISO_STATUS(MFDES_S_SIGNATURE) &&
|
||||
isw != DESFIRE_GET_ISO_STATUS(MFDES_S_ADDITIONAL_FRAME) &&
|
||||
|
@ -1655,7 +1655,7 @@ static bool DesfireCheckISOAuthCmd(DesfireISOSelectWay way, uint32_t appID, char
|
|||
uint8_t p2 = ((app_level) ? 0x80 : 0x00) | keyNum;
|
||||
res = DesfireExchangeISO(false, &dctx, (sAPDU_t) {0x00, ISO7816_EXTERNAL_AUTHENTICATION, p1, p2, rndlen * 2, piccrnd}, 0, resp, &resplen, &sw);
|
||||
DropField();
|
||||
return (sw == 0x9000 || sw == 0x6982);
|
||||
return (sw == ISO7816_OK || sw == ISO7816_SECURITY_STATUS_NOT_SATISFIED);
|
||||
}
|
||||
|
||||
void DesfireCheckAuthCommands(DesfireISOSelectWay way, uint32_t appID, char *dfname, uint8_t keyNum, AuthCommandsChk_t *authCmdCheck) {
|
||||
|
@ -2859,7 +2859,7 @@ int DesfireISOSelectEx(DesfireContext_t *dctx, bool fieldon, DesfireISOSelectCon
|
|||
size_t xresplen = 0;
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(fieldon, dctx, (sAPDU_t) {0x00, ISO7816_SELECT_FILE, cntr, ((resp == NULL) ? 0x0C : 0x00), datalen, data}, APDU_INCLUDE_LE_00, xresp, &xresplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
if (resp != NULL && resplen != NULL) {
|
||||
|
@ -2885,7 +2885,7 @@ int DesfireISOSelectDF(DesfireContext_t *dctx, char *dfname, uint8_t *resp, size
|
|||
int DesfireISOGetChallenge(DesfireContext_t *dctx, DesfireCryptoAlgorithm keytype, uint8_t *resp, size_t *resplen) {
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_GET_CHALLENGE, 0x00, 0x00, 0x00, NULL}, DesfireGetRndLenForKey(keytype), resp, resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2900,7 +2900,7 @@ int DesfireISOExternalAuth(DesfireContext_t *dctx, bool app_level, uint8_t keynu
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_EXTERNAL_AUTHENTICATION, p1, p2, DesfireGetRndLenForKey(keytype) * 2, data}, 0, resp, &resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2913,7 +2913,7 @@ int DesfireISOInternalAuth(DesfireContext_t *dctx, bool app_level, uint8_t keynu
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_INTERNAL_AUTHENTICATION, p1, p2, keylen, data}, keylen * 2, resp, resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2929,7 +2929,7 @@ int DesfireISOReadBinary(DesfireContext_t *dctx, bool use_file_id, uint8_t filei
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_READ_BINARY, p1, p2, 0, NULL}, (length == 0) ? APDU_INCLUDE_LE_00 : length, resp, resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2948,7 +2948,7 @@ int DesfireISOUpdateBinary(DesfireContext_t *dctx, bool use_file_id, uint8_t fil
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_UPDATE_BINARY, p1, p2, datalen, data}, 0, resp, &resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2959,7 +2959,7 @@ int DesfireISOReadRecords(DesfireContext_t *dctx, uint8_t recordnum, bool read_a
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_READ_RECORDS, recordnum, p2, 0, NULL}, (length == 0) ? APDU_INCLUDE_LE_00 : length, resp, resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
@ -2973,7 +2973,7 @@ int DesfireISOAppendRecord(DesfireContext_t *dctx, uint8_t fileid, uint8_t *data
|
|||
|
||||
uint16_t sw = 0;
|
||||
int res = DesfireExchangeISO(false, dctx, (sAPDU_t) {0x00, ISO7816_APPEND_RECORD, 0x00, p2, datalen, data}, 0, resp, &resplen, &sw);
|
||||
if (res == PM3_SUCCESS && sw != 0x9000)
|
||||
if (res == PM3_SUCCESS && sw != ISO7816_OK)
|
||||
return PM3_ESOFT;
|
||||
|
||||
return res;
|
||||
|
|
Loading…
Reference in a new issue