This commit is contained in:
Peter D. Gray 2024-03-26 10:35:22 -04:00
parent 1468cf0051
commit c9ecc2ddf7
No known key found for this signature in database
GPG Key ID: A2DCD558C2BE5D7C
2 changed files with 13 additions and 5 deletions

View File

@ -22,10 +22,12 @@ async def login_repl():
NUM_LINES = 7 # 10 - title - 2 for prompt
re_prefix = re.compile(r'^(\d\d+)-$')
re_pin = re.compile(r'^(\d\d+)-(\d\d+)$')
# recognise 12-12 / 12- but also accept underscore, or even space in pin: "12 12"
re_prefix = re.compile(r'^(\d\d+)[-_]$')
re_pin = re.compile(r'^(\d\d+)[-_ ](\d\d+)$')
blacklist = ['import', '__', ]
# in decreasing order of hazard...
blacklist = ['import', '__', 'exec', 'locals', 'globals', 'eval' ]
lines = '''\
@ -40,8 +42,10 @@ Example Commands:
state = dict()
state['sha256'] = lambda x: B2A(ngu.hash.sha256s(x))
state['sha512'] = lambda x: B2A(ngu.hash.sha512(x).digest())
state['ripemd'] = lambda x: B2A(ngu.hash.ripemd160(x))
state['cls'] = lambda: lines.clear()
state['help'] = lambda: 'Sorry, no help!'
state['help'] = lambda: 'Commands: ' + (', '.join(state))
while 1:
dis.clear()
@ -69,6 +73,9 @@ Example Commands:
ans = state[ln]()
elif re_pin.match(ln) and len(ln) <= 13:
# try login
m = re_pin.match(ln)
ln = m.group(1)+ '-' + m.group(2)
print(ln)
try:
pa.setup(ln)
ok = pa.login()

View File

@ -108,7 +108,7 @@ LoginPrefsMenu = [
NonDefaultMenuItem('Login Countdown', 'lgto', prelogin=True, chooser=countdown_chooser),
NonDefaultMenuItem('MicroSD 2FA', 'sd2fa', menu=microsd_2fa, predicate=se2_and_real_secret),
PreloginToggleMenuItem('Calculator Login', 'calc', ['Default Off', 'Calculator Login'],
story='''Boots into calculator mode. Enter your PIN as formula to login, or 12- to see prefix words. Normal calculator math works too.'''),
story='''Boots into calculator mode. Enter your PIN as formula to login, or 12- to see prefix words. Normal calculator math works too.''', predicate=lambda: version.has_qwerty),
MenuItem('Test Login Now', f=login_now, arg=1),
]
@ -265,6 +265,7 @@ DangerZoneMenu = [
MenuItem("Set High-Water", f=set_highwater),
MenuItem('Wipe HSM Policy', f=wipe_hsm_policy, predicate=hsm_policy_available),
MenuItem('Clear OV cache', f=wipe_ovc),
MenuItem("Clear Address cache", f=wipe_address_cache),
ToggleMenuItem("Sighash Checks", "sighshchk", ["Default: Block", "Warn"], invert=True,
story='''\
If you disable sighash flag restrictions, and ignore the \