diff --git a/CHANGELOG.md b/CHANGELOG.md index 86aa37671..ff0985fd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +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] -- Changed flash-stored key dictionaries (Mifare, iClass, T55XX) to SPIFFS files (@piotrva) +- Changed flash-stored key dictionaries (Mifare, iClass, T55XX) and T55XX configurations to SPIFFS files (@piotrva) - Added `hf iclass trbl` to perform tear-off attacks on iClass (@antiklesys) - Added support for connection to host device in all Docker envs (@doegox) - Changed `hf 15 info` to show all type matches and check ST25TVxC signature (@doegox) diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 6731cba86..c93880944 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -325,9 +325,9 @@ void setT55xxConfig(uint8_t arg0, const t55xx_configurations_t *c) { return; } - rdv40_spiffs_write(T55XX_CONFIG_FILE, (uint8_t*)&T55xx_Timing, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE); - - DbpString("T55XX Config save " _GREEN_("success")); + if (SPIFFS_OK == rdv40_spiffs_write(T55XX_CONFIG_FILE, (uint8_t*)&T55xx_Timing, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE)) { + DbpString("T55XX Config save " _GREEN_("success")); + } BigBuf_free(); #endif @@ -352,6 +352,12 @@ void loadT55xxConfig(void) { return; } + if (SPIFFS_OK != rdv40_spiffs_read(T55XX_CONFIG_FILE, buf, T55XX_CONFIG_LEN, RDV40_SPIFFS_SAFETY_SAFE)) { + Dbprintf("Spiffs file: %s cannot be read.", T55XX_CONFIG_FILE); + BigBuf_free(); + return; + } + // verify read mem is actual data. uint8_t cntA = T55XX_CONFIG_LEN, cntB = T55XX_CONFIG_LEN; for (int i = 0; i < T55XX_CONFIG_LEN; i++) { @@ -2148,9 +2154,12 @@ void T55xx_ChkPwds(uint8_t flags, bool ledcontrol) { // adjust available pwd_count pwd_count = pwd_size_available / T55XX_KEY_LENGTH; - rdv40_spiffs_read_as_filetype(T55XX_KEYS_FILE, pwds, pwd_size_available, RDV40_SPIFFS_SAFETY_SAFE); - - if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u passwords from spiffs file: %s", pwd_count, T55XX_KEYS_FILE); + if (SPIFFS_OK == rdv40_spiffs_read_as_filetype(T55XX_KEYS_FILE, pwds, pwd_size_available, RDV40_SPIFFS_SAFETY_SAFE)) { + if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u passwords from spiffs file: %s", pwd_count, T55XX_KEYS_FILE); + } else { + Dbprintf("Spiffs file: %s cannot be read.", T55XX_KEYS_FILE); + goto OUT; + } #endif diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index b59b17a79..bf308364d 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -1924,9 +1924,12 @@ void MifareChkKeys_fast(uint32_t arg0, uint32_t arg1, uint32_t arg2, uint8_t *da if (datain == NULL) goto OUT; - rdv40_spiffs_read_as_filetype(MF_KEYS_FILE, datain, keyCount * MF_KEY_LENGTH, RDV40_SPIFFS_SAFETY_SAFE); - - if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u keys from spiffs file: %s", keyCount, MF_KEYS_FILE); + if (SPIFFS_OK == rdv40_spiffs_read_as_filetype(MF_KEYS_FILE, datain, keyCount * MF_KEY_LENGTH, RDV40_SPIFFS_SAFETY_SAFE)) { + if (g_dbglevel >= DBG_ERROR) Dbprintf("Loaded %u keys from spiffs file: %s", keyCount, MF_KEYS_FILE); + } else { + Dbprintf("Spiffs file: %s cannot be read.", MF_KEYS_FILE); + goto OUT; + } } #endif diff --git a/doc/ext_flash_notes.md b/doc/ext_flash_notes.md index 42a5d0829..d54c2be53 100644 --- a/doc/ext_flash_notes.md +++ b/doc/ext_flash_notes.md @@ -37,20 +37,20 @@ Therefore a flash address can be interpreted as such: Page 0: * available for user data * to dump it: `mem dump -f page0_dump -o 0 -l 65536` -* to erase it: `mem wipe p 0` +* to erase it: `mem wipe -p 0` Page 1: * available for user data * to dump it: `mem dump -f page1_dump -o 65536 -l 65536` -* to erase it: `mem wipe p 1` +* to erase it: `mem wipe -p 1` Page 2: * available for user data * to dump it: `mem dump -f page2_dump -o 131072 -l 65536` -* to erase it: `mem wipe p 2` +* to erase it: `mem wipe -p 2` Page 3: -* used by Proxmark3 RDV4 specific functions: flash signature and configurations, see below for details +* used by Proxmark3 RDV4 specific functions: flash signature, see below for details * to dump it: `mem dump -f page3_dump -o 196608 -l 65536` * to erase it: * **Beware** it will erase your flash signature so better to back it up first as you won't be able to regenerate it by yourself! @@ -62,10 +62,6 @@ Page 3: Page3 is used as follows by the Proxmark3 RDV4 firmware: -* **T55XX_CONFIG** - * offset: page 3 sector 13 (0xD) @ 3*0x10000+13*0x1000=0x3D000 - * length: 1 sector (actually only a few bytes are used to store `t55xx_config` structure) - * **RSA SIGNATURE**, see below for details * offset: page 3 sector 15 (0xF) offset 0xF7F @ 3*0x10000+15*0x1000+0xF7F=0x3FF7F (decimal 262015) * length: 128 bytes