1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-27 01:48:17 +00:00

clear pin failures on wipe and when in debug mode

This commit is contained in:
Pavol Rusnak 2016-05-20 17:00:10 +02:00
parent d20671b517
commit 46119bd007
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
4 changed files with 12 additions and 0 deletions

View File

@ -241,6 +241,7 @@ void fsm_msgWipeDevice(WipeDevice *msg)
storage_reset();
storage_reset_uuid();
storage_commit();
storage_clearPinArea();
// the following does not work on Mac anyway :-/ Linux/Windows are fine, so it is not needed
// usbReconnect(); // force re-enumeration because of the serial number change
fsm_sendSuccess("Device wiped");

View File

@ -419,6 +419,15 @@ bool session_isPinCached(void)
return sessionPinCached;
}
void storage_clearPinArea()
{
flash_clear_status_flags();
flash_unlock();
flash_erase_sector(FLASH_META_SECTOR_LAST, FLASH_CR_PROGRAM_X32);
flash_lock();
storage_check_flash_errors();
}
void storage_resetPinFails(uint32_t *pinfailsptr)
{
flash_clear_status_flags();

View File

@ -56,6 +56,7 @@ bool storage_hasPin(void);
void storage_setPin(const char *pin);
void session_cachePin(void);
bool session_isPinCached(void);
void storage_clearPinArea(void);
void storage_resetPinFails(uint32_t *pinfailptr);
bool storage_increasePinFails(uint32_t *pinfailptr);
uint32_t *storage_getPinFailsPtr(void);

View File

@ -50,6 +50,7 @@ int main(void)
storage_reset(); // wipe storage if debug link
storage_reset_uuid();
storage_commit();
storage_clearPinArea(); // reset PIN failures if debug link
#endif
oledDrawBitmap(40, 0, &bmp_logo64);