From 4e6a59f169495b88f57a254aa96eaab80f0b006a Mon Sep 17 00:00:00 2001 From: merlokk <807634+merlokk@users.noreply.github.com> Date: Mon, 9 Aug 2021 13:19:28 +0300 Subject: [PATCH] fix iso id byte order --- client/src/cmdhfmfdes.c | 5 ++--- client/src/mifare/desfirecore.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/src/cmdhfmfdes.c b/client/src/cmdhfmfdes.c index 3d6aa95c9..bb413c857 100644 --- a/client/src/cmdhfmfdes.c +++ b/client/src/cmdhfmfdes.c @@ -2954,8 +2954,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { datalen = 5; if (fileidpresent || (data[4] & 0x20) != 0) { - data[5] = fileid & 0xff; - data[6] = (fileid >> 8) & 0xff; + Uint2byteToMemBe(&data[5], fileid); data[4] |= 0x20; // set bit FileID in the ks2 memcpy(&data[7], dfname, dfnamelen); datalen = 7 + dfnamelen; @@ -2970,7 +2969,7 @@ static int CmdHF14ADesCreateApp(const char *Cmd) { PrintAndLogEx(INFO, "Key Set 2 0x%02X", data[4]); PrintAndLogEx(INFO, "ISO file ID %s", (data[4] & 0x20) ? "enabled" : "disabled"); if ((data[4] & 0x20)) { - PrintAndLogEx(INFO, "FID 0x%02x%02x", data[6], data[5]); + PrintAndLogEx(INFO, "FID 0x%04x", MemBeToUint2byte(&data[5])); PrintAndLogEx(INFO, "DF Name[%02zu] %s\n", strnlen((char *)&data[7], 16), (char *)&data[7]); } PrintKeySettings(data[3], data[4], true, true); diff --git a/client/src/mifare/desfirecore.c b/client/src/mifare/desfirecore.c index bb06f2671..b44fb22cd 100644 --- a/client/src/mifare/desfirecore.c +++ b/client/src/mifare/desfirecore.c @@ -2683,7 +2683,7 @@ int DesfireSelectEx(DesfireContext *ctx, bool fieldon, DesfireISOSelectWay way, return DesfireSelectAIDHexNoFieldOn(ctx, id); } else if (way == ISWIsoID) { uint8_t data[2] = {0}; - Uint2byteToMemBe(data, id); + Uint2byteToMemLe(data, id); return DesfireISOSelectEx(ctx, fieldon, ISSMFDFEF, data, 2, resp, &resplen); } else if (way == ISWDFName) { return DesfireISOSelect(ctx, ISSMFDFEF, NULL, 0, resp, &resplen);