pub struct RatchetSession { /* private fields */ }Expand description
Ratcheting session for forward secrecy.
Each encrypt/decrypt advances the key chain, destroying previous keys automatically.
Chain keys are securely zeroized from memory when dropped.
Implementations§
Source§impl RatchetSession
impl RatchetSession
Sourcepub fn new(root_key: &[u8; 32], is_initiator: bool) -> Self
pub fn new(root_key: &[u8; 32], is_initiator: bool) -> Self
Create a new ratchet session from shared root key.
§Arguments
root_key- Shared secret from key exchangeis_initiator- True if this party initiated the session
Sourcepub fn encrypt(&mut self, plaintext: &[u8]) -> Result<Vec<u8>>
pub fn encrypt(&mut self, plaintext: &[u8]) -> Result<Vec<u8>>
Encrypt a message with forward secrecy.
Advances the send chain - previous keys are destroyed.
Sourcepub fn decrypt(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>>
pub fn decrypt(&mut self, ciphertext: &[u8]) -> Result<Vec<u8>>
Decrypt a message with forward secrecy.
Advances the receive chain only AFTER successful MAC and counter verification. A forged packet will not desynchronize the session.
Sourcepub fn send_counter(&self) -> u64
pub fn send_counter(&self) -> u64
Get send counter (for diagnostics).
Sourcepub fn recv_counter(&self) -> u64
pub fn recv_counter(&self) -> u64
Get receive counter (for diagnostics).
Trait Implementations§
Source§impl Drop for RatchetSession
impl Drop for RatchetSession
Auto Trait Implementations§
impl Freeze for RatchetSession
impl RefUnwindSafe for RatchetSession
impl Send for RatchetSession
impl Sync for RatchetSession
impl Unpin for RatchetSession
impl UnsafeUnpin for RatchetSession
impl UnwindSafe for RatchetSession
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