fira_session.c
Range + URSK store for the CCC Pre-POLL responder.
Overview
Range + URSK store for the CCC Pre-POLL responder.
depends on woz_port.h aliro_kdf.h fira_session.h
API
Fvoid fira_session_set_provisioned_ursk(const uint8_t *ursk)
Stash an Aliro URSK for the CCC Pre-POLL STS decode; NULL clears it.
Fconst uint8_t *fira_session_get_ursk(void)
The stashed Aliro URSK (32 bytes), or NULL if none — for the Pre-POLL decode.
Fuint32_t fira_session_current_slot(void)
STS-index slot clock (inert without a MAC time base); returns 0.
Fbool fira_session_last_range(int32_t *cm_out, uint16_t *addr_out, uint8_t *nlos_out, uint32_t *block_out, int64_t *age_ms_out)
Fetch the most recent valid DS-TWR range; out-params optional (NULL to skip).
Fbool fira_session_range_plausible(int32_t cm)
Layer 1: true if @p cm is a physically plausible DS-TWR distance.
fira_session_set_ccc_range_cmFbool fira_session_sts_quality_ok(int32_t driver_verdict, int16_t quality_index)
Layer 2: true if the STS correlated well enough to trust its timestamp.
driver_verdict- dwt_readstsquality() return (>=0 good, <0 bad).
quality_index- the signed STS quality index it wrote.
fira_session_set_ccc_range_stsFbool fira_session_range_trusted(void)
Layer 4: true once >= K consecutive plausible, mutually consistent ranges have been latched. Cleared by any implausible or outlier block.
Fuint8_t fira_session_trust_level(void)
Layer 4 diagnostic: the live run length of agreeing plausible blocks (0..FIRA_RANGE_TRUST_K) behind fira_session_range_trusted().
Fvoid fira_session_reset_ranges(void)
Invalidate the old session's range and consensus before a new URSK session starts. The monotonic generation is retained so callers can prove that a later latch happened after their checkpoint.
Fvoid fira_session_set_ccc_range_sts(int32_t driver_verdict, int16_t quality_index)
Record the layer-2 STS evidence for the block that is about to latch. Separate from the latch itself because the responder RX path owns the DW3000 diagnostics and the store does not. Call it immediately before fira_session_set_ccc_range_cm(); the latch consumes the evidence and clears it, so a latch with no preceding call records "no evidence", which reads as a failed STS rather than a passed one.
driver_verdict- dwt_readstsquality() return (>=0 good, <0 bad).
quality_index- the signed STS quality index it wrote.
fira_session_sts_quality_okFbool fira_session_last_range_integrity(struct fira_range_integrity *out)
Read the integrity evidence for the latched range. Reports the run, not the last block: a consumer that fails closed needs to know that every block which built the consensus was well-correlated, since an attacker who can land one good block among three suspect ones has not been stopped by a check that only inspects the last.
- returns
- false (leaving @p out untouched) when no range has been latched.
Fuint32_t fira_session_range_generation(void)
Monotonic generation incremented after every accepted range latch.
Fvoid fira_session_set_range_listener(void (*cb)(void))
Register a callback fired after each accepted range latch (NULL to clear). Runs on the UWB RX path — keep it to a task wake, nothing heavier.
Fvoid fira_session_set_ccc_range_cm(int32_t cm, uint32_t block)
Latch a CCC DS-TWR range so it flows up the Aliro mRangingData seam.
fira_session_range_plausible