pub struct Ratchet { /* private fields */ }Expand description
One party’s half of a Double Ratchet session: a sending chain, a receiving chain, and the skipped-key store that lets messages arrive out of order.
Implementations§
Source§impl Ratchet
impl Ratchet
Sourcepub fn encrypt(&mut self, plaintext: &[u8]) -> Result<RatchetMessage, Error>
pub fn encrypt(&mut self, plaintext: &[u8]) -> Result<RatchetMessage, Error>
Encrypt plaintext, advancing the sending chain by one step.
Sourcepub fn decrypt(
&mut self,
msg: &RatchetMessage,
rng: &mut impl RandomSource,
) -> Result<Vec<u8>, Error>
pub fn decrypt( &mut self, msg: &RatchetMessage, rng: &mut impl RandomSource, ) -> Result<Vec<u8>, Error>
Decrypt msg, advancing the receiving chain (and performing a DH ratchet step, when the
header names a new peer key) only once the AEAD tag verifies.
The whole state is cloned, mutated on the clone, and only committed back on success, so a forged frame with a plausible header but garbage ciphertext cannot burn a skipped-key slot or desync the receiving chain.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ratchet
impl RefUnwindSafe for Ratchet
impl Send for Ratchet
impl Sync for Ratchet
impl Unpin for Ratchet
impl UnsafeUnpin for Ratchet
impl UnwindSafe for Ratchet
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