summaryrefslogtreecommitdiffstats
path: root/movement/lib/TOTP/example.c
diff options
context:
space:
mode:
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>2024-03-17 19:32:27 -0300
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>2024-03-17 20:48:54 -0300
commitdf38c262b80151af06f15e6a1a8899c51dec438e (patch)
tree80eb38c1b95cbd9ced5bb2c3b4c2d7597bd81a60 /movement/lib/TOTP/example.c
parent955ac94de3afcad4e79bcf16e8fecd512a3dddca (diff)
downloadSensor-Watch-df38c262b80151af06f15e6a1a8899c51dec438e.tar.gz
Sensor-Watch-df38c262b80151af06f15e6a1a8899c51dec438e.tar.bz2
Sensor-Watch-df38c262b80151af06f15e6a1a8899c51dec438e.zip
faces/totp: improve memory usage
The TOTP face is working in the simulator but fails on the real hardware when loaded with lots of codes, just like the LFS version. This is likely caused by the recent refactoring of the TOTP face which introduced a declarative credential interface for ease of use. That's accomplished by decoding the secrets at runtime which increases the RAM requirements. Users are likely hitting memory limits. In order to mitigate this, the algorithm is changed from decoding all of the secrets only once during initialization to on the fly decoding of the secret for the current TOTP credential only. This converts this face's dynamic memory usage from O(N) to O(1) at the cost of memory management when switching faces and credentials which could impact power consumption. Issue is confirmed fixed by author of issue who has tested it on real hardware. Fixes #384. Due to variable key sizes, the memory cannot be statically allocated. Perhaps there's a maximum key size that can serve as worst case? Also took this opportunity to restructure the code a bit. Also added code to check for memory allocation failure. Reported-by: madhogs <59648482+madhogs@users.noreply.github.com> Fixed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com> 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-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/384
Diffstat (limited to 'movement/lib/TOTP/example.c')
0 files changed, 0 insertions, 0 deletions