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