Require sha.sha.
Local Open Scope logic.
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).
(*(Ssequence (fn_body f_HMAC) (Sreturn (@Some expr (Etempvar _md (tptr tuchar)))))*)

Lemma body_hmac_crypto: semax_body HmacVarSpecs HmacFunSpecs
f_HMAC HMAC_crypto.