add the se wipe and reorder the ErasePublicInfo to fix the power lose issue
What changed, and why it matters
This commit changes the factory-reset/wipe routine in a Keystone hardware wallet's startup self-check. It replaces one wipe step with a call to wipe the secure element (SE_WipeAll) and moves the 'ErasePublicInfo' step to occur after account destruction and flash erasure, right before the device reboots. The stated goal is to fix a problem where losing power during a wipe could leave sensitive data partially intact. The change is defensive, but because it is a partial patch and the commit message is terse, we cannot fully verify that the new ordering eliminates all power-loss recovery risks.
Treat as a security-hardening fix for a potential data-remanence/power-loss failure mode. Review the full wipe routine for atomic progress tracking, verify that SE_WipeAll and ErasePublicInfo cannot be interrupted in a way that leaves recoverable key material, and confirm whether this change corresponds to a disclosed vulnerability or bug report. If the device has a tamper/factory-reset trigger, ensure the new ordering does not introduce a window where an attacker can abort reset before the secure element is wiped.
Security signals we found
Secure-element wipe added to factory-reset path
Flash/public-info erasure reordered before final system reset
Commit message frames change as fixing power-loss-related data-remanence issue
No visible persistence of wipe-progress state or rollback guard in diff
Evidence from the diff
In src/driver/power_on_self_check.c, the PowerOnSelfCheck() function’s wipe branch now includes #include ‘se_manager.h’, calls SE_WipeAll() where ErasePublicInfo() was previously called, and moves ErasePublicInfo() to the end of the sequence after DestroyAccount(0..2) and Gd25FlashBlockErase loops but before NVIC_SystemReset(). The reordering is intended to address a ‘power lose issue’ during the erase process. No additional atomicity, rollback, or progress-state mechanism is visible in the diff, so the fix relies on sequence ordering alone.
Changed components
src/driver/power_on_self_check.cPowerOnSelfCheck() wipe/reset pathSecure element manager (se_manager.h / SE_WipeAll)Public info erase routine (ErasePublicInfo)Account destruction and SPI flash erase loopsInspect captured patch +4 / −2
diff --git a/src/driver/power_on_self_check.c b/src/driver/power_on_self_check.c
index f08bb93..6428a09 100644
--- a/src/driver/power_on_self_check.c
+++ b/src/driver/power_on_self_check.c
@@ -11,6 +11,7 @@
#include "keystore.h"
#include "draw_on_lcd.h"
#include "account_manager.h"
+#include "se_manager.h"
#include "drv_mpu.h"
#define GD25_FLASH_ID (0xC84018)
@@ -55,7 +56,7 @@ void PowerOnSelfCheck(void)
uint32_t c = 0x666666;
DrawStringOnLcd(170, 456, "About 1 minute", (uint16_t)(((c & 0xF80000) >> 16) | ((c & 0xFC00) >> 13) | ((c & 0x1C00) << 3) | ((c & 0xF8) << 5)), &openSans_20);
FpWipeManageInfo();
- ErasePublicInfo();
+ SE_WipeAll();
DestroyAccount(0);
DestroyAccount(1);
DestroyAccount(2);
@@ -63,6 +64,7 @@ void PowerOnSelfCheck(void)
Gd25FlashBlockErase(addr);
printf("flash erase address: %#x\n", addr);
}
+ ErasePublicInfo();
NVIC_SystemReset();
}
-}
\ No newline at end of file
+}
Why this scored 57/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.