pub struct Session { /* private fields */ }Expand description
Handshake + rekey state machine for Foctet Core.
Implementations§
Source§impl Session
impl Session
Sourcepub fn new_initiator(thresholds: RekeyThresholds) -> (Self, ControlMessage)
pub fn new_initiator(thresholds: RekeyThresholds) -> (Self, ControlMessage)
Creates an initiator session and returns the initial ClientHello.
Sourcepub fn new_initiator_with_auth(
thresholds: RekeyThresholds,
auth: SessionAuthConfig,
) -> (Self, ControlMessage)
pub fn new_initiator_with_auth( thresholds: RekeyThresholds, auth: SessionAuthConfig, ) -> (Self, ControlMessage)
Creates an initiator session with explicit authentication configuration.
Sourcepub fn new_responder(thresholds: RekeyThresholds) -> Self
pub fn new_responder(thresholds: RekeyThresholds) -> Self
Creates a responder session waiting for a peer ClientHello.
Sourcepub fn new_responder_with_auth(
thresholds: RekeyThresholds,
auth: SessionAuthConfig,
) -> Self
pub fn new_responder_with_auth( thresholds: RekeyThresholds, auth: SessionAuthConfig, ) -> Self
Creates a responder session with explicit authentication configuration.
Sourcepub fn state(&self) -> SessionState
pub fn state(&self) -> SessionState
Returns current session state.
Sourcepub fn role(&self) -> HandshakeRole
pub fn role(&self) -> HandshakeRole
Returns configured handshake role.
Sourcepub fn peer_authenticated(&self) -> bool
pub fn peer_authenticated(&self) -> bool
Returns whether the peer presented and passed handshake authentication.
Sourcepub fn outbound_direction(&self) -> Direction
pub fn outbound_direction(&self) -> Direction
Returns outbound traffic direction for this role.
Sourcepub fn inbound_direction(&self) -> Direction
pub fn inbound_direction(&self) -> Direction
Returns inbound traffic direction for this role.
Sourcepub fn handle_control(
&mut self,
msg: &ControlMessage,
) -> Result<Option<ControlMessage>, CoreError>
pub fn handle_control( &mut self, msg: &ControlMessage, ) -> Result<Option<ControlMessage>, CoreError>
Applies an incoming control message and optionally returns a response.
Sourcepub fn active_keys(&self) -> Option<TrafficKeys>
pub fn active_keys(&self) -> Option<TrafficKeys>
Returns the currently active traffic keys, if session is active.
Sourcepub fn active_and_previous_keys(&self) -> Option<Vec<TrafficKeys>>
pub fn active_and_previous_keys(&self) -> Option<Vec<TrafficKeys>>
Returns active key followed by retained previous keys.
Sourcepub fn key_ring(&self) -> Result<Vec<TrafficKeys>, CoreError>
pub fn key_ring(&self) -> Result<Vec<TrafficKeys>, CoreError>
Returns current key ring as transport-ready list.
Sourcepub fn on_outbound_payload(
&mut self,
plaintext_len: usize,
) -> Result<Option<ControlMessage>, CoreError>
pub fn on_outbound_payload( &mut self, plaintext_len: usize, ) -> Result<Option<ControlMessage>, CoreError>
Records outbound payload usage and emits rekey control when needed.
Sourcepub fn force_rekey(&mut self) -> Result<ControlMessage, CoreError>
pub fn force_rekey(&mut self) -> Result<ControlMessage, CoreError>
Forces immediate rekey and returns the Rekey control message.