Struct Poly1305

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

Poly1305 MAC (branch-free limb arithmetic)

Implementations§

Source§

impl Poly1305

Source

pub fn new(key: &[u8]) -> Result<Self>

Construct a new Poly1305 context from a 32-byte key.

The key is split into the clamped r portion (first 16 bytes) and the s portion (last 16 bytes) exactly as specified in RFC 8439 §2.5.2.

Source

pub fn update(&mut self, chunk: &[u8]) -> Result<()>

Absorb additional message data into the MAC state.

This can be called zero or more times before Self::finalize.
Data is internally buffered in 16-byte blocks.
Always returns Ok(()) (provided for API symmetry).

Source

pub fn finalize(self) -> Tag<POLY1305_TAG_SIZE>

Consume the context and return the 16-byte authentication tag.

After this call the Poly1305 instance must be discarded because its internal key material has been moved.

Trait Implementations§

Source§

impl Clone for Poly1305

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for Poly1305

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Mac for Poly1305

Source§

type Key = [u8; 32]

Key type with appropriate algorithm binding
Source§

type Tag = Tag<POLY1305_TAG_SIZE>

Tag output type with appropriate size constraint
Source§

fn new(key: &[u8]) -> Result<Self>

Creates a new MAC instance with the given key
Source§

fn update(&mut self, data: &[u8]) -> Result<&mut Self>

Updates the MAC state with data, returning self for method chaining
Source§

fn finalize(&mut self) -> Result<Self::Tag>

Finalizes and returns the MAC tag
Source§

fn reset(&mut self) -> Result<()>

Reset the MAC state for reuse
Source§

fn compute_tag(key: &[u8], data: &[u8]) -> Result<Self::Tag>

One-shot MAC computation
Source§

fn verify_tag(key: &[u8], data: &[u8], tag: &[u8]) -> Result<bool>

Verify a MAC tag in constant time
Source§

impl Zeroize for Poly1305

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> MacExt for T
where T: Mac,

Source§

fn builder(&mut self) -> GenericMacBuilder<'_, T>

Creates a builder for this MAC instance
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V