pub struct ShieldChannel<S> { /* private fields */ }Expand description
Shield secure channel for encrypted communication.
Provides TLS-like security using only symmetric cryptography:
- PAKE handshake establishes shared key from password
RatchetSessionprovides forward secrecy- All messages authenticated with HMAC
Implementations§
Source§impl<S: Read + Write> ShieldChannel<S>
impl<S: Read + Write> ShieldChannel<S>
Sourcepub fn connect(stream: S, config: &ChannelConfig) -> Result<Self>
pub fn connect(stream: S, config: &ChannelConfig) -> Result<Self>
Connect as client (initiator).
Performs PAKE handshake and establishes encrypted channel.
§Arguments
stream- Underlying transport (TCP, etc.)config- Channel configuration with shared password
Sourcepub fn accept(stream: S, config: &ChannelConfig) -> Result<Self>
pub fn accept(stream: S, config: &ChannelConfig) -> Result<Self>
Accept connection as server.
Waits for client handshake and establishes encrypted channel.
§Arguments
stream- Underlying transport (TCP, etc.)config- Channel configuration with shared password
Sourcepub fn send(&mut self, data: &[u8]) -> Result<()>
pub fn send(&mut self, data: &[u8]) -> Result<()>
Send encrypted message.
Message is encrypted with current ratchet key, then key advances.
Sourcepub fn recv(&mut self) -> Result<Vec<u8>>
pub fn recv(&mut self) -> Result<Vec<u8>>
Receive and decrypt message.
Verifies authentication and advances receive ratchet.
Sourcepub fn messages_sent(&self) -> u64
pub fn messages_sent(&self) -> u64
Get send message count.
Sourcepub fn messages_received(&self) -> u64
pub fn messages_received(&self) -> u64
Get receive message count.
Sourcepub fn into_inner(self) -> S
pub fn into_inner(self) -> S
Get underlying stream (for shutdown, etc.)
Source§impl ShieldChannel<TcpStream>
impl ShieldChannel<TcpStream>
Sourcepub fn connect_tcp(stream: TcpStream, config: &ChannelConfig) -> Result<Self>
pub fn connect_tcp(stream: TcpStream, config: &ChannelConfig) -> Result<Self>
Connect as client with handshake timeout enforcement.
Sets socket read/write timeouts during handshake, then clears them so post-handshake messaging is not affected.
Sourcepub fn accept_tcp(stream: TcpStream, config: &ChannelConfig) -> Result<Self>
pub fn accept_tcp(stream: TcpStream, config: &ChannelConfig) -> Result<Self>
Accept connection as server with handshake timeout enforcement.
Sets socket read/write timeouts during handshake, then clears them so post-handshake messaging is not affected.