From 45605acb3d89d10cd2f2f9d749329a388a7e46a5 Mon Sep 17 00:00:00 2001 From: "@shinhub" Date: Sat, 28 Sep 2019 17:51:13 +0200 Subject: [PATCH] Move DETECTION canary write to AppInit instead of STATE_AUTHING --- Firmware/ChameleonMini/Application/MifareClassic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/ChameleonMini/Application/MifareClassic.c b/Firmware/ChameleonMini/Application/MifareClassic.c index 8f4d29a..62f399b 100644 --- a/Firmware/ChameleonMini/Application/MifareClassic.c +++ b/Firmware/ChameleonMini/Application/MifareClassic.c @@ -280,6 +280,10 @@ void MifareClassicAppInit(uint16_t ATQA_4B, uint8_t SAK, bool is7B, bool isDetec CardSAKValue = SAK; isFromHaltState = false; isDetectionEnabled = isDetection; + if(isDetectionEnabled) { + uint8_t canary[DETECTION_BLOCK0_CANARY_SIZE] = { DETECTION_BLOCK0_CANARY }; + AppMemoryWrite(canary, DETECTION_BLOCK0_CANARY_ADDR, DETECTION_BLOCK0_CANARY_SIZE); + } } void MifareClassicAppInit1K(void) { @@ -558,8 +562,6 @@ uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount) { DetectionAttemptsKeyB++; DetectionAttemptsKeyB = DetectionAttemptsKeyB % DETECTION_MEM_MAX_KEYX_SAVES; } - uint8_t canary[DETECTION_BLOCK0_CANARY_SIZE] = { DETECTION_BLOCK0_CANARY }; - AppMemoryWrite(canary, DETECTION_BLOCK0_CANARY_ADDR, DETECTION_BLOCK0_CANARY_SIZE); // Write to app memory AppMemoryWrite(DetectionDataSave, memSaveAddr, DETECTION_BYTES_PER_SAVE); // Rage quit