Local Open Scope logic.

(* Specifications: *)
Lemma rel_lvalue_var {cs: compspecs}:
forall (P: mpred) i t v rho,
v = eval_var i t rho ->
isptr v ->
P |-- rel_lvalue (Evar i t) v rho.
Lemma isptr_not_Vundef:
forall v, isptr v -> v <> Vundef.
Lemma eval_id_get:
forall rho i v, eval_id i rho = v -> v <> Vundef -> Map.get (te_of rho) i = Some v.
Lemma denote_tc_assert_andp:
forall {CS: compspecs} (a b : tc_assert),
denote_tc_assert (tc_andp a b) = andp (denote_tc_assert a) (denote_tc_assert b).
Lemma denote_tc_assert_orp:
forall {CS: compspecs} (a b : tc_assert),
denote_tc_assert (tc_orp a b) = orp (denote_tc_assert a) (denote_tc_assert b).
Lemma denote_tc_assert_bool:
forall {CS: compspecs} b c, denote_tc_assert (tc_bool b c) =
prop (b=true).
Lemma neutral_isCastResultType_64:
Archi.ptr64 = true ->
forall {cs: compspecs}  P t t' v rho,
is_neutral_cast t' t = true ->
P |-- denote_tc_assert (isCastResultType t' t v) rho.
Lemma neutral_isCastResultType_32:
Archi.ptr64 = false ->
forall {cs: compspecs}  P t t' v rho,
is_neutral_cast t' t = true ->
P |-- denote_tc_assert (isCastResultType t' t v) rho.
Lemma neutral_isCastResultType:
forall {cs: compspecs}  P t t' v rho,
is_neutral_cast t' t = true ->
P |-- denote_tc_assert (isCastResultType t' t v) rho.
Lemma tc_andp_TT2:  forall e, tc_andp e tc_TT = e.
Lemma typed_true_nullptr:
forall v t0 t t',
typed_true t0 (force_val (sem_cmp Ceq (tptr t) (tptr t') v (Vint Int.zero))) ->
v=nullval.
Lemma typed_true_nullptr':
forall  {cs: compspecs} t0  t t' v,
typed_true t0 (eval_binop Cop.Oeq (tptr t) (tptr t') v nullval) -> v=nullval.
Lemma typed_true_Oeq_nullval:
forall  {cs: compspecs}  v t t',
local (`(typed_true tint) (`(eval_binop Cop.Oeq (tptr t) (tptr t')) v `(nullval))) |--
local (`(eq nullval) v).
Lemma canon1: forall P1 B  P Q R,
do_canon (prop P1 && B) (PROPx P (LOCALx Q (SEPx R))) = do_canon B  (PROPx (P1::P) (LOCALx Q (SEPx R))).
Lemma canon2: forall Q1 B P Q R,
do_canon (local (locald_denote Q1) && B) (PROPx P (LOCALx Q (SEPx R))) = do_canon B (PROPx (P) (LOCALx (Q1::Q) (SEPx R))).
Lemma is_neutral_cast_by_value: forall t t',
is_neutral_cast t t' = true ->
type_is_by_value t = true.
Lemma ptrofs_of_ints_unfold:
forall x, Ptrofs.of_ints x = Ptrofs.repr (Int.signed x).
Lemma semax_while_peel:
forall {CS: compspecs} {Espec: OracleKind} Inv Delta P expr body R,
@semax CS Espec Delta P (Ssequence (Sifthenelse expr Sskip Sbreak) body)
(loop1_ret_assert Inv R) ->
@semax CS Espec Delta Inv (Swhile expr body) R ->
@semax CS Espec Delta P (Swhile expr body) R.
Lemma semax_func_cons_ext_vacuous:
forall {Espec: OracleKind} (V : varspecs) (G : funspecs) (C : compspecs)
(fs : list (ident * Clight.fundef)) (id : ident) (ef : external_function)
(argsig : typelist) (retsig : type)
(G' : funspecs) cc,
(id_in_list id (map fst fs)) = false ->
ef_sig ef =
{|
sig_args := typlist_of_typelist (type_of_params (arglist 1 argsig));
sig_res := opttyp_of_type retsig;
sig_cc := cc_of_fundef (External ef argsig retsig cc) |} ->
semax_func V G fs G' ->
semax_func V G ((id, External ef argsig retsig cc) :: fs)
((id, vacuous_funspec (External ef argsig retsig cc)) :: G').
Lemma int_eq_false_e:
forall i j, Int.eq i j = false -> i <> j.
Lemma repr_inj_signed:
forall i j,
repable_signed i -> repable_signed j -> Int.repr i = Int.repr j -> i=j.
Lemma repr_inj_unsigned:
forall i j,
0 <= i <= Int.max_unsigned ->
0 <= j <= Int.max_unsigned ->
Int.repr i = Int.repr j -> i=j.
Lemma repr_inj_signed':
forall i j,
repable_signed i -> repable_signed j ->
Int.repr i <> Int.repr j -> i<>j.
Lemma no_post_exists_unit:
forall P Q R,
PROPx P (LOCALx Q (SEPx R)) =
EX _:unit, PROPx P (LOCALx Q (SEPx R)).
(*from verif_ld_st*)
Lemma Byte_unsigned_range_32 b: 0 <= Byte.unsigned b <= Int.max_unsigned.
Lemma verify16_spec_ok: semax_body SalsaVarSpecs SalsaFunSpecs
f_crypto_verify_16_tweet verify16_spec.
Lemma verify32_spec_ok: semax_body SalsaVarSpecs SalsaFunSpecs
f_crypto_verify_32_tweet verify32_spec.
Lemma int_max_unsigned_int64_max_unsigned: Int.max_unsigned < Int64.max_unsigned.
Lemma sublist_hi_plus {A} (l:list A) lo a b: 0<=lo<=a -> 0<=b -> sublist lo (a + b) l =
sublist lo a l ++ sublist a (a+b) l.
Lemma sublist0_hi_plus {A} (l:list A) a b: 0<=a -> 0<=b -> sublist 0 (a + b) l =
sublist 0 a l ++ sublist a (a+b) l.
Lemma byte_unsigned_range_3 b: 0 <= Byte.unsigned b <= Int.max_unsigned.
Lemma Int_unsigned_repr_byte b: Int.unsigned (Int.repr (Byte.unsigned b)) = Byte.unsigned b.
Lemma zero_ext8_byte b: Int.zero_ext 8 (Int.repr (Byte.unsigned b)) = Int.repr (Byte.unsigned b).
Lemma Zlxor_range_byte b1 b2: 0<= Z.lxor (Byte.unsigned b1) (Byte.unsigned b2) <= Byte.max_unsigned.
Lemma Znth_sublist':
forall (A : Type){d: Inhabitant A} (lo i hi : Z) (al : list A),
0 <= lo ->
Zlength al <= hi ->
0 <= i <= hi - lo -> Znth i (sublist lo hi al) = Znth (i + lo) al.
Lemma xor_byte_int b1 b2: Int.xor (Int.repr (Byte.unsigned b1)) (Int.repr (Byte.unsigned b2)) =
Int.repr (Byte.unsigned (Byte.xor b1 b2)).
Lemma Zlength_combinelist {A} f xs ys l:
combinelist A f xs ys = Some l -> Zlength l = Zlength ys.
Lemma Tarray_0_emp sh v c: data_at sh (Tarray tuchar 0 noattr) v c |--  emp.
Lemma Tarray_0_emp' sh c: field_compatible (Tarray tuchar 0 noattr) nil c ->
emp |-- data_at sh (Tarray tuchar 0 noattr) nil c.
Lemma Tarray_0_emp_iff sh c: field_compatible (Tarray tuchar 0 noattr) [] c ->
data_at sh (Tarray tuchar 0 noattr) nil c = emp.
Lemma Tarray_0_emp_ sh c: data_at_ sh (Tarray tuchar 0 noattr) c |--  emp.
Lemma Tarray_0_emp'_ sh c: field_compatible (Tarray tuchar 0 noattr) nil c ->
emp |-- data_at_ sh (Tarray tuchar 0 noattr) c.
Lemma Tarray_0_emp_iff_ sh c: field_compatible (Tarray tuchar 0 noattr) [] c ->
data_at_ sh (Tarray tuchar 0 noattr) c = emp.
Lemma bxorlist_app xs2 ys2: forall xs1 ys1 zs1 zs2,
bxorlist xs1 ys1 = Some zs1 -> bxorlist xs2 ys2 = Some zs2 ->
bxorlist (xs1 ++ xs2) (ys1 ++ ys2) = Some(zs1 ++ zs2).
Lemma Int64_ltu_false x y: Int64.ltu x y = false ->
0 <= Int64.unsigned y <= Int64.unsigned x.
Lemma Zlength_Bl2VL l: Zlength (Bl2VL l) = Zlength l.
Lemma Bl2VL_app l m: Bl2VL (l ++ m) = Bl2VL l ++ Bl2VL m.
Lemma ZZ_is_byte: forall n zbytes u U, ZZ zbytes n = (u,U) ->
0<= Int.unsigned u <256.
Lemma crypto_stream_salsa20_tweet_ok: semax_body SalsaVarSpecs (*(crypto_stream_salsa20_xor_spec::*)SalsaFunSpecs
f_crypto_stream_salsa20_tweet
f_crypto_stream_salsa20_tweet_spec.
(*The crypto_stream function*)
Lemma crypto_stream_xsalsa20_tweet_ok:
semax_body SalsaVarSpecs SalsaFunSpecs
f_crypto_stream_xsalsa20_tweet
f_crypto_stream_xsalsa20_tweet_spec.
(*The crypto_stream_xor function*)
Lemma crypto_stream_xsalsa20_tweet_xor_ok:
semax_body SalsaVarSpecs SalsaFunSpecs
f_crypto_stream_xsalsa20_tweet_xor
f_crypto_stream_xsalsa20_tweet_xor_spec.
(*generalizes Lemma data_at_lemmas.memory_block_data_at__aux1*)
Lemma unsigned_add: forall i pos, 0 <= pos -> Ptrofs.unsigned (Ptrofs.add i (Ptrofs.repr pos)) = (Ptrofs.unsigned i + pos) mod Ptrofs.modulus.
Lemma Arith_aux1: forall i pos z,
0 <= pos /\ pos + z <= Ptrofs.modulus - Ptrofs.unsigned i ->
Ptrofs.unsigned (Ptrofs.add i (Ptrofs.repr pos)) + z <= Ptrofs.modulus.
Lemma offset_in_range_0 v: offset_in_range 0 v.
destruct v; simpl; trivial. rewrite Z.add_0_r.
Lemma wandQ_frame_refine {A} {ND: NatDed A} {SL: SepLog A}: forall B C (P: B -> A) (f: C -> B),
allp P |-- allp (fun c => P (f c)).
Lemma wandQ_frame_intro {A} {ND: NatDed A} {SL: SepLog A}: forall B (P: B -> A) (Q: A),
Q |-- allp (P -* P * (fun _ => Q)).
Lemma wandQ_frame_elim {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q: B -> A) (a: B),
P a * allp (P -* Q) |-- Q a.
Lemma wandQ_frame_ver {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q R: B -> A),
allp (P -* Q) * allp (Q -* R) |-- allp (P -* R).
Lemma wandQ_frame_hor {A} {ND: NatDed A} {SL: SepLog A}: forall B (P1 P2 Q1 Q2: B -> A),
allp (P1 -* Q1) * allp (P2 -* Q2) |-- allp (P1 * P2 -* Q1 * Q2).
Lemma wandQ_frame_frame {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q F: B -> A),
allp (P -* Q) |-- allp (P * F -* Q * F).
Lemma wand_frame_intro {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q: A),
Q |-- P -* P * Q.
Lemma wand_frame_elim {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q: A),
P * (P -* Q) |-- Q.
Lemma wand_frame_ver {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q R: A),
(P -* Q) * (Q -* R) |-- P -* R.
Lemma wand_frame_hor {A} {ND: NatDed A} {SL: SepLog A}: forall (P1 P2 Q1 Q2: A),
(P1 -* Q1) * (P2 -* Q2) |-- P1 * P2 -* Q1 * Q2.
Lemma wand_frame_frame {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q F: A),
P -* Q |-- P * F -* Q * F.
Lemma mpred_prop_right: forall (P: mpred) (Q: Prop), Q -> P |-- !! Q.
Lemma mpred_now_later: forall (P: mpred), P |-- |> P.
Lemma mpred_derives_refl: forall (P: mpred), P |-- P.
Lemma mpred_semax_post' : forall (R' : environ -> mpred) (Espec : OracleKind)
(Delta : tycontext) (R P : environ -> mpred)
(c : statement),
(forall rho, R' rho |-- R rho) ->
semax Delta P c (normal_ret_assert R') ->
semax Delta P c (normal_ret_assert R).
Lemma body_md_free: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_md_free md_free_spec.
Lemma body_md_get_size: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_md_get_size md_get_size_spec.
Lemma body_md_start: semax_body HmacDrbgVarSpecs (HmacDrbgFunSpecs)
f_mbedtls_md_hmac_starts md_starts_spec.
Lemma Zgt_is_gt_bool_f: forall n m : Z, n <= m <-> (n >? m) = false.
Lemma da_emp_isptrornull sh t v p :
da_emp sh t v p = (!!is_pointer_or_null p) &&  da_emp sh t v p.
Lemma da_emp_null sh t v p: p=nullval -> da_emp sh t v p = emp.
Lemma da_emp_ptr sh t v b i: da_emp sh t v (Vptr b i) = !! (sizeof t > 0) && data_at sh t v (Vptr b i).
Lemma false_zgt z a: false = (z >? a) -> z<=a.
Lemma false_zge z a: false = (z >=? a) -> z<=a.
(* Lemma da_emp_isptrornull sh t v p : da_emp sh t v p = (!!is_pointer_or_null p) &&  da_emp sh t v p.  Lemma da_emp_null sh t v p: p=nullval -> da_emp sh t v p = emp. Lemma da_emp_ptr sh t v b i: da_emp sh t v (Vptr b i) = data_at sh t v (Vptr b i). *)
Lemma Tarray_0_emp sh v c: data_at sh (Tarray tuchar 0 noattr) v c |--  emp.
unfold data_at. unfold field_at, data_at_rec, at_offset; simpl.
Lemma body_hmac_drbg_free: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_hmac_drbg_free hmac_drbg_free_spec.
Lemma body_hmac_drbg_random: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_hmac_drbg_random hmac_drbg_random_spec.
Lemma body_hmac_drbg_seed_buf: semax_body HmacDrbgVarSpecs HmacDrbgFunSpecs
f_mbedtls_hmac_drbg_seed_buf hmac_drbg_seed_buf_spec.
Lemma BDY_update: forall
(Espec : OracleKind)
(contents : list byte)
(additional : val) (sha: share)
(add_len : Z)
(ctx : val) (shc: share)
(initial_state : hmac256drbgstate)
(initial_state_abs : hmac256drbgabs)
(gv : globals)
(info_contents : md_info_state)
(sep: val)( K : val)
(H : 0 <= add_len <= Int.max_unsigned)
(H0 : Zlength (hmac256drbgabs_value initial_state_abs) = 32)
(H1 : add_len = Zlength contents \/ add_len = 0)
(Hsha: readable_share sha)
(Hshc: writable_share shc),
@semax hmac_drbg_compspecs.CompSpecs Espec
(func_tycontext f_mbedtls_hmac_drbg_update HmacDrbgVarSpecs
HmacDrbgFunSpecs nil)
(PROP ( )
LOCAL (lvar _K (tarray tuchar 32) K; lvar _sep (tarray tuchar 1) sep;
temp _ctx ctx; temp _additional additional;
temp _add_len (Vint (Int.repr add_len)); gvars gv)
SEP (data_at_ Tsh (tarray tuchar 32) K;
data_at_ Tsh (tarray tuchar 1) sep;
da_emp sha (tarray tuchar (Zlength contents))
(map Vubyte contents) additional;
data_at shc t_struct_hmac256drbg_context_st initial_state ctx;
hmac256drbg_relate initial_state_abs initial_state;
data_at shc t_struct_mbedtls_md_info info_contents
(hmac256drbgstate_md_info_pointer initial_state); K_vector gv))
(Ssequence (fn_body f_mbedtls_hmac_drbg_update) (Sreturn None))
(frame_ret_assert
(function_body_ret_assert tvoid
(PROP ( )
LOCAL ()
SEP (hmac256drbgabs_common_mpreds shc
(hmac256drbgabs_hmac_drbg_update initial_state_abs
(contents_with_add additional add_len contents))
initial_state ctx info_contents;
da_emp sha (tarray tuchar (Zlength contents))
(map Vubyte contents) additional; K_vector gv)))
(stackframe_of f_mbedtls_hmac_drbg_update)).
Lemma AUX s I n bytes J ss: mbedtls_HMAC256_DRBG_generate_function s I n [] =
ENTROPY.success (bytes, J) ss ->
hmac256drbgabs_generate I s n [] =
match J with ((((VV, KK), RC), _), PR) =>
HMAC256DRBGabs KK VV RC (hmac256drbgabs_entropy_len I) PR
(hmac256drbgabs_reseed_interval I)
end.
Lemma wandQ_frame_refine {A} {ND: NatDed A} {SL: SepLog A}: forall B C (P: B -> A) (f: C -> B),
allp P |-- allp (fun c => P (f c)).
Lemma wandQ_frame_intro {A} {ND: NatDed A} {SL: SepLog A}: forall B (P: B -> A) (Q: A),
Q |-- allp (P -* P * (fun _ => Q)).
Lemma wandQ_frame_intro' {A} {ND: NatDed A} {SL: SepLog A}: forall B (P: B -> A) (Q: A) (R: B -> A),
(forall x: B, P x * Q |-- R x) ->
Q |-- allp (P -* R).
Lemma wandQ_frame_elim {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q: B -> A) (a: B),
P a * allp (P -* Q) |-- Q a.
Lemma wandQ_frame_ver {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q R: B -> A),
allp (P -* Q) * allp (Q -* R) |-- allp (P -* R).
Lemma wandQ_frame_hor {A} {ND: NatDed A} {SL: SepLog A}: forall B (P1 P2 Q1 Q2: B -> A),
allp (P1 -* Q1) * allp (P2 -* Q2) |-- allp (P1 * P2 -* Q1 * Q2).
Lemma wandQ_frame_frame {A} {ND: NatDed A} {SL: SepLog A}: forall B (P Q F: B -> A),
allp (P -* Q) |-- allp (P * F -* Q * F).
Lemma sepcon_wandQ_eq {A} {ND: NatDed A} {SL: SepLog A}: forall B (P: B -> A) (Q: A) (a: B),
P a * (ALL b: B, P b -* P b * Q) = P a * Q.
Lemma wand_frame_intro {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q: A),
Q |-- P -* P * Q.
Lemma wand_frame_intro' {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q R: A),
P * Q |-- R ->
Q |-- P -* R.
Lemma wand_frame_elim {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q: A),
P * (P -* Q) |-- Q.
Lemma wand_frame_elim' {A} {ND: NatDed A} {SL: SepLog A}: forall (P P' Q: A),
P |-- P' -> P * (P' -* Q) |-- Q.
Lemma wand_frame_ver {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q R: A),
(P -* Q) * (Q -* R) |-- P -* R.
Lemma wand_frame_hor {A} {ND: NatDed A} {SL: SepLog A}: forall (P1 P2 Q1 Q2: A),
(P1 -* Q1) * (P2 -* Q2) |-- P1 * P2 -* Q1 * Q2.
Lemma wand_frame_frame {A} {ND: NatDed A} {SL: SepLog A}: forall (P Q F: A),
P -* Q |-- P * F -* Q * F.
Lemma int_unsigned_mod:
forall i, Int.unsigned i mod Int.modulus = Int.unsigned i.
Lemma Z_div_mul: forall a b, b <> 0 ->
(a/b*b = a - a mod b)%Z.
Lemma eqm_mod1:
forall a b, Int.eqm a b <-> Int.eqm (a mod Int.modulus) b.
Lemma eqm_mod2:
forall a b, Int.eqm a b <-> Int.eqm a (b mod Int.modulus).
Lemma addlength_assist:
forall (a b : Z),
Int.eqm
(((a / Int.modulus) mod Int.modulus +
(a mod Int.modulus + b mod Int.modulus -
(a mod Int.modulus + b) mod Int.modulus) / Int.modulus) mod Int.modulus +
(b / Int.modulus) mod Int.modulus) ((a + b) / Int.modulus).
Lemma addlength_aux2:
forall len n,
0 <= len < Int.modulus ->
Int.unsigned (Int.repr (n + len * 8)) < Int.unsigned (lo_part n) ->
Int.unsigned (hi_part n) +
(Int.unsigned (lo_part n) + (len * 8) mod Int.modulus -
(Int.unsigned (lo_part n) + len * 8) mod Int.modulus) / Int.modulus
= Int.unsigned (hi_part n) + 1.
Lemma body_SHA256_addlength: semax_body Vprog Gtot f_SHA256_addlength SHA256_addlength_spec.
Lemma upd_Znth_append:
forall (t: Type) len N dd ee (v: t),
len = Zlength dd ->
len < N ->
N <= Zlength ee ->
upd_Znth len (dd++ sublist len N ee) v =
(dd ++ [v]) ++ sublist (len+1) N ee.
Lemma body_SHA256_Final: semax_body Vprog Gtot f_SHA256_Final SHA256_Final_spec.
Lemma body_sha256_block_data_order: semax_body Vprog Gtot f_sha256_block_data_order sha256_block_data_order_spec.
Lemma rearrange_aux:
forall h f c k l,
Int.add (Int.add (Int.add (Int.add h f) c) k) l =
Int.add (Int.add (Int.add (Int.add l h) f) c) k.
Lemma loop1_aux_lemma1:
forall i b,
(0 <= i < Zlength b) ->
Zlength b <= 16 ->
upd_Znth i
(map Vint (sublist 0 i b) ++ list_repeat (Z.to_nat (16 - i)) Vundef)
(Vint (Znth i b))
=  map Vint (sublist 0 (i+1) b) ++ list_repeat (Z.to_nat (16 - (i+1))) Vundef.
Lemma body_SHA256: semax_body Vprog Gtot f_SHA256 SHA256_spec.
Lemma body_hkdf: semax_body Hkdf_VarSpecs Hkdf_FunSpecs
f_HKDF HKDF_spec.
Lemma body_hkdf_extract: semax_body Hkdf_VarSpecs Hkdf_FunSpecs
f_HKDF_extract HKDF_extract_spec.
Lemma extra_expansion_sublist : forall k : list word,
Zlength k = Nk -> sublist 0 (Nb*(Nr+1)) (blocks_to_ints (extra_key_expansion k)) = blocks_to_ints (KeyExpansion k).