From 316e4aff8af7ada1b86264ba606f53d201ae3444 Mon Sep 17 00:00:00 2001 From: "Peter D. Gray" Date: Tue, 27 Feb 2024 10:43:22 -0500 Subject: [PATCH] Revert "remove obsolete code" This reverts commit 527d24a5fd646cb23d3c75aa3f6f03f146167fc2. --- shared/login.py | 19 ++++++++++++++++++- shared/pincodes.py | 6 ++++++ shared/selftest.py | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/shared/login.py b/shared/login.py index ab31f033..a5a3c24c 100644 --- a/shared/login.py +++ b/shared/login.py @@ -214,6 +214,20 @@ class LoginUX: self.show_pin() + async def do_delay(self): + # show # of failures and implement the delay, which could be + # very long. + dis.clear() + dis.text(None, 0, "Checking...", FontLarge) + dis.text(None, 24, 'Wait '+pretty_delay(pa.delay_required * pa.seconds_per_tick)) + dis.text(None, 40, "(%d failures)" % pa.num_fails) + + while pa.is_delay_needed(): + dis.progress_bar(pa.delay_achieved / pa.delay_required) + dis.show() + + pa.delay() + async def we_are_ewaste(self, num_fails): msg = '''After %d failed PIN attempts this Coldcard is locked forever. \ By design, there is no way to reset or recover the secure element, and its contents \ @@ -261,10 +275,13 @@ Press OK to continue, X to stop for now. dis.fullscreen("Wait...") pa.setup(pin) - if pa.num_fails > 3: + if version.has_608 and pa.num_fails > 3: # they are approaching brickage, so warn them each attempt await self.confirm_attempt(pa.attempts_left, pa.num_fails, pin) dis.fullscreen("Wait...") + elif pa.is_delay_needed(): + # mark 1/2 might come here, never mark3 + await self.do_delay() # do the actual login attempt now try: diff --git a/shared/pincodes.py b/shared/pincodes.py index 05d11ed9..a439390c 100644 --- a/shared/pincodes.py +++ b/shared/pincodes.py @@ -308,6 +308,12 @@ class PinAttempt: return rv + def is_delay_needed(self): + # obsolete starting w/ mk3 and values re-used for other stuff + if version.has_608: + return False + return self.delay_achieved < self.delay_required + def is_blank(self): # device has no PIN at this point return bool(self.state_flags & PA_IS_BLANK) diff --git a/shared/selftest.py b/shared/selftest.py index ad5f955e..fc780a46 100644 --- a/shared/selftest.py +++ b/shared/selftest.py @@ -34,9 +34,13 @@ def set_genuine(): # - or logged in already as main from pincodes import pa + if pa.is_secondary: + return + if not pa.is_successful(): # assume blank pin during factory selftest pa.setup(b'') + assert not pa.is_delay_needed() # "PIN failures?" if not pa.is_successful(): pa.login()