pub struct KmRefreshDriver { /* private fields */ }crypto only.Expand description
Sans-IO SEK-rotation state machine (draft-sharabayko-srt-01 §6.1.6).
Tracks which KeyParity is currently active and fires
KmRefreshEvents as the packet count crosses the configured
KmRefreshThresholds. Does not hold key material itself — see the
module doc. Rotates indefinitely: once a cycle’s KmRefreshEvent::Decommission
fires, the next cycle’s thresholds are armed again against the new active
key’s epoch.
Implementations§
Source§impl KmRefreshDriver
impl KmRefreshDriver
Sourcepub fn new(thresholds: KmRefreshThresholds, initial_parity: KeyParity) -> Self
pub fn new(thresholds: KmRefreshThresholds, initial_parity: KeyParity) -> Self
A fresh driver. initial_parity is the SEK negotiated at handshake
time (this crate’s handshake convention is KeyParity::Even — see
crate::handshake_sm::build_key_material_extension, crypto feature
only).
Sourcepub fn active_parity(&self) -> KeyParity
pub fn active_parity(&self) -> KeyParity
The currently-active parity for new outgoing packets.
Sourcepub fn total_sent(&self) -> u64
pub fn total_sent(&self) -> u64
Total packets recorded via Self::on_packet_sent/Self::tick.
Sourcepub fn is_key_valid(&self, parity: KeyParity) -> bool
pub fn is_key_valid(&self, parity: KeyParity) -> bool
Whether parity’s key should still be considered held/valid. The
active key always is; the just-retired key is too, from switchover
until decommission (§6.1.6’s “both keys valid in parallel” transition
window) — a data packet under either may legitimately arrive during
that window (in-flight or retransmitted).
Sourcepub fn on_packet_sent(&mut self, n: u64) -> Vec<KmRefreshEvent>
pub fn on_packet_sent(&mut self, n: u64) -> Vec<KmRefreshEvent>
Record n more packets sent under the active key and return any
KmRefreshEvents newly crossed, in spec order (PreAnnounce,
Switchover, Decommission). A single call can fire more than one event
if n is large enough to cross multiple thresholds at once.
Sourcepub fn tick(&mut self) -> Vec<KmRefreshEvent>
pub fn tick(&mut self) -> Vec<KmRefreshEvent>
Record exactly one packet sent — convenience wrapper over
Self::on_packet_sent.
Trait Implementations§
Source§impl Clone for KmRefreshDriver
impl Clone for KmRefreshDriver
Source§fn clone(&self) -> KmRefreshDriver
fn clone(&self) -> KmRefreshDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KmRefreshDriver
impl Debug for KmRefreshDriver
Source§impl PartialEq for KmRefreshDriver
impl PartialEq for KmRefreshDriver
Source§fn eq(&self, other: &KmRefreshDriver) -> bool
fn eq(&self, other: &KmRefreshDriver) -> bool
self and other values to be equal, and is used by ==.