Delete the U2F counter if it's set to None.

pull/25/head
andrew 5 years ago committed by Pavol Rusnak
parent 92faa9f958
commit 1d43f9bea2
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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…
Cancel
Save