rokdocs
v0.1

rok::core::crypto::hmac

HMAC (RFC 2104) and HKDF (RFC 5869) over a SHA-2 function.

Structs

Hmac

pub struct Hmac

A running HMAC. A value: copying it forks the running MAC.

  • pub fn new(alg: HashAlgorithm, key: Bytes) -> Hmac
  • pub fn mac(alg: HashAlgorithm, key: Bytes, data: Bytes) -> List<u8>

    The tag of data under key.

  • pub fn verify(alg: HashAlgorithm, key: Bytes, data: Bytes, tag: Bytes) -> bool

    Whether tag is the tag of data, compared in constant time.

  • pub fn update(ref self, data: Bytes)
  • pub const fn finish(self) -> List<u8>

Hkdf

pub struct Hkdf

HKDF: extract a pseudorandom key, expand it into output keying material.

  • pub fn extract(alg: HashAlgorithm, salt: Bytes, ikm: Bytes) -> Secret

    HMAC(salt, ikm); an empty salt is output_len zero bytes.

  • pub fn expand(alg: HashAlgorithm, prk: Bytes, info: Bytes, len: usize) throws (ValueError) -> Secret

    len bytes of output keying material; len is at most 255 * output_len.