Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Commit

Permalink
Proposed initial fix to issue emsec#302 where some application functi…
Browse files Browse the repository at this point in the history
…ons return bit counts instead of expected byte counts
  • Loading branch information
maxieds committed Jan 1, 2022
1 parent 61b547a commit a038fd0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Firmware/Chameleon-Mini/Application/MifareDESFire.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ This notice must be retained at the top of all source files where indicated.
#include "DESFire/DESFireLogging.h"
#include "DESFire/DESFireUtils.h"

/* Quick fix to the problem pointed out by @colinoflynn in
* emsec/ChameleonMini issue #302:
* (see new usages below in the function MifareDesfireAppProcess(., .))
*/
#define __DESFire_RoundToBytes(bitCount) ((unsigned int) (bitCount + BITS_PER_BYTE - 1) / BITS_PER_BYTE)

DesfireStateType DesfireState = DESFIRE_HALT;
DesfireStateType DesfirePreviousState = DESFIRE_IDLE;
bool DesfireFromHalt = false;
Expand Down Expand Up @@ -222,12 +228,12 @@ uint16_t MifareDesfireAppProcess(uint8_t* Buffer, uint16_t BitCount) {
//LogEntry(LOG_INFO_DESFIRE_INCOMING_DATA, Buffer, ByteCount);
if(ByteCount >= 8 && DesfireCLA(Buffer[0]) && Buffer[2] == 0x00 &&
Buffer[3] == 0x00 && Buffer[4] == ByteCount - 8) {
return MifareDesfireProcess(Buffer, BitCount);
return __DESFire_RoundToBytes(MifareDesfireProcess(Buffer, BitCount));
}
else if(ByteCount >= 6 && DesfireCLA(Buffer[0]) && Buffer[2] == 0x00 &&
Buffer[3] == 0x00 && Buffer[4] == ByteCount - 6) {
// Native wrapped command send without CRCA checksum bytes appended:
return MifareDesfireProcess(Buffer, BitCount);
return __DESFire_RoundToBytes(MifareDesfireProcess(Buffer, BitCount));
}
else {
return ISO144433APiccProcess(Buffer, BitCount);
Expand Down

0 comments on commit a038fd0

Please sign in to comment.