Struct chacha20stream::Sink[][src]

pub struct Sink<W> { /* fields omitted */ }

ChaCha Sink

Encryption

To create an encrypting wrapper stream:

let mut stream = Sink::encrypt(&mut backing_stream, key, iv).expect("Failed to create encryptor");
/* do work with `stream` */

// It is recommended to `flush` the stream to clear out any remaining data in the internal transformation buffer.
stream.flush().unwrap();

Decryption

To create a decrypting wrapper stream:

let mut stream = Sink::decrypt(&mut backing_stream, key, iv).expect("Failed to create decryptor");
/* do work with `stream` */

// It is recommended to `flush` the stream to clear out any remaining data in the internal transformation buffer.
stream.flush().unwrap();

Note

When writing, a temporary buffer stored in the structure is used. This buffer is not cleared after a write, for efficiency reasons. This may leave sensitive information in the buffer after the write operation. The flush() implementation does clear this buffer. You can use the prune() function to zero out this buffer manually too.

Implementations

impl<W> Sink<W> where
    W: Write
[src]

pub fn encrypt(stream: W, key: Key, iv: IV) -> Result<Self, ErrorStack>[src]

Create an encrypting Chacha Sink stream wrapper

pub fn decrypt(stream: W, key: Key, iv: IV) -> Result<Self, ErrorStack>[src]

Create a decrypting Chacha Sink stream wrapper

pub fn into_inner(self) -> W[src]

Consume into the inner stream

pub fn into_parts(self) -> (W, Crypter)[src]

Consume into the inner stream and crypter

pub fn crypter(&self) -> &Crypter[src]

The crypter of this instance

pub fn crypter_mut(&mut self) -> &mut Crypter[src]

The crypter of this instance

pub fn inner(&self) -> &W[src]

The inner stream

pub fn inner_mut(&mut self) -> &mut W[src]

The inner stream

pub fn prune(&mut self)[src]

Clear the internal buffer while keeping it allocated for further use.

This does not affect operations at all, all it does is 0 out the left-over temporary buffer from the last operation(s).

Trait Implementations

impl<W: Debug> Debug for Sink<W>[src]

impl<W: Write> Write for Sink<W>[src]

Auto Trait Implementations

impl<W> RefUnwindSafe for Sink<W> where
    W: RefUnwindSafe

impl<W> Send for Sink<W> where
    W: Send

impl<W> Sync for Sink<W> where
    W: Sync

impl<W> Unpin for Sink<W> where
    W: Unpin

impl<W> UnwindSafe for Sink<W> where
    W: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.