Struct chacha20stream::Sink [−][src]
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]
W: Write,
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]
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
[src]
pub fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>
1.36.0[src]
pub fn is_write_vectored(&self) -> bool
[src]
pub fn write_all_vectored(
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
[src]
&mut self,
bufs: &mut [IoSlice<'_>]
) -> Result<(), Error>
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>
1.0.0[src]
pub fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<W> RefUnwindSafe for Sink<W> where
W: RefUnwindSafe,
W: RefUnwindSafe,
impl<W> Send for Sink<W> where
W: Send,
W: Send,
impl<W> Sync for Sink<W> where
W: Sync,
W: Sync,
impl<W> Unpin for Sink<W> where
W: Unpin,
W: Unpin,
impl<W> UnwindSafe for Sink<W> where
W: UnwindSafe,
W: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,