pub struct DryocStream<Mode> { /* private fields */ }
Expand description

Secret-key authenticated encrypted streams

Implementations§

source§

impl<M> DryocStream<M>

source

pub fn rekey(&mut self)

Manually rekeys the stream. Both the push and pull sides of the stream need to manually rekey if you use this function (i.e., it’s not handled by the library).

Automatic rekeying will occur normally, and you generally shouldn’t need to manually rekey.

Refer to the libsodium docs for details.

source§

impl DryocStream<Push>

source

pub fn init_push<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: NewByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>( key: &Key ) -> (Self, Header)

Returns a new push stream, initialized from key.

source

pub fn push<Input: Bytes, Output: NewBytes + ResizableBytes>( &mut self, message: &Input, associated_data: Option<&Input>, tag: Tag ) -> Result<Output, Error>

Encrypts message for this stream with associated_data and tag, returning the ciphertext.

source

pub fn push_to_vec<Input: Bytes>( &mut self, message: &Input, associated_data: Option<&Input>, tag: Tag ) -> Result<Vec<u8>, Error>

Encrypts message for this stream with associated_data and tag, returning the ciphertext.

source§

impl DryocStream<Pull>

source

pub fn init_pull<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>( key: &Key, header: &Header ) -> Self

Returns a new pull stream, initialized from key and header.

source

pub fn pull<Input: Bytes, Output: MutBytes + Default + ResizableBytes>( &mut self, ciphertext: &Input, associated_data: Option<&Input> ) -> Result<(Output, Tag), Error>

Decrypts ciphertext for this stream with associated_data, returning the decrypted message and tag.

source

pub fn pull_to_vec<Input: Bytes>( &mut self, ciphertext: &Input, associated_data: Option<&Input> ) -> Result<(Vec<u8>, Tag), Error>

Decrypts ciphertext for this stream with associated_data, returning the decrypted message and tag into a Vec.

Trait Implementations§

source§

impl<Mode: Clone> Clone for DryocStream<Mode>

source§

fn clone(&self) -> DryocStream<Mode>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Mode> Drop for DryocStream<Mode>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<Mode: PartialEq> PartialEq<DryocStream<Mode>> for DryocStream<Mode>

source§

fn eq(&self, other: &DryocStream<Mode>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Mode> Zeroize for DryocStream<Mode>where PhantomData<Mode>: Zeroize, Mode: Zeroize,

source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
source§

impl<Mode: Eq> Eq for DryocStream<Mode>

source§

impl<Mode> StructuralEq for DryocStream<Mode>

source§

impl<Mode> StructuralPartialEq for DryocStream<Mode>

Auto Trait Implementations§

§

impl<Mode> RefUnwindSafe for DryocStream<Mode>where Mode: RefUnwindSafe,

§

impl<Mode> Send for DryocStream<Mode>where Mode: Send,

§

impl<Mode> Sync for DryocStream<Mode>where Mode: Sync,

§

impl<Mode> Unpin for DryocStream<Mode>where Mode: Unpin,

§

impl<Mode> UnwindSafe for DryocStream<Mode>where Mode: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.