From bdc35db431efa24ac34cf7bd536af19cfd7c1c9d Mon Sep 17 00:00:00 2001 From: Siddharth Chandrasekaran Date: Sat, 9 Mar 2024 22:40:04 +0100 Subject: [PATCH] libosdp: Fix issue with SC retry timer When SC fails, we missed updating the sc_tstamp which resulted in CP retrying SC back to back causing CP to do nothing but bouncing between online and sc-init sates. Signed-off-by: Siddharth Chandrasekaran --- src/osdp_cp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osdp_cp.c b/src/osdp_cp.c index facd95d..a8a43a6 100644 --- a/src/osdp_cp.c +++ b/src/osdp_cp.c @@ -1104,6 +1104,11 @@ static enum osdp_cp_state_e get_next_err_state(struct osdp_pd *pd) return OSDP_CP_STATE_SC_CHLNG; } CLEAR_FLAG(pd, PD_FLAG_SC_USE_SCBKD); + /** + * SC setup failed; Update sc_tstamp so the next retry happens + * after OSDP_PD_SC_RETRY_MS. + */ + pd->sc_tstamp = osdp_millis_now(); return OSDP_CP_STATE_ONLINE; case OSDP_CP_STATE_SC_SCRYPT: if (is_enforce_secure(pd)) {