Skip to main content

TokenDecryptStream

Struct TokenDecryptStream 

Source
pub struct TokenDecryptStream { /* private fields */ }
Expand description

An incremental Token::decrypt_chunks: the token’s bytes are fed in order with TokenDecryptStream::update, and TokenDecryptStream::finish checks the tag and returns the plaintext. The last 32 bytes seen are held back as the candidate tag; everything before them is authenticated and decrypted as it arrives. Decrypted bytes are not authentic until finish accepts the tag.

Implementations§

Source§

impl TokenDecryptStream

Source

pub fn hash_plaintext(&mut self)

Also hash the plaintext, together with the tag’s MAC, as it settles; Self::finish_hashed returns the hash. Call before any update.

Source

pub fn reserve(&mut self, additional: usize)

Reserve room for additional more plaintext bytes.

Source

pub fn plaintext(&self) -> &[u8] ⓘ

The plaintext decrypted so far, without the skipped bytes. Its last block may still hold the padding, and none of it is authentic until Self::finish succeeds.

Source

pub fn update(&mut self, data: &[u8])

Feed the token’s next bytes.

Source

pub fn finish_hashed(self) -> Result<(Vec<u8>, Option<Sha256>), TokenError>

Self::finish, with the SHA-256 state over the whole plaintext when Self::hash_plaintext was called.

Source

pub fn finish(self) -> Result<Vec<u8>, TokenError>

Check the tag and return the plaintext, as Token::decrypt_chunks of every byte fed.

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.