Local Open Scope logic.
Definition WF (I:hmac256drbgabs):=
Zlength (hmac256drbgabs_value I) = 32 /\
0 < hmac256drbgabs_entropy_len I <= 384 /\
RI_range (hmac256drbgabs_reseed_interval I)  /\
0 <= hmac256drbgabs_reseed_counter I < Int.max_signed.
Definition hmac_drbg_random_spec_simple :=
DECLARE _mbedtls_hmac_drbg_random
WITH output: val, n: Z,
ctx: val, i: hmac256drbgstate,
I: hmac256drbgabs,
info: md_info_state,
s: ENTROPY.stream, bytes:_, J:_, ss:_, gv: globals
PRE [_p_rng OF tptr tvoid, _output OF tptr tuchar, _out_len OF tuint ]
PROP ( WF I;
0 <= n <= 1024;
mbedtls_HMAC256_DRBG_generate_function s I n [] = ENTROPY.success (bytes, J) ss)
LOCAL (temp _p_rng ctx; temp _output output;
temp _out_len (Vint (Int.repr n)); gvars gv)
SEP (
data_at_ Ews (tarray tuchar n) output;
data_at Ews t_struct_hmac256drbg_context_st i ctx;
hmac256drbg_relate I i;
data_at Ews t_struct_mbedtls_md_info info (hmac256drbgstate_md_info_pointer i);
Stream s;
K_vector gv)
POST [ tint ] EX F: hmac256drbgabs, EX f: hmac256drbgstate,
PROP (F = match J with ((((VV, KK), RC), _), PR) =>
HMAC256DRBGabs KK VV RC (hmac256drbgabs_entropy_len I) PR
(hmac256drbgabs_reseed_interval I)
end)
LOCAL (temp ret_temp (Vint Int.zero))
SEP (data_at Ews (tarray tuchar n) (map Vubyte bytes) output;
data_at Ews t_struct_hmac256drbg_context_st f ctx;
hmac256drbg_relate F f;
data_at Ews t_struct_mbedtls_md_info info (hmac256drbgstate_md_info_pointer f);
Stream ss; K_vector gv).
Opaque hmac256drbgabs_generate.
(* Definition myProp s n I (i F:hmac256drbgstate): Prop := F = (hmac256drbgabs_to_state (hmac256drbgabs_generate I s n []) i).  Definition hmac_drbg_random_spec_simple := DECLARE _mbedtls_hmac_drbg_random WITH output: val, out_len: Z, ctx: val, i: hmac256drbgstate, I: hmac256drbgabs, kv: val, info: md_info_state, s: ENTROPY.stream, bytes:_, J:_, ss:_ PRE [_p_rng OF tptr tvoid, _output OF tptr tuchar, _out_len OF tuint ] PROP ( WF I; 0 <= out_len <= 1024; mbedtls_HMAC256_DRBG_generate_function s I out_len [] = ENTROPY.success (bytes, J) ss) LOCAL (temp _p_rng ctx; temp _output output; temp _out_len (Vint (Int.repr out_len)); gvar sha._K256 kv) SEP ( data_at_ Ews (tarray tuchar out_len) output; data_at Ews t_struct_hmac256drbg_context_st i ctx; hmac256drbg_relate I i; data_at Ews t_struct_mbedtls_md_info info (hmac256drbgstate_md_info_pointer i); Stream s; K_vector kv) POST [ tint ] EX final_state: hmac256drbgstate, PROP (final_state = hmac256drbgabs_to_state (hmac256drbgabs_generate I s out_len []) i) LOCAL (temp ret_temp (Vint Int.zero)) SEP (data_at Ews (tarray tuchar out_len) (map Vint (map Int.repr bytes)) output; data_at Ews t_struct_hmac256drbg_context_st final_state ctx; hmac256drbg_relate (hmac256drbgabs_generate I s out_len []) final_state; data_at Ews t_struct_mbedtls_md_info info (hmac256drbgstate_md_info_pointer final_state); Stream ss; K_vector kv). (* generatePOST (Vint Int.zero) nil nullval 0 output out_len ctx initial_state I kv info_contents s). *)
Opaque hmac256drbgabs_generate.

Lemma body_hmac_drbg_random_simple: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_hmac_drbg_random hmac_drbg_random_spec_simple.