]> git.earman.xyz Git - sensor-watch.git/commit
faces/totp: avoid displaying when key is invalid
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Wed, 20 Mar 2024 14:35:58 +0000 (11:35 -0300)
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Wed, 20 Mar 2024 15:54:20 +0000 (12:54 -0300)
commit10701f3d505170f57655b111c77977f270fe9e42
tree6e9697a7ae91c1c5e004e77aa0aedca432a93002
parent7e5c34773a4e8a47c2f8e77bd5c7ec58f4a7a84c
faces/totp: avoid displaying when key is invalid

Fixes a division by zero bug caused by calling getCodeFromTimestamp
without having initialized the TOTP library with a secret first.
This was happening because the face calls totp_display on activation,
meaning the validity of the secret was not checked since this is
done in the generate function.

Now the validity of the key is determined solely by the size
of the current decoded key. A general display function checks it
and decides whether to display the code or just the error message.

The size of the current decoded key is initialized to zero
on watch face activation, ensuring fail safe operation.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: madhogs <59648482+madhogs@users.noreply.github.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/385
movement/watch_faces/complication/totp_face.c