Skip to content

Commit

Permalink
fixup! feat(core): Integrate Optiga into PIN verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkozlik committed Sep 27, 2023
1 parent 4ed316b commit 5d79134
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions storage/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,15 @@ static secbool is_not_wipe_code(const uint8_t *pin, size_t pin_len) {
static secbool ui_progress(uint32_t elapsed_ms) {
ui_rem -= elapsed_ms;
if (ui_callback && ui_message) {
uint32_t progress = 1000 * (ui_total - ui_rem) / ui_total;
return ui_callback(ui_rem / 1000, progress, ui_message);
uint32_t progress = 0;
if (ui_total < 1000000) {
progress = 1000 * (ui_total - ui_rem) / ui_total;
} else {
// Avoid overflow. Precise enough.
progress = (ui_total - ui_rem) / (ui_total / 1000);
}
// Round the remaining time to the nearest second.
return ui_callback((ui_rem + 500) / 1000, progress, ui_message);
} else {
return secfalse;
}
Expand Down

0 comments on commit 5d79134

Please sign in to comment.