// HMAC (RFC 2104), parameterized over any supported hash algorithm.

///|
/// Compute HMAC: `H((K' xor opad) || H((K' xor ipad) || message))`.
///
/// Keys longer than the hash block size are first replaced by their digest.
/// Shorter keys are zero-padded to the block size.
pub fn hmac(
  algo : HashAlgorithm,
  key : BytesView,
  message : BytesView,
) -> Bytes {
  let bs = block_size(algo)

  // Normalize the key to at most one block.
  let norm = if key.length() > bs {
    digest(algo, key)
  } else {
    let b = Buffer()
    b.write_bytesview(key)
    b.to_bytes()
  }

  // Inner pass: (K xor ipad) || message.
  let inner_input = Buffer()
  for i in 0..