Skip to main content

Module km_refresh

Module km_refresh 

Source
Available on crate feature crypto only.
Expand description

SEK-rotation (“KM Refresh”) driver — draft-sharabayko-srt-01 §6.1.6 (KM Refresh), curated at specs/rules/srt-crypto.md (“KM Refresh — §6.1.6”).

Sans-IO: KmRefreshDriver::on_packet_sent / KmRefreshDriver::tick take a caller-supplied packet count — this crate never reads a wall clock or a socket (the same contract as crate::handshake_sm / crate::arq / crate::tsbpd). The driver only tracks when to rotate and which parity is active; it does not generate, wrap, or send key material itself — the actual SEK PRNG/wrap/Key-Material-message send is the caller’s job (mirroring crate::handshake_sm::CryptoConfig’s design: this crate’s sans-IO core never owns a CSPRNG), triggered by KmRefreshEvent::PreAnnounce.

  • KM Refresh Period = 2^25 packets: how long a key stays active before switchover.
  • KM Pre-Announcement Period = 4000 packets: how long before switchover the new key is announced, and — symmetrically — how long after switchover the old key stays valid before decommission. “Both keys are valid in parallel for 2 * Pre-Announcement Period”, to tolerate late/retransmitted packets that were encrypted under the old key.

All three thresholds are measured from the start of the current active key’s epoch (packet 0 of that key):

0 ── refresh - pre_announce ── refresh ── refresh + pre_announce
     PreAnnounce fires         Switchover  Decommission fires
     (generate + wrap +       (old key     (old key dropped)
      ready next key)          still valid)

KmRefreshThresholds::RECOMMENDED is the spec’s 2^25/4000 pair; tests/km_refresh.rs drives the same state machine with a scaled-down threshold pair so the test suite does not need 2^25 real iterations — the state machine logic is identical, only the threshold constants differ.

Structs§

KmRefreshDriver
Sans-IO SEK-rotation state machine (draft-sharabayko-srt-01 §6.1.6).
KmRefreshThresholds
KM Refresh packet-count thresholds (draft-sharabayko-srt-01 §6.1.6).

Enums§

KeyParity
Which of the two alternating SEKs (draft-sharabayko-srt-01 §3.1’s data packet KK field / §6.1.6’s odd/even alternation) is meant.
KmRefreshEvent
One state transition KmRefreshDriver::on_packet_sent / KmRefreshDriver::tick can fire (draft-sharabayko-srt-01 §6.1.6).