pub struct PullState { /* private fields */ }Expand description
Decrypting half of a crypto_secretstream session - built from the master key and the header
PushState::init produced, driven one chunk at a time by PullState::pull.
Implementations§
Source§impl PullState
impl PullState
Sourcepub fn init(key: &Key, header: &[u8; 32]) -> Self
pub fn init(key: &Key, header: &[u8; 32]) -> Self
Re-derives the stream’s initial subkey from key and header (as produced by
PushState::init). Infallible - deriving the wrong subkey from a tampered header is
not detected here, only once the first chunk’s tag fails to verify (see the module doc).
pub fn is_finalized(&self) -> bool
Sourcepub fn pull(
&mut self,
tag_byte: u8,
ciphertext: &[u8],
auth_tag: &[u8],
plaintext_out: &mut [u8],
) -> Result<Tag, SecretstreamError>
pub fn pull( &mut self, tag_byte: u8, ciphertext: &[u8], auth_tag: &[u8], plaintext_out: &mut [u8], ) -> Result<Tag, SecretstreamError>
Verifies and decrypts one chunk. tag_byte is untrusted wire input - it is folded into the
AAD verified against auth_tag, so a value that doesn’t match what PushState::push
actually used fails the tag check (see the module doc). Returns the authenticated Tag
on success.
§Errors
Returns SecretstreamError::UnknownTag if tag_byte isn’t a value Tag::to_byte
produces, SecretstreamError::InvalidLength if plaintext_out.len() != ciphertext.len(),
SecretstreamError::StreamFinalized if a previous chunk already used Tag::Final, or
SecretstreamError::TagMismatch if authentication fails - plaintext_out is left
all-zero on any authentication failure, never unverified plaintext.