Add secure erase via zeroing page contents on deletion

This commit is contained in:
Vasily Evseenko
2019-11-08 19:39:29 +03:00
parent f7d3e9f2b2
commit 554b59c147
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -350,6 +350,10 @@
#endif
#endif
#ifndef SPIFFS_SECURE_ERASE
#define SPIFFS_SECURE_ERASE 0
#endif
// Types depending on configuration such as the amount of flash bytes
// given to spiffs file system in total (spiffs_file_system_size),
// the logical block size (log_block_size), and the logical page size
+10
View File
@@ -889,6 +889,16 @@ s32_t spiffs_page_delete(
fs->stats_p_deleted++;
fs->stats_p_allocated--;
#if SPIFFS_SECURE_ERASE
// Secure erase
unsigned char data[SPIFFS_CFG_LOG_PAGE_SZ(fs) - sizeof(spiffs_page_header)];
bzero(data, sizeof(data));
res = _spiffs_wr(fs, SPIFFS_OP_T_OBJ_DA | SPIFFS_OP_C_DELE,
0,
SPIFFS_PAGE_TO_PADDR(fs, pix) + sizeof(spiffs_page_header), sizeof(data), data);
SPIFFS_CHECK_RES(res);
#endif
// mark deleted in source page
u8_t flags = 0xff;
#if SPIFFS_NO_BLIND_WRITES