Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self):
self.board = "na-satbus-3c0-gcc"
self.arch = "ARM"
self.cpu = "stm32f405"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27)
}
def __init__(self):
self.board = "stm32f407-disco-gcc"
self.arch = "ARM"
self.cpu = "stm32f407"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22) # optional
}
def __init__(self):
self.board = "msp430f5529-gcc"
self.arch = "MSP430"
self.cpu = "msp430f5529"
self.binfiletype = "ELF"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22) # optional
}
def __init__(self):
self.board = "noboard"
self.arch = "noarch"
self.cpu = "nocpu"
self.binfiletype = "nobinfile"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'opt' : Pin(name = 'opt', number = 22)
}
def __init__(self):
self.board = "pyboard-gcc"
self.arch = "ARM"
self.cpu = "stm32f405"
self.binfiletype = "BIN"
self.pins = {
'rst' : Pin(name = 'rst', number = 17),
'pwr' : Pin(name = 'pwr', number = 27),
'prg' : Pin(name = 'prg', number = 18),
'opt' : Pin(name = 'opt', number = 22)
}
style.text.color = lv.color_hex(0xffffff)
style.text.letter_space = 15
pin_lbl.set_style(lv.label.STYLE.MAIN, style)
pin_lbl.set_width(HOR_RES-2*PADDING)
pin_lbl.set_x(PADDING)
pin_lbl.set_y(PADDING+50)
pin_lbl.set_cursor_type(lv.CURSOR.HIDDEN)
pin_lbl.set_one_line(True)
pin_lbl.set_text_align(lv.label.ALIGN.CENTER)
pin_lbl.set_pwd_show_time(0)
instruct_txt = "Device tamper check.\nThese words should remain #ffffff the same every time#:"
instruct_label = add_label(instruct_txt, 180, style="hint")
instruct_label.set_recolor(True)
antiphish_label = add_label(antiphishing_word(""), 250)
Pin.read_counter()
@feed_rng
def cb(obj, event):
nonlocal first_time_usage
if event == lv.EVENT.RELEASED:
c = obj.get_active_btn_text()
if c is None:
return
if c == lv.SYMBOL.CLOSE:
pin_lbl.set_text("")
antiphish_label.set_text(antiphishing_word(""))
elif c == lv.SYMBOL.OK:
# FIXME: check PIN len
Key.generate_key(pin_lbl.get_text());
if first_time_usage:
Secret.save_secret(alert);
if c is None:
return
if c == lv.SYMBOL.CLOSE:
pin_lbl.set_text("")
antiphish_label.set_text(antiphishing_word(""))
elif c == lv.SYMBOL.OK:
# FIXME: check PIN len
Key.generate_key(pin_lbl.get_text());
if first_time_usage:
Secret.save_secret(alert);
callback()
else:
Pin.counter -= 1
Pin.save_counter(alert)
if Pin.is_pin_valid():
Pin.reset_counter(alert)
callback()
else:
instruct_label.set_text("#f07070 Wrong pin: %d/%d #" % (Pin.counter, Pin.ATTEMPTS_MAX))
if Pin.counter <= 0:
Factory_settings.restore(alert)
Secret.generate_secret()
alert("Security","Device has been factory reset!")
first_time_usage = True
title_lbl.set_text(first_time_title)
instruct_label.set_text(instruct_txt)
pin_lbl.set_text("")
antiphish_label.set_text(antiphishing_word(""))
else:
instruct_label.set_text(instruct_txt)
pin_lbl.add_text(c)
word = antiphishing_word(pin_lbl.get_text())