mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
storage: wipe storage after 15 wrong pins
This commit is contained in:
parent
fa2f5fb33f
commit
c778d7b9c3
@ -318,10 +318,7 @@ void fsm_msgWipeDevice(WipeDevice *msg)
|
|||||||
layoutHome();
|
layoutHome();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
storage_reset();
|
storage_wipe();
|
||||||
storage_reset_uuid();
|
|
||||||
storage_commit();
|
|
||||||
storage_clearPinArea();
|
|
||||||
// the following does not work on Mac anyway :-/ Linux/Windows are fine, so it is not needed
|
// 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
|
// usbReconnect(); // force re-enumeration because of the serial number change
|
||||||
fsm_sendSuccess(_("Device wiped"));
|
fsm_sendSuccess(_("Device wiped"));
|
||||||
|
@ -30,6 +30,8 @@
|
|||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
|
|
||||||
|
#define MAX_WRONG_PINS 15
|
||||||
|
|
||||||
bool protectAbortedByInitialize = false;
|
bool protectAbortedByInitialize = false;
|
||||||
|
|
||||||
bool protectButton(ButtonRequestType type, bool confirm_only)
|
bool protectButton(ButtonRequestType type, bool confirm_only)
|
||||||
@ -183,14 +185,23 @@ bool protectPin(bool use_cached)
|
|||||||
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
|
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (storage_increasePinFails(fails) && storage_containsPin(pin)) {
|
if (!storage_increasePinFails(fails)) {
|
||||||
|
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (storage_containsPin(pin)) {
|
||||||
session_cachePin();
|
session_cachePin();
|
||||||
storage_resetPinFails(fails);
|
storage_resetPinFails(fails);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
|
if (~*fails > MAX_WRONG_PINS) {
|
||||||
return false;
|
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, _("Too many wrong PINs"), _("entered. Storage has"), _("been wiped."), NULL, _("Please unplug"), _("the device."));
|
||||||
|
storage_wipe();
|
||||||
|
for (;;) {} // loop forever
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool protectChangePin(void)
|
bool protectChangePin(void)
|
||||||
|
@ -622,3 +622,11 @@ void storage_setU2FCounter(uint32_t u2fcounter)
|
|||||||
storage.u2f_counter = u2fcounter - storage_u2f_offset;
|
storage.u2f_counter = u2fcounter - storage_u2f_offset;
|
||||||
storage_commit();
|
storage_commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void storage_wipe(void)
|
||||||
|
{
|
||||||
|
storage_reset();
|
||||||
|
storage_reset_uuid();
|
||||||
|
storage_commit();
|
||||||
|
storage_clearPinArea();
|
||||||
|
}
|
||||||
|
@ -73,6 +73,8 @@ bool storage_needsBackup(void);
|
|||||||
void storage_applyFlags(uint32_t flags);
|
void storage_applyFlags(uint32_t flags);
|
||||||
uint32_t storage_getFlags(void);
|
uint32_t storage_getFlags(void);
|
||||||
|
|
||||||
|
void storage_wipe(void);
|
||||||
|
|
||||||
extern Storage storage;
|
extern Storage storage;
|
||||||
|
|
||||||
extern char storage_uuid_str[25];
|
extern char storage_uuid_str[25];
|
||||||
|
Loading…
Reference in New Issue
Block a user