From 8e25538d83bf5119a1b8f62e7c65e55506b06fc9 Mon Sep 17 00:00:00 2001 From: Maxie Dion Schmidt Date: Fri, 13 May 2022 08:27:42 -0400 Subject: [PATCH] Attempt to fix bug with `pm3 --> hf mfdes info` reported in #313 --- Firmware/Chameleon-Mini/Application/MifareDESFire.c | 11 +++++++++++ Firmware/Chameleon-Mini/Makefile | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Firmware/Chameleon-Mini/Application/MifareDESFire.c b/Firmware/Chameleon-Mini/Application/MifareDESFire.c index 5ffd057b..d53181ee 100644 --- a/Firmware/Chameleon-Mini/Application/MifareDESFire.c +++ b/Firmware/Chameleon-Mini/Application/MifareDESFire.c @@ -232,6 +232,17 @@ uint16_t MifareDesfireAppProcess(uint8_t *Buffer, uint16_t BitCount) { ProcessedByteCount = DesfirePostprocessAPDU(ActiveCommMode, Buffer, ProcessedByteCount); LogEntry(LOG_INFO_DESFIRE_OUTGOING_DATA, Buffer, ProcessedByteCount); return ISO14443AStoreLastDataFrameAndReturn(Buffer, ProcessedByteCount * BITS_PER_BYTE); + } else if (ByteCount >= 8 && DesfireCLA(Buffer[1]) && Buffer[3] == 0x00 && + Buffer[4] == 0x00 && Buffer[5] == ByteCount - 8) { + DesfireCmdCLA = Buffer[1]; + uint16_t IncomingByteCount = MAX(0, (BitCount + BITS_PER_BYTE - 1) / BITS_PER_BYTE - 1); + memmove(&Buffer[0], &Buffer[1], IncomingByteCount); + uint16_t UnwrappedBitCount = DesfirePreprocessAPDU(ActiveCommMode, Buffer, IncomingByteCount) * BITS_PER_BYTE; + uint16_t ProcessedBitCount = MifareDesfireProcess(Buffer, UnwrappedBitCount); + uint16_t ProcessedByteCount = (ProcessedBitCount + BITS_PER_BYTE - 1) / BITS_PER_BYTE; + ProcessedByteCount = DesfirePostprocessAPDU(ActiveCommMode, Buffer, ProcessedByteCount); + LogEntry(LOG_INFO_DESFIRE_OUTGOING_DATA, Buffer, ProcessedByteCount); + return ISO14443AStoreLastDataFrameAndReturn(Buffer, ProcessedByteCount * BITS_PER_BYTE); } Iso7816CmdType = IsWrappedISO7816CommandType(Buffer, ByteCount); if (Iso7816CmdType != ISO7816_WRAPPED_CMD_TYPE_NONE) { diff --git a/Firmware/Chameleon-Mini/Makefile b/Firmware/Chameleon-Mini/Makefile index 9b377866..46dd9b52 100644 --- a/Firmware/Chameleon-Mini/Makefile +++ b/Firmware/Chameleon-Mini/Makefile @@ -269,7 +269,7 @@ dfu-prog: $(TARGET).hex $(TARGET).eep check_size dfu-programmer $(MCU) flash $(TARGET).hex dfu-programmer $(MCU) reset -check_size: SHELL:=$(shell which bash) +#check_size: SHELL:=$(shell which bash) check_size: @{ \ set -e; \