Definition b := (c+p)%nat.(* The iteration of the compression function gives a keyed hash function on lists of words. *)
  Definition h_star k (m : Blist) :=
    hash_blocks_bits b B h k m.(* The composition of the keyed hash function with the IV.*)
  Definition hash_words := h_star iv.Definition app_fpad (x : Blist) : Blist :=
    x ++ fpad x.Definition h_star_pad k x :=
    app_fpad (h_star k x).(* The "two-key" version of GHMAC and HMAC. *)
  Definition GHMAC_2K (k : Blist) m :=
    let (k_Out, k_In) := splitList b k in
      let h_in := (hash_words (k_In ++ m)) in
        hash_words (k_Out ++ app_fpad h_in).Definition HMAC_2K (k : Blist) (m : Blist) :=
    GHMAC_2K k (splitAndPad m).Definition HMAC (k : Blist) :=
    HMAC_2K (BLxor k opad ++ BLxor k ipad).

(* Specifications: *)
Lemma h_star_eq : sha.HMAC_spec_pad.h_star = h_star.
Theorem HMAC_concat_pad c p (C: NPeano.Nat.divide 8 c) B sap sap' fp (sap_sap': forall l m, length l = (c+p)%nat -> sap (l ++ m) = l ++ sap' m) (sap_appfpad: forall (l m : Blist), length l = (c+p)%nat -> InBlocks 8 m -> sap (l ++ m) = l ++ app_fpad fp m) (InBlocks_sap': forall m, InBlocks (c+p)%nat (sap' m)) h (HH: forall x y, length x = c -> length y = (c+p)%nat -> length (h x y) = c) iv (IV: length iv = c) (op ip : Blist) (IL: length ip = (c+p)%nat) (OL: length op = (c+p)%nat) : forall (k m : Blist), length k = (c+p)%nat -> sha.HMAC_spec_pad.HMAC c p B h iv sap op ip k m = HMAC_Concat.HMAC c p B h iv sap' fp op ip k m.