pub struct Poly1305 { /* private fields */ }
Expand description

Define the Poly1305 struct for the Poly1305 MAC algorithm.

Implementations§

source§

impl Poly1305

source

pub fn new() -> Self

Creates a new instance of Poly1305.

This constructor initializes a new Poly1305 instance with default values. It is typically used to start a new message authentication code (MAC) computation.

Returns

A new instance of Poly1305.

Trait Implementations§

source§

impl Default for Poly1305

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Permutation for Poly1305

source§

fn init(&mut self, key: &[u8], _iv: &[u8])

Initializes the Poly1305 state with the given key.

This method sets up the Poly1305 state using a 32-byte key. The key is split into two parts: the r array (for the algorithm’s internal state) and the pad (used in the final computation steps).

Arguments
  • key - A byte slice containing the 32-byte key.
  • _iv - An optional Initialization Vector, not used in Poly1305.
Returns

A mutable reference to the initialized Poly1305 instance.

Notes

The Initialization Vector (_iv) is not used in Poly1305 and can be passed as an empty slice.

source§

fn process(&mut self, data: &[u8]) -> Vec<u8>

Processes the given data and computes the MAC.

This method processes the input data in 16-byte blocks to compute the message authentication code (MAC). If the data does not divide evenly into 16-byte blocks, the final block is padded as necessary.

Arguments
  • data - A byte slice representing the data to be processed.
Returns

A vector of bytes (Vec<u8>) containing the computed MAC.

source§

fn clear(&mut self)

Clears the internal state of the Poly1305 instance.

This method resets the internal state variables (r, h, and pad) to zero. It is useful for security purposes when the MAC computation is complete and the instance needs to be cleared before being reused or discarded.

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

§

type Output = T

Should always be Self
source§

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

§

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

§

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.