Instance CompSpecs : compspecs.(*
Instance CompSpecs_Preserve: change_composite_env spec_sha.CompSpecs CompSpecs.
  make_cs_preserve spec_sha.CompSpecs CompSpecs.
Defined.*)
Instance CompSpecs_Preserve: change_composite_env spec_hmac.CompSpecs CompSpecs.(*Require Import sha.hkdf_compspecs.*)

Declare Module HMAC_SPEC : HMAC_ABSTRACT_SPEC.Definition digest_len:Z := 32.Definition expand_out_post sh PrkCont InfoCont olen out: Z * mpred :=
  let n := (olen + digest_len - 1) / digest_len in
  if zlt (olen + digest_len) olen 
  then (0, memory_block sh olen out)
  else if zlt 255 n 
       then (0, memory_block sh olen out)
       else (1, data_block sh (HKDF_expand PrkCont InfoCont olen) out).(*Definition memcpy_spec := (_memcpy, snd spec_sha.memcpy_spec). *)

(***************** We combine all specifications to a specification context *******)

(*Definition SHA256_spec := (_SHA256, snd spec_sha.SHA256_spec). *)(*
Definition sha256init_spec := (_SHA256_Init, snd SHA256_Init_spec).
Definition sha256update_spec := (_SHA256_Update, snd SHA256_Update_spec).
Definition sha256final_spec := (_SHA256_Final, snd SHA256_Final_spec).
Definition memset_spec := (_memset, snd spec_sha.memset_spec). *)

Definition Hkdf_VarSpecs : varspecs := (sha._K256, tarray tuint 64)::nil.Definition Hkdf_FunSpecs : funspecs := ltac:(with_library prog (
  HKDF_spec :: HKDF_expand_spec :: HKDF_extract_spec :: 
  memcpy_tuchar_array_spec:: (*memcpy__data_at:: *)
  (*memset_spec::*)
  (HMAC_SPEC.hmac_update_spec)::
  (HMAC_SPEC.hmac_final_spec)::  
  (HMAC_SPEC.hmac_cleanup_spec)::  
  (_HMAC_Init, hmac_init_funspec)::
  (HMAC_SPEC.hmac_crypto_spec)::nil)).

Lemma change_compspecs_data_block: forall sh v, @data_block spec_hmac.CompSpecs sh v = @data_block CompSpecs sh v.