(*Variant of Gen_loop_bvec that uses list byte instead of Bvector 256*)
Fixpoint Gen_loop_Zlist (k : list byte) (v : list byte) (n : nat)
  : list (list byte) * (list byte) :=
  match n with
  | O => (nil, v)
  | S n' =>
    let v' := HMAC256 v k in
    let (bits, v'') := Gen_loop_Zlist k v' n' in
    (List.app bits (List.cons v' List.nil), v'')     
  end.

(* Specifications: *)
Lemma Gen_loop_Zlist_ZlengthBlocks k: forall n v blocks u, Gen_loop_Zlist k v n = (blocks,u) -> Zlength blocks = Z.of_nat n.
Lemma Gen_loop_Zlist_Blist k: forall n v, match Gen_loop_Zlist k v n with (blocks,u) => Gen_loop_Blist (bytesToBits k) (bytesToBits v) n = (map bytesToBits blocks, bytesToBits u) end.
Lemma Gen_loop_Zlist_nestedV k: forall n v blocks u blocks' u', Gen_loop_Zlist k (HMAC256 v k) n = (blocks, u) -> Gen_loop_Zlist k v n = (blocks', u') -> u = HMAC256 u' k /\ blocks = map (fun z => HMAC256 z k) blocks'.
Lemma Gen_loop_Zlist_nestedV' k: forall n v blocks u, Gen_loop_Zlist k (HMAC256 v k) n = (blocks, u) -> exists blocks' u', Gen_loop_Zlist k v n = (blocks', u') /\ u = HMAC256 u' k /\ blocks = map (fun z => HMAC256 z k) blocks'.