pub struct HMAC;
Implementations§
source§impl HMAC
impl HMAC
sourcepub fn mac(input: &[u8], secret_key: &[u8]) -> [u8; 20]
pub fn mac(input: &[u8], secret_key: &[u8]) -> [u8; 20]
This implements HMAC for SHA1. The function takes in the bytes to hash and a secret key used to hash. The high level overview looks like this: input: &u8: the message to hash secret_key: &u8: the secret key to use in hashing.
- The secret key is sized appropriately. (64 bytes in SHA-1)
- If the key is too long or too short, it is set to 64 bytes.
- If too short, it is padded with zeroes on the right
- if too long, it is hashed and then padded with zeroes on the right
- Two keys are generated
- An outer key, which takes the sized key and xors it with 0x5c
- And inner key, which is xored with 0x36.
- The inner key is concatenated with the input and then hashed.
- And then the hash is calculated of the outer key concatenated by that result.
fn block_size_key(secret_key: &[u8]) -> [u8; 64]
Auto Trait Implementations§
impl Freeze for HMAC
impl RefUnwindSafe for HMAC
impl Send for HMAC
impl Sync for HMAC
impl Unpin for HMAC
impl UnwindSafe for HMAC
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T, U> FromLossy<T> for Uwhere
U: From<T>,
impl<T, U> FromLossy<T> for Uwhere
U: From<T>,
§fn from_lossy(t: T) -> U
fn from_lossy(t: T) -> U
Convert to this type lossily
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T, U> IntoLossy<T> for Uwhere
T: FromLossy<U>,
impl<T, U> IntoLossy<T> for Uwhere
T: FromLossy<U>,
§fn into_lossy(self) -> T
fn into_lossy(self) -> T
Convert this type lossily