(* Lemmas used by the hmac proofs that are independent of C/CompCert/VST*)
(*Require Import sublist.*)

(* Specifications: *)
Lemma str_to_bytes_length: forall k,
String.length k = length (str_to_bytes k).
Lemma Zlength_mkArgZ k pad: Zlength (HMAC_SHA256.mkArg k pad) = Z.of_nat (min (length k) 64).
Lemma nth_zeropad_left {d d'}: forall l i (I: 0<= i < Zlength l),
nth (Z.to_nat i) (HMAC_SHA256.zeroPad l) d = nth (Z.to_nat i) l d'.
Lemma mkKey_left {d d'}: forall l (L: false = (Zlength l >? 64))
i (I: 0<= i < Zlength l),
nth (Z.to_nat i) (HMAC_SHA256.mkKey l) d = nth (Z.to_nat i) l d'.
Lemma nth_zeropad_right {d} l i (I: Zlength l <= i < 64):
nth (Z.to_nat i) (HMAC_SHA256.zeroPad l) d = Byte.zero.
Lemma mkKey_right {d}: forall l (L: false = (Zlength l >? 64))
i (I: Zlength l <= i < 64),
nth (Z.to_nat i) (HMAC_SHA256.mkKey l) d = Byte.zero.
Lemma zeroPad_BlockSize: forall k, (length k <= SHA256.BlockSize)%nat ->
length (HMAC_SHA256.zeroPad k) = SHA256.BlockSize%nat.
Lemma length_SHA256': forall l,
length (functional_prog.SHA_256' l) = SHA256.DigestLength.
Lemma mkKey_length l: length (HMAC_SHA256.mkKey l) = SHA256.BlockSize.
Lemma mkKey_atBlockSize s: length s = SHA256.BlockSize%nat ->
HMAC_SHA256.mkKey s = s.
Lemma HMAC_length d k: length (HMAC256 d k) = 32%nat.
Lemma HMAC_Zlength d k: Zlength (HMAC256 d k) = 32.