From c27100295a800be92d6488fb3fa9c2c7924f18dd Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Fri, 6 Aug 2021 14:52:33 +0300 Subject: [PATCH] fix iso command data --- client/src/mifare/desfirecore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index b5a4e1f44..17a7e0197 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -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;