mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-19 13:00:42 -07:00
removed the inconsistency of both being a status value and length value
This commit is contained in:
parent
69ec1c6c04
commit
562faa8489
2 changed files with 95 additions and 43 deletions
|
@ -1316,7 +1316,7 @@ static RAMFUNC int Handle14443bSamplesFromTag(int ci, int cq) {
|
||||||
/*
|
/*
|
||||||
* Demodulate the samples we received from the tag, also log to tracebuffer
|
* Demodulate the samples we received from the tag, also log to tracebuffer
|
||||||
*/
|
*/
|
||||||
static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, uint32_t timeout, uint32_t *eof_time) {
|
static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, uint32_t timeout, uint32_t *eof_time, uint16_t *retlen) {
|
||||||
|
|
||||||
// Set up the demodulator for tag -> reader responses.
|
// Set up the demodulator for tag -> reader responses.
|
||||||
Demod14bInit(response, max_len);
|
Demod14bInit(response, max_len);
|
||||||
|
@ -1412,7 +1412,11 @@ static int Get14443bAnswerFromTag(uint8_t *response, uint16_t max_len, uint32_t
|
||||||
+ (10)); // time for EOF transfer
|
+ (10)); // time for EOF transfer
|
||||||
LogTrace(Demod.output, Demod.len, sof_time, *eof_time, NULL, false);
|
LogTrace(Demod.output, Demod.len, sof_time, *eof_time, NULL, false);
|
||||||
}
|
}
|
||||||
return Demod.len;
|
|
||||||
|
if (retlen) {
|
||||||
|
*retlen = Demod.len;
|
||||||
|
}
|
||||||
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1613,15 +1617,16 @@ int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, void
|
||||||
// 65536/fc == 4833 µS
|
// 65536/fc == 4833 µS
|
||||||
// SSP_CLK = 4833 µS * 3.39 = 16384
|
// SSP_CLK = 4833 µS * 3.39 = 16384
|
||||||
|
|
||||||
int len = Get14443bAnswerFromTag(rxdata, rxmaxlen, iso14b_timeout, &eof_time);
|
uint16_t len = 0;
|
||||||
|
if (Get14443bAnswerFromTag(rxdata, rxmaxlen, iso14b_timeout, &eof_time, &len) != PM3_SUCCESS) {
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
uint8_t *data_bytes = (uint8_t *) rxdata;
|
uint8_t *data_bytes = (uint8_t *) rxdata;
|
||||||
|
|
||||||
if (len <= 0) {
|
if (len) {
|
||||||
// DATA LINK ERROR
|
|
||||||
return PM3_ECARDEXCHANGE;
|
|
||||||
} else {
|
|
||||||
// S-Block WTX
|
// S-Block WTX
|
||||||
while (len && ((data_bytes[0] & 0xF2) == 0xF2)) {
|
while (len && ((data_bytes[0] & 0xF2) == 0xF2)) {
|
||||||
|
|
||||||
|
@ -1648,7 +1653,11 @@ int iso14443b_apdu(uint8_t const *msg, size_t msg_len, bool send_chaining, void
|
||||||
|
|
||||||
// retrieve the result again (with increased timeout)
|
// retrieve the result again (with increased timeout)
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
len = Get14443bAnswerFromTag(rxdata, rxmaxlen, iso14b_timeout, &eof_time);
|
|
||||||
|
if (Get14443bAnswerFromTag(rxdata, rxmaxlen, iso14b_timeout, &eof_time, &len) != PM3_SUCCESS) {
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
data_bytes = rxdata;
|
data_bytes = rxdata;
|
||||||
|
@ -1714,7 +1723,11 @@ static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(cmdINIT, sizeof(cmdINIT), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(cmdINIT, sizeof(cmdINIT), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
int retlen = Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time);
|
uint16_t retlen = 0;
|
||||||
|
if (Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
if (retlen != 4) {
|
if (retlen != 4) {
|
||||||
|
@ -1734,7 +1747,9 @@ static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(cmdMSBUID, sizeof(cmdMSBUID), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(cmdMSBUID, sizeof(cmdMSBUID), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
if (retlen != 4) {
|
if (retlen != 4) {
|
||||||
|
@ -1752,7 +1767,9 @@ static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(cmdLSBUID, sizeof(cmdLSBUID), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(cmdLSBUID, sizeof(cmdLSBUID), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(r, sizeof(r), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
if (retlen != 4) {
|
if (retlen != 4) {
|
||||||
|
@ -1767,6 +1784,9 @@ static int iso14443b_select_cts_card(iso14b_cts_card_select_t *card) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
out:
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* SRx Initialise.
|
* SRx Initialise.
|
||||||
|
@ -1783,12 +1803,12 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(init_srx, sizeof(init_srx), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(init_srx, sizeof(init_srx), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
int retlen = Get14443bAnswerFromTag(r_init, sizeof(r_init), iso14b_timeout, &eof_time);
|
uint16_t retlen = 0;
|
||||||
FpgaDisableTracing();
|
if (Get14443bAnswerFromTag(r_init, sizeof(r_init), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
FpgaDisableTracing();
|
||||||
if (retlen <= 0) {
|
|
||||||
return PM3_ECARDEXCHANGE;
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
|
FpgaDisableTracing();
|
||||||
|
|
||||||
// Randomly generated Chip ID
|
// Randomly generated Chip ID
|
||||||
if (card) {
|
if (card) {
|
||||||
|
@ -1805,7 +1825,10 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(select_srx, sizeof(select_srx), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(select_srx, sizeof(select_srx), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r_select, sizeof(r_select), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(r_select, sizeof(r_select), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
if (retlen != 3) {
|
if (retlen != 3) {
|
||||||
|
@ -1829,7 +1852,9 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(select_srx, 3, &start_time, &eof_time, true); // Only first three bytes for this one
|
CodeAndTransmit14443bAsReader(select_srx, 3, &start_time, &eof_time, true); // Only first three bytes for this one
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r_papid, sizeof(r_papid), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(r_papid, sizeof(r_papid), iso14b_timeout, &eof_time, & retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
|
@ -1846,6 +1871,9 @@ static int iso14443b_select_srx_card(iso14b_card_select_t *card) {
|
||||||
memcpy(card->uid, r_papid, 8);
|
memcpy(card->uid, r_papid, 8);
|
||||||
}
|
}
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
out:
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Xerox tag connect function: wup, anticoll, attrib, password
|
// Xerox tag connect function: wup, anticoll, attrib, password
|
||||||
|
@ -1873,7 +1901,7 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(x_wup2, sizeof(x_wup2), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(x_wup2, sizeof(x_wup2), &start_time, &eof_time, true);
|
||||||
|
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
int retlen;
|
uint16_t retlen = 0;
|
||||||
|
|
||||||
for (int uid_pos = 0; uid_pos < 64; uid_pos += 2) {
|
for (int uid_pos = 0; uid_pos < 64; uid_pos += 2) {
|
||||||
int slot;
|
int slot;
|
||||||
|
@ -1881,14 +1909,12 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
for (slot = 0; slot < 4; slot++) {
|
for (slot = 0; slot < 4; slot++) {
|
||||||
start_time = eof_time + HF14_ETU_TO_SSP(30); //(24); // next slot after 24 ETU
|
start_time = eof_time + HF14_ETU_TO_SSP(30); //(24); // next slot after 24 ETU
|
||||||
|
|
||||||
retlen = Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
if (retlen > 0) {
|
||||||
if (retlen > 0) {
|
Dbprintf("unexpected data %d", retlen);
|
||||||
FpgaDisableTracing();
|
Dbprintf("crc %s", check_crc(CRC_14443_B, x_atqb, retlen) ? "OK" : "BAD");
|
||||||
|
}
|
||||||
Dbprintf("unexpected data %d", retlen);
|
goto out;
|
||||||
Dbprintf("crc %s", check_crc(CRC_14443_B, x_atqb, retlen) ? "OK" : "BAD");
|
|
||||||
return PM3_ECARDEXCHANGE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tx unframed slot-marker
|
// tx unframed slot-marker
|
||||||
|
@ -1915,7 +1941,9 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retlen = Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_dbglevel >= DBG_DEBUG) {
|
if (g_dbglevel >= DBG_DEBUG) {
|
||||||
Dbprintf("anticollision uid %llx", uid);
|
Dbprintf("anticollision uid %llx", uid);
|
||||||
|
@ -1958,7 +1986,9 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(txbuf + 1, 15, &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(txbuf + 1, 15, &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
if (retlen < 3) {
|
if (retlen < 3) {
|
||||||
|
@ -1990,7 +2020,9 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(txbuf, 17, &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(txbuf, 17, &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(x_atqb, sizeof(x_atqb), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (retlen < 4) {
|
if (retlen < 4) {
|
||||||
return PM3_ELENGTH;
|
return PM3_ELENGTH;
|
||||||
|
@ -2005,6 +2037,10 @@ static int iso14443b_select_xrx_card(iso14b_card_select_t *card) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
|
out:
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Perform the ISO 14443 B Card Selection procedure
|
/* Perform the ISO 14443 B Card Selection procedure
|
||||||
|
@ -2031,7 +2067,11 @@ int iso14443b_select_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(wupb, sizeof(wupb), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(wupb, sizeof(wupb), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
int retlen = Get14443bAnswerFromTag(r_pupid, sizeof(r_pupid), iso14b_timeout, &eof_time);
|
uint16_t retlen = 0;
|
||||||
|
if (Get14443bAnswerFromTag(r_pupid, sizeof(r_pupid), iso14b_timeout, &eof_time) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
// ATQB too short?
|
// ATQB too short?
|
||||||
|
@ -2060,7 +2100,9 @@ int iso14443b_select_card(iso14b_card_select_t *card) {
|
||||||
CodeAndTransmit14443bAsReader(attrib, sizeof(attrib), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(attrib, sizeof(attrib), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
retlen = Get14443bAnswerFromTag(r_attrib, sizeof(r_attrib), iso14b_timeout, &eof_time);
|
if (Get14443bAnswerFromTag(r_attrib, sizeof(r_attrib), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
// Answer to ATTRIB too short?
|
// Answer to ATTRIB too short?
|
||||||
|
@ -2097,6 +2139,10 @@ int iso14443b_select_card(iso14b_card_select_t *card) {
|
||||||
// reset PCB block number
|
// reset PCB block number
|
||||||
iso14b_pcb_blocknum = 0;
|
iso14b_pcb_blocknum = 0;
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
|
||||||
|
out:
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up ISO 14443 Type B communication (similar to iso14443a_setup)
|
// Set up ISO 14443 Type B communication (similar to iso14443a_setup)
|
||||||
|
@ -2158,7 +2204,12 @@ static int read_14b_srx_block(uint8_t blocknr, uint8_t *block) {
|
||||||
CodeAndTransmit14443bAsReader(cmd, sizeof(cmd), &start_time, &eof_time, true);
|
CodeAndTransmit14443bAsReader(cmd, sizeof(cmd), &start_time, &eof_time, true);
|
||||||
|
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
int retlen = Get14443bAnswerFromTag(r_block, sizeof(r_block), iso14b_timeout, &eof_time);
|
uint16_t retlen = 0;
|
||||||
|
if (Get14443bAnswerFromTag(r_block, sizeof(r_block), iso14b_timeout, &eof_time, &retlen) != PM3_SUCCESS) {
|
||||||
|
FpgaDisableTracing();
|
||||||
|
return PM3_ECARDEXCHANGE;
|
||||||
|
|
||||||
|
}
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
||||||
// Check if we got an answer from the tag
|
// Check if we got an answer from the tag
|
||||||
|
@ -2496,9 +2547,14 @@ void SendRawCommand14443B_Ex(iso14b_raw_cmd_t *p) {
|
||||||
reply_ng(CMD_HF_ISO14443B_COMMAND, PM3_ETEAROFF, NULL, 0);
|
reply_ng(CMD_HF_ISO14443B_COMMAND, PM3_ETEAROFF, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
eof_time += DELAY_ISO14443B_PCD_TO_PICC_READER;
|
||||||
status = Get14443bAnswerFromTag(buf, sizeof(buf), iso14b_timeout, &eof_time); // raw
|
uint16_t retlen = 0;
|
||||||
sendlen = MIN(Demod.len, PM3_CMD_DATA_SIZE);
|
status = Get14443bAnswerFromTag(buf, sizeof(buf), iso14b_timeout, &eof_time, &retlen);
|
||||||
reply_ng(CMD_HF_ISO14443B_COMMAND, status, Demod.output, sendlen);
|
if (status == PM3_SUCCESS) {
|
||||||
|
sendlen = MIN(retlen, PM3_CMD_DATA_SIZE);
|
||||||
|
reply_ng(CMD_HF_ISO14443B_COMMAND, status, Demod.output, sendlen);
|
||||||
|
} else {
|
||||||
|
reply_ng(CMD_HF_ISO14443B_COMMAND, status, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1491,10 +1491,8 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
|
|
||||||
// select SR tag
|
// select SR tag
|
||||||
int status;
|
|
||||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, 2000)) {
|
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, 2000)) {
|
||||||
status = resp.status;
|
if (resp.status != PM3_SUCCESS) {
|
||||||
if (status != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(FAILED, "failed to select arg0[%" PRId64 "]", resp.oldarg[0]);
|
PrintAndLogEx(FAILED, "failed to select arg0[%" PRId64 "]", resp.oldarg[0]);
|
||||||
free(packet);
|
free(packet);
|
||||||
return switch_off_field_14b();
|
return switch_off_field_14b();
|
||||||
|
@ -1507,7 +1505,7 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||||
memset(data, 0, sizeof(data));
|
memset(data, 0, sizeof(data));
|
||||||
uint16_t blocknum = 0;
|
uint16_t blocknum = 0;
|
||||||
|
|
||||||
for (int retry = 0; retry < 5; retry++) {
|
for (int retry = 0; retry < 3; retry++) {
|
||||||
|
|
||||||
// set up the read command
|
// set up the read command
|
||||||
packet->flags = (ISO14B_APPEND_CRC | ISO14B_RAW);
|
packet->flags = (ISO14B_APPEND_CRC | ISO14B_RAW);
|
||||||
|
@ -1519,16 +1517,14 @@ static int CmdHF14BDump(const char *Cmd) {
|
||||||
SendCommandNG(CMD_HF_ISO14443B_COMMAND, (uint8_t *)packet, sizeof(iso14b_raw_cmd_t) + 2);
|
SendCommandNG(CMD_HF_ISO14443B_COMMAND, (uint8_t *)packet, sizeof(iso14b_raw_cmd_t) + 2);
|
||||||
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, 2000)) {
|
if (WaitForResponseTimeout(CMD_HF_ISO14443B_COMMAND, &resp, 2000)) {
|
||||||
|
|
||||||
status = resp.status;
|
if (resp.status != PM3_SUCCESS) {
|
||||||
if (status != PM3_SUCCESS) {
|
|
||||||
PrintAndLogEx(FAILED, "retrying one more time");
|
PrintAndLogEx(FAILED, "retrying one more time");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t len = (resp.oldarg[1] & 0xFFFF);
|
|
||||||
uint8_t *recv = resp.data.asBytes;
|
uint8_t *recv = resp.data.asBytes;
|
||||||
|
|
||||||
if (check_crc(CRC_14443_B, recv, len) == false) {
|
if (check_crc(CRC_14443_B, recv, resp.length) == false) {
|
||||||
PrintAndLogEx(FAILED, "crc fail, retrying one more time");
|
PrintAndLogEx(FAILED, "crc fail, retrying one more time");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue