pub struct StreamDecryptor<W> { /* private fields */ }Expand description
Incremental STREAM decryption of a ciphertext that arrives in pieces of any size.
update buffers at most two ciphertext chunks: a chunk is opened as soon as
a byte past it has arrived (proving it is not the last), and finish opens
the final chunk under the last-block flag. Truncation, reordering, a chunk swapped in from
another file and a toggled last flag all fail authentication, and an empty ciphertext fails
at finish. After the first failure every later call fails too.
Plaintext reaches the inner writer chunk by chunk, each chunk authenticated before it is
written; the whole file is authentic only once finish returns Ok. A caller that writes
to a file must treat it as unverified, and discard it, until then.
Implementations§
Source§impl<W: Write> StreamDecryptor<W>
impl<W: Write> StreamDecryptor<W>
Sourcepub fn new(file_key: &[u8; 32], nonce_prefix: &[u8; 7], inner: W) -> Self
pub fn new(file_key: &[u8; 32], nonce_prefix: &[u8; 7], inner: W) -> Self
A decryptor writing plaintext to inner.
Sourcepub fn update(&mut self, data: &[u8]) -> Result<(), StreamError>
pub fn update(&mut self, data: &[u8]) -> Result<(), StreamError>
Feed the next ciphertext bytes.
Sourcepub fn finish(self) -> Result<W, StreamError>
pub fn finish(self) -> Result<W, StreamError>
Open the final chunk and return the inner writer.
Trait Implementations§
Source§impl<W> Debug for StreamDecryptor<W>
impl<W> Debug for StreamDecryptor<W>
Source§impl<W: Write> Write for StreamDecryptor<W>
io::Write over StreamDecryptor::update, so the decryptor can be the sink of anything
that writes bytes. An authentication failure surfaces as io::ErrorKind::InvalidData.
impl<W: Write> Write for StreamDecryptor<W>
io::Write over StreamDecryptor::update, so the decryptor can be the sink of anything
that writes bytes. An authentication failure surfaces as io::ErrorKind::InvalidData.
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
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)Auto Trait Implementations§
impl<W> Freeze for StreamDecryptor<W>where
W: Freeze,
impl<W> RefUnwindSafe for StreamDecryptor<W>where
W: RefUnwindSafe,
impl<W> Send for StreamDecryptor<W>where
W: Send,
impl<W> Sync for StreamDecryptor<W>where
W: Sync,
impl<W> Unpin for StreamDecryptor<W>where
W: Unpin,
impl<W> UnsafeUnpin for StreamDecryptor<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for StreamDecryptor<W>where
W: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more