Skip to main content

PullState

Struct PullState 

Source
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

Source

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).

Source

pub fn is_finalized(&self) -> bool

Source

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.

Trait Implementations§

Source§

impl Drop for PullState

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.