pub struct StreamOpener { /* private fields */ }Expand description
Decrypts a stream produced by StreamSealer, one chunk at a time.
You must call finish after the last chunk.
Per-chunk authentication catches reordering, duplication, and corruption,
but truncation — an attacker dropping the trailing chunks, including the
final one — is only detected by finish, which fails with
Error::StreamTruncated if it never saw a chunk marked last. A consumer
that just loops open_chunk until its input is exhausted and skips finish
will silently accept a truncated stream.
Implementations§
Source§impl StreamOpener
impl StreamOpener
Sourcepub fn new(keypair: &KeyPair, header_bytes: &[u8]) -> Result<Self>
pub fn new(keypair: &KeyPair, header_bytes: &[u8]) -> Result<Self>
Begin decrypting from the stream header bytes.
§Errors
Error::InvalidEnvelope if the header is malformed;
version/suite errors for other formats.
Sourcepub fn open_chunk(&mut self, frame: &[u8]) -> Result<(Vec<u8>, bool)>
pub fn open_chunk(&mut self, frame: &[u8]) -> Result<(Vec<u8>, bool)>
Decrypt one chunk frame. Returns (plaintext, was_last).
§Errors
Error::DecryptionFailed on any authentication failure (including a
reordered, duplicated, or spliced chunk); Error::StreamFinished if
called after the last chunk.