module Vale.Stdcalls.X64.Fsub open FStar.Mul val z3rlimit_hack (x:nat) : squash (x < x + x + 1) #reset-options "--z3rlimit 50" open FStar.HyperStack.ST module HS = FStar.HyperStack module B = LowStar.Buffer module DV = LowStar.BufferView.Down open Vale.Def.Types_s open Vale.Interop.Base module IX64 = Vale.Interop.X64 module VSig = Vale.AsLowStar.ValeSig module LSig = Vale.AsLowStar.LowStarSig module ME = Vale.X64.Memory module V = Vale.X64.Decls module IA = Vale.Interop.Assumptions module W = Vale.AsLowStar.Wrapper open Vale.X64.MemoryAdapters module VS = Vale.X64.State module MS = Vale.X64.Machine_s open Vale.AsLowStar.MemoryHelpers module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t (* A little utility to trigger normalization in types *) noextract let as_t (#a:Type) (x:normal a) : a = x noextract let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] noextract let b64 = buf_t TUInt64 TUInt64 [@__reduce__] noextract let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] noextract let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] noextract let tuint64 = TD_Base TUInt64 [@__reduce__] noextract let dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] noextract let fsub_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] noextract let fsub_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FH.va_ens_Fsub_stdcall c va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 100" [@__reduce__] noextract let fsub_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires fsub_pre code out f1 f2 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions_stdcall va_s0 va_s1 /\ fsub_post code out f1 f2 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ ME.buffer_writeable (as_vale_buffer f2) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out)) ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FH.va_lemma_Fsub_stdcall code va_s0 IA.win (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2; (va_s1, f) (* Prove that fsub_lemma' has the required type *) noextract let fsub_lemma = as_t #(VSig.vale_sig_stdcall fsub_pre fsub_post) fsub_lemma' noextract let code_Fsub = FH.va_code_Fsub_stdcall IA.win (* Here's the type expected for the fsub wrapper *) [@__reduce__] noextract let lowstar_Fsub_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 4); IX64.as_lowstar_sig_t_weak_stdcall code_Fsub dom [] _ _ (W.mk_prediction code_Fsub dom [] (fsub_lemma code_Fsub IA.win)) [@ (CCConv "stdcall") ] val fsub_e: normal lowstar_Fsub_t