mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
Fix check for max try and add another check before
This commit is contained in:
parent
0feede5a01
commit
33ed08ec32
@ -144,6 +144,15 @@ const char *requestPin(PinMatrixRequestType type, const char *text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void protectCheckMaxTry(uint32_t wait) {
|
||||||
|
if (wait < (1 << MAX_WRONG_PINS))
|
||||||
|
return;
|
||||||
|
|
||||||
|
storage_wipe();
|
||||||
|
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, _("Too many wrong PIN"), _("attempts. Storage has"), _("been wiped."), NULL, _("Please unplug"), _("the device."));
|
||||||
|
for (;;) {} // loop forever
|
||||||
|
}
|
||||||
|
|
||||||
bool protectPin(bool use_cached)
|
bool protectPin(bool use_cached)
|
||||||
{
|
{
|
||||||
if (!storage.has_pin || storage.pin[0] == 0 || (use_cached && session_isPinCached())) {
|
if (!storage.has_pin || storage.pin[0] == 0 || (use_cached && session_isPinCached())) {
|
||||||
@ -151,6 +160,7 @@ bool protectPin(bool use_cached)
|
|||||||
}
|
}
|
||||||
uint32_t *fails = storage_getPinFailsPtr();
|
uint32_t *fails = storage_getPinFailsPtr();
|
||||||
uint32_t wait = ~*fails;
|
uint32_t wait = ~*fails;
|
||||||
|
protectCheckMaxTry(wait);
|
||||||
usbTiny(1);
|
usbTiny(1);
|
||||||
while (wait > 0) {
|
while (wait > 0) {
|
||||||
// convert wait to secstr string
|
// convert wait to secstr string
|
||||||
@ -194,14 +204,10 @@ bool protectPin(bool use_cached)
|
|||||||
storage_resetPinFails(fails);
|
storage_resetPinFails(fails);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if (~*fails > MAX_WRONG_PINS) {
|
protectCheckMaxTry(~*fails);
|
||||||
layoutDialog(&bmp_icon_error, NULL, NULL, NULL, _("Too many wrong PIN"), _("attempts. Storage has"), _("been wiped."), NULL, _("Please unplug"), _("the device."));
|
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
|
||||||
storage_wipe();
|
return false;
|
||||||
for (;;) {} // loop forever
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool protectChangePin(void)
|
bool protectChangePin(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user