Пример #1
0
def change_lastgood(the_pin, new_value, idx=0):
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.write_encrypted(KN_lastgood[idx], KN_pins[idx], the_pin, new_value)

    ae.reset_chip()
    ae.do_checkmac(KN_pairing, pairing_key)
    rb = ae.read_data_slot(KN_lastgood[idx], blkcount=1)
    assert rb == new_value

    return rb
Пример #2
0
def change_secret(the_pin, new_secret, idx=0):
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.write_encrypted(KN_secrets[idx], KN_pins[idx], the_pin, new_secret)

    ae.reset_chip()
    ae.do_checkmac(KN_pairing, pairing_key)
    rb = ae.read_encrypted(KN_secrets[idx], KN_pins[idx], the_pin)
    assert rb == new_secret

    return rb
Пример #3
0
def test_fw(fw=None):
    # write a value (someday will be the flash checksum)
    fw = fw or b'test'*8
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.write_encrypted(KN_firmware, KN_pairing, pairing_key, fw)

    # verify it's what we wanted
    ae.reset_watchdog()
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.do_checkmac(KN_firmware, fw)

    # we can now show the green light
    return ae.set_gpio(1)
Пример #4
0
def change_pin(old_pin, new_pin, idx=0):
    ae.reset_watchdog()
    ae.do_checkmac(KN_pairing, pairing_key)
    try:
        ae.do_checkmac(KN_pins[idx], old_pin)
    except WrongMacVerify:
        print("that's the wrong PIN")
        return 0

    ae.reset_watchdog()
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.write_encrypted(KN_pins[idx], KN_pins[idx], old_pin, new_pin)
    
    # verify change
    ae.do_checkmac(KN_pairing, pairing_key)
    ae.do_checkmac(KN_pins[idx], new_pin)

    print("[%d] new pin in effect" % idx)
    ae.reset_chip()
    ae.do_checkmac(KN_pairing, pairing_key)

    if idx < len(KN_secrets):
        return ae.read_encrypted(KN_secrets[idx], KN_pins[idx], new_pin)