Struct wolf_crypto::chacha::Writer
source · pub struct Writer<W, const CHUNK: usize> { /* private fields */ }std only.Expand description
A wrapper for any implementor of std::io::Write.
Writer implements std::io::Write and takes a child which also implements this trait.
This type can wrap any writer, and ensure all data passed to said writer is encrypted.
Implementations§
Methods from Deref<Target = ChaCha20<Streaming>>§
sourcepub fn decrypt_into(&mut self, cipher: &[u8], output: &mut [u8]) -> Res
pub fn decrypt_into(&mut self, cipher: &[u8], output: &mut [u8]) -> Res
sourcepub fn decrypt_into_sized<const I: usize, const O: usize>(
&mut self,
cipher: &[u8; I],
output: &mut [u8; O],
) -> Res
pub fn decrypt_into_sized<const I: usize, const O: usize>( &mut self, cipher: &[u8; I], output: &mut [u8; O], ) -> Res
Decrypts the ciphertext into the output buffer with compile-time size checking.
§Type Parameters
I- The size of the ciphertext array.O- The size of the output array.
§Arguments
cipher- The ciphertext array to decrypt.output- The array to store the decrypted data.
§Returns
A Res indicating the success or failure of the operation.
sourcepub fn decrypt_into_exact<const C: usize>(
&mut self,
cipher: &[u8; C],
output: &mut [u8; C],
) -> Res
pub fn decrypt_into_exact<const C: usize>( &mut self, cipher: &[u8; C], output: &mut [u8; C], ) -> Res
Decrypts the ciphertext into the output buffer with exact sizes.
§Type Parameters
C- The size of both the ciphertext and output arrays.
§Arguments
cipher- The ciphertext array to decrypt.output- The array to store the decrypted data.
§Returns
A Res indicating the success or failure of the operation.
sourcepub fn decrypt(&mut self, cipher: &[u8]) -> Result<Vec<u8>, Unspecified>
Available on crate feature alloc only.
pub fn decrypt(&mut self, cipher: &[u8]) -> Result<Vec<u8>, Unspecified>
alloc only.sourcepub fn decrypt_exact<const O: usize>(
&mut self,
cipher: &[u8; O],
) -> Result<[u8; O], Unspecified>
pub fn decrypt_exact<const O: usize>( &mut self, cipher: &[u8; O], ) -> Result<[u8; O], Unspecified>
sourcepub fn encrypt_into(&mut self, input: &[u8], output: &mut [u8]) -> Res
pub fn encrypt_into(&mut self, input: &[u8], output: &mut [u8]) -> Res
sourcepub fn encrypt_into_sized<const I: usize, const O: usize>(
&mut self,
input: &[u8; I],
output: &mut [u8; O],
) -> Res
pub fn encrypt_into_sized<const I: usize, const O: usize>( &mut self, input: &[u8; I], output: &mut [u8; O], ) -> Res
Encrypts the input into the output buffer in streaming mode with compile-time size checking.
§Type Parameters
I- The size of the input array.O- The size of the output array.
§Arguments
input- The input array to encrypt.output- The array to store the encrypted data.
§Returns
A Res indicating the success or failure of the operation.
sourcepub fn encrypt_into_exact<const C: usize>(
&mut self,
input: &[u8; C],
output: &mut [u8; C],
) -> Res
pub fn encrypt_into_exact<const C: usize>( &mut self, input: &[u8; C], output: &mut [u8; C], ) -> Res
Encrypts the input into the output buffer in streaming mode with exact sizes.
§Type Parameters
C- The size of both the input and output arrays.
§Arguments
input- The input array to encrypt.output- The array to store the encrypted data.
§Returns
A Res indicating the success or failure of the operation.
Trait Implementations§
source§impl<W: Write, const CHUNK: usize> Write for Writer<W, CHUNK>
impl<W: Write, const CHUNK: usize> Write for Writer<W, CHUNK>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Encrypts and writes the given buffer.
§Arguments
buf- The buffer to encrypt and write.
§Returns
The number of bytes written on success, or an io::Error on failure.
§Note
The maximum number of bytes this can write in a single invocation is capped by the
CHUNK size. If this is not desirable, please consider using the write_all
implementation.
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes the underlying writer.
§Returns
Propagates the result of invoking flush for the underlying writer
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)