Struct dryoc::onetimeauth::OnetimeAuth
source · pub struct OnetimeAuth { /* private fields */ }
Expand description
One-time authentication implementation based on Poly1305, compatible with
libsodium’s crypto_onetimeauth_*
functions.
Implementations
sourceimpl OnetimeAuth
impl OnetimeAuth
sourcepub fn compute<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>, Input: Bytes, Output: NewByteArray<CRYPTO_ONETIMEAUTH_BYTES>>(
key: Key,
input: &Input
) -> Output
pub fn compute<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>, Input: Bytes, Output: NewByteArray<CRYPTO_ONETIMEAUTH_BYTES>>(
key: Key,
input: &Input
) -> Output
Single-part interface for OnetimeAuth
. Computes (and returns) the
message authentication code for input
using key
. The key
is
consumed to prevent accidental re-use of the same key.
sourcepub fn compute_to_vec<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>, Input: Bytes>(
key: Key,
input: &Input
) -> Vec<u8>
pub fn compute_to_vec<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>, Input: Bytes>(
key: Key,
input: &Input
) -> Vec<u8>
Convience wrapper around OnetimeAuth::compute
. Returns the message
authentication code as a Vec
. The key
is
consumed to prevent accidental re-use of the same key.
sourcepub fn compute_and_verify<OtherMac: ByteArray<CRYPTO_ONETIMEAUTH_BYTES>, Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>, Input: Bytes>(
other_mac: &OtherMac,
key: Key,
input: &Input
) -> Result<(), Error>
pub fn compute_and_verify<OtherMac: ByteArray<CRYPTO_ONETIMEAUTH_BYTES>, Key: ByteArray<CRYPTO_ONETIMEAUTH_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.
sourcepub fn new<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>>(key: Key) -> Self
pub fn new<Key: ByteArray<CRYPTO_ONETIMEAUTH_KEYBYTES>>(key: Key) -> Self
Returns a new one-time authenticator for key
. The key
is
consumed to prevent accidental re-use of the same key.
sourcepub fn update<Input: Bytes>(&mut self, input: &Input)
pub fn update<Input: Bytes>(&mut self, input: &Input)
Updates the one-time authenticator at self
with input
.
sourcepub fn finalize<Output: NewByteArray<CRYPTO_ONETIMEAUTH_BYTES>>(self) -> Output
pub fn finalize<Output: NewByteArray<CRYPTO_ONETIMEAUTH_BYTES>>(self) -> Output
Finalizes this one-time authenticator, returning the message authentication code.
sourcepub fn finalize_to_vec(self) -> Vec<u8>
pub fn finalize_to_vec(self) -> Vec<u8>
Finalizes this one-time authenticator, returning the message
authentication code as a Vec
. Convenience wrapper around
OnetimeAuth::finalize
.