Skip to content

Commit

Permalink
Attempt to fix bug with pm3 --> hf mfdes info reported in emsec#313
Browse files Browse the repository at this point in the history
  • Loading branch information
maxieds committed May 13, 2022
1 parent 83ce182 commit 8e25538
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Firmware/Chameleon-Mini/Application/MifareDESFire.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Firmware/Chameleon-Mini/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down

0 comments on commit 8e25538

Please sign in to comment.