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.)
Auto Trait Implementations§
impl<S> Freeze for ShieldChannel<S>where
S: Freeze,
impl<S> RefUnwindSafe for ShieldChannel<S>where
S: RefUnwindSafe,
impl<S> Send for ShieldChannel<S>where
S: Send,
impl<S> Sync for ShieldChannel<S>where
S: Sync,
impl<S> Unpin for ShieldChannel<S>where
S: Unpin,
impl<S> UnwindSafe for ShieldChannel<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more