1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![allow(non_snake_case)]
#[cfg(feature = "sha")]
#[cfg_attr(docsrs, doc(cfg(feature = "sha")))]
pub fn HMAC_SHA256(data: &[u8], key: &[u8], mac: &mut [u8; 32]) {
use hmac_::Mac;
let mut m = hmac_::Hmac::<sha2::Sha256>::new_from_slice(key).unwrap();
m.update(data);
mac.copy_from_slice(&m.finalize().into_bytes())
}
#[cfg(feature = "sha")]
#[cfg_attr(docsrs, doc(cfg(feature = "sha")))]
pub fn HMAC_SHA384(data: &[u8], key: &[u8], mac: &mut [u8; 48]) {
use hmac_::Mac;
let mut m = hmac_::Hmac::<sha2::Sha384>::new_from_slice(key).unwrap();
m.update(data);
mac.copy_from_slice(&m.finalize().into_bytes())
}
#[cfg(feature = "sha")]
#[cfg_attr(docsrs, doc(cfg(feature = "sha")))]
pub fn HMAC_SHA512(data: &[u8], key: &[u8], mac: &mut [u8; 64]) {
use hmac_::Mac;
let mut m = hmac_::Hmac::<sha2::Sha512>::new_from_slice(key).unwrap();
m.update(data);
mac.copy_from_slice(&m.finalize().into_bytes())
}