Skip to main content

TokenOpenStream

Struct TokenOpenStream 

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

token_open_in_place for a token landing in contiguous spans: absorb_to authenticates and decrypts each span in place as it grows, and finalize verifies the MAC in constant time before inspecting any padding, then names the plaintext. The final ciphertext block waits for that verdict too, so nothing padding-shaped is ever examined ahead of authentication. Callers must not release a decrypted byte before finalize.

Implementations§

Source§

impl TokenOpenStream

Source

pub fn begin( key: &TokenKey<'_>, iv: &[u8; 16], token_len: usize, ) -> Result<TokenOpenStream, TokenOpenError>

token_len is the whole token’s length; the shapes refused are exactly token_open_in_place’s Malformed.

Source

pub fn pending_span(&self, contiguous_byte_len: usize) -> Range<usize>

The whole-block span absorb_to would process next, in token coordinates: everything past earlier calls up to contiguous_byte_len, minus the held-back final block. Empty when nothing is absorbable yet.

Source

pub fn fully_absorbed(&self) -> bool

Whether every span before the held-back final block has been absorbed — all that finalize requires.

Source

pub fn absorb_to<'t>( &mut self, token: &'t mut [u8], contiguous_byte_len: usize, ) -> &'t [u8]

Authenticate then decrypt the token’s contiguous prefix past what earlier calls covered, whole blocks at a time, returning the bytes decrypted by this call. token is the same buffer every call, filled at least to contiguous_byte_len.

Source

pub fn absorb_span(&mut self, span: &mut [u8])

absorb_to for a span carried away from its token — exactly the bytes pending_span named, handed as their own slice and decrypted in place there. The offloading caller owns copying them back where they came from.

Source

pub fn finalize(self, token: &mut [u8]) -> Result<&[u8], TokenOpenError>

The MAC is verified in constant time before the held-back final block is decrypted and its padding inspected, preserving token_open_in_place’s refusal order.

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.