Revert "remove obsolete code"

This reverts commit 527d24a5fd.
This commit is contained in:
Peter D. Gray 2024-02-27 10:43:22 -05:00
parent 5173a4e533
commit 316e4aff8a
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
3 changed files with 28 additions and 1 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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()