Skip to content

Commit

Permalink
Merge pull request #163 from shinhub/mf_detection_canary_init
Browse files Browse the repository at this point in the history
Move DETECTION canary write to AppInit instead of STATE_AUTHING
  • Loading branch information
securechicken committed Sep 28, 2019
2 parents c99e40d + 45605ac commit db81ad5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Firmware/ChameleonMini/Application/MifareClassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit db81ad5

Please sign in to comment.