Definition bitspec KEY MSG :=
Vector.to_list ( HMAC_spec.HMAC EQ.h_v iv_v (HMAC_spec_abstract.HMAC_Abstract.wrappedSAP _ _ splitAndPad_v)
fpad_v EQ.opad_v EQ.ipad_v
(of_list_length _ (key_vector (CONT KEY)))
(mkCont (CONT MSG))).
Definition CRYPTO (A : Comp.OracleComp (HMAC_spec_abstract.HMAC_Abstract.Message PARS256.P)
(Bvector.Bvector c) bool)
(A_wf : DistSem.well_formed_oc A):=
forall tau eps sig, PRFMod.h_PRF A tau ->
PRFMod.h_star_WCR A eps ->
PRFMod.dual_h_RKA A sig ->
PRFMod.isPRF (Comp.Rnd (HMAC_PRF.b c p))
(Comp.Rnd c)
(HMAC_PRF.HMAC PRFMod.M.h_v EQ256.iv_v
(HMAC_spec_abstract.HMAC_Abstract.wrappedSAP _ _ splitAndPad_v) EQ256.fpad_v PRFMod.M.opad_v PRFMod.M.ipad_v)
PRFMod.Message_eqdec
(EqDec.Bvector_EqDec c)
(Rat.ratAdd (Rat.ratAdd tau eps) sig) A.
Definition HMAC_crypto :=
DECLARE _HMAC
WITH keyVal: val, KEY:DATA,
msgVal: val, MSG:DATA,
shk: share, shm: share, shmd: share, md: val, gv: globals
PRE [ _key OF tptr tuchar,
_key_len OF tint,
_d OF tptr tuchar,
_n OF tint,
_md OF tptr tuchar ]
PROP (readable_share shk; readable_share shm; writable_share shmd;
has_lengthK (LEN KEY) (CONT KEY);
has_lengthD 512 (LEN MSG) (CONT MSG))
LOCAL (temp _md md; temp _key keyVal;
temp _key_len (Vint (Int.repr (LEN KEY)));
temp _d msgVal; temp _n (Vint (Int.repr (LEN MSG)));
gvars gv)
SEP(data_block shk (CONT KEY) keyVal;
data_block shm (CONT MSG) msgVal;
K_vector gv;
memory_block shmd 32 md)
POST [ tptr tuchar ]
EX digest:_,
PROP (digest= HMAC256 (CONT MSG) (CONT KEY) /\
bytesToBits digest = bitspec KEY MSG /\
forall A Awf, CRYPTO A Awf)
LOCAL (temp ret_temp md)
SEP(K_vector gv;
data_block shmd digest md;
initPostKey shk keyVal (CONT KEY);
data_block shm (CONT MSG) msgVal).

Lemma hmacbodycryptoproof Espec k KEY msg  MSG gv shk shm shmd md buf
(Hshk: readable_share shk) (Hshm: readable_share shm) (SH : writable_share shmd)
(KL: has_lengthK (LEN KEY) (CONT KEY))
(DL: has_lengthD 512 (LEN MSG) (CONT MSG)):
@semax CompSpecs Espec (func_tycontext f_HMAC HmacVarSpecs HmacFunSpecs nil)
(PROP  ()
LOCAL  (lvar _c (Tstruct _hmac_ctx_st noattr) buf; temp _md md;
temp _key k; temp _key_len (Vint (Int.repr (LEN KEY)));
temp _d msg; temp _n (Vint (Int.repr (LEN MSG))); gvars gv)
SEP  (data_at_ Tsh (Tstruct _hmac_ctx_st noattr) buf;
data_block shk (CONT KEY) k; data_block shm (CONT MSG) msg;
K_vector gv; memory_block shmd 32 md))
(fn_body f_HMAC)
(frame_ret_assert
(function_body_ret_assert (tptr tuchar)
(EX  digest : list byte,
PROP
(digest= HMAC256 (CONT MSG) (CONT KEY) /\ bytesToBits digest = bitspec KEY MSG /\
(forall
(A : Comp.OracleComp
(HMAC_spec_abstract.HMAC_Abstract.Message PARS256.P)
(Bvector c) bool)
(Awf : @DistSem.well_formed_oc
(HMAC_spec_abstract.HMAC_Abstract.Message PARS256.P)
(Bvector c) bool A), CRYPTO A Awf))
LOCAL (temp ret_temp md)
SEP  (K_vector gv; @data_block CompSpecs shmd digest md;
initPostKey shk k (CONT KEY);
@data_block CompSpecs shm (CONT MSG) msg))%assert)
(stackframe_of f_HMAC)%assert).