Struct dryoc::auth::Auth

source ·
pub struct Auth { /* private fields */ }
Expand description

secret-key authentication implementation based on Poly1305, compatible with libsodium’s crypto_Auth_* functions.

Implementations§

source§

impl Auth

source

pub fn compute<Key: ByteArray<CRYPTO_AUTH_KEYBYTES>, Input: Bytes, Output: NewByteArray<CRYPTO_AUTH_BYTES>>( key: Key, input: &Input ) -> Output

Single-part interface for Auth. Computes (and returns) the message authentication code for input using key. The key is consumed to prevent accidental re-use of the same key.

source

pub fn compute_to_vec<Key: ByteArray<CRYPTO_AUTH_KEYBYTES>, Input: Bytes>( key: Key, input: &Input ) -> Vec<u8>

Convience wrapper around Auth::compute. Returns the message authentication code as a Vec. The key is consumed to prevent accidental re-use of the same key.

source

pub fn compute_and_verify<OtherMac: ByteArray<CRYPTO_AUTH_BYTES>, Key: ByteArray<CRYPTO_AUTH_KEYBYTES>, Input: Bytes>( other_mac: &OtherMac, key: Key, input: &Input ) -> Result<(), Error>

Verifies the message authentication code other_mac matches the expected code for key and input. The key is consumed to prevent accidental re-use of the same key.

source

pub fn new<Key: ByteArray<CRYPTO_AUTH_KEYBYTES>>(key: Key) -> Self

Returns a new secret-key authenticator for key. The key is consumed to prevent accidental re-use of the same key.

source

pub fn update<Input: Bytes>(&mut self, input: &Input)

Updates the secret-key authenticator at self with input.

source

pub fn finalize<Output: NewByteArray<CRYPTO_AUTH_BYTES>>(self) -> Output

Finalizes this secret-key authenticator, returning the message authentication code.

source

pub fn finalize_to_vec(self) -> Vec<u8>

Finalizes this secret-key authenticator, returning the message authentication code as a Vec. Convenience wrapper around Auth::finalize.

source

pub fn verify<OtherMac: ByteArray<CRYPTO_AUTH_BYTES>>( self, other_mac: &OtherMac ) -> Result<(), Error>

Finalizes this authenticator, and verifies that the computed code matches other_mac using a constant-time comparison.

Auto Trait Implementations§

§

impl RefUnwindSafe for Auth

§

impl Send for Auth

§

impl Sync for Auth

§

impl Unpin for Auth

§

impl UnwindSafe for Auth

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.