Skip to main content

DryocStream

Struct DryocStream 

Source
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 must rekey at the same position.

Automatic rekeying normally makes manual rekeying unnecessary.

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.

§Errors

Returns an error if tag contains unknown bits, the message exceeds the stream’s maximum message length, or the output storage does not resize to exactly the required ciphertext length.

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.

§Errors

Returns an error if tag contains unknown bits or the message exceeds the stream’s maximum message length.

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.

§Errors

Returns an error if the ciphertext is too short or too long, the output storage cannot hold the plaintext, or authentication fails. Authentication fails for a wrong key or header, mismatched associated data, modified ciphertext, or messages processed out of order. Authenticated tag values containing unknown bits are also rejected without advancing the stream.

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.

§Errors

Returns an error if the ciphertext is too short or too long, or authentication fails because the key, header, associated data, stream position, or ciphertext does not match. Authenticated tag values containing unknown bits are also rejected without advancing the stream.

Trait Implementations§

Source§

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

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

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

Source§

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

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

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

Source§

impl<Mode> Zeroize for DryocStream<Mode>

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.

Auto Trait Implementations§

§

impl<Mode> Freeze for DryocStream<Mode>

§

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> UnsafeUnpin for DryocStream<Mode>

§

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

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.