pub struct Decryptor<'a> { /* private fields */ }Expand description
A BufferedReader that decrypts symmetrically-encrypted data as
it is read.
Implementations§
Source§impl<'a> Decryptor<'a>
impl<'a> Decryptor<'a>
Sourcepub fn new<R>(
algo: SymmetricAlgorithm,
mode: BlockCipherMode,
padding: UnpaddingMode,
key: &SessionKey,
iv: Option<&[u8]>,
source: R,
) -> Result<Self>where
R: BufferedReader<Cookie> + 'a,
pub fn new<R>(
algo: SymmetricAlgorithm,
mode: BlockCipherMode,
padding: UnpaddingMode,
key: &SessionKey,
iv: Option<&[u8]>,
source: R,
) -> Result<Self>where
R: BufferedReader<Cookie> + 'a,
Instantiate a new symmetric decryptor.
If iv is None, and the given mode requires an IV, an
all-zero IV is used.
Like Decryptor::new, but sets a cookie.
Trait Implementations§
Source§impl<'a> BufferedReader<Cookie> for Decryptor<'a>
impl<'a> BufferedReader<Cookie> for Decryptor<'a>
Source§fn data(&mut self, amount: usize) -> Result<&[u8]>
fn data(&mut self, amount: usize) -> Result<&[u8]>
Ensures that the internal buffer has at least
amount bytes
of data, and returns it. Read moreSource§fn data_hard(&mut self, amount: usize) -> Result<&[u8]>
fn data_hard(&mut self, amount: usize) -> Result<&[u8]>
Like
BufferedReader::data, but returns an error if there is not at least
amount bytes available. Read moreSource§fn data_eof(&mut self) -> Result<&[u8]>
fn data_eof(&mut self) -> Result<&[u8]>
Returns all of the data until EOF. Like
BufferedReader::data, this does not
actually consume the data that is read. Read moreSource§fn data_consume_hard(&mut self, amount: usize) -> Result<&[u8]>
fn data_consume_hard(&mut self, amount: usize) -> Result<&[u8]>
A convenience function that effectively combines
BufferedReader::data_hard
and BufferedReader::consume. Read moreSource§fn read_be_u16(&mut self) -> Result<u16>
fn read_be_u16(&mut self) -> Result<u16>
A convenience function for reading a 16-bit unsigned integer
in big endian format.
Source§fn read_be_u32(&mut self) -> Result<u32>
fn read_be_u32(&mut self) -> Result<u32>
A convenience function for reading a 32-bit unsigned integer
in big endian format.
Source§fn steal(&mut self, amount: usize) -> Result<Vec<u8>>
fn steal(&mut self, amount: usize) -> Result<Vec<u8>>
Like
BufferedReader::data_consume_hard, but returns the data in a
caller-owned buffer. Read moreSource§fn steal_eof(&mut self) -> Result<Vec<u8>>
fn steal_eof(&mut self) -> Result<Vec<u8>>
Like
BufferedReader::steal, but instead of stealing a fixed number of
bytes, steals all of the data until the end of file.Source§fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<Cookie>>
fn get_mut(&mut self) -> Option<&mut dyn BufferedReader<Cookie>>
Returns a mutable reference to the inner
BufferedReader, if
any. Read moreSource§fn get_ref(&self) -> Option<&dyn BufferedReader<Cookie>>
fn get_ref(&self) -> Option<&dyn BufferedReader<Cookie>>
Returns a reference to the inner
BufferedReader, if any.Source§fn into_inner<'b>(
self: Box<Self>,
) -> Option<Box<dyn BufferedReader<Cookie> + 'b>>where
Self: 'b,
fn into_inner<'b>(
self: Box<Self>,
) -> Option<Box<dyn BufferedReader<Cookie> + 'b>>where
Self: 'b,
Returns the underlying reader, if any. Read more
Sets the
BufferedReader’s cookie and returns the old value.Returns a reference to the
BufferedReader’s cookie.Returns a mutable reference to the
BufferedReader’s cookie.Source§fn consummated(&mut self) -> bool
fn consummated(&mut self) -> bool
Checks whether this reader is consummated. Read more
Source§fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
fn read_to(&mut self, terminal: u8) -> Result<&[u8], Error>
Reads until either
terminal is encountered or EOF. Read moreSource§fn drop_until(&mut self, terminals: &[u8]) -> Result<usize, Error>
fn drop_until(&mut self, terminals: &[u8]) -> Result<usize, Error>
Discards the input until one of the bytes in terminals is
encountered. Read more
Source§fn drop_through(
&mut self,
terminals: &[u8],
match_eof: bool,
) -> Result<(Option<u8>, usize), Error>
fn drop_through( &mut self, terminals: &[u8], match_eof: bool, ) -> Result<(Option<u8>, usize), Error>
Discards the input until one of the bytes in
terminals is
encountered. Read moreSource§fn drop_eof(&mut self) -> Result<bool, Error>
fn drop_eof(&mut self) -> Result<bool, Error>
Like
BufferedReader::steal_eof, but instead of returning the data, the
data is discarded. Read moreSource§fn copy(&mut self, sink: &mut dyn Write) -> Result<u64, Error>
fn copy(&mut self, sink: &mut dyn Write) -> Result<u64, Error>
Copies data to the given writer returning the copied amount. Read more
Source§fn dump(&self, sink: &mut dyn Write) -> Result<(), Error>where
Self: Sized,
fn dump(&self, sink: &mut dyn Write) -> Result<(), Error>where
Self: Sized,
A helpful debugging aid to pretty print a Buffered Reader stack. Read more
Source§fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: Sized + 'a,
fn into_boxed<'a>(self) -> Box<dyn BufferedReader<C> + 'a>where
Self: Sized + 'a,
Boxes the reader.
Source§impl<'a> Read for Decryptor<'a>
impl<'a> Read for Decryptor<'a>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning
how many bytes were read. Read more
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
Reads all bytes until EOF in this source, placing them into
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Reads all bytes until EOF in this source, appending them to
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Reads the exact number of bytes required to fill
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Pull some bytes from this source into the specified buffer. Read more
Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Reads the exact number of bytes required to fill
cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Creates a “by reference” adapter for this instance of
Read. Read moreAuto Trait Implementations§
impl<'a> Freeze for Decryptor<'a>
impl<'a> !RefUnwindSafe for Decryptor<'a>
impl<'a> Send for Decryptor<'a>
impl<'a> Sync for Decryptor<'a>
impl<'a> Unpin for Decryptor<'a>
impl<'a> !UnwindSafe for Decryptor<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more