mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
rework pin handling
This commit is contained in:
parent
012d38a9a0
commit
40efefc571
@ -145,24 +145,26 @@ bool protectPin(bool use_cached)
|
|||||||
if (!storage.has_pin || strlen(storage.pin) == 0 || (use_cached && session_isPinCached())) {
|
if (!storage.has_pin || strlen(storage.pin) == 0 || (use_cached && session_isPinCached())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char *pin;
|
uint32_t fails = storage_getPinFails();
|
||||||
uint32_t wait = storage_getPinFails();
|
if (fails) {
|
||||||
if (wait) {
|
if (fails > 2) {
|
||||||
if (wait > 2) {
|
|
||||||
layoutDialogSwipe(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait ...", NULL, NULL, NULL);
|
layoutDialogSwipe(DIALOG_ICON_INFO, NULL, NULL, NULL, "Wrong PIN entered", NULL, "Please wait ...", NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
wait = (wait < 32) ? (1u << wait) : 0xFFFFFFFF;
|
uint32_t wait;
|
||||||
|
wait = (fails < 32) ? (1u << fails) : 0xFFFFFFFF;
|
||||||
while (--wait > 0) {
|
while (--wait > 0) {
|
||||||
delay(10000000);
|
delay(10000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
storage_increasePinFails();
|
storage_increasePinFails();
|
||||||
|
bool increase_failed = (fails >= storage_getPinFails());
|
||||||
|
const char *pin;
|
||||||
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, "Please enter current PIN:");
|
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, "Please enter current PIN:");
|
||||||
if (!pin) {
|
if (!pin) {
|
||||||
fsm_sendFailure(FailureType_Failure_PinCancelled, "PIN Cancelled");
|
fsm_sendFailure(FailureType_Failure_PinCancelled, "PIN Cancelled");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (storage_isPinCorrect(pin)) {
|
if (storage_isPinCorrect(pin) && !increase_failed) {
|
||||||
session_cachePin(pin);
|
session_cachePin(pin);
|
||||||
storage_resetPinFails();
|
storage_resetPinFails();
|
||||||
return true;
|
return true;
|
||||||
|
@ -350,6 +350,7 @@ void storage_increasePinFails(void)
|
|||||||
|
|
||||||
uint32_t storage_getPinFails(void)
|
uint32_t storage_getPinFails(void)
|
||||||
{
|
{
|
||||||
|
storage_from_flash(STORAGE_VERSION); // reload from flash
|
||||||
return storage.has_pin_failed_attempts ? storage.pin_failed_attempts : 0;
|
return storage.has_pin_failed_attempts ? storage.pin_failed_attempts : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user