Skip to main content

State

Struct State 

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

Poly1305 state for incremental authentication

This structure allows computing a Poly1305 authentication tag incrementally, which is useful when the entire message is not available at once or when processing large messages in chunks to avoid excessive memory usage.

§Memory Efficiency

Using the incremental API allows processing messages of any size without needing to load the entire message into memory at once. This is particularly useful for:

  • Large files that don’t fit in memory
  • Streaming data from a network or other source
  • Memory-constrained environments

§Security Note

The security properties of Poly1305 are maintained when using the incremental API. The same tag will be produced regardless of how the message is chunked, as long as the chunks are processed in the correct order.

Implementations§

Source§

impl State

Source

pub fn new(key: &Key) -> Self

Creates a new Poly1305 authentication state

§Arguments
  • key - The key to use for authentication
§Returns
  • Self - The initialized state
§Panics

This function should never panic with valid inputs. The key validity is ensured by the Key type.

Source

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

Updates the authentication state with more input data

§Arguments
  • input - The data to include in the authentication

This function cannot fail with valid inputs, and we validate inputs through the State constructor.

Source

pub fn finalize(&mut self) -> Tag

Finalizes the authentication computation and returns the tag

§Returns
  • Tag - The authentication tag

This function cannot fail with valid inputs, and we validate inputs through the State constructor.

Auto Trait Implementations§

§

impl Freeze for State

§

impl RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl UnsafeUnpin for State

§

impl UnwindSafe for State

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