From 88d9345bc7d74b5488b52c61d04f7c6e7a6b155e Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 7 Dec 2024 13:12:01 +0100 Subject: [PATCH 1/4] Correct list of flash pages to be erased after extenging Mifare flash dictionary area --- armsrc/appmain.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index ff38906c5..56bf68326 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -2753,6 +2753,15 @@ static void PacketReceived(PacketCommandNG *packet) { Flash_WriteEnable(); Flash_Erase4k(3, 0xC); } else if (payload->startidx == DEFAULT_MF_KEYS_OFFSET_P(spi_flash_pages64k)) { + Flash_CheckBusy(BUSY_TIMEOUT); + Flash_WriteEnable(); + Flash_Erase4k(3, 0x5); + Flash_CheckBusy(BUSY_TIMEOUT); + Flash_WriteEnable(); + Flash_Erase4k(3, 0x6); + Flash_CheckBusy(BUSY_TIMEOUT); + Flash_WriteEnable(); + Flash_Erase4k(3, 0x7); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); Flash_Erase4k(3, 0x8); From a516c2e857aafcb0c5098016d3d9d095b702168b Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 7 Dec 2024 13:14:46 +0100 Subject: [PATCH 2/4] Correct list of flash pages to be erased after extenging Mifare flash dictionary area - update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5462c11be..1fba56039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log... ## [unreleased][unreleased] +- Fixed `mem load --mfc` not erasing all SPI flash blocks after extending to 4095 keys (@piotrva) - Extended area for Mifare keys in SPI flash to hold 4095 keys (@piotrva) - Fixed DESFire D40 secure channel crypto (@nvx) - Fixed `hf mfp info` fix signature check on 4b UID cards (@doegox) @@ -13,6 +14,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Added JEDEC information for SPI flash W25Q64JV (@ANTodorov) - Added special iclass legacy config cards in `hf iclass configcard` (@antiklesys) - Added simulation function to `hf iclass legrec` (@antiklesys) +- Added keys from Momentum firmware projects. (@onovy) - Added Dutch Statistics Agency default key (@eagle00789) ## [Orca.4.19552][2024-11-22] From d46bff75824463735237c1f1ecaa50083a3c86f3 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 7 Dec 2024 13:30:32 +0100 Subject: [PATCH 3/4] Reverting change in Changelog.md commited by repo missynchronization. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fba56039..5c673bbcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,6 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Added JEDEC information for SPI flash W25Q64JV (@ANTodorov) - Added special iclass legacy config cards in `hf iclass configcard` (@antiklesys) - Added simulation function to `hf iclass legrec` (@antiklesys) -- Added keys from Momentum firmware projects. (@onovy) - Added Dutch Statistics Agency default key (@eagle00789) ## [Orca.4.19552][2024-11-22] From 0e0dcf4f4ed38604a47f966a094cd941b577d0d1 Mon Sep 17 00:00:00 2001 From: Piotr Rzeszut Date: Sat, 7 Dec 2024 16:48:59 +0100 Subject: [PATCH 4/4] Fix memory erase before writing keys dictionaries for SPI flash with different page number than 4 - always erase on the last page. --- armsrc/appmain.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 56bf68326..2422db883 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -2751,34 +2751,34 @@ static void PacketReceived(PacketCommandNG *packet) { if (payload->startidx == DEFAULT_T55XX_KEYS_OFFSET_P(spi_flash_pages64k)) { Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0xC); + Flash_Erase4k(spi_flash_pages64k - 1, 0xC); } else if (payload->startidx == DEFAULT_MF_KEYS_OFFSET_P(spi_flash_pages64k)) { Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0x5); + Flash_Erase4k(spi_flash_pages64k - 1, 0x5); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0x6); + Flash_Erase4k(spi_flash_pages64k - 1, 0x6); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0x7); + Flash_Erase4k(spi_flash_pages64k - 1, 0x7); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0x8); + Flash_Erase4k(spi_flash_pages64k - 1, 0x8); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0x9); + Flash_Erase4k(spi_flash_pages64k - 1, 0x9); Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0xA); + Flash_Erase4k(spi_flash_pages64k - 1, 0xA); } else if (payload->startidx == DEFAULT_ICLASS_KEYS_OFFSET_P(spi_flash_pages64k)) { Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0xB); + Flash_Erase4k(spi_flash_pages64k - 1, 0xB); } else if (payload->startidx == FLASH_MEM_SIGNATURE_OFFSET_P(spi_flash_pages64k)) { Flash_CheckBusy(BUSY_TIMEOUT); Flash_WriteEnable(); - Flash_Erase4k(3, 0xF); + Flash_Erase4k(spi_flash_pages64k - 1, 0xF); } uint16_t res = Flash_Write(payload->startidx, payload->data, payload->len);