mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-31 17:36:27 +08:00
tx chaining iso native
This commit is contained in:
parent
6459e5cc39
commit
6066d949af
1 changed files with 26 additions and 4 deletions
|
@ -411,6 +411,7 @@ static int DesfireExchangeNative(bool activate_field, DesfireContext *ctx, uint8
|
||||||
PrintAndLogEx(DEBUG, "error DESFIRESendRaw %s", DesfireGetErrorString(res, &ssw));
|
PrintAndLogEx(DEBUG, "error DESFIRESendRaw %s", DesfireGetErrorString(res, &ssw));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
sentdatalen += len;
|
sentdatalen += len;
|
||||||
if (rcode != MFDES_ADDITIONAL_FRAME || buflen > 0) {
|
if (rcode != MFDES_ADDITIONAL_FRAME || buflen > 0) {
|
||||||
if (sentdatalen != cdatalen)
|
if (sentdatalen != cdatalen)
|
||||||
|
@ -494,12 +495,33 @@ static int DesfireExchangeISO(bool activate_field, DesfireContext *ctx, uint8_t
|
||||||
apdu.P2 = 0;
|
apdu.P2 = 0;
|
||||||
apdu.data = data;
|
apdu.data = data;
|
||||||
|
|
||||||
int res = DESFIRESendApdu(activate_field, apdu, buf, sizeof(buf), &buflen, &sw);
|
int res = 0;
|
||||||
|
// tx chaining
|
||||||
|
size_t sentdatalen = 0;
|
||||||
|
while(datalen >= sentdatalen) {
|
||||||
|
if (datalen - sentdatalen > DESFIRE_TX_FRAME_MAX_LEN)
|
||||||
|
apdu.Lc = DESFIRE_TX_FRAME_MAX_LEN;
|
||||||
|
else
|
||||||
|
apdu.Lc = datalen - sentdatalen;
|
||||||
|
apdu.data = &data[sentdatalen];
|
||||||
|
|
||||||
|
if (sentdatalen > 0)
|
||||||
|
apdu.INS = MFDES_ADDITIONAL_FRAME;
|
||||||
|
|
||||||
|
res = DESFIRESendApdu(activate_field, apdu, buf, sizeof(buf), &buflen, &sw);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(DEBUG, "error DESFIRESendApdu %s", DesfireGetErrorString(res, &sw));
|
PrintAndLogEx(DEBUG, "error DESFIRESendApdu %s", DesfireGetErrorString(res, &sw));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sentdatalen += apdu.Lc;
|
||||||
|
if (sw != DESFIRE_GET_ISO_STATUS(MFDES_ADDITIONAL_FRAME) || buflen > 0) {
|
||||||
|
if (sentdatalen != datalen)
|
||||||
|
PrintAndLogEx(WARNING, "Tx chaining error. Needs to send: %d but sent: %d", datalen, sentdatalen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (respcode != NULL && ((sw & 0xff00) == 0x9100))
|
if (respcode != NULL && ((sw & 0xff00) == 0x9100))
|
||||||
*respcode = sw & 0xff;
|
*respcode = sw & 0xff;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue