Function orion::default::hmac [−][src]
pub fn hmac(
secret_key: &[u8],
data: &[u8]
) -> Result<Vec<u8>, UnknownCryptoError>
HMAC with SHA512.
Exceptions:
An exception will be thrown if:
- The length of the secret key is less than 64 bytes
Note:
The secret key should always be generated using a CSPRNG. The gen_rand_key
function
in util
can be used for this.
Usage example:
use orion::default; use orion::core::util; let key = util::gen_rand_key(64).unwrap(); let msg = "Some message.".as_bytes(); let hmac = default::hmac(&key, msg).unwrap();