mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +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())) {
|
||||
return true;
|
||||
}
|
||||
const char *pin;
|
||||
uint32_t wait = storage_getPinFails();
|
||||
if (wait) {
|
||||
if (wait > 2) {
|
||||
uint32_t fails = storage_getPinFails();
|
||||
if (fails) {
|
||||
if (fails > 2) {
|
||||
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) {
|
||||
delay(10000000);
|
||||
}
|
||||
}
|
||||
storage_increasePinFails();
|
||||
bool increase_failed = (fails >= storage_getPinFails());
|
||||
const char *pin;
|
||||
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, "Please enter current PIN:");
|
||||
if (!pin) {
|
||||
fsm_sendFailure(FailureType_Failure_PinCancelled, "PIN Cancelled");
|
||||
return false;
|
||||
}
|
||||
if (storage_isPinCorrect(pin)) {
|
||||
if (storage_isPinCorrect(pin) && !increase_failed) {
|
||||
session_cachePin(pin);
|
||||
storage_resetPinFails();
|
||||
return true;
|
||||
|
@ -350,6 +350,7 @@ void storage_increasePinFails(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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user