diff --git a/Firmware/Chameleon-Mini/.gitignore b/Firmware/Chameleon-Mini/.gitignore index 11e4750f..ec42b485 100644 --- a/Firmware/Chameleon-Mini/.gitignore +++ b/Firmware/Chameleon-Mini/.gitignore @@ -1,8 +1,11 @@ -/Chameleon-Mini.eep -/Chameleon-Mini.hex -/Chameleon-Mini.elf -/Chameleon-Mini.map -/Chameleon-Mini.bin -/Chameleon-Mini.lss -/Chameleon-Mini.sym -/Bin/ +Chameleon-Mini.eep +Chameleon-Mini.hex +Chameleon-Mini.elf +Chameleon-Mini.map +Chameleon-Mini.bin +Chameleon-Mini.lss +Chameleon-Mini.sym +Bin/ +Bin/* +Latest/ +Latest/* diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.c b/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.c index 246dbab2..d91b7d0c 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.c +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.c @@ -46,6 +46,8 @@ uint8_t LastReaderSentCmd = 0x00; uint8_t ISO14443ALastDataFrame[MAX_DATA_FRAME_XFER_SIZE] = { 0x00 }; uint16_t ISO14443ALastDataFrameBits = 0; +uint8_t ISO14443ALastIncomingDataFrame[MAX_DATA_FRAME_XFER_SIZE] = { 0x00 }; +uint16_t ISO14443ALastIncomingDataFrameBits = 0; bool CheckStateRetryCount2(bool resetByDefault, bool performLogging) { if (resetByDefault || ++StateRetryCount > MAX_STATE_RETRY_COUNT) { @@ -157,6 +159,8 @@ static uint16_t ISO144434ProcessBlock(uint8_t *Buffer, uint16_t ByteCount, uint1 case ISO14443_4_STATE_LAST: { return ISO14443A_APP_NO_RESPONSE; } + default: + break; } switch (PCB & ISO14443_PCB_BLOCK_TYPE_MASK) { @@ -186,9 +190,9 @@ static uint16_t ISO144434ProcessBlock(uint8_t *Buffer, uint16_t ByteCount, uint1 } Buffer[0] = PCB; /* Let the DESFire application code process the input data */ - ByteCount = MifareDesfireProcessCommand(Buffer + PrologueLength, ByteCount - PrologueLength); + ByteCount = MifareDesfireProcessCommand(&Buffer[PrologueLength], ByteCount - PrologueLength); /* Short-circuit in case the app decides not to respond at all */ - if (ByteCount == ISO14443A_APP_NO_RESPONSE) { + if (ByteCount == 0) { const char *debugPrintStr = PSTR("ISO14443-4: APP_NO_RESP"); LogDebuggingMsg(debugPrintStr); return ISO14443A_APP_NO_RESPONSE; @@ -295,6 +299,7 @@ void ISO144433AReset(void) { void ISO144433AHalt(void) { ISO144433ASwitchState(ISO14443_3A_STATE_HALT); Iso144433AIdleState = ISO14443_3A_STATE_HALT; + ISO144433AReset(); StateRetryCount = 0x00; } @@ -318,23 +323,25 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) { /* Wakeup and Request may occure in all states */ bool checkStateRetryStatus = CheckStateRetryCount(false); bool incrementRetryCount = true; - if ((Cmd == ISO14443A_CMD_REQA) && (LastReaderSentCmd == ISO14443A_CMD_REQA) && !checkStateRetryStatus) { - /* Catch timing issues where the reader sends multiple - REQA bytes, in between which we would have already sent - back a response, so that we should not reset. */ + if (Cmd == ISO14443A_CMD_REQA) { + LOG_AT_LEVEL(LogEntry(LOG_INFO_APP_CMD_REQA, NULL, 0), VERBOSE); + //ISO144434Reset(); + ISO144433ASwitchState(ISO14443_3A_STATE_IDLE); incrementRetryCount = false; - } else if (Cmd == ISO14443A_CMD_REQA || ISO14443ACmdIsWUPA(Cmd)) { - ISO144434Reset(); + } else if (ISO14443ACmdIsWUPA(Cmd)) { + LOG_AT_LEVEL(LogEntry(LOG_INFO_APP_CMD_WUPA, NULL, 0), VERBOSE); + //ISO144434Reset(); ISO144433ASwitchState(ISO14443_3A_STATE_IDLE); incrementRetryCount = false; + //return ISO14443A_APP_NO_RESPONSE; } else if (ISO144433AIsHalt(Buffer, BitCount)) { - LogEntry(LOG_INFO_APP_CMD_HALT, NULL, 0); + LOG_AT_LEVEL(LogEntry(LOG_INFO_APP_CMD_HALT, NULL, 0), VERBOSE); const char *logMsg = PSTR("ISO14443-3: HALTING"); LogDebuggingMsg(logMsg); - ISO144434Reset(); ISO144433AHalt(); return ISO14443A_APP_NO_RESPONSE; } + LastReaderSentCmd = Cmd; if (incrementRetryCount) { StateRetryCount += 1; @@ -424,8 +431,26 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) { LogDebuggingMsg(logMsg); } else if (Cmd == ISO14443A_CMD_SELECT_CL3) { Buffer[0] = ISO14443A_SAK_COMPLETE_NOT_COMPLIANT; - ISO14443AAppendCRCA(Buffer, 1); + ISO14443AAppendCRCA(&Buffer[0], 1); return ISO14443A_SAK_FRAME_SIZE; + } else if (Cmd == ISO14443A_CMD_DESELECT) { + LOG_AT_LEVEL(LogEntry(LOG_INFO_APP_CMD_DESELECT, NULL, 0), VERBOSE); + /* See if the process can make sense of the first byte: */ + //uint16_t ByteCount = ASBYTES(BitCount); + //uint16_t ReturnBits = ISO144434ProcessBlock(Buffer, ByteCount, BitCount); + //if (ReturnBits > 0) { + // return ReturnBits; + //} + /* Otherwise (doesn't seem to work): Return a HALT frame to the reader: */ + //Buffer[0] = ISO14443A_CMD_HLTA; + //Buffer[1] = 0x00; + //ISO14443AAppendCRCA(&Buffer[0], 2); + //ISO144434SwitchState(ISO14443_3A_STATE_HALT); + //return ISO14443A_DESELECT_FRAME_SIZE; + /* Otherwise: Return a WUPA frame to the reader to reset: */ + //Buffer[0] = ISO14443A_CMD_WUPA; + //ISO144434SwitchState(ISO14443_3A_STATE_HALT); + //return ASBITS(1); } /* Forward to ISO/IEC 14443-4 processing code */ uint16_t ByteCount = ASBYTES(BitCount); @@ -439,7 +464,7 @@ uint16_t ISO144433APiccProcess(uint8_t *Buffer, uint16_t BitCount) { } - /* Unknown command. Reset back to idle/halt state. */ + /* Fallthrough: Unknown command. Reset back to idle/halt state. */ bool defaultReset = false; if (!CheckStateRetryCount(defaultReset)) { const char *logMsg = PSTR("ISO14443-3: RESET TO IDLE 0x%02x"); diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.h b/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.h index 06ae029b..c2a75a83 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.h +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireISO14443Support.h @@ -45,6 +45,8 @@ This notice must be retained at the top of all source files where indicated. #define ISO14443A_RATS_FRAME_SIZE ASBITS(6) /* Bit */ #define ISO14443A_CMD_RNAK 0xB2 #define ISO14443A_CRC_FRAME_SIZE ASBITS(ISO14443A_CRCA_SIZE) +#define ISO14443A_CMD_DESELECT 0xC2 +#define ISO14443A_DESELECT_FRAME_SIZE (ISO14443A_HLTA_FRAME_SIZE + ASBITS(ISO14443A_CRCA_SIZE)) #define ISO14443ACmdIsPM3WUPA(cmd) ((cmd & 0x54) == 0x54) #define ISO14443ACmdIsWUPA(cmd) ((cmd == ISO14443A_CMD_WUPA) || ISO14443ACmdIsPM3WUPA(cmd)) @@ -101,6 +103,8 @@ extern uint8_t LastReaderSentCmd; #define MAX_DATA_FRAME_XFER_SIZE (64) extern uint8_t ISO14443ALastDataFrame[MAX_DATA_FRAME_XFER_SIZE]; extern uint16_t ISO14443ALastDataFrameBits; +extern uint8_t ISO14443ALastIncomingDataFrame[MAX_DATA_FRAME_XFER_SIZE]; +extern uint16_t ISO14443ALastIncomingDataFrameBits; INLINE ISO14443AStoreLastDataFrameAndReturn(const uint8_t *Buffer, uint16_t BufferBitCount) { uint16_t ISO14443ALastDataFrameBytes = MIN((BufferBitCount + BITS_PER_BYTE - 1) / BITS_PER_BYTE, MAX_DATA_FRAME_XFER_SIZE); @@ -113,7 +117,7 @@ INLINE ISO14443AStoreLastDataFrameAndReturn(const uint8_t *Buffer, uint16_t Buff /* Setup some fuzzy response handling for problematic readers like the ACR122U */ -#define MAX_STATE_RETRY_COUNT (0x0a) +#define MAX_STATE_RETRY_COUNT (0x0b) extern uint8_t StateRetryCount; bool CheckStateRetryCount(bool resetByDefault); bool CheckStateRetryCount2(bool resetByDefault, bool performLogging); diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.h b/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.h index a31bf770..4dfe556c 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.h +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.h @@ -104,10 +104,6 @@ typedef enum DESFIRE_FIRMWARE_ENUM_PACKING { CMD_ISO7816_UPDATE_BINARY = 0xD6, CMD_ISO7816_APPEND_RECORD = 0xE2, - /* Space for undocumented command codes -- - * Need command codes and parameters to make these work moving forward: */ - //CMD_READ_SIGNATURE /* See page 87 of AN12343.pdf (for Mifare DESFire Light tags) */ - } DESFireCommandType; typedef uint16_t (*InsCodeHandlerFunc)(uint8_t *Buffer, uint16_t ByteCount); diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireLogging.h b/Firmware/Chameleon-Mini/Application/DESFire/DESFireLogging.h index 4385fd95..bf40b82d 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireLogging.h +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireLogging.h @@ -52,6 +52,18 @@ typedef enum DESFIRE_FIRMWARE_ENUM_PACKING { DEBUGGING = 3, } DESFireLoggingMode; +#ifndef DESFIRE_DEFAULT_LOGGING_MODE +#define DESFIRE_DEFAULT_LOGGING_MODE (OFF) +#endif + +#define LOG_AT_LEVEL(cmdToRun, loggingThreshold) ({ \ + do { \ + if (loggingThreshold >= DESFIRE_DEFAULT_LOGGING_MODE) { \ + cmdToRun; \ + } \ + } while(0); \ + }) + extern DESFireLoggingMode LocalLoggingMode; /* diff --git a/Firmware/Chameleon-Mini/Application/MifareDESFire.c b/Firmware/Chameleon-Mini/Application/MifareDESFire.c index bec1e62e..a266a482 100644 --- a/Firmware/Chameleon-Mini/Application/MifareDESFire.c +++ b/Firmware/Chameleon-Mini/Application/MifareDESFire.c @@ -47,6 +47,11 @@ This notice must be retained at the top of all source files where indicated. #define MIFARE_DESFIRE_EV1 (0x01) #define MIFARE_DESFIRE_EV2 (0x02) +#define IsControlCmd(Buffer, BitCount) \ + (BitCount > 0 && \ + ((Buffer[0] == ISO14443A_CMD_WUPA) || \ + (Buffer[0] == ISO14443A_CMD_REQA))) + DesfireStateType DesfireState = DESFIRE_HALT; DesfireStateType DesfirePreviousState = DESFIRE_IDLE; bool DesfireFromHalt = false; @@ -127,10 +132,15 @@ uint16_t MifareDesfireProcessCommand(uint8_t *Buffer, uint16_t ByteCount) { if (ByteCount == 0) { return ISO14443A_APP_NO_RESPONSE; + } else if (MutualAuthenticateCmd(Buffer[0])) { + LastReaderSentCmd = Buffer[0]; } else if (Buffer[0] != STATUS_ADDITIONAL_FRAME) { DesfireState = DESFIRE_IDLE; + LastReaderSentCmd = Buffer[0]; uint16_t ReturnBytes = CallInstructionHandler(Buffer, ByteCount); return ReturnBytes; + } else { + LastReaderSentCmd = Buffer[0]; } uint16_t ReturnBytes = 0; @@ -153,6 +163,18 @@ uint16_t MifareDesfireProcessCommand(uint8_t *Buffer, uint16_t ByteCount) { case DESFIRE_AES_AUTHENTICATE2: ReturnBytes = DesfireCmdAuthenticateAES2(Buffer, ByteCount); break; + case DESFIRE_ISO7816_EXT_AUTH: + DEBUG_PRINT_P(PSTR("TODO -- ISO7816-ExtAuth")); + ReturnBytes = ISO14443A_APP_NO_RESPONSE; + break; + case DESFIRE_ISO7816_INT_AUTH: + DEBUG_PRINT_P(PSTR("TODO -- ISO7816-IntAuth")); + ReturnBytes = ISO14443A_APP_NO_RESPONSE; + break; + case DESFIRE_ISO7816_GET_CHALLENGE: + DEBUG_PRINT_P(PSTR("TODO -- ISO7816-GetChall")); + ReturnBytes = ISO14443A_APP_NO_RESPONSE; + break; case DESFIRE_READ_DATA_FILE: ReturnBytes = ReadDataFileIterator(Buffer); break; @@ -226,6 +248,18 @@ uint16_t MifareDesfireAppProcess(uint8_t *Buffer, uint16_t BitCount) { uint16_t ReturnedBytes = 0; uint16_t ByteCount = ASBYTES(BitCount); LogEntry(LOG_INFO_DESFIRE_INCOMING_DATA, Buffer, ByteCount); + if (ByteCount > 1 && + !memcmp(&Buffer[0], &ISO14443ALastIncomingDataFrame[0], MIN(ASBYTES(ISO14443ALastIncomingDataFrameBits), ByteCount))) { + /* The PCD resent the same data frame (probably a synchronization issue): + * Send out the same data as last time: + */ + memcpy(&Buffer[0], &ISO14443ALastDataFrame[0], ASBYTES(ISO14443ALastDataFrameBits)); + return ISO14443ALastDataFrameBits; + } else { + memcpy(&ISO14443ALastIncomingDataFrame[0], &Buffer[0], ByteCount); + ISO14443ALastIncomingDataFrameBits = BitCount; + LastReaderSentCmd = Buffer[0]; + } if (ByteCount >= 3 && Buffer[2] == STATUS_ADDITIONAL_FRAME && DesfireStateExpectingAdditionalFrame(DesfireState)) { /* [PM3-V1] : Handle the ISO-prologue-only-wrapped version of the additional frame data: */ diff --git a/Firmware/Chameleon-Mini/Application/MifareDESFire.h b/Firmware/Chameleon-Mini/Application/MifareDESFire.h index 9c2974c0..59792dc8 100644 --- a/Firmware/Chameleon-Mini/Application/MifareDESFire.h +++ b/Firmware/Chameleon-Mini/Application/MifareDESFire.h @@ -81,20 +81,28 @@ typedef enum DESFIRE_FIRMWARE_ENUM_PACKING { DESFIRE_ISO_AUTHENTICATE2, DESFIRE_AES_AUTHENTICATE, DESFIRE_AES_AUTHENTICATE2, + DESFIRE_ISO7816_EXT_AUTH, + DESFIRE_ISO7816_INT_AUTH, + DESFIRE_ISO7816_GET_CHALLENGE, DESFIRE_READ_DATA_FILE, DESFIRE_WRITE_DATA_FILE, } DesfireStateType; -#define DesfireStateExpectingAdditionalFrame(dfState) \ - ((dfState == DESFIRE_GET_VERSION2) || \ - (dfState == DESFIRE_GET_VERSION3) || \ - (dfState == DESFIRE_GET_APPLICATION_IDS2) || \ - (dfState == DESFIRE_LEGACY_AUTHENTICATE2) || \ - (dfState == DESFIRE_ISO_AUTHENTICATE2) || \ - (dfState == DESFIRE_AES_AUTHENTICATE2) || \ - (dfState == DESFIRE_READ_DATA_FILE) || \ +#define DesfireStateExpectingAdditionalFrame(dfState) \ + ((dfState == DESFIRE_GET_VERSION2) || \ + (dfState == DESFIRE_GET_VERSION3) || \ + (dfState == DESFIRE_GET_APPLICATION_IDS2) || \ + (dfState == DESFIRE_LEGACY_AUTHENTICATE2) || \ + (dfState == DESFIRE_ISO_AUTHENTICATE2) || \ + (dfState == DESFIRE_AES_AUTHENTICATE2) || \ + (dfState == DESFIRE_READ_DATA_FILE) || \ (dfState == DESFIRE_WRITE_DATA_FILE)) +#define MutualAuthenticateCmd(cmdCode) \ + ((cmdCode == CMD_ISO7816_EXTERNAL_AUTHENTICATE) || \ + (cmdCode == CMD_ISO7816_INTERNAL_AUTHENTICATE) || \ + (cmdCode == CMD_ISO7816_GET_CHALLENGE)) + extern DesfireStateType DesfireState; extern DesfireStateType DesfirePreviousState; extern bool DesfireFromHalt; diff --git a/Firmware/Chameleon-Mini/BuildScripts/lufa_build_extra.mk b/Firmware/Chameleon-Mini/BuildScripts/lufa_build_extra.mk index 740d8b9e..bea9177c 100644 --- a/Firmware/Chameleon-Mini/BuildScripts/lufa_build_extra.mk +++ b/Firmware/Chameleon-Mini/BuildScripts/lufa_build_extra.mk @@ -193,14 +193,17 @@ ifneq ($(UNKNOWN_SOURCE),) endif # Convert input source filenames into a list of required output object files -FWSRC_OBJECT_FILES := $(addsuffix .o, $(basename $(FULL_SOURCE))) -OBJECT_FILES += $(sort $(FWSRC_OBJECT_FILES)) -LUFA_OBJECT_FILES := $(addsuffix .o, $(basename $(LUFA_SRC))) +FWSRC_OBJECT_FILES := $(addsuffix .o, $(basename $(FULL_SOURCE))) +OBJECT_FILES += $(sort $(FWSRC_OBJECT_FILES)) +CHAMELEON_OBJECT_FILES := $(addsuffix .o, $(basename $(SRC))) +LUFA_OBJECT_FILES := $(addsuffix .o, $(basename $(LUFA_SRC))) # Check if an output object file directory was specified instead of the input file location ifneq ("$(OBJDIR)",".") # Prefix all the object filenames with the output object file directory path - OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES))) + OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES))) + CHAMELEON_OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(CHAMELEON_OBJECT_FILES))) + LUFA_OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(LUFA_OBJECT_FILES))) # Check if any object file (without path) appears more than once in the object file list ifneq ($(words $(sort $(OBJECT_FILES))), $(words $(OBJECT_FILES))) diff --git a/Firmware/Chameleon-Mini/Log.h b/Firmware/Chameleon-Mini/Log.h index c833d4d4..757ac6e6 100644 --- a/Firmware/Chameleon-Mini/Log.h +++ b/Firmware/Chameleon-Mini/Log.h @@ -19,38 +19,41 @@ extern uint16_t LogMemLeft; /** Enum for log entry type. \note Every entry type has a specific integer value, which can be found in the source code. */ typedef enum { /* Generic */ - LOG_INFO_GENERIC = 0x10, ///< Unspecific log entry. - LOG_INFO_CONFIG_SET = 0x11, ///< Configuration change. - LOG_INFO_SETTING_SET = 0x12, ///< Setting change. - LOG_INFO_UID_SET = 0x13, ///< UID change. - LOG_INFO_RESET_APP = 0x20, ///< Application reset. + LOG_INFO_GENERIC = 0x10, ///< Unspecific log entry. + LOG_INFO_CONFIG_SET = 0x11, ///< Configuration change. + LOG_INFO_SETTING_SET = 0x12, ///< Setting change. + LOG_INFO_UID_SET = 0x13, ///< UID change. + LOG_INFO_RESET_APP = 0x20, ///< Application reset. /* Codec */ - LOG_INFO_CODEC_RX_DATA = 0x40, ///< Currently active codec received data. - LOG_INFO_CODEC_TX_DATA = 0x41, ///< Currently active codec sent data. - LOG_INFO_CODEC_RX_DATA_W_PARITY = 0x42, ///< Currently active codec received data. - LOG_INFO_CODEC_TX_DATA_W_PARITY = 0x43, ///< Currently active codec sent data. - LOG_INFO_CODEC_SNI_READER_DATA = 0x44, //< Sniffing codec receive data from reader - LOG_INFO_CODEC_SNI_READER_DATA_W_PARITY = 0x45, //< Sniffing codec receive data from reader - LOG_INFO_CODEC_SNI_CARD_DATA = 0x46, //< Sniffing codec receive data from card - LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY = 0x47, //< Sniffing codec receive data from card - LOG_INFO_CODEC_READER_FIELD_DETECTED = 0x48, ///< Add logging of the LEDHook case for FIELD_DETECTED + LOG_INFO_CODEC_RX_DATA = 0x40, ///< Currently active codec received data. + LOG_INFO_CODEC_TX_DATA = 0x41, ///< Currently active codec sent data. + LOG_INFO_CODEC_RX_DATA_W_PARITY = 0x42, ///< Currently active codec received data. + LOG_INFO_CODEC_TX_DATA_W_PARITY = 0x43, ///< Currently active codec sent data. + LOG_INFO_CODEC_SNI_READER_DATA = 0x44, //< Sniffing codec receive data from reader + LOG_INFO_CODEC_SNI_READER_DATA_W_PARITY = 0x45, //< Sniffing codec receive data from reader + LOG_INFO_CODEC_SNI_CARD_DATA = 0x46, //< Sniffing codec receive data from card + LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY = 0x47, //< Sniffing codec receive data from card + LOG_INFO_CODEC_READER_FIELD_DETECTED = 0x48, ///< Add logging of the LEDHook case for FIELD_DETECTED /* App */ - LOG_INFO_APP_CMD_READ = 0x80, ///< Application processed read command. - LOG_INFO_APP_CMD_WRITE = 0x81, ///< Application processed write command. - LOG_INFO_APP_CMD_INC = 0x84, ///< Application processed increment command. - LOG_INFO_APP_CMD_DEC = 0x85, ///< Application processed decrement command. + LOG_INFO_APP_CMD_READ = 0x80, ///< Application processed read command. + LOG_INFO_APP_CMD_WRITE = 0x81, ///< Application processed write command. + LOG_INFO_APP_CMD_INC = 0x84, ///< Application processed increment command. + LOG_INFO_APP_CMD_DEC = 0x85, ///< Application processed decrement command. LOG_INFO_APP_CMD_TRANSFER = 0x86, ///< Application processed transfer command. LOG_INFO_APP_CMD_RESTORE = 0x87, ///< Application processed restore command. - LOG_INFO_APP_CMD_AUTH = 0x90, ///< Application processed authentication command. - LOG_INFO_APP_CMD_HALT = 0x91, ///< Application processed halt command. + LOG_INFO_APP_CMD_AUTH = 0x90, ///< Application processed authentication command. + LOG_INFO_APP_CMD_HALT = 0x91, ///< Application processed halt command. LOG_INFO_APP_CMD_UNKNOWN = 0x92, ///< Application processed an unknown command. - LOG_INFO_APP_AUTHING = 0xA0, ///< Application is in `authing` state. - LOG_INFO_APP_AUTHED = 0xA1, ///< Application is in `auth` state. - LOG_ERR_APP_AUTH_FAIL = 0xC0, ///< Application authentication failed. + LOG_INFO_APP_CMD_REQA = 0x93, ///< Application (ISO14443A handler) processed REQA. + LOG_INFO_APP_CMD_WUPA = 0x94, ///< Application (ISO14443A handler) processed WUPA. + LOG_INFO_APP_CMD_DESELECT = 0x95, ///< Application (ISO14443A handler) processed DESELECT. + LOG_INFO_APP_AUTHING = 0xA0, ///< Application is in `authing` state. + LOG_INFO_APP_AUTHED = 0xA1, ///< Application is in `auth` state. + LOG_ERR_APP_AUTH_FAIL = 0xC0, ///< Application authentication failed. LOG_ERR_APP_CHECKSUM_FAIL = 0xC1, ///< Application had a checksum fail. - LOG_ERR_APP_NOT_AUTHED = 0xC2, ///< Application is not authenticated. + LOG_ERR_APP_NOT_AUTHED = 0xC2, ///< Application is not authenticated. /* DESFire emulation and development related logging messages (0xEx): */ #ifdef CONFIG_MF_DESFIRE_SUPPORT diff --git a/Firmware/Chameleon-Mini/Makefile b/Firmware/Chameleon-Mini/Makefile index 92955746..758de75d 100644 --- a/Firmware/Chameleon-Mini/Makefile +++ b/Firmware/Chameleon-Mini/Makefile @@ -282,7 +282,6 @@ LD_FLAGS = $(CC_FLAGS) \ -Wl,--section-start=.flashdata=$(FLASH_DATA_ADDR) \ -Wl,--section-start=.spmhelper=$(SPM_HELPER_ADDR) OBJDIR = Bin -LUFA_OBJDIR = LUFABin TEMPDIR = $(OBJDIR)/Temp OBJECT_FILES = FWROOT = ../.. @@ -395,18 +394,11 @@ style: --style=google --pad-oper --unpad-paren --pad-header \ --align-pointer=name {} \; -local-clean: BASH:=$(if $(shell which bash), $(shell which bash), /bin/bash) -local-clean: BASH_SCRIPT_EXEC_LINES:=' \ - for lufaobj in $$(ls $(LUFA_OBJDIR)); do \ - lobj_basename=$$(basename $$lufaobj); \ - ln -s $(LUFA_OBJDIR)/$$lobj_basename $(OBJDIR)/$$lobj_basename; \ - done \ - ' local-clean: @rm -f $(TARGET)*.{elf,hex,eep,bin,lss,map} - @rm -rf $(OBJDIR) $(LUFA_OBJ) - @mkdir -p $(OBJDIR) $(LUFA_OBJDIR) - @$(BASH) -c $(BASH_SCRIPT_EXEC_LINES) || $(SHELL) -c $(BASH_SCRIPT_EXEC_LINES) + ## : Try to avoid rebuilding the LUFA objects that rarely change: + @rm -f $(CHAMELEON_OBJECT_FILES) + @mkdir -p $(OBJDIR) clean: local-clean git-add-dev: LOCALFW_SOURCE_FILES:=Makefile ./*.{c,h} ./*/*.{c,h} ./*/*/*.{c,h} @@ -417,6 +409,7 @@ git-add-dev: @cd $(BUILD_SCR) && git add -f $(LOCALFW_BUILD_SCRIPT_FILES) @cd $(FWROOT)/Software/DESFireLibNFCTesting && make style && git add $(TESTING_SOURCE_FILES) @git add $(FWROOT)/Doc/DESFireSupportReadme.md + @cd $(FWROOT)/Software/ChamTool && git add ./*.py ./*/*.py configure-chameleon-usb: UDEV_RULES_CONFIG_LINES:='\n \ \# ChameleonMini (RevG)\n \ diff --git a/Software/ChamTool/Chameleon/Log.py b/Software/ChamTool/Chameleon/Log.py index 92043be0..18951ded 100644 --- a/Software/ChamTool/Chameleon/Log.py +++ b/Software/ChamTool/Chameleon/Log.py @@ -86,7 +86,10 @@ def binaryParityDecoder(data): 0x90: { 'name': 'APP AUTH', 'decoder': binaryDecoder }, 0x91: { 'name': 'APP HALT', 'decoder': binaryDecoder }, 0x92: { 'name': 'APP UNKNOWN', 'decoder': binaryDecoder }, - + 0x93: { 'name': 'APP REQA', 'decoder': binaryDecoser }, + 0x94: { 'name': 'APP WUPA', 'decoder': binaryDecoser }, + 0x95: { 'name': 'APP DESELECT', 'decoder': binaryDecoser }, + 0xA0: { 'name': 'APP AUTHING' , 'decoder': binaryDecoder }, 0xA1: { 'name': 'APP AUTHED', 'decoder': binaryDecoder },