///|
/// HMAC-SHA256 (RFC 2104) over the library's Array[Int32] byte shape:
/// hash((K xor opad) || hash((K xor ipad) || message)) with the key
/// zero-padded to the 64-byte block size. Keys longer than 64 bytes are
/// first hashed down, per the RFC.
fn hmac_sha256(key : Array[Int32], message : Array[Int32]) -> Array[Int32] {
let block = 64
let normalized : Array[Int32] = []
if key.length() > block {
// RFC 2104: a long key is first hashed down, then zero-padded to
// the block size - the padding was missing, and any key over 64
// bytes walked off the array in the ipad loop. RFC 4231's case 3
// caught it; nothing shorter than the block size ever could.
let hashed = sha256_raw(key)
for i in 0.. Array[Int32] {
let salted : Array[Int32] = []
for byte in salt {
salted.push(byte & 0xFF)
}
// Block index 1, big-endian 32 bits (one block covers our 32-byte need).
salted.push(0)
salted.push(0)
salted.push(0)
salted.push(1)
let mut u = hmac_sha256(password, salted)
let out : Array[Int32] = []
for i in 0..<32 {
out.push(u[i] & 0xFF)
}
for _ in 1..