fix iso command data

This commit is contained in:
merlokk
2021-08-06 14:52:33 +03:00
parent 18e2d55c57
commit c27100295a

View File

@@ -2629,13 +2629,13 @@ int DesfireISOInternalAuth(DesfireContext *dctx, bool app_level, uint8_t keynum,
int DesfireISOReadBinary(DesfireContext *dctx, bool use_file_id, uint8_t fileid, uint16_t offset, uint8_t length, uint8_t *resp, size_t *resplen) {
uint8_t p1 = 0;
if (use_file_id)
p1 = 0x80 & (fileid & 0x1f);
p1 = 0x80 | (fileid & 0x1f);
else
p1 = (offset >> 8) & 0x7f;
uint8_t p2 = offset & 0xff;
uint16_t sw = 0;
int res = DesfireExchangeISO(false, dctx, (sAPDU) {0x00, ISO7816_READ_BINARY, p1, p2, 0, NULL}, length, resp, resplen, &sw);
int res = DesfireExchangeISO(false, dctx, (sAPDU) {0x00, ISO7816_READ_BINARY, p1, p2, 0, NULL}, (length == 0) ? APDU_INCLUDE_LE_00 : length, resp, resplen, &sw);
if (res == PM3_SUCCESS && sw != 0x9000)
return PM3_ESOFT;
@@ -2645,7 +2645,7 @@ int DesfireISOReadBinary(DesfireContext *dctx, bool use_file_id, uint8_t fileid,
int DesfireISOUpdateBinary(DesfireContext *dctx, bool use_file_id, uint8_t fileid, uint16_t offset, uint8_t *data, size_t datalen) {
uint8_t p1 = 0;
if (use_file_id)
p1 = 0x80 & (fileid & 0x1f);
p1 = 0x80 | (fileid & 0x1f);
else
p1 = (offset >> 8) & 0x7f;
uint8_t p2 = offset & 0xff;
@@ -2665,7 +2665,7 @@ int DesfireISOReadRecords(DesfireContext *dctx, uint8_t recordnum, bool read_all
uint8_t p2 = ((fileid & 0x1f) << 3) | ((read_all_records) ? 0x05 : 0x04);
uint16_t sw = 0;
int res = DesfireExchangeISO(false, dctx, (sAPDU) {0x00, ISO7816_READ_RECORDS, recordnum, p2, 0, NULL}, length, resp, resplen, &sw);
int res = DesfireExchangeISO(false, dctx, (sAPDU) {0x00, ISO7816_READ_RECORDS, recordnum, p2, 0, NULL}, (length == 0) ? APDU_INCLUDE_LE_00 : length, resp, resplen, &sw);
if (res == PM3_SUCCESS && sw != 0x9000)
return PM3_ESOFT;