mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 07:28:10 +00:00
Delete the U2F counter if it's set to None.
This commit is contained in:
parent
92faa9f958
commit
1d43f9bea2
@ -45,6 +45,10 @@ def _get_bool(app: int, key: int, public: bool = False) -> bool:
|
||||
|
||||
|
||||
def _set_counter(app: int, key: int, count: int, public: bool = False) -> None:
|
||||
if count is None:
|
||||
config.delete(app, key, public)
|
||||
return
|
||||
|
||||
value = count.to_bytes(_COUNTER_HEAD_LEN, "big")
|
||||
if public:
|
||||
value += _COUNTER_TAIL_LEN * b"\xff"
|
||||
|
@ -15,6 +15,10 @@ class TestConfig(unittest.TestCase):
|
||||
storage.set_u2f_counter(350)
|
||||
for i in range(351, 500):
|
||||
self.assertEqual(storage.next_u2f_counter(), i)
|
||||
storage.set_u2f_counter(0)
|
||||
self.assertEqual(storage.next_u2f_counter(), 1)
|
||||
storage.set_u2f_counter(None)
|
||||
self.assertEqual(storage.next_u2f_counter(), 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user