Function orion::default::hmac[][src]

pub fn hmac(
    secret_key: &[u8],
    data: &[u8]
) -> Result<[u8; 64], UnknownCryptoError>

HMAC-SHA512.

Parameters:

  • secret_key: The authentication key
  • data: Data to be authenticated

See RFC for more information.

Exceptions:

An exception will be thrown if:

  • The length of the secret key is less than 64 bytes.

Security:

The secret key should always be generated using a CSPRNG. The gen_rand_key function in util can be used for this.

Example:

use orion::default;
use orion::utilities::util;

let mut key = [0u8; 64];
util::gen_rand_key(&mut key).unwrap();
let msg = "Some message.".as_bytes();

let hmac = default::hmac(&key, msg).unwrap();