function hmac is input: key: Bytes // Array of bytes message: Bytes // Array of bytes to be hashed hash: Function // The hash function to use (e.g. SHA-1) blockSize: Integer // The block size of the underlying hash function (e.g. 64 bytes for SHA-1) outputSize: Integer // The output size of the underlying hash function (e.g. 20 bytes for SHA-1) // Keys longer than blockSize are shortened by hashing them if (length(key) > blockSize) then key ← hash(key) // Key becomes outputSize bytes long // Keys shorter than blockSize are padded to blockSize by padding with zeros on the right if (length(key) < blockSize) then key ← Pad(key, blockSize) // Pad key with zeros to make it blockSize bytes long o_key_pad ← key xor [0x5c * blockSize] // Outer padded key i_key_pad ← key xor [0x36 * blockSize] // Inner padded key return hash(o_key_pad ∥ hash(i_key_pad ∥ message)) // Where ∥ is concatenation