file_name
stringlengths
5
52
name
stringlengths
4
95
original_source_type
stringlengths
0
23k
source_type
stringlengths
9
23k
source_definition
stringlengths
9
57.9k
source
dict
source_range
dict
file_context
stringlengths
0
721k
dependencies
dict
opens_and_abbrevs
listlengths
2
94
vconfig
dict
interleaved
bool
1 class
verbose_type
stringlengths
1
7.42k
effect
stringclasses
118 values
effect_flags
sequencelengths
0
2
mutual_with
sequencelengths
0
11
ideal_premises
sequencelengths
0
236
proof_features
sequencelengths
0
1
is_simple_lemma
bool
2 classes
is_div
bool
2 classes
is_proof
bool
2 classes
is_simply_typed
bool
2 classes
is_type
bool
2 classes
partial_definition
stringlengths
5
3.99k
completed_definiton
stringlengths
1
1.63M
isa_cross_project_example
bool
1 class
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_add1_normal_t
val lowstar_add1_normal_t:normal lowstar_add1_t
val lowstar_add1_normal_t:normal lowstar_add1_t
let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 154, "start_col": 0, "start_line": 153 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Pervasives.norm [ FStar.Pervasives.iota; FStar.Pervasives.zeta; FStar.Pervasives.delta_attr ["Vale.Arch.HeapTypes_s.__reduce__"; "FStar.BigOps.__reduce__"]; FStar.Pervasives.delta_only [ "Vale.Interop.Base.uu___is_TD_Buffer"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace"; "FStar.FunctionalExtensionality.on_dom"; "FStar.FunctionalExtensionality.on"; "FStar.List.Tot.Base.fold_right_gtot"; "FStar.List.Tot.Base.map_gtot"; "FStar.List.Tot.Base.length"; "FStar.Pervasives.Native.fst"; "FStar.Pervasives.Native.snd"; "FStar.Pervasives.Native.__proj__Mktuple2__item___1"; "FStar.Pervasives.Native.__proj__Mktuple2__item___2" ]; FStar.Pervasives.primops; FStar.Pervasives.simplify ] Vale.Inline.X64.Fadd_inline.lowstar_add1_t <: Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_normal_t", "Vale.Inline.X64.Fadd_inline.lowstar_add1_t", "Vale.Inline.X64.Fadd_inline.lowstar_add1" ]
[]
false
false
false
false
false
let lowstar_add1_normal_t:normal lowstar_add1_t =
as_normal_t #lowstar_add1_t lowstar_add1
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_pre
val fadd_pre:VSig.vale_pre fadd_dom
val fadd_pre:VSig.vale_pre fadd_dom
let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 193, "start_col": 0, "start_line": 186 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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 *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Inline.X64.Fadd_inline.fadd_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fadd_inline.b64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastHybrid.va_req_Fadd", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fadd_pre:VSig.vale_pre fadd_dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: b64) (va_s0: V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_st1
val rsapss_verify_st1 : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 448, "start_col": 0, "start_line": 431 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.as_seq", "Hacl.Spec.RSAPSS.rsapss_verify_pre", "Lib.Buffer.modifies0", "Hacl.Spec.RSAPSS.rsapss_verify_", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_verify_st1 (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen: size_t -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
false
LowParse.Spec.DepLen.fst
LowParse.Spec.DepLen.parse_deplen_unfold2
val parse_deplen_unfold2 (min: nat) (max: nat{min <= max /\ max < 4294967296}) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: (ht -> Tot (bounded_int32 min max))) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) (input: bytes) : Lemma (parse (parse_deplen min max hp dlf ps) input == (match parse hp input with | None -> None | Some (h, consumed) -> if (U32.v (dlf h) + consumed) > (Seq.length input) then None else let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in match parse pp input' with | None -> None | Some (t, consumed') -> if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then Some ((h, t), consumed + (U32.v (dlf h))) else None))
val parse_deplen_unfold2 (min: nat) (max: nat{min <= max /\ max < 4294967296}) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: (ht -> Tot (bounded_int32 min max))) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) (input: bytes) : Lemma (parse (parse_deplen min max hp dlf ps) input == (match parse hp input with | None -> None | Some (h, consumed) -> if (U32.v (dlf h) + consumed) > (Seq.length input) then None else let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in match parse pp input' with | None -> None | Some (t, consumed') -> if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then Some ((h, t), consumed + (U32.v (dlf h))) else None))
let parse_deplen_unfold2 (min: nat) (max: nat { min <= max /\ max < 4294967296 } ) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: ht -> Tot (bounded_int32 min max)) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) (input : bytes) : Lemma (parse (parse_deplen min max hp dlf ps) input == (match parse hp input with | None -> None | Some (h, consumed) -> begin if (U32.v (dlf h) + consumed) > (Seq.length input) then None else let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in match parse pp input' with | None -> None | Some (t, consumed') -> if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then Some ((h, t), consumed + (U32.v (dlf h))) else None end) ) = parse_tagged_union_eq hp (calc_tag_of_deplen_data min max dlf ps) (parse_deplen_payload min max dlf ps) input; match parse hp input with | None -> () | Some (h, consumed) -> let input' = Seq.slice input consumed (Seq.length input) in parse_deplen_payload_unfold min max dlf ps h input'; let sz = (U32.v (dlf h)) in if Seq.length input < consumed + sz then () else Seq.slice_slice input consumed (Seq.length input) 0 sz
{ "file_name": "src/lowparse/LowParse.Spec.DepLen.fst", "git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
{ "end_col": 60, "end_line": 292, "start_col": 0, "start_line": 247 }
module LowParse.Spec.DepLen (* LowParse specification module for parsing structures with dependent length Example: struct { uint len; uint foo; uint buf[len]; }; *) include LowParse.Spec.Combinators include LowParse.Spec.AllIntegers include LowParse.Spec.VLGen module U32 = FStar.UInt32 module Seq = FStar.Seq (* arguments @min : @max : integer bounds @ht : header type @hk : header parser metadata @hp : header parser @h : header data @dlf : dependent length function @pt : payload type @pk : payload parser metadata @pp : payload parser @ps : payload serializer @x : data *) (* data type of the dependent length parser, which is a pair of the header and the payload *) let parse_deplen_data_t (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (#ht : Type) (#pt : Type) (dlf : ht -> Tot (bounded_int32 min max) ) (#pk : parser_kind) (#pp : parser pk pt) (ps : serializer pp) = x:(ht & pt) {U32.v (dlf (fst x)) == Seq.length (serialize ps (snd x) ) } (* the tag for a piece of dependent length data is just its header *) let calc_tag_of_deplen_data (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (#ht : Type) (#pt : Type) (dlf : ht -> Tot (bounded_int32 min max) ) (#pk : parser_kind) (#pp : parser pk pt) (ps : serializer pp) (x : parse_deplen_data_t min max dlf ps) : GTot ht = fst x (* synth put the header and the payload together to get the data *) let synth_deplen_data (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (#ht : Type) (#pt : Type) (dlf : ht -> Tot (bounded_int32 min max) ) (#pk : parser_kind) (#pp : parser pk pt) (ps : serializer pp) (h : ht) (x : parse_fldata_strong_t ps (U32.v (dlf h))) : Tot (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) = (h, x) (* metadata of the payload, reuse bounded_vlgen_payload *) let parse_deplen_payload_kind = parse_bounded_vlgen_payload_kind (* parser spec for the dependent length payload which attaches the header to generate the data *) let parse_deplen_payload (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (#ht : Type) (#pt : Type) (dlf : ht -> Tot (bounded_int32 min max) ) (#pk : parser_kind) (#pp : parser pk pt) (ps : serializer pp) (h : ht) : Tot (parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h)) = let sz = (U32.v (dlf h)) in let bounds_off = pk.parser_kind_low > sz || ( match pk.parser_kind_high with | None -> false | Some pkmax -> pkmax < sz ) in if bounds_off then fail_parser (parse_deplen_payload_kind min max pk) (refine_with_tag (calc_tag_of_deplen_data min max dlf ps) h) else weaken (parse_deplen_payload_kind min max pk) (parse_fldata_strong ps sz `parse_synth` synth_deplen_data min max dlf ps h) (* unfold is a more human readable version and do double-check of the definition This lemma says using the parser defined above is equivalent to using a fixed-length parser with the calculated size and then attach the header *) let parse_deplen_payload_unfold (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (#ht : Type) (#pt : Type) (dlf : ht -> Tot (bounded_int32 min max) ) (#pk : parser_kind) (#pp : parser pk pt) (ps : serializer pp) (h : ht) (input: bytes) : Lemma (parse (parse_deplen_payload min max dlf ps h) input == (match (parse (parse_fldata_strong ps (U32.v (dlf h))) input) with | None -> None | Some (x, consumed) -> Some (synth_deplen_data min max dlf ps h x, consumed))) = let sz = (U32.v (dlf h)) in let bounds_off = pk.parser_kind_low > sz || ( match pk.parser_kind_high with | None -> false | Some pkmax -> pkmax < sz ) in if bounds_off then () else parse_synth_eq (parse_fldata_strong ps sz) (synth_deplen_data min max dlf ps h) input (* metadata for dependent length parser @min : @max : integer bounds @hk : header metadata @pk : payload metadata *) let parse_deplen_kind (min : nat) (max : nat { min <= max /\ max < 4294967296 } ) (hk : parser_kind) (pk : parser_kind) = and_then_kind hk (parse_deplen_payload_kind min max pk) (* parse spec for dependent length structures *) let parse_deplen (min: nat) (max: nat { min <= max /\ max < 4294967296 } ) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: ht -> Tot (bounded_int32 min max)) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) : Tot (parser (parse_deplen_kind min max hk pk) (parse_deplen_data_t min max dlf ps)) = parse_tagged_union hp (calc_tag_of_deplen_data min max dlf ps) (parse_deplen_payload min max dlf ps) (* This lemma says using the parser above is equivalent to using the header parser and then the deplen_payload parser *) let parse_deplen_unfold (min: nat) (max: nat { min <= max /\ max < 4294967296 } ) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: ht -> Tot (bounded_int32 min max)) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) (input : bytes) : Lemma (parse (parse_deplen min max hp dlf ps) input == (match parse hp input with | None -> None | Some (h, consumed) -> begin if (U32.v (dlf h) + consumed) > (Seq.length input) then None else let input' = Seq.slice input consumed (Seq.length input) in match parse (parse_deplen_payload min max dlf ps h) input' with | None -> None | Some(x, consumed') -> if consumed' = U32.v (dlf h) then Some (x, consumed + (U32.v (dlf h))) else None end) ) = parse_tagged_union_eq hp (calc_tag_of_deplen_data min max dlf ps) (parse_deplen_payload min max dlf ps) input; match parse hp input with | None -> () | Some (h, consumed) -> let input' = Seq.slice input consumed (Seq.length input) in parse_deplen_payload_unfold min max dlf ps h input'; let sz = (U32.v (dlf h)) in if Seq.length input < consumed + sz then () else Seq.slice_slice input consumed (Seq.length input) 0 sz (* a stronger version that further unfolds the payload *)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowParse.Spec.VLGen.fst.checked", "LowParse.Spec.Combinators.fsti.checked", "LowParse.Spec.AllIntegers.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "LowParse.Spec.DepLen.fst" }
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": false, "full_module": "LowParse.Spec.VLGen", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.AllIntegers", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
min: Prims.nat -> max: Prims.nat{min <= max /\ max < 4294967296} -> hp: LowParse.Spec.Base.parser hk ht -> dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) -> ps: LowParse.Spec.Base.serializer pp -> input: LowParse.Bytes.bytes -> FStar.Pervasives.Lemma (ensures LowParse.Spec.Base.parse (LowParse.Spec.DepLen.parse_deplen min max hp dlf ps) input == (match LowParse.Spec.Base.parse hp input with | FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None | FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ h consumed) -> (match FStar.UInt32.v (dlf h) + consumed > FStar.Seq.Base.length input with | true -> FStar.Pervasives.Native.None | _ -> let input' = FStar.Seq.Base.slice input consumed (FStar.UInt32.v (dlf h) + consumed) in (match LowParse.Spec.Base.parse pp input' with | FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None | FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ t consumed') -> (match consumed' = FStar.UInt32.v (dlf h) && FStar.Seq.Base.length (LowParse.Spec.Base.serialize ps t) = consumed' with | true -> FStar.Pervasives.Native.Some ((h, t), consumed + FStar.UInt32.v (dlf h)) | _ -> FStar.Pervasives.Native.None) <: FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps * LowParse.Spec.Base.consumed_length input)) <: FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps * LowParse.Spec.Base.consumed_length input)) <: FStar.Pervasives.Native.option (LowParse.Spec.DepLen.parse_deplen_data_t min max dlf ps * LowParse.Spec.Base.consumed_length input)))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "LowParse.Spec.Base.parser_kind", "LowParse.Spec.Base.parser", "LowParse.Spec.BoundedInt.bounded_int32", "LowParse.Spec.Base.serializer", "LowParse.Bytes.bytes", "LowParse.Spec.Base.parse", "LowParse.Spec.Base.consumed_length", "FStar.Seq.Base.length", "LowParse.Bytes.byte", "Prims.op_Addition", "Prims.bool", "FStar.Seq.Properties.slice_slice", "Prims.unit", "FStar.UInt.uint_t", "FStar.UInt32.v", "LowParse.Spec.DepLen.parse_deplen_payload_unfold", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "LowParse.Spec.Combinators.parse_tagged_union_eq", "LowParse.Spec.DepLen.parse_deplen_data_t", "LowParse.Spec.DepLen.calc_tag_of_deplen_data", "LowParse.Spec.DepLen.parse_deplen_payload_kind", "LowParse.Spec.DepLen.parse_deplen_payload", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.tuple2", "LowParse.Spec.DepLen.parse_deplen", "FStar.Pervasives.Native.None", "Prims.op_GreaterThan", "Prims.op_AmpAmp", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.op_GreaterThanOrEqual", "FStar.UInt.size", "FStar.UInt32.n", "LowParse.Spec.Base.serialize", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let parse_deplen_unfold2 (min: nat) (max: nat{min <= max /\ max < 4294967296}) (#hk: parser_kind) (#ht: Type) (hp: parser hk ht) (dlf: (ht -> Tot (bounded_int32 min max))) (#pk: parser_kind) (#pt: Type) (#pp: parser pk pt) (ps: serializer pp) (input: bytes) : Lemma (parse (parse_deplen min max hp dlf ps) input == (match parse hp input with | None -> None | Some (h, consumed) -> if (U32.v (dlf h) + consumed) > (Seq.length input) then None else let input' = Seq.slice input consumed (U32.v (dlf h) + consumed) in match parse pp input' with | None -> None | Some (t, consumed') -> if consumed' = U32.v (dlf h) && Seq.length (serialize ps t) = consumed' then Some ((h, t), consumed + (U32.v (dlf h))) else None)) =
parse_tagged_union_eq hp (calc_tag_of_deplen_data min max dlf ps) (parse_deplen_payload min max dlf ps) input; match parse hp input with | None -> () | Some (h, consumed) -> let input' = Seq.slice input consumed (Seq.length input) in parse_deplen_payload_unfold min max dlf ps h input'; let sz = (U32.v (dlf h)) in if Seq.length input < consumed + sz then () else Seq.slice_slice input consumed (Seq.length input) 0 sz
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_st1
val rsapss_sign_st1 : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 79, "end_line": 205, "start_col": 0, "start_line": 185 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Spec.RSAPSS.rsapss_sign_pre", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_sign_st1 (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.code_Fadd
val code_Fadd : Vale.X64.Decls.va_code
let code_Fadd = FH.va_code_Fadd ()
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 248, "start_col": 0, "start_line": 248 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma'
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.Curve25519.X64.FastHybrid.va_code_Fadd" ]
[]
false
false
false
true
false
let code_Fadd =
FH.va_code_Fadd ()
false
FStar.WellFoundedRelation.fst
FStar.WellFoundedRelation.option_wfr
val option_wfr (#a: Type u#a) (wfr: wfr_t a) : wfr': wfr_t (option a){wfr'.relation == option_relation wfr}
val option_wfr (#a: Type u#a) (wfr: wfr_t a) : wfr': wfr_t (option a){wfr'.relation == option_relation wfr}
let option_wfr (#a: Type u#a) (wfr: wfr_t a) : wfr': wfr_t (option a){wfr'.relation == option_relation wfr} = // We'll need the unit type raised to universe u#a let unit_a: Type u#a = raise_t unit in // Step 1: Create a function f mapping an `option a` to a // `(b: bool & (if b then a else unit_a))`. It should map // `Some x` to `(| true, x |)` and `None` to `(| false, () |)`. let f: option a -> (b: bool & (if b then a else unit_a)) = fun opt -> (match opt with | Some x -> (| true, x |) | None -> (| false, raise_val () |) ) in // Step 2: Create a wfr for (b: bool & (if b then a else unit_a)) using lex_dep_wfr. // The precedence for the bool field should be bool_wfr (i.e., false precedes true). // The precedence for the (if b then a else unit_a) field should be either wfr or // empty_wfr, depending on whether b is true or false. let bool_to_wfr_a (b: bool) : wfr_t (if b then a else unit_a) = if b then wfr else empty_wfr unit_a in let wfr_bool_a: wfr_t (b: bool & (if b then a else unit_a)) = lex_dep_wfr bool_wfr bool_to_wfr_a in assert (forall (bx1: (b: bool & (if b then a else unit_a))) (bx2: (b: bool & (if b then a else unit_a))). wfr_bool_a.relation bx1 bx2 <==> (let (| b1, x1 |), (| b2, x2 |) = bx1, bx2 in (not b1 && b2) \/ (b1 && b2 /\ wfr.relation x1 x2))); // Step 3: Create the final wfr using inverse_image_to_wfr, using `f` as the mapping // function from `option a` to `(b: bool & (if b then a else unit_a))` and // `wfr_bool_a` as the wfr_t for `(b: bool & (if b then a else unit_a))`. assert (forall opt1 opt2. (option_relation wfr) opt1 opt2 ==> wfr_bool_a.relation (f opt1) (f opt2)); inverse_image_to_wfr (option_relation wfr) f wfr_bool_a
{ "file_name": "ulib/FStar.WellFoundedRelation.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 57, "end_line": 213, "start_col": 0, "start_line": 176 }
(* Copyright 2022 Jay Lorch and Nikhil Swamy, Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* This library is intended to simplify using well-founded relations in decreases clauses. *) module FStar.WellFoundedRelation open FStar.Universe module WF = FStar.WellFounded module WFU = FStar.WellFounded.Util let rec default_decreaser (#a: Type u#a) (x: a) : Tot (acc_classical (default_relation #a) x) (decreases x) = let smaller (y: a{default_relation y x}) : acc_classical (default_relation #a) y = default_decreaser y in AccClassicalIntro smaller let default_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == default_relation}) = let proof (x1: a) (x2: a) : Lemma (requires default_relation x1 x2) (ensures default_decreaser x1 << default_decreaser x2) = assert ((default_decreaser x2).access_smaller x1 == default_decreaser x1) in { relation = default_relation; decreaser = default_decreaser; proof = proof; } let rec empty_decreaser (#a: Type u#a) (x: a) : Tot (acc_classical (empty_relation #a) x) (decreases x) = let smaller (y: a{empty_relation y x}) : acc_classical (empty_relation #a) y = empty_decreaser y in AccClassicalIntro smaller let empty_wfr (a: Type u#a) : (wfr: wfr_t a{wfr.relation == empty_relation}) = let proof (x1: a) (x2: a) : Lemma (requires empty_relation x1 x2) (ensures empty_decreaser x1 << empty_decreaser x2) = assert ((empty_decreaser x2).access_smaller x1 == empty_decreaser x1) in { relation = empty_relation; decreaser = empty_decreaser; proof = proof; } let rec acc_decreaser (#a: Type u#a) (r: a -> a -> Type0) (f: WF.well_founded r{forall x1 x2 (p: r x1 x2). (f x2).access_smaller x1 p == f x1}) (x: a) : Tot (acc_classical (acc_relation r) x) (decreases (f x)) = let smaller (y: a{(acc_relation r) y x}) : (acc_classical (acc_relation r) y) = ( eliminate exists (p: r y x). True returns f y << f x with _. assert ((f x).access_smaller y p == f y); acc_decreaser r f y ) in AccClassicalIntro smaller let rec eta_expand_well_founded (#a: Type) (r: WF.binrel a) (wf_r: WF.well_founded r) (x: a) : Tot (WF.acc r x) (decreases {:well-founded (WFU.lift_binrel_as_well_founded_relation wf_r) (| a, x |)}) = WF.AccIntro (let g_smaller (y: a) (u: r y x) : WF.acc r y = WFU.intro_lift_binrel r y x; eta_expand_well_founded r wf_r y in g_smaller) let acc_to_wfr (#a: Type u#a) (r: WF.binrel u#a u#0 a) (f: WF.well_founded r) : (wfr: wfr_t a{wfr.relation == acc_relation r}) = let f = eta_expand_well_founded r f in let proof (x1: a) (x2: a) : Lemma (requires acc_relation r x1 x2) (ensures acc_decreaser r f x1 << acc_decreaser r f x2) = assert ((acc_decreaser r f x2).access_smaller x1 == acc_decreaser r f x1) in { relation = acc_relation r; decreaser = acc_decreaser r f; proof = proof; } let rec subrelation_decreaser (#a: Type u#a) (r: a -> a -> Type0) (wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) (x: a) : Tot (acc_classical r x) (decreases wfr.decreaser x) = let smaller (y: a{r y x}) : (acc_classical r y) = subrelation_decreaser r wfr y in AccClassicalIntro smaller let subrelation_to_wfr (#a: Type u#a) (r: a -> a -> Type0) (wfr: wfr_t a{forall x1 x2. r x1 x2 ==> wfr.relation x1 x2}) : (wfr': wfr_t a{wfr'.relation == r}) = let proof (x1: a) (x2: a) : Lemma (requires r x1 x2) (ensures subrelation_decreaser r wfr x1 << subrelation_decreaser r wfr x2) = assert ((subrelation_decreaser r wfr x2).access_smaller x1 == subrelation_decreaser r wfr x1) in { relation = r; decreaser = subrelation_decreaser r wfr; proof = proof; } let rec inverse_image_decreaser (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b) (wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)}) (x: a) : Tot (acc_classical r x) (decreases wfr.decreaser (f x)) = let smaller (y: a{r y x}) : (acc_classical r y) = inverse_image_decreaser r f wfr y in AccClassicalIntro smaller let inverse_image_to_wfr (#a: Type u#a) (#b: Type u#b) (r: a -> a -> Type0) (f: a -> b) (wfr: wfr_t b{forall x1 x2. r x1 x2 ==> wfr.relation (f x1) (f x2)}) : (wfr': wfr_t a{wfr'.relation == r}) = let proof (x1: a) (x2: a) : Lemma (requires r x1 x2) (ensures inverse_image_decreaser r f wfr x1 << inverse_image_decreaser r f wfr x2) = assert ((inverse_image_decreaser r f wfr x2).access_smaller x1 == inverse_image_decreaser r f wfr x1) in { relation = r; decreaser = inverse_image_decreaser r f wfr; proof = proof; } let rec lex_nondep_decreaser (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b) (xy: a * b) : Tot (acc_classical (lex_nondep_relation wfr_a wfr_b) xy) (decreases %[wfr_a.decreaser (fst xy); wfr_b.decreaser (snd xy)]) = let smaller (xy': a * b{lex_nondep_relation wfr_a wfr_b xy' xy}) : (acc_classical (lex_nondep_relation wfr_a wfr_b) xy') = lex_nondep_decreaser wfr_a wfr_b xy' in AccClassicalIntro smaller let lex_nondep_wfr (#a: Type u#a) (#b: Type u#b) (wfr_a: wfr_t a) (wfr_b: wfr_t b) : wfr: wfr_t (a * b){wfr.relation == lex_nondep_relation wfr_a wfr_b} = let proof (xy1: a * b) (xy2: a * b) : Lemma (requires lex_nondep_relation wfr_a wfr_b xy1 xy2) (ensures lex_nondep_decreaser wfr_a wfr_b xy1 << lex_nondep_decreaser wfr_a wfr_b xy2) = assert ((lex_nondep_decreaser wfr_a wfr_b xy2).access_smaller xy1 == lex_nondep_decreaser wfr_a wfr_b xy1) in { relation = lex_nondep_relation wfr_a wfr_b; decreaser = lex_nondep_decreaser wfr_a wfr_b; proof = proof; } let rec lex_dep_decreaser (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a) (a_to_wfr_b: (x: a -> wfr_t (b x))) (xy: (x: a & b x)) : Tot (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy) (decreases %[wfr_a.decreaser (dfst xy); (a_to_wfr_b (dfst xy)).decreaser (dsnd xy)]) = let smaller (xy': (x: a & b x){lex_dep_relation wfr_a a_to_wfr_b xy' xy}) : (acc_classical (lex_dep_relation wfr_a a_to_wfr_b) xy') = lex_dep_decreaser wfr_a a_to_wfr_b xy' in AccClassicalIntro smaller let lex_dep_wfr (#a: Type u#a) (#b: a -> Type u#b) (wfr_a: wfr_t a) (a_to_wfr_b: (x: a -> wfr_t (b x))) : wfr: wfr_t (x: a & b x){wfr.relation == lex_dep_relation wfr_a a_to_wfr_b} = let proof (xy1: (x: a & b x)) (xy2: (x: a & b x)) : Lemma (requires lex_dep_relation wfr_a a_to_wfr_b xy1 xy2) (ensures lex_dep_decreaser wfr_a a_to_wfr_b xy1 << lex_dep_decreaser wfr_a a_to_wfr_b xy2) = assert ((lex_dep_decreaser wfr_a a_to_wfr_b xy2).access_smaller xy1 == lex_dep_decreaser wfr_a a_to_wfr_b xy1) in { relation = lex_dep_relation wfr_a a_to_wfr_b; decreaser = lex_dep_decreaser wfr_a a_to_wfr_b; proof = proof; } let bool_wfr: (wfr: wfr_t bool{wfr.relation == bool_relation}) = inverse_image_to_wfr #bool #nat bool_relation (fun b -> if b then 1 else 0) (default_wfr nat)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.WellFounded.Util.fsti.checked", "FStar.WellFounded.fst.checked", "FStar.Universe.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "FStar.WellFoundedRelation.fst" }
[ { "abbrev": true, "full_module": "FStar.WellFounded.Util", "short_module": "WFU" }, { "abbrev": true, "full_module": "FStar.WellFounded", "short_module": "WF" }, { "abbrev": false, "full_module": "FStar.Universe", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
wfr: FStar.WellFoundedRelation.wfr_t a -> wfr': FStar.WellFoundedRelation.wfr_t (FStar.Pervasives.Native.option a) {Mkwfr_t?.relation wfr' == FStar.WellFoundedRelation.option_relation wfr}
Prims.Tot
[ "total" ]
[]
[ "FStar.WellFoundedRelation.wfr_t", "FStar.WellFoundedRelation.inverse_image_to_wfr", "FStar.Pervasives.Native.option", "Prims.dtuple2", "Prims.bool", "FStar.WellFoundedRelation.option_relation", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.l_imp", "FStar.WellFoundedRelation.__proj__Mkwfr_t__item__relation", "Prims.l_iff", "Prims.l_or", "Prims.b2t", "Prims.op_AmpAmp", "Prims.op_Negation", "Prims.l_and", "Prims.logical", "FStar.Pervasives.Native.tuple2", "FStar.Pervasives.Native.Mktuple2", "FStar.WellFoundedRelation.lex_dep_wfr", "FStar.WellFoundedRelation.bool_wfr", "FStar.WellFoundedRelation.empty_wfr", "Prims.Mkdtuple2", "FStar.Universe.raise_val", "FStar.Universe.raise_t", "Prims.eq2" ]
[]
false
false
false
false
false
let option_wfr (#a: Type u#a) (wfr: wfr_t a) : wfr': wfr_t (option a) {wfr'.relation == option_relation wfr} =
let unit_a:Type u#a = raise_t unit in let f: option a -> (b: bool & (if b then a else unit_a)) = fun opt -> (match opt with | Some x -> (| true, x |) | None -> (| false, raise_val () |)) in let bool_to_wfr_a (b: bool) : wfr_t (if b then a else unit_a) = if b then wfr else empty_wfr unit_a in let wfr_bool_a:wfr_t (b: bool & (if b then a else unit_a)) = lex_dep_wfr bool_wfr bool_to_wfr_a in assert (forall (bx1: (b: bool & (if b then a else unit_a))) (bx2: (b: bool & (if b then a else unit_a))). wfr_bool_a.relation bx1 bx2 <==> (let (| b1 , x1 |), (| b2 , x2 |) = bx1, bx2 in (not b1 && b2) \/ (b1 && b2 /\ wfr.relation x1 x2))); assert (forall opt1 opt2. (option_relation wfr) opt1 opt2 ==> wfr_bool_a.relation (f opt1) (f opt2)); inverse_image_to_wfr (option_relation wfr) f wfr_bool_a
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_names
val fadd_names : n: Prims.nat -> Prims.string
let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 296, "start_col": 0, "start_line": 291 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"]
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.int", "Prims.string" ]
[]
false
false
false
true
false
let fadd_names (n: nat) =
match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.bn_lt_pow2
val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 289, "start_col": 0, "start_line": 285 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
modBits: Lib.IntTypes.size_t{1 < Lib.IntTypes.v modBits} -> m: Hacl.Bignum.Definitions.lbignum t (Hacl.Bignum.Definitions.blocks modBits (Lib.IntTypes.size (Lib.IntTypes.bits t))) -> FStar.HyperStack.ST.Stack Prims.bool
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.op_Negation", "Lib.IntTypes.op_Equals_Dot", "Lib.IntTypes.op_Percent_Dot", "Lib.IntTypes.op_Subtraction_Bang", "FStar.UInt32.__uint_to_t", "Prims.bool", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb0", "Hacl.Bignum.Definitions.limb", "Hacl.Bignum.bn_get_ith_bit" ]
[]
false
true
false
false
false
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_st
val rsapss_sign_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 247, "start_col": 0, "start_line": 228 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_sign_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_pkey_verify_st
val rsapss_pkey_verify_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
let rsapss_pkey_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 74, "end_line": 592, "start_col": 0, "start_line": 575 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false inline_for_extraction noextract let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s)) inline_for_extraction noextract val rsapss_skey_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits -> rsapss_sign:rsapss_sign_st t ke a modBits -> rsapss_skey_sign_st t ke a modBits let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt = [@inline_let] let bits = size (bits t) in let h0 = ST.get () in push_frame (); let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in let b = rsapss_load_skey eBits dBits nb eb db skey in LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db); let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in pop_frame (); let h1 = ST.get () in assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)); res
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies0", "Spec.RSAPSS.rsapss_pkey_verify", "Lib.Buffer.as_seq" ]
[]
false
false
false
false
true
let rsapss_pkey_verify_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: size_t) =
eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> nb: lbuffer uint8 (blocks modBits 8ul) -> eb: lbuffer uint8 (blocks eBits 8ul) -> saltLen: size_t -> sgntLen: size_t -> sgnt: lbuffer uint8 sgntLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ disjoint msg sgnt /\ disjoint nb eb /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint msg nb /\ disjoint msg eb) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.rsapss_pkey_verify a (v modBits) (v eBits) (as_seq h0 nb) (as_seq h0 eb) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_bn_st
val rsapss_verify_bn_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 119, "end_line": 305, "start_col": 0, "start_line": 293 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.as_seq", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_verify_bn", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_verify_bn_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def: lbignum t len -> s: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s) )
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_compute_msg_st
val rsapss_verify_compute_msg_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 109, "end_line": 401, "start_col": 0, "start_line": 388 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Lib.Sequence.lseq", "Lib.Buffer.as_seq", "Lib.Sequence.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Hacl.Spec.RSAPSS.rsapss_pkey_pre", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_verify_compute_msg", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_verify_compute_msg_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey: lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> m: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_comments
val fadd_comments:list string
val fadd_comments:list string
let fadd_comments : list string = ["Computes the field addition of two field elements"]
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 87, "end_line": 289, "start_col": 0, "start_line": 289 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Prims.string
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
false
false
false
true
false
let fadd_comments:list string =
["Computes the field addition of two field elements"]
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_fadd_normal_t
val lowstar_fadd_normal_t:normal lowstar_fadd_t
val lowstar_fadd_normal_t:normal lowstar_fadd_t
let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 280, "start_col": 0, "start_line": 279 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Pervasives.norm [ FStar.Pervasives.iota; FStar.Pervasives.zeta; FStar.Pervasives.delta_attr ["Vale.Arch.HeapTypes_s.__reduce__"; "FStar.BigOps.__reduce__"]; FStar.Pervasives.delta_only [ "Vale.Interop.Base.uu___is_TD_Buffer"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace"; "FStar.FunctionalExtensionality.on_dom"; "FStar.FunctionalExtensionality.on"; "FStar.List.Tot.Base.fold_right_gtot"; "FStar.List.Tot.Base.map_gtot"; "FStar.List.Tot.Base.length"; "FStar.Pervasives.Native.fst"; "FStar.Pervasives.Native.snd"; "FStar.Pervasives.Native.__proj__Mktuple2__item___1"; "FStar.Pervasives.Native.__proj__Mktuple2__item___2" ]; FStar.Pervasives.primops; FStar.Pervasives.simplify ] Vale.Inline.X64.Fadd_inline.lowstar_fadd_t <: Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_normal_t", "Vale.Inline.X64.Fadd_inline.lowstar_fadd_t", "Vale.Inline.X64.Fadd_inline.lowstar_fadd" ]
[]
false
false
false
false
false
let lowstar_fadd_normal_t:normal lowstar_fadd_t =
as_normal_t #lowstar_fadd_t lowstar_fadd
false
Steel.ST.Effect.fst
Steel.ST.Effect.repr
val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) : Type u#2
val repr (a:Type) (framed:bool) (pre:pre_t) (post:post_t a) (req:pure_pre) (ens:pure_post a) : Type u#2
let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v)
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 73, "end_line": 29, "start_col": 0, "start_line": 28 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off"
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> framed: Prims.bool -> pre: Steel.Effect.Common.pre_t -> post: Steel.Effect.Common.post_t a -> req: Prims.pure_pre -> ens: Prims.pure_post a -> Type
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Prims.pure_pre", "Prims.pure_post", "Steel.Effect.repr", "Steel.Effect.Common.rmem" ]
[]
false
false
false
true
true
let repr a framed pre post req ens : Type u#2 =
Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v)
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_bn_st
val rsapss_sign_bn_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 105, "end_line": 56, "start_col": 0, "start_line": 40 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Bignum.Definitions.bn_v", "Lib.Buffer.gsub", "Lib.Buffer.modifies", "Lib.Buffer.op_Bar_Plus_Bar", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Bignum.Definitions.lbignum", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_bn", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_sign_bn_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m: lbignum t len -> m': lbignum t len -> s: lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_pre
val fsub_pre:VSig.vale_pre fsub_dom
val fsub_pre:VSig.vale_pre fsub_dom
let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 316, "start_col": 0, "start_line": 309 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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 *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Inline.X64.Fadd_inline.fsub_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fadd_inline.b64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastHybrid.va_req_Fsub", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsub_pre:VSig.vale_pre fsub_dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: b64) (va_s0: V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_xmms_modified
val fsub_xmms_modified : _: _ -> Prims.bool
let fsub_xmms_modified = fun _ -> false
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 336, "start_col": 0, "start_line": 336 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: _ -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Prims.bool" ]
[]
false
false
false
true
false
let fsub_xmms_modified =
fun _ -> false
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.code_Fsub
val code_Fsub : Vale.X64.Decls.va_code
let code_Fsub = FH.va_code_Fsub ()
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 34, "end_line": 371, "start_col": 0, "start_line": 371 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma'
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.Curve25519.X64.FastHybrid.va_code_Fsub" ]
[]
false
false
false
true
false
let code_Fsub =
FH.va_code_Fsub ()
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_post
val fsub_post:VSig.vale_post fsub_dom
val fsub_post:VSig.vale_post fsub_dom
let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 97, "end_line": 327, "start_col": 0, "start_line": 319 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_post Vale.Inline.X64.Fadd_inline.fsub_dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fadd_inline.b64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastHybrid.va_ens_Fsub", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "Prims.prop" ]
[]
false
false
false
true
false
let fsub_post:VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt_st
val rsapss_sign_compute_sgnt_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 121, "end_line": 154, "start_col": 0, "start_line": 140 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.disjoint", "Hacl.Spec.RSAPSS.rsapss_skey_pre", "Lib.Buffer.as_seq", "Hacl.Bignum.Definitions.bn_v", "Lib.Buffer.gsub", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.tuple2", "Lib.Sequence.lseq", "FStar.Pervasives.Native.Mktuple2", "Hacl.Spec.RSAPSS.rsapss_sign_compute_sgnt", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int" ]
[]
false
false
false
false
true
let rsapss_sign_compute_sgnt_st (t: limb_t) (ke: BE.exp t) (modBits: modBits_t t) =
let len = blocks modBits (size (bits t)) in eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey: lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m: lbignum t len -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m) )
false
Vale.Inline.X64.Fswap_inline.fst
Vale.Inline.X64.Fswap_inline.cswap2
val cswap2 (bit:UInt64.t{UInt64.v bit <= 1}) (p0:u512) (p1:u512) : Stack unit (requires fun h -> B.live h p0 /\ B.live h p1 /\ (B.disjoint p0 p1 \/ p0 == p1)) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer p0) (B.loc_buffer p1)) h0 h1 /\ (let old_p0 = B.as_seq h0 p0 in let new_p0 = B.as_seq h1 p0 in let old_p1 = B.as_seq h0 p1 in let new_p1 = B.as_seq h1 p1 in (UInt64.v bit = 1 ==> (Seq.equal old_p0 new_p1 /\ Seq.equal old_p1 new_p0)) /\ (UInt64.v bit = 0 ==> (Seq.equal old_p0 new_p0 /\ Seq.equal old_p1 new_p1)) ) )
val cswap2 (bit:UInt64.t{UInt64.v bit <= 1}) (p0:u512) (p1:u512) : Stack unit (requires fun h -> B.live h p0 /\ B.live h p1 /\ (B.disjoint p0 p1 \/ p0 == p1)) (ensures fun h0 _ h1 -> B.modifies (B.loc_union (B.loc_buffer p0) (B.loc_buffer p1)) h0 h1 /\ (let old_p0 = B.as_seq h0 p0 in let new_p0 = B.as_seq h1 p0 in let old_p1 = B.as_seq h0 p1 in let new_p1 = B.as_seq h1 p1 in (UInt64.v bit = 1 ==> (Seq.equal old_p0 new_p1 /\ Seq.equal old_p1 new_p0)) /\ (UInt64.v bit = 0 ==> (Seq.equal old_p0 new_p0 /\ Seq.equal old_p1 new_p1)) ) )
let cswap2 bit p0 p1 = DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let (x, _) = lowstar_cswap_normal_t bit p0 p1 () in ()
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fswap_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 6, "end_line": 161, "start_col": 0, "start_line": 157 }
module Vale.Inline.X64.Fswap_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil let uint64 = UInt64.t (* A little utility to trigger normalization in types *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let cswap_dom: IX64.arity_ok 3 td = let y = [tuint64; t64_mod; t64_mod] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let cswap_pre : VSig.vale_pre cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) -> FU.va_req_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) [@__reduce__] let cswap_post : VSig.vale_post cswap_dom = fun (c:V.va_code) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Cswap2 c va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) va_s1 f #set-options "--z3rlimit 50" let cswap_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRdi || r = rR8 || r = rR9 || r = rR10 then true else false let cswap_xmms_modified = fun _ -> false [@__reduce__] let cswap_lemma' (code:V.va_code) (_win:bool) (bit:uint64) (p0:b64) (p1:b64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires cswap_pre code bit p0 p1 va_s0) (ensures (fun (va_s1, f) -> V.eval_code code va_s0 f va_s1 /\ VSig.vale_calling_conventions va_s0 va_s1 cswap_regs_modified cswap_xmms_modified /\ cswap_post code bit p0 p1 va_s0 va_s1 f /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p0) /\ ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer p1) /\ ME.buffer_writeable (as_vale_buffer p0) /\ ME.buffer_writeable (as_vale_buffer p1) /\ ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer p0)) (ME.loc_union (ME.loc_buffer (as_vale_buffer p1)) ME.loc_none)) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1) )) = let va_s1, f = FU.va_lemma_Cswap2 code va_s0 (UInt64.v bit) (as_vale_buffer p0) (as_vale_buffer p1) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p0; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 p1; (va_s1, f) (* Prove that cswap_lemma' has the required type *) let cswap_lemma = as_t #(VSig.vale_sig cswap_regs_modified cswap_xmms_modified cswap_pre cswap_post) cswap_lemma' let code_cswap = FU.va_code_Cswap2 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the cswap wrapper *) [@__reduce__] let lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) (* And here's the cswap wrapper itself *) let lowstar_cswap : lowstar_cswap_t = assert_norm (List.length cswap_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg cswap_regs_modified cswap_xmms_modified code_cswap cswap_dom (W.mk_prediction code_cswap cswap_dom [] (cswap_lemma code_cswap IA.win)) let lowstar_cswap_normal_t : normal lowstar_cswap_t = as_normal_t #lowstar_cswap_t lowstar_cswap open Vale.AsLowStar.MemoryHelpers
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fswap_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
bit: FStar.UInt64.t{FStar.UInt64.v bit <= 1} -> p0: Vale.Inline.X64.Fswap_inline.u512 -> p1: Vale.Inline.X64.Fswap_inline.u512 -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "FStar.UInt64.t", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.UInt64.v", "Vale.Inline.X64.Fswap_inline.u512", "FStar.Ghost.erased", "Vale.Interop.X64.as_lowstar_sig_ret", "Prims.unit", "Vale.Interop.X64.als_ret", "Vale.Inline.X64.Fswap_inline.lowstar_cswap_normal_t", "LowStar.BufferView.Down.length_eq", "FStar.UInt8.t", "Vale.Interop.Types.get_downview", "Vale.Arch.HeapTypes_s.TUInt64", "LowStar.Buffer.trivial_preorder" ]
[]
false
true
false
false
false
let cswap2 bit p0 p1 =
DV.length_eq (get_downview p0); DV.length_eq (get_downview p1); let x, _ = lowstar_cswap_normal_t bit p0 p1 () in ()
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify
val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 514, "start_col": 0, "start_line": 499 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_st t ke a modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.RSAPSS.rsapss_verify_", "Prims.bool", "Prims.op_AmpAmp", "Lib.IntTypes.op_Less_Equals_Dot", "Lib.IntTypes.op_Subtraction_Bang", "Lib.IntTypes.op_Equals_Dot", "Prims.unit", "Prims._assert", "Prims.op_LessThan", "Prims.op_Addition", "Lib.IntTypes.max_size_t", "Prims.op_LessThanOrEqual", "FStar.Math.Lemmas.pow2_lt_compat", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_GreaterThan", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.RSAPSS.MGF.hash_len" ]
[]
false
false
false
false
false
let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg =
let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_skey_sign_st
val rsapss_skey_sign_st : t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) = eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb:lbuffer uint8 (blocks modBits 8ul) -> eb:lbuffer uint8 (blocks eBits 8ul) -> db:lbuffer uint8 (blocks dBits 8ul) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 82, "end_line": 540, "start_col": 0, "start_line": 518 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b inline_for_extraction noextract let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st1 t ke a modBits let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in pop_frame (); res inline_for_extraction noextract let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> saltLen:size_t -> sgntLen:size_t -> sgnt:lbuffer uint8 sgntLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h msg /\ live h sgnt /\ live h pkey /\ disjoint msg sgnt /\ disjoint msg pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey) (v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_verify: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_st t ke a modBits let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); assert (v msgLen <= max_size_t); assert (v hLen + 8 < max_size_t); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && sgntLen =. blocks modBits 8ul in if b then rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg else false
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
t: Hacl.Bignum.Definitions.limb_t -> ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Lib.IntTypes.size_t -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.blocks", "FStar.UInt32.__uint_to_t", "Prims.bool", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "Prims.l_or", "Prims.int", "Lib.IntTypes.range", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Lib.IntTypes.max_size_t", "FStar.Mul.op_Star", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.op_LessThan", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__bn", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Lib.Buffer.modifies", "Lib.Buffer.loc", "FStar.Pervasives.Native.uu___is_Some", "Lib.ByteSequence.lbytes", "Spec.RSAPSS.blocks", "Lib.Sequence.seq", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.as_seq", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Pervasives.Native.uu___is_None", "Prims.logical", "FStar.Pervasives.Native.option", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Spec.RSAPSS.rsapss_skey_sign" ]
[]
false
false
false
false
true
let rsapss_skey_sign_st (t: limb_t) (ke: BE.exp t) (a: Hash.hash_alg{S.hash_is_supported a}) (modBits: size_t) =
eBits: size_t -> dBits: size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> nb: lbuffer uint8 (blocks modBits 8ul) -> eb: lbuffer uint8 (blocks eBits 8ul) -> db: lbuffer uint8 (blocks dBits 8ul) -> saltLen: size_t -> salt: lbuffer uint8 saltLen -> msgLen: size_t -> msg: lbuffer uint8 msgLen -> sgnt: lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h nb /\ live h eb /\ live h db /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\ disjoint salt msg) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_Fsub_normal_t
val lowstar_Fsub_normal_t:normal lowstar_Fsub_t
val lowstar_Fsub_normal_t:normal lowstar_Fsub_t
let lowstar_Fsub_normal_t : normal lowstar_Fsub_t = as_normal_t #lowstar_Fsub_t lowstar_Fsub
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 44, "end_line": 403, "start_col": 0, "start_line": 402 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *) [@__reduce__] let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) (* And here's the fsub wrapper itself *) let lowstar_Fsub : lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
FStar.Pervasives.norm [ FStar.Pervasives.iota; FStar.Pervasives.zeta; FStar.Pervasives.delta_attr ["Vale.Arch.HeapTypes_s.__reduce__"; "FStar.BigOps.__reduce__"]; FStar.Pervasives.delta_only [ "Vale.Interop.Base.uu___is_TD_Buffer"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint"; "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace"; "FStar.FunctionalExtensionality.on_dom"; "FStar.FunctionalExtensionality.on"; "FStar.List.Tot.Base.fold_right_gtot"; "FStar.List.Tot.Base.map_gtot"; "FStar.List.Tot.Base.length"; "FStar.Pervasives.Native.fst"; "FStar.Pervasives.Native.snd"; "FStar.Pervasives.Native.__proj__Mktuple2__item___1"; "FStar.Pervasives.Native.__proj__Mktuple2__item___2" ]; FStar.Pervasives.primops; FStar.Pervasives.simplify ] Vale.Inline.X64.Fadd_inline.lowstar_Fsub_t <: Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_normal_t", "Vale.Inline.X64.Fadd_inline.lowstar_Fsub_t", "Vale.Inline.X64.Fadd_inline.lowstar_Fsub" ]
[]
false
false
false
false
false
let lowstar_Fsub_normal_t:normal lowstar_Fsub_t =
as_normal_t #lowstar_Fsub_t lowstar_Fsub
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.mk_arrow
val mk_arrow : ty: Pulse.Syntax.Base.term -> t: Pulse.Syntax.Base.term -> FStar.Stubs.Reflection.Types.term
let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t)
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 73, "end_line": 53, "start_col": 0, "start_line": 53 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: Pulse.Syntax.Base.term -> t: Pulse.Syntax.Base.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "FStar.Reflection.Typing.mk_arrow", "Pulse.Elaborate.Pure.elab_term", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Stubs.Reflection.Types.term" ]
[]
false
false
false
true
false
let mk_arrow ty t =
RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t)
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign
val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 9, "end_line": 271, "start_col": 0, "start_line": 258 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ke: Hacl.Bignum.Exponentiation.exp t -> a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_st t ke a modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Impl.RSAPSS.rsapss_sign_", "Prims.bool", "Prims.op_AmpAmp", "Lib.IntTypes.op_Less_Equals_Dot", "Lib.IntTypes.op_Subtraction_Bang", "Prims.unit", "FStar.Math.Lemmas.pow2_lt_compat", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_GreaterThan", "Spec.Hash.Definitions.hash_length", "Hacl.Impl.RSAPSS.MGF.hash_len" ]
[]
false
false
false
false
false
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.mk_abs
val mk_abs : ty: Pulse.Syntax.Base.term -> t: Pulse.Syntax.Base.term -> FStar.Stubs.Reflection.Types.term
let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t))
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 71, "end_line": 54, "start_col": 0, "start_line": 54 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ty: Pulse.Syntax.Base.term -> t: Pulse.Syntax.Base.term -> FStar.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.term", "FStar.Reflection.Typing.mk_abs", "Pulse.Elaborate.Pure.elab_term", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Stubs.Reflection.Types.term" ]
[]
false
false
false
true
false
let mk_abs ty t =
let open RT in mk_abs (elab_term ty) T.Q_Explicit (elab_term t)
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_comments
val fsub_comments:list string
val fsub_comments:list string
let fsub_comments : list string = ["Computes the field substraction of two field elements"]
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 91, "end_line": 412, "start_col": 0, "start_line": 412 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *) [@__reduce__] let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) (* And here's the fsub wrapper itself *) let lowstar_Fsub : lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) let lowstar_Fsub_normal_t : normal lowstar_Fsub_t = as_normal_t #lowstar_Fsub_t lowstar_Fsub let fsub out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_Fsub_normal_t out f1 f2 () in ()
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.list Prims.string
Prims.Tot
[ "total" ]
[]
[ "Prims.Cons", "Prims.string", "Prims.Nil" ]
[]
false
false
false
true
false
let fsub_comments:list string =
["Computes the field substraction of two field elements"]
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.debug
val debug (g:env) (f:unit -> T.Tac string) : T.Tac unit
val debug (g:env) (f:unit -> T.Tac string) : T.Tac unit
let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f())
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 17, "end_line": 32, "start_col": 0, "start_line": 30 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> f: (_: Prims.unit -> FStar.Tactics.Effect.Tac Prims.string) -> FStar.Tactics.Effect.Tac Prims.unit
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Prims.unit", "Prims.string", "Pulse.RuntimeUtils.debug_at_level", "Pulse.Typing.Env.fstar_env", "FStar.Stubs.Tactics.V2.Builtins.print", "Prims.bool" ]
[]
false
true
false
false
false
let debug (g: env) (f: (unit -> T.Tac string)) : T.Tac unit =
if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f ())
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_names
val fsub_names : n: Prims.nat -> Prims.string
let fsub_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 419, "start_col": 0, "start_line": 414 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *) [@__reduce__] let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) (* And here's the fsub wrapper itself *) let lowstar_Fsub : lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) let lowstar_Fsub_normal_t : normal lowstar_Fsub_t = as_normal_t #lowstar_Fsub_t lowstar_Fsub let fsub out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_Fsub_normal_t out f1 f2 () in () let fsub_comments : list string = ["Computes the field substraction of two field elements"]
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
n: Prims.nat -> Prims.string
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.int", "Prims.string" ]
[]
false
false
false
true
false
let fsub_names (n: nat) =
match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.as_normal_t
val as_normal_t (#a: Type) (x: a) : normal a
val as_normal_t (#a: Type) (x: a) : normal a
let as_normal_t (#a:Type) (x:a) : normal a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 46, "end_line": 31, "start_col": 0, "start_line": 31 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> Vale.Interop.Base.normal a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_normal_t (#a: Type) (x: a) : normal a =
x
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.ve_unit_r
val ve_unit_r (g: _) (p: term) : vprop_equiv g (tm_star p tm_emp) p
val ve_unit_r (g: _) (p: term) : vprop_equiv g (tm_star p tm_emp) p
let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _)
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 48, "end_line": 218, "start_col": 0, "start_line": 217 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post}
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> p: Pulse.Syntax.Base.term -> Pulse.Typing.vprop_equiv g (Pulse.Syntax.Base.tm_star p Pulse.Syntax.Base.tm_emp) p
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.VE_Trans", "Pulse.Syntax.Base.tm_star", "Pulse.Syntax.Base.tm_emp", "Pulse.Typing.VE_Comm", "Pulse.Typing.VE_Unit", "Pulse.Typing.vprop_equiv" ]
[]
false
false
false
false
false
let ve_unit_r g (p: term) : vprop_equiv g (tm_star p tm_emp) p =
VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _)
false
Steel.GhostPCMReference.fst
Steel.GhostPCMReference.share
val share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True)
val share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True)
let share (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (v:a) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) = P.split r v v0 v1
{ "file_name": "lib/steel/Steel.GhostPCMReference.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 100, "start_col": 0, "start_line": 86 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.GhostPCMReference (* A ghost variant of Steel.PCMReference *) open FStar.PCM open FStar.Ghost open Steel.Memory open Steel.Effect.Atomic open Steel.Effect module Mem = Steel.Memory module P = Steel.PCMReference let ref (a:Type) (p:pcm a) = erased (Steel.Memory.ref a p) /// Its selector is non-informative (it is unit) [@@__reduce__] let pts_to (#a:Type u#1) (#pcm:pcm a) (r:ref a pcm) ([@@@smt_fallback]v:a) = to_vprop (Steel.Memory.pts_to r v) let alloc (#o:inames) (#a:Type) (#pcm:pcm a) (x:a) : SteelGhost (ref a pcm) o (emp) (fun r -> pts_to r x) (requires fun _ -> pcm.refine x) (ensures fun _ _ _ -> True) = rewrite_slprop emp (to_vprop Mem.emp) (fun _ -> reveal_emp ()); FStar.PCM.compatible_refl pcm x; let r = as_atomic_action_ghost (alloc_action o x) in r let read (#o:inames) (#a:Type) (#pcm:pcm a) (#v0:a) (r:ref a pcm) : SteelGhost a o (pts_to r v0) (fun _ -> pts_to r v0) (requires fun _ -> True) (ensures fun _ v _ -> compatible pcm v0 v) = let v = as_atomic_action_ghost (sel_action o r v0) in v let write (#o:inames) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:a) (v1:a) : SteelGhost unit o (pts_to r v0) (fun _ -> pts_to r v1) (requires fun _ -> frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ _ _ -> True) = as_atomic_action_ghost (upd_action o r v0 v1) let upd_gen (#o:inames) (#a:Type) (#p:pcm a) (r:ref a p) (x y:a) (f:frame_preserving_upd p x y) : SteelGhostT unit o (pts_to r x) (fun _ -> pts_to r y) = as_atomic_action_ghost (Steel.Memory.upd_gen o r x y f)
{ "checked_file": "/", "dependencies": [ "Steel.Preorder.fst.checked", "Steel.PCMReference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.PCM.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Steel.GhostPCMReference.fst" }
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Atomic", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Steel.GhostPCMReference.ref a p -> v: a -> v0: a -> v1: a -> Steel.Effect.Atomic.SteelGhost Prims.unit
Steel.Effect.Atomic.SteelGhost
[]
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.GhostPCMReference.ref", "Steel.PCMReference.split", "FStar.Ghost.reveal", "Steel.Memory.ref", "FStar.Ghost.hide", "Prims.unit", "Steel.GhostPCMReference.pts_to", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Steel.Effect.Common.rmem", "Prims.l_and", "FStar.PCM.composable", "Prims.eq2", "FStar.PCM.op", "Prims.l_True" ]
[]
false
true
false
false
false
let share (#o: inames) (#a: Type) (#p: pcm a) (r: ref a p) (v v0 v1: a) : SteelGhost unit o (pts_to r v) (fun _ -> (pts_to r v0) `star` (pts_to r v1)) (requires fun _ -> composable p v0 v1 /\ v == op p v0 v1) (ensures fun _ _ _ -> True) =
P.split r v v0 v1
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.as_t
val as_t (#a: Type) (x: normal a) : a
val as_t (#a: Type) (x: normal a) : a
let as_t (#a:Type) (x:normal a) : a = x
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 39, "end_line": 30, "start_col": 0, "start_line": 30 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s module FU = Vale.Curve25519.X64.FastUtil module FH = Vale.Curve25519.X64.FastHybrid module FW = Vale.Curve25519.X64.FastWide let uint64 = UInt64.t
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Interop.Base.normal a -> a
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.Base.normal" ]
[]
false
false
false
true
false
let as_t (#a: Type) (x: normal a) : a =
x
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.vprop_equiv_typing_bk
val vprop_equiv_typing_bk (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g p ctxt) : tot_typing g p tm_vprop
val vprop_equiv_typing_bk (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g p ctxt) : tot_typing g p tm_vprop
let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 18, "end_line": 288, "start_col": 0, "start_line": 284 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = ()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop -> d: Pulse.Typing.vprop_equiv g p ctxt -> Pulse.Typing.tot_typing g p Pulse.Syntax.Base.tm_vprop
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.vprop_equiv", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Combinators.vprop_equiv_typing" ]
[]
false
false
false
false
false
let vprop_equiv_typing_bk (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g p ctxt) : tot_typing g p tm_vprop =
let _, bk = vprop_equiv_typing d in bk ctxt_typing
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.vprop_equiv_typing_fwd
val vprop_equiv_typing_fwd (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g ctxt p) : tot_typing g p tm_vprop
val vprop_equiv_typing_fwd (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g ctxt p) : tot_typing g p tm_vprop
let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g ctxt p) : tot_typing g p tm_vprop = let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 19, "end_line": 329, "start_col": 0, "start_line": 325 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre} let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (pre:term) (veq: vprop_equiv g (comp_pre c) pre) : st_typing g t (comp_with_pre c pre) = if eq_tm pre (comp_pre c) then d else let c' = comp_with_pre c pre in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _) in t_equiv d st_equiv #push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0" let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term) (k:continuation_elaborator g1 ctxt g2 ctxt1) (d:vprop_equiv g2 ctxt1 ctxt2) : continuation_elaborator g1 ctxt g2 ctxt2 = fun post_hint res -> let (| st, c, st_d |) = res in let st_d : st_typing g2 st c = st_d in assert (comp_pre c == ctxt2); let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in k post_hint (| st, _, st_d' |) #pop-options
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctxt_typing: Pulse.Typing.tot_typing g ctxt Pulse.Syntax.Base.tm_vprop -> d: Pulse.Typing.vprop_equiv g ctxt p -> Pulse.Typing.tot_typing g p Pulse.Syntax.Base.tm_vprop
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.vprop_equiv", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Combinators.vprop_equiv_typing" ]
[]
false
false
false
false
false
let vprop_equiv_typing_fwd (#g: env) (#ctxt: _) (ctxt_typing: tot_typing g ctxt tm_vprop) (#p: _) (d: vprop_equiv g ctxt p) : tot_typing g p tm_vprop =
let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.dom
val dom:IX64.arity_ok 3 td
val dom:IX64.arity_ok 3 td
let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 46, "start_col": 0, "start_line": 43 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.X64.arity_ok 3 Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Inline.X64.Fadd_inline.t64_mod", "Vale.Inline.X64.Fadd_inline.t64_no_mod", "Vale.Inline.X64.Fadd_inline.tuint64", "Prims.Nil" ]
[]
false
false
false
false
false
let dom:IX64.arity_ok 3 td =
let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_regs_modified
val add1_regs_modified: MS.reg_64 -> bool
val add1_regs_modified: MS.reg_64 -> bool
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 75, "start_col": 0, "start_line": 72 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Vale.X64.Machine_s.reg_64 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg_64", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR11", "Prims.bool" ]
[]
false
false
false
true
false
let add1_regs_modified: MS.reg_64 -> bool =
fun (r: MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.k_elab_equiv
val k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2'
val k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2'
let k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2' = let k : continuation_elaborator g1 ctxt1 g2 ctxt2' = k_elab_equiv_continuation k d2 in let k : continuation_elaborator g1 ctxt1' g2 ctxt2' = k_elab_equiv_prefix k d1 in k
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 359, "start_col": 0, "start_line": 348 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre} let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (pre:term) (veq: vprop_equiv g (comp_pre c) pre) : st_typing g t (comp_with_pre c pre) = if eq_tm pre (comp_pre c) then d else let c' = comp_with_pre c pre in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _) in t_equiv d st_equiv #push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0" let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term) (k:continuation_elaborator g1 ctxt g2 ctxt1) (d:vprop_equiv g2 ctxt1 ctxt2) : continuation_elaborator g1 ctxt g2 ctxt2 = fun post_hint res -> let (| st, c, st_d |) = res in let st_d : st_typing g2 st c = st_d in assert (comp_pre c == ctxt2); let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in k post_hint (| st, _, st_d' |) #pop-options let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g ctxt p) : tot_typing g p tm_vprop = let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing #push-options "--z3rlimit_factor 4 --ifuel 1 --fuel 0" let k_elab_equiv_prefix (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt2 #ctxt:term) (k:continuation_elaborator g1 ctxt1 g2 ctxt) (d:vprop_equiv g1 ctxt1 ctxt2) : continuation_elaborator g1 ctxt2 g2 ctxt = fun post_hint res -> let framing_token : frame_for_req_in_ctxt g1 ctxt2 ctxt1 = let d = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Trans _ _ _ _ (VE_Unit _ _) d) in (| tm_emp, emp_typing, d |) in let res = k post_hint res in let (| st, c, st_d |) = res in assert (comp_pre c == ctxt1); (| _, _, st_equiv_pre st_d _ d |) #pop-options
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Pulse.Checker.Base.continuation_elaborator g1 ctxt1 g2 ctxt2 -> d1: Pulse.Typing.vprop_equiv g1 ctxt1 ctxt1' -> d2: Pulse.Typing.vprop_equiv g2 ctxt2 ctxt2' -> Pulse.Checker.Base.continuation_elaborator g1 ctxt1' g2 ctxt2'
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Typing.Env.env_extends", "Pulse.Syntax.Base.term", "Pulse.Checker.Base.continuation_elaborator", "Pulse.Typing.vprop_equiv", "Pulse.Checker.Base.k_elab_equiv_prefix", "Pulse.Checker.Base.k_elab_equiv_continuation" ]
[]
false
false
false
false
false
let k_elab_equiv (#g1: env) (#g2: env{g2 `env_extends` g1}) (#ctxt1 #ctxt1' #ctxt2 #ctxt2': term) (k: continuation_elaborator g1 ctxt1 g2 ctxt2) (d1: vprop_equiv g1 ctxt1 ctxt1') (d2: vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2' =
let k:continuation_elaborator g1 ctxt1 g2 ctxt2' = k_elab_equiv_continuation k d2 in let k:continuation_elaborator g1 ctxt1' g2 ctxt2' = k_elab_equiv_prefix k d1 in k
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_post
val add1_post:VSig.vale_post dom
val add1_post:VSig.vale_post dom
let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 96, "end_line": 68, "start_col": 0, "start_line": 60 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_post Vale.Inline.X64.Fadd_inline.dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fadd_inline.b64", "Vale.Inline.X64.Fadd_inline.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "Vale.Curve25519.X64.FastUtil.va_ens_Fast_add1", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.UInt64.v", "Prims.prop" ]
[]
false
false
false
true
false
let add1_post:VSig.vale_post dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: uint64) (va_s0: V.va_state) (va_s1: V.va_state) (f: V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg
val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 384, "start_col": 0, "start_line": 363 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_bn_to_msg_st t a modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.Padding.pss_verify", "Hacl.Bignum.bn_to_bytes_be", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims._assert", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.op_Subtraction_Bang", "Prims.pos", "Lib.IntTypes.numbytes", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@@ inline_let ]let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_add1_t
val lowstar_add1_t : Type0
let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 139, "start_col": 0, "start_line": 126 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.add1_regs_modified", "Vale.Inline.X64.Fadd_inline.add1_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_add1", "Vale.Inline.X64.Fadd_inline.dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Inline.X64.Fadd_inline.add1_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.add1_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.add1_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
true
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([] <: list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_pre
val add1_pre:VSig.vale_pre dom
val add1_pre:VSig.vale_pre dom
let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 57, "start_col": 0, "start_line": 50 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_pre Vale.Inline.X64.Fadd_inline.dom
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_code", "Vale.Inline.X64.Fadd_inline.b64", "Vale.Inline.X64.Fadd_inline.uint64", "Vale.X64.Decls.va_state", "Vale.Curve25519.X64.FastUtil.va_req_Fast_add1", "Vale.X64.MemoryAdapters.as_vale_buffer", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.UInt64.v", "Prims.prop" ]
[]
false
false
false
true
false
let add1_pre:VSig.vale_pre dom =
fun (c: V.va_code) (out: b64) (f1: b64) (f2: uint64) (va_s0: V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
false
Steel.ST.Effect.fst
Steel.ST.Effect.equiv_star_emp_r
val equiv_star_emp_r (p: vprop) : Lemma ((p `star` emp) `equiv` p)
val equiv_star_emp_r (p: vprop) : Lemma ((p `star` emp) `equiv` p)
let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 47, "end_line": 36, "start_col": 0, "start_line": 31 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v)
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
p: Steel.Effect.Common.vprop -> FStar.Pervasives.Lemma (ensures Steel.Effect.Common.equiv (Steel.Effect.Common.star p Steel.Effect.Common.emp) p)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.Effect.Common.equiv_trans", "Steel.Effect.Common.star", "Steel.Effect.Common.emp", "Prims.unit", "Steel.Effect.Common.star_commutative", "Prims._assert", "Steel.Effect.Common.equiv", "Steel.Effect.Common.cm_identity", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let equiv_star_emp_r (p: vprop) : Lemma ((p `star` emp) `equiv` p) =
cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.emp_inames_included
val emp_inames_included: g: env -> i: term -> tot_typing g i tm_inames -> prop_validity g (tm_inames_subset tm_emp_inames i)
val emp_inames_included: g: env -> i: term -> tot_typing g i tm_inames -> prop_validity g (tm_inames_subset tm_emp_inames i)
let emp_inames_included (g:env) (i:term) (_:tot_typing g i tm_inames) : prop_validity g (tm_inames_subset tm_emp_inames i) = RU.magic()
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 12, "end_line": 548, "start_col": 0, "start_line": 546 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre} let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (pre:term) (veq: vprop_equiv g (comp_pre c) pre) : st_typing g t (comp_with_pre c pre) = if eq_tm pre (comp_pre c) then d else let c' = comp_with_pre c pre in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _) in t_equiv d st_equiv #push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0" let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term) (k:continuation_elaborator g1 ctxt g2 ctxt1) (d:vprop_equiv g2 ctxt1 ctxt2) : continuation_elaborator g1 ctxt g2 ctxt2 = fun post_hint res -> let (| st, c, st_d |) = res in let st_d : st_typing g2 st c = st_d in assert (comp_pre c == ctxt2); let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in k post_hint (| st, _, st_d' |) #pop-options let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g ctxt p) : tot_typing g p tm_vprop = let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing #push-options "--z3rlimit_factor 4 --ifuel 1 --fuel 0" let k_elab_equiv_prefix (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt2 #ctxt:term) (k:continuation_elaborator g1 ctxt1 g2 ctxt) (d:vprop_equiv g1 ctxt1 ctxt2) : continuation_elaborator g1 ctxt2 g2 ctxt = fun post_hint res -> let framing_token : frame_for_req_in_ctxt g1 ctxt2 ctxt1 = let d = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Trans _ _ _ _ (VE_Unit _ _) d) in (| tm_emp, emp_typing, d |) in let res = k post_hint res in let (| st, c, st_d |) = res in assert (comp_pre c == ctxt1); (| _, _, st_equiv_pre st_d _ d |) #pop-options let k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2' = let k : continuation_elaborator g1 ctxt1 g2 ctxt2' = k_elab_equiv_continuation k d2 in let k : continuation_elaborator g1 ctxt1' g2 ctxt2' = k_elab_equiv_prefix k d1 in k #push-options "--query_stats --fuel 2 --ifuel 2 --split_queries no --z3rlimit_factor 20" open Pulse.PP let continuation_elaborator_with_bind (#g:env) (ctxt:term) (#c1:comp{stateful_comp c1}) (#e1:st_term) (e1_typing:st_typing g e1 c1) (ctxt_pre1_typing:tot_typing g (tm_star ctxt (comp_pre c1)) tm_vprop) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g (tm_star ctxt (comp_pre c1)) (push_binding g (snd x) (fst x) (comp_res c1)) (tm_star (open_term (comp_post c1) (snd x)) ctxt)) = let pre1 = comp_pre c1 in let res1 = comp_res c1 in let post1 = comp_post c1 in let ctxt_typing = star_typing_inversion_l ctxt_pre1_typing in // let p_prop = Metatheory.pure_typing_inversion pure_typing in let v_eq = VE_Comm g ctxt pre1 in let framing_token : frame_for_req_in_ctxt g (tm_star ctxt pre1) pre1 = (| ctxt, ctxt_typing, VE_Comm g pre1 ctxt |) in let (| c1, e1_typing |) = apply_frame ctxt_pre1_typing e1_typing framing_token in let (| u_of_1, pre_typing, _, _ |) = Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness e1_typing))) in let b = res1 in let ppname, x = x in let g' = push_binding g x ppname b in let post1_opened = open_term_nv post1 (v_as_nv x) in let k : continuation_elaborator g (tm_star ctxt pre1) g' (tm_star post1_opened ctxt) = fun post_hint res -> let (| e2, c2, e2_typing |) = res in assert (comp_post_matches_hint c2 post_hint); let e2_typing : st_typing g' e2 c2 = e2_typing in let e2_closed = close_st_term e2 x in assume (open_st_term e2_closed x == e2); assert (comp_pre c1 == (tm_star ctxt pre1)); assert (comp_post c1 == tm_star post1 ctxt); assert (comp_pre c2 == tm_star post1_opened ctxt); assert (open_term (comp_post c1) x == tm_star post1_opened (open_term ctxt x)); // ctxt is well-typed, hence ln assume (open_term ctxt x == ctxt); assert (open_term (comp_post c1) x == comp_pre c2); // we closed e2 with x assume (~ (x `Set.mem` freevars_st e2_closed)); if x `Set.mem` freevars (comp_post c2) then fail g' None "Impossible: freevar clash when constructing continuation elaborator for bind, please file a bug-report" else ( let t_typing, post_typing = Pulse.Typing.Combinators.bind_res_and_post_typing g c2 x post_hint in let g = push_context g "mk_bind" e1.range in // info_doc g None // [prefix 4 1 (doc_of_string "mk_bind e1 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e1)); // prefix 4 1 (doc_of_string "mk_bind c1 = ") (pp #comp c1); // prefix 4 1 (doc_of_string "mk_bind e2 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e2)); // prefix 4 1 (doc_of_string "mk_bind c2 = ") (pp #comp c2)] // ; let (| e, c, e_typing |) = Pulse.Typing.Combinators.mk_bind g (tm_star ctxt pre1) e1 e2_closed c1 c2 (ppname, x) e1_typing u_of_1 e2_typing t_typing post_typing (Some? post_hint) in (| e, c, e_typing |) ) in k #pop-options module LN = Pulse.Typing.LN #push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1" let st_comp_typing_with_post_hint (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g { Some? post_hint }) (c:comp_st { comp_pre c == ctxt /\ comp_post_matches_hint c post_hint }) : st_comp_typing g (st_comp_of_comp c) = let st = st_comp_of_comp c in let Some ph = post_hint in let post_typing_src : tot_typing (push_binding ph.g ph.x ppname_default ph.ret_ty) (open_term ph.post ph.x) tm_vprop = ph.post_typing_src in let x = fresh g in assume (fresh_wrt x g (freevars ph.post)); assume (None? (lookup g ph.x)); let post_typing_src : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = if x = ph.x then post_typing_src else let open Pulse.Typing.Metatheory.Base in let tt : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (subst_term (open_term ph.post ph.x) (renaming ph.x x)) (subst_term tm_vprop (renaming ph.x x)) = tot_typing_renaming1 ph.g ph.x ph.ret_ty (open_term ph.post ph.x) tm_vprop post_typing_src x in assert (subst_term tm_vprop (renaming ph.x x) == tm_vprop); assume (subst_term (open_term ph.post ph.x) (renaming ph.x x) == open_term ph.post x); tt in let post_typing_src : tot_typing (push_binding g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = //weakening: TODO RU.magic () in let ty_typing : universe_of ph.g st.res st.u = ph.ty_typing in let ty_typing : universe_of g st.res st.u = Pulse.Typing.Metatheory.tot_typing_weakening_standard ph.g ty_typing g in assert (st.res == ph.ret_ty); assert (st.post == ph.post); STC g st x ty_typing ctxt_typing post_typing_src let continuation_elaborator_with_bind_fn (#g:env) (#ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (#e1:st_term) (#c1:comp { C_Tot? c1 }) (b:binder{b.binder_ty == comp_res c1}) (e1_typing:st_typing g e1 c1) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g ctxt (push_binding g (snd x) ppname_default (comp_res c1)) ctxt) = let t1 = comp_res c1 in assert ((push_binding g (snd x) (fst x) t1) `env_extends` g); fun post_hint (| e2, c2, d2 |) -> if None? post_hint then T.fail "bind_fn: expects the post_hint to be set"; let ppname, x = x in let e2_closed = close_st_term e2 x in assume (open_st_term (close_st_term e2 x) x == e2); let e = wr c2 (Tm_Bind {binder=b; head=e1; body=e2_closed}) in let (| u, c1_typing |) = Pulse.Typing.Metatheory.Base.st_typing_correctness_ctot e1_typing in let c2_typing : comp_typing g c2 (universe_of_comp c2) = match c2 with | C_ST st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in let i_typing = CP.core_check_term g i T.E_Total tm_inames in CT_STAtomic _ _ obs _ i_typing stc | C_STGhost st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_STGhost _ _ stc in let d : st_typing g e c2 = T_BindFn g e1 e2_closed c1 c2 b x e1_typing u c1_typing d2 c2_typing in (| e, c2, d |) let rec check_equiv_emp (g:env) (vp:term) : option (vprop_equiv g vp tm_emp) = match vp.t with | Tm_Emp -> Some (VE_Refl _ _) | Tm_Star vp1 vp2 -> (match check_equiv_emp g vp1, check_equiv_emp g vp2 with | Some d1, Some d2 -> let d3 : vprop_equiv g (tm_star vp1 vp2) (tm_star tm_emp tm_emp) = VE_Ctxt _ _ _ _ _ d1 d2 in let d4 : vprop_equiv g (tm_star tm_emp tm_emp) tm_emp = VE_Unit _ _ in Some (VE_Trans _ _ _ _ d3 d4) | _, _ -> None) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.LN", "short_module": "LN" }, { "abbrev": false, "full_module": "Pulse.PP", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> i: Pulse.Syntax.Base.term -> _: Pulse.Typing.tot_typing g i Pulse.Syntax.Base.tm_inames -> Pulse.Typing.prop_validity g (Pulse.Typing.tm_inames_subset Pulse.Syntax.Base.tm_emp_inames i)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_inames", "Pulse.RuntimeUtils.magic", "Pulse.Typing.prop_validity", "Pulse.Typing.tm_inames_subset", "Pulse.Syntax.Base.tm_emp_inames" ]
[]
false
false
false
false
false
let emp_inames_included (g: env) (i: term) (_: tot_typing g i tm_inames) : prop_validity g (tm_inames_subset tm_emp_inames i) =
RU.magic ()
false
Steel.ST.Effect.fst
Steel.ST.Effect.weaken_repr
val weaken_repr: a: _ -> framed: _ -> pre: pre_t -> post: post_t a -> req: req_t pre -> req': req_t pre -> ens: ens_t pre a post -> ens': ens_t pre a post -> f: Steel.Effect.repr a framed pre post req ens -> squash (forall (h0: hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0)) -> squash (forall (h0: hmem pre) x (h1: hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1)) -> Tot (Steel.Effect.repr a framed pre post req' ens')
val weaken_repr: a: _ -> framed: _ -> pre: pre_t -> post: post_t a -> req: req_t pre -> req': req_t pre -> ens: ens_t pre a post -> ens': ens_t pre a post -> f: Steel.Effect.repr a framed pre post req ens -> squash (forall (h0: hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0)) -> squash (forall (h0: hmem pre) x (h1: hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1)) -> Tot (Steel.Effect.repr a framed pre post req' ens')
let weaken_repr a framed (pre:pre_t) (post:post_t a) (req req':req_t pre) (ens ens':ens_t pre a post) (f:Steel.Effect.repr a framed pre post req ens) (_:squash (forall (h0:hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_:squash (forall (h0:hmem pre) x (h1:hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') = let focus_rmem_refl (r:vprop) (h:rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z:vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p:vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x. post x `equiv` (post x `star` emp) with ( equiv_star_emp_r (post x); equiv_sym (post x `star` emp) (post x) ); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 26, "end_line": 93, "start_col": 0, "start_line": 38 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v) let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> framed: Prims.bool -> pre: Steel.Effect.Common.pre_t -> post: Steel.Effect.Common.post_t a -> req: Steel.Effect.Common.req_t pre -> req': Steel.Effect.Common.req_t pre -> ens: Steel.Effect.Common.ens_t pre a post -> ens': Steel.Effect.Common.ens_t pre a post -> f: Steel.Effect.repr a framed pre post req ens -> _: Prims.squash (forall (h0: Steel.Effect.Common.hmem pre). req' (Steel.Effect.Common.mk_rmem pre h0) ==> req (Steel.Effect.Common.mk_rmem pre h0)) -> _: Prims.squash (forall (h0: Steel.Effect.Common.hmem pre) (x: a) (h1: Steel.Effect.Common.hmem (post x)). ens (Steel.Effect.Common.mk_rmem pre h0) x (Steel.Effect.Common.mk_rmem (post x) h1) ==> ens' (Steel.Effect.Common.mk_rmem pre h0) x (Steel.Effect.Common.mk_rmem (post x) h1)) -> Steel.Effect.repr a framed pre post req' ens'
Prims.Tot
[ "total" ]
[]
[ "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.req_t", "Steel.Effect.Common.ens_t", "Steel.Effect.repr", "Prims.squash", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "Steel.Effect.Common.mk_rmem", "Steel.Effect.subcomp_opaque", "Steel.Effect.Common.emp", "Prims.l_True", "Prims.unit", "Steel.Effect.Common.equiv_forall", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Prims.Nil", "FStar.Pervasives.pattern", "Steel.Effect.Common.equiv_forall_elim", "FStar.Classical.Sugar.forall_intro", "Steel.Effect.Common.equiv", "Steel.Effect.Common.equiv_sym", "Steel.ST.Effect.equiv_star_emp_r", "Steel.Effect.Common.can_be_split", "Prims.Cons", "FStar.Pervasives.smt_pat", "Steel.Effect.Common.equiv_can_be_split", "Steel.Effect.Common.cm_identity", "Steel.Effect.Common.star_commutative", "Prims.l_and", "Prims.prop", "Steel.Effect.Common.equiv_trans", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Prims.eq2", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.rmem", "Steel.Effect.Common.focus_rmem_refl" ]
[]
false
false
false
false
false
let weaken_repr a framed (pre: pre_t) (post: post_t a) (req: req_t pre) (req': req_t pre) (ens: ens_t pre a post) (ens': ens_t pre a post) (f: Steel.Effect.repr a framed pre post req ens) (_: squash (forall (h0: hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_: squash (forall (h0: hmem pre) x (h1: hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') =
let focus_rmem_refl (r: vprop) (h: rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z: vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p: vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x . (post x) `equiv` ((post x) `star` emp) with (equiv_star_emp_r (post x); equiv_sym ((post x) `star` emp) (post x)); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f
false
Steel.ST.Effect.fst
Steel.ST.Effect.return_
val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p True (fun v -> v == x)
val return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : repr a true (return_pre (p x)) p True (fun v -> v == x)
let return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : Tot (repr a true (return_pre (p x)) p True (fun v -> v == x)) = let k : Steel.Effect.repr a true (p x) p (fun _ -> True) (return_ens a x p) = Steel.Effect.return_ a x #p in weaken_repr _ _ _ _ _ _ _ _ k () ()
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 107, "start_col": 0, "start_line": 96 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v) let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p let weaken_repr a framed (pre:pre_t) (post:post_t a) (req req':req_t pre) (ens ens':ens_t pre a post) (f:Steel.Effect.repr a framed pre post req ens) (_:squash (forall (h0:hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_:squash (forall (h0:hmem pre) x (h1:hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') = let focus_rmem_refl (r:vprop) (h:rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z:vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p:vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x. post x `equiv` (post x `star` emp) with ( equiv_star_emp_r (post x); equiv_sym (post x `star` emp) (post x) ); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> x: a -> Steel.ST.Effect.repr a true (Steel.Effect.Common.return_pre (p x)) p Prims.l_True (fun v -> v == x)
Prims.Tot
[ "total" ]
[]
[ "Steel.Effect.Common.vprop", "Steel.ST.Effect.weaken_repr", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Prims.l_True", "Steel.Effect.Common.rmem", "Steel.Effect.Common.return_pre", "Prims.l_and", "Prims.eq2", "FStar.Tactics.Effect.rewrite_with_tactic", "Steel.Effect.Common.frame_vc_norm", "Steel.Effect.Common.frame_equalities'", "Steel.Effect.Common.focus_rmem", "Steel.Effect.repr", "Steel.Effect.return_", "Steel.ST.Effect.repr" ]
[]
false
false
false
false
false
let return_ (a: Type) (x: a) (#[@@@ framing_implicit]p: (a -> vprop)) : Tot (repr a true (return_pre (p x)) p True (fun v -> v == x)) =
let k:Steel.Effect.repr a true (p x) p (fun _ -> True) (return_ens a x p) = Steel.Effect.return_ a x #p in weaken_repr _ _ _ _ _ _ _ _ k () ()
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.of_arg
val of_arg (i: IX64.reg_nat 3) : MS.reg_64
val of_arg (i: IX64.reg_nat 3) : MS.reg_64
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 120, "start_col": 0, "start_line": 117 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
i: Vale.Interop.X64.reg_nat 3 -> Vale.X64.Machine_s.reg_64
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.reg_nat", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.reg_64" ]
[]
false
false
false
false
false
let of_arg (i: IX64.reg_nat 3) : MS.reg_64 =
match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_add1
val lowstar_add1:lowstar_add1_t
val lowstar_add1:lowstar_add1_t
let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 68, "end_line": 151, "start_col": 0, "start_line": 142 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Inline.X64.Fadd_inline.lowstar_add1_t
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.wrap_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.add1_regs_modified", "Vale.Inline.X64.Fadd_inline.add1_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_add1", "Vale.Inline.X64.Fadd_inline.dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Inline.X64.Fadd_inline.add1_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.add1_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.add1_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
false
let lowstar_add1:lowstar_add1_t =
assert_norm (List.length dom + List.length ([] <: list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_code_inline
val add1_code_inline: Prims.unit -> FStar.All.ML int
val add1_code_inline: Prims.unit -> FStar.All.ML int
let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 120, "end_line": 175, "start_col": 0, "start_line": 174 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.int
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.X64.Print_Inline_s.print_inline", "FStar.Pervasives.Native.None", "Prims.string", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Vale.Inline.X64.Fadd_inline.dom", "Vale.Inline.X64.Fadd_inline.add1_names", "Vale.Inline.X64.Fadd_inline.code_add1", "Vale.Inline.X64.Fadd_inline.of_arg", "Vale.Inline.X64.Fadd_inline.add1_regs_modified", "Vale.Inline.X64.Fadd_inline.add1_comments", "Prims.int" ]
[]
false
true
false
false
false
let add1_code_inline () : FStar.All.ML int =
PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.arg_reg
val arg_reg:IX64.arg_reg_relation 3
val arg_reg:IX64.arg_reg_relation 3
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 62, "end_line": 122, "start_col": 0, "start_line": 122 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
v: Vale.Interop.X64.arg_reg_relation' 3 { forall (r: Vale.X64.Machine_s.reg_64). {:pattern Rel?.of_reg v r} Some? (Rel?.of_reg v r) ==> Rel?.of_arg v (Some?.v (Rel?.of_reg v r)) = r }
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.Rel", "Vale.Inline.X64.Fadd_inline.of_reg", "Vale.Inline.X64.Fadd_inline.of_arg" ]
[]
false
false
false
false
false
let arg_reg:IX64.arg_reg_relation 3 =
IX64.Rel of_reg of_arg
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.apply_conversion
val apply_conversion (#g: env) (#e: term) (#eff: _) (#t0: term) (d: typing g e eff t0) (#t1: term) (eq: Ghost.erased (RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1))) : typing g e eff t1
val apply_conversion (#g: env) (#e: term) (#eff: _) (#t0: term) (d: typing g e eff t0) (#t1: term) (eq: Ghost.erased (RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1))) : typing g e eff t1
let apply_conversion (#g:env) (#e:term) (#eff:_) (#t0:term) (d:typing g e eff t0) (#t1:term) (eq:Ghost.erased (RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1))) : typing g e eff t1 = let d : RT.typing (elab_env g) (elab_term e) (eff, (elab_term t0)) = d._0 in let r : RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1) = eq in let r = RT.Rel_equiv _ _ _ RT.R_Sub r in let s : RT.sub_comp (elab_env g) (eff, (elab_term t0)) (eff, elab_term t1) = RT.Relc_typ _ _ _ _ _ r in E (RT.T_Sub _ _ _ _ d s)
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 28, "end_line": 784, "start_col": 0, "start_line": 772 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre} let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (pre:term) (veq: vprop_equiv g (comp_pre c) pre) : st_typing g t (comp_with_pre c pre) = if eq_tm pre (comp_pre c) then d else let c' = comp_with_pre c pre in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _) in t_equiv d st_equiv #push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0" let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term) (k:continuation_elaborator g1 ctxt g2 ctxt1) (d:vprop_equiv g2 ctxt1 ctxt2) : continuation_elaborator g1 ctxt g2 ctxt2 = fun post_hint res -> let (| st, c, st_d |) = res in let st_d : st_typing g2 st c = st_d in assert (comp_pre c == ctxt2); let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in k post_hint (| st, _, st_d' |) #pop-options let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g ctxt p) : tot_typing g p tm_vprop = let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing #push-options "--z3rlimit_factor 4 --ifuel 1 --fuel 0" let k_elab_equiv_prefix (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt2 #ctxt:term) (k:continuation_elaborator g1 ctxt1 g2 ctxt) (d:vprop_equiv g1 ctxt1 ctxt2) : continuation_elaborator g1 ctxt2 g2 ctxt = fun post_hint res -> let framing_token : frame_for_req_in_ctxt g1 ctxt2 ctxt1 = let d = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Trans _ _ _ _ (VE_Unit _ _) d) in (| tm_emp, emp_typing, d |) in let res = k post_hint res in let (| st, c, st_d |) = res in assert (comp_pre c == ctxt1); (| _, _, st_equiv_pre st_d _ d |) #pop-options let k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2' = let k : continuation_elaborator g1 ctxt1 g2 ctxt2' = k_elab_equiv_continuation k d2 in let k : continuation_elaborator g1 ctxt1' g2 ctxt2' = k_elab_equiv_prefix k d1 in k #push-options "--query_stats --fuel 2 --ifuel 2 --split_queries no --z3rlimit_factor 20" open Pulse.PP let continuation_elaborator_with_bind (#g:env) (ctxt:term) (#c1:comp{stateful_comp c1}) (#e1:st_term) (e1_typing:st_typing g e1 c1) (ctxt_pre1_typing:tot_typing g (tm_star ctxt (comp_pre c1)) tm_vprop) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g (tm_star ctxt (comp_pre c1)) (push_binding g (snd x) (fst x) (comp_res c1)) (tm_star (open_term (comp_post c1) (snd x)) ctxt)) = let pre1 = comp_pre c1 in let res1 = comp_res c1 in let post1 = comp_post c1 in let ctxt_typing = star_typing_inversion_l ctxt_pre1_typing in // let p_prop = Metatheory.pure_typing_inversion pure_typing in let v_eq = VE_Comm g ctxt pre1 in let framing_token : frame_for_req_in_ctxt g (tm_star ctxt pre1) pre1 = (| ctxt, ctxt_typing, VE_Comm g pre1 ctxt |) in let (| c1, e1_typing |) = apply_frame ctxt_pre1_typing e1_typing framing_token in let (| u_of_1, pre_typing, _, _ |) = Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness e1_typing))) in let b = res1 in let ppname, x = x in let g' = push_binding g x ppname b in let post1_opened = open_term_nv post1 (v_as_nv x) in let k : continuation_elaborator g (tm_star ctxt pre1) g' (tm_star post1_opened ctxt) = fun post_hint res -> let (| e2, c2, e2_typing |) = res in assert (comp_post_matches_hint c2 post_hint); let e2_typing : st_typing g' e2 c2 = e2_typing in let e2_closed = close_st_term e2 x in assume (open_st_term e2_closed x == e2); assert (comp_pre c1 == (tm_star ctxt pre1)); assert (comp_post c1 == tm_star post1 ctxt); assert (comp_pre c2 == tm_star post1_opened ctxt); assert (open_term (comp_post c1) x == tm_star post1_opened (open_term ctxt x)); // ctxt is well-typed, hence ln assume (open_term ctxt x == ctxt); assert (open_term (comp_post c1) x == comp_pre c2); // we closed e2 with x assume (~ (x `Set.mem` freevars_st e2_closed)); if x `Set.mem` freevars (comp_post c2) then fail g' None "Impossible: freevar clash when constructing continuation elaborator for bind, please file a bug-report" else ( let t_typing, post_typing = Pulse.Typing.Combinators.bind_res_and_post_typing g c2 x post_hint in let g = push_context g "mk_bind" e1.range in // info_doc g None // [prefix 4 1 (doc_of_string "mk_bind e1 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e1)); // prefix 4 1 (doc_of_string "mk_bind c1 = ") (pp #comp c1); // prefix 4 1 (doc_of_string "mk_bind e2 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e2)); // prefix 4 1 (doc_of_string "mk_bind c2 = ") (pp #comp c2)] // ; let (| e, c, e_typing |) = Pulse.Typing.Combinators.mk_bind g (tm_star ctxt pre1) e1 e2_closed c1 c2 (ppname, x) e1_typing u_of_1 e2_typing t_typing post_typing (Some? post_hint) in (| e, c, e_typing |) ) in k #pop-options module LN = Pulse.Typing.LN #push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1" let st_comp_typing_with_post_hint (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g { Some? post_hint }) (c:comp_st { comp_pre c == ctxt /\ comp_post_matches_hint c post_hint }) : st_comp_typing g (st_comp_of_comp c) = let st = st_comp_of_comp c in let Some ph = post_hint in let post_typing_src : tot_typing (push_binding ph.g ph.x ppname_default ph.ret_ty) (open_term ph.post ph.x) tm_vprop = ph.post_typing_src in let x = fresh g in assume (fresh_wrt x g (freevars ph.post)); assume (None? (lookup g ph.x)); let post_typing_src : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = if x = ph.x then post_typing_src else let open Pulse.Typing.Metatheory.Base in let tt : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (subst_term (open_term ph.post ph.x) (renaming ph.x x)) (subst_term tm_vprop (renaming ph.x x)) = tot_typing_renaming1 ph.g ph.x ph.ret_ty (open_term ph.post ph.x) tm_vprop post_typing_src x in assert (subst_term tm_vprop (renaming ph.x x) == tm_vprop); assume (subst_term (open_term ph.post ph.x) (renaming ph.x x) == open_term ph.post x); tt in let post_typing_src : tot_typing (push_binding g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = //weakening: TODO RU.magic () in let ty_typing : universe_of ph.g st.res st.u = ph.ty_typing in let ty_typing : universe_of g st.res st.u = Pulse.Typing.Metatheory.tot_typing_weakening_standard ph.g ty_typing g in assert (st.res == ph.ret_ty); assert (st.post == ph.post); STC g st x ty_typing ctxt_typing post_typing_src let continuation_elaborator_with_bind_fn (#g:env) (#ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (#e1:st_term) (#c1:comp { C_Tot? c1 }) (b:binder{b.binder_ty == comp_res c1}) (e1_typing:st_typing g e1 c1) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g ctxt (push_binding g (snd x) ppname_default (comp_res c1)) ctxt) = let t1 = comp_res c1 in assert ((push_binding g (snd x) (fst x) t1) `env_extends` g); fun post_hint (| e2, c2, d2 |) -> if None? post_hint then T.fail "bind_fn: expects the post_hint to be set"; let ppname, x = x in let e2_closed = close_st_term e2 x in assume (open_st_term (close_st_term e2 x) x == e2); let e = wr c2 (Tm_Bind {binder=b; head=e1; body=e2_closed}) in let (| u, c1_typing |) = Pulse.Typing.Metatheory.Base.st_typing_correctness_ctot e1_typing in let c2_typing : comp_typing g c2 (universe_of_comp c2) = match c2 with | C_ST st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in let i_typing = CP.core_check_term g i T.E_Total tm_inames in CT_STAtomic _ _ obs _ i_typing stc | C_STGhost st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_STGhost _ _ stc in let d : st_typing g e c2 = T_BindFn g e1 e2_closed c1 c2 b x e1_typing u c1_typing d2 c2_typing in (| e, c2, d |) let rec check_equiv_emp (g:env) (vp:term) : option (vprop_equiv g vp tm_emp) = match vp.t with | Tm_Emp -> Some (VE_Refl _ _) | Tm_Star vp1 vp2 -> (match check_equiv_emp g vp1, check_equiv_emp g vp2 with | Some d1, Some d2 -> let d3 : vprop_equiv g (tm_star vp1 vp2) (tm_star tm_emp tm_emp) = VE_Ctxt _ _ _ _ _ d1 d2 in let d4 : vprop_equiv g (tm_star tm_emp tm_emp) tm_emp = VE_Unit _ _ in Some (VE_Trans _ _ _ _ d3 d4) | _, _ -> None) | _ -> None let emp_inames_included (g:env) (i:term) (_:tot_typing g i tm_inames) : prop_validity g (tm_inames_subset tm_emp_inames i) = RU.magic() let return_in_ctxt (g:env) (y:var) (y_ppname:ppname) (u:universe) (ty:term) (ctxt:vprop) (ty_typing:universe_of g ty u) (post_hint0:post_hint_opt g { Some? post_hint0 /\ checker_res_matches_post_hint g post_hint0 y ty ctxt}) : Pure (st_typing_in_ctxt g ctxt post_hint0) (requires lookup g y == Some ty) (ensures fun _ -> True) = let Some post_hint = post_hint0 in let x = fresh g in assume (~ (x `Set.mem` freevars post_hint.post)); let ctag = match post_hint.effect_annot with | EffectAnnotAtomic _ -> STT_Atomic | EffectAnnotGhost -> STT_Ghost | _ -> STT in let y_tm = tm_var {nm_index=y;nm_ppname=y_ppname} in let d = T_Return g ctag false u ty y_tm post_hint.post x ty_typing (RU.magic ()) // that null_var y is well typed at ty in g, we know since lookup g y == Some ty (RU.magic ()) // typing of (open post x) in (g, x) ... post_hint is well-typed, so should get in let t = wtag (Some ctag) (Tm_Return {expected_type=tm_unknown;insert_eq=false;term=y_tm}) in let c = comp_return ctag false u ty y_tm post_hint.post x in let d : st_typing g t c = d in assume (comp_u c == post_hint.u); // this u should follow from equality of t match c, post_hint.effect_annot with | C_STAtomic _ obs _, EffectAnnotAtomic { opens } -> assert (comp_inames c == tm_emp_inames); let pht = post_hint_typing g post_hint x in let validity = emp_inames_included g opens pht.effect_annot_typing in let d = T_Sub _ _ _ _ d (STS_AtomicInvs _ (st_comp_of_comp c) tm_emp_inames opens obs obs validity) in (| _, _, d |) | _ -> (| _, _, d |) let match_comp_res_with_post_hint (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post_hint:post_hint_opt g) : T.Tac (t':st_term & c':comp_st & st_typing g t' c') = match post_hint with | None -> (| t, c, d |) | Some { ret_ty } -> let cres = comp_res c in if eq_tm cres ret_ty then (| t, c, d |) else match Pulse.Checker.Pure.check_equiv g cres ret_ty with | None -> fail g (Some t.range) (Printf.sprintf "Could not prove equiv for computed type %s and expected type %s" (P.term_to_string cres) (P.term_to_string ret_ty)) | Some tok -> let d_equiv : RT.equiv _ (elab_term cres) (elab_term ret_ty) = RT.Rel_eq_token _ _ _ (FStar.Squash.return_squash tok) in let c' = with_st_comp c {(st_comp_of_comp c) with res = ret_ty } in let (| cres_typing, cpre_typing, x, cpost_typing |) = st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness d)) in let d_stequiv : st_equiv g c c' = ST_VPropEquiv _ c c' _ cpre_typing cres_typing cpost_typing d_equiv (VE_Refl _ _) (VE_Refl _ _) in (| t, c', T_Equiv _ _ _ _ d d_stequiv |) let apply_checker_result_k (#g:env) (#ctxt:vprop) (#post_hint:post_hint_for_env g) (r:checker_result_t g ctxt (Some post_hint)) (res_ppname:ppname) : T.Tac (st_typing_in_ctxt g ctxt (Some post_hint)) = // TODO: FIXME add to checker result type? let (| y, g1, (| u_ty, ty_y, d_ty_y |), (| pre', _ |), k |) = r in let (| u_ty_y, d_ty_y |) = Pulse.Checker.Pure.check_universe g1 ty_y in let d : st_typing_in_ctxt g1 pre' (Some post_hint) = return_in_ctxt g1 y res_ppname u_ty_y ty_y pre' d_ty_y (Some post_hint) in k (Some post_hint) d #push-options "--z3rlimit_factor 4 --fuel 0 --ifuel 1 --query_stats" let checker_result_for_st_typing (#g:env) (#ctxt:vprop) (#post_hint:post_hint_opt g) (d:st_typing_in_ctxt g ctxt post_hint) (ppname:ppname) : T.Tac (checker_result_t g ctxt post_hint) = let (| t, c, d |) = d in let x = fresh g in let g' = push_binding g x ppname (comp_res c) in let ctxt' = open_term_nv (comp_post c) (ppname, x) in let k : continuation_elaborator g (tm_star tm_emp (comp_pre c)) g' (tm_star ctxt' tm_emp) = continuation_elaborator_with_bind tm_emp d (RU.magic ()) (ppname, x) in let k : continuation_elaborator g (comp_pre c) g' ctxt' = k_elab_equiv k (RU.magic ()) (RU.magic ()) in let _ : squash (checker_res_matches_post_hint g post_hint x (comp_res c) ctxt') = match post_hint with | None -> () | Some post_hint -> () in assert (g' `env_extends` g); let comp_res_typing, _, f = Metatheory.(st_comp_typing_inversion_cofinite (fst <| comp_typing_inversion (st_typing_correctness d))) in // RU.magic is the typing of comp_res in g' // weaken comp_res_typing assume (~ (x `Set.mem` freevars (comp_post c))); let tt : universe_of _ _ _ = RU.magic () in (| x, g', (| comp_u c, comp_res c, tt |), (| ctxt', f x |), k |) #pop-options module R = FStar.Reflection.V2 let readback_comp_res_as_comp (c:T.comp) : option comp = match c with | T.C_Total t -> ( match readback_comp t with | None -> None | Some c -> Some c ) | _ -> None let rec is_stateful_arrow (g:env) (c:option comp) (args:list T.argv) (out:list T.argv) : T.Tac (option (list T.argv & T.argv)) = let open R in match c with | None -> None | Some (C_ST _) | Some (C_STGhost _) | Some (C_STAtomic _ _ _) -> ( match args, out with | [], hd::tl -> Some (List.rev tl, hd) | _ -> None //leftover or not enough args ) | Some (C_Tot c_res) -> ( if not (Tm_FStar? c_res.t) then None else ( let Tm_FStar c_res = c_res.t in let ht = T.inspect c_res in match ht with | T.Tv_Arrow b c -> ( match args with | [] -> ( //no more args; check that only implicits remain, ending in an stateful comp let bs, c = T.collect_arr_ln_bs c_res in if List.Tot.for_all (fun b -> R.Q_Implicit? (R.inspect_binder b).qual) bs then is_stateful_arrow g (readback_comp_res_as_comp (R.inspect_comp c)) [] out else None //too few args ) | (arg, qual)::args' -> ( //check that this arg qual matches the binder and recurse accordingly match b.qual, qual with | T.Q_Meta _, T.Q_Implicit | T.Q_Implicit, T.Q_Implicit | T.Q_Explicit, T.Q_Explicit -> //consume this argument is_stateful_arrow g (readback_comp_res_as_comp c) args' ((arg, qual)::out) | T.Q_Meta _, T.Q_Explicit | T.Q_Implicit, T.Q_Explicit -> //don't consume this argument is_stateful_arrow g (readback_comp_res_as_comp c) args out | _ -> None //incompatible qualifiers; bail ) ) | _ -> let c_res' = RU.whnf_lax (elab_env g) c_res in let ht = T.inspect c_res' in if T.Tv_Arrow? ht then ( assume (not_tv_unknown c_res'); let c_res' = tm_fstar c_res' (T.range_of_term c_res') in is_stateful_arrow g (Some (C_Tot c_res')) args out ) else None ) ) module RU = Pulse.RuntimeUtils let is_stateful_application (g:env) (e:term) : T.Tac (option st_term) = match e.t with | Tm_FStar host_term -> ( let head, args = T.collect_app_ln host_term in assume (not_tv_unknown head); match RU.lax_check_term_with_unknown_universes (elab_env g) head with | None -> None | Some ht -> assume (not_tv_unknown ht); let head_t = tm_fstar ht (T.range_of_term ht) in match is_stateful_arrow g (Some (C_Tot head_t)) args [] with | None -> None | Some (applied_args, (last_arg, aqual))-> let head = T.mk_app head applied_args in assume (not_tv_unknown head); let head = tm_fstar head (T.range_of_term head) in assume (not_tv_unknown last_arg); let last_arg = tm_fstar last_arg (T.range_of_term last_arg) in let qual = match aqual with | T.Q_Implicit -> Some Implicit | _ -> None in let st_app = Tm_STApp { head; arg=last_arg; arg_qual=qual} in let st_app = { term = st_app; range=e.range; effect_tag=default_effect_hint } in Some st_app ) | _ -> None
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "Pulse.Typing.LN", "short_module": "LN" }, { "abbrev": false, "full_module": "Pulse.PP", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: Pulse.Typing.typing g e eff t0 -> eq: FStar.Ghost.erased (FStar.Reflection.Typing.related (Pulse.Typing.elab_env g) (Pulse.Elaborate.Pure.elab_term t0) FStar.Reflection.Typing.R_Eq (Pulse.Elaborate.Pure.elab_term t1)) -> Pulse.Typing.typing g e eff t1
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "FStar.Stubs.TypeChecker.Core.tot_or_ghost", "Pulse.Typing.typing", "FStar.Ghost.erased", "FStar.Reflection.Typing.related", "Pulse.Typing.elab_env", "Pulse.Elaborate.Pure.elab_term", "FStar.Reflection.Typing.R_Eq", "Pulse.Typing.E", "FStar.Reflection.Typing.typing", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.typ", "FStar.Reflection.Typing.T_Sub", "FStar.Reflection.Typing.sub_comp", "FStar.Reflection.Typing.Relc_typ", "FStar.Reflection.Typing.R_Sub", "FStar.Reflection.Typing.Rel_equiv", "FStar.Ghost.reveal", "Pulse.Typing.__proj__E__item___0" ]
[]
false
false
false
false
false
let apply_conversion (#g: env) (#e: term) (#eff: _) (#t0: term) (d: typing g e eff t0) (#t1: term) (eq: Ghost.erased (RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1))) : typing g e eff t1 =
let d:RT.typing (elab_env g) (elab_term e) (eff, (elab_term t0)) = d._0 in let r:RT.related (elab_env g) (elab_term t0) RT.R_Eq (elab_term t1) = eq in let r = RT.Rel_equiv _ _ _ RT.R_Sub r in let s:RT.sub_comp (elab_env g) (eff, (elab_term t0)) (eff, elab_term t1) = RT.Relc_typ _ _ _ _ _ r in E (RT.T_Sub _ _ _ _ d s)
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_regs_modified
val fadd_regs_modified: MS.reg_64 -> bool
val fadd_regs_modified: MS.reg_64 -> bool
let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 211, "start_col": 0, "start_line": 208 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50"
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Vale.X64.Machine_s.reg_64 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg_64", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR11", "Prims.bool" ]
[]
false
false
false
true
false
let fadd_regs_modified: MS.reg_64 -> bool =
fun (r: MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
false
Steel.ST.Effect.fst
Steel.ST.Effect.bind_pure_st_
val bind_pure_st_ (a:Type) (b:Type) (#[@@@ framing_implicit] wp:pure_wp a) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] req:a -> pure_pre) (#[@@@ framing_implicit] ens:a -> pure_post b) (f:eqtype_as_type unit -> PURE a wp) (g:(x:a -> repr b framed pre post (req x) (ens x))) : repr b framed pre post (bind_pure_st_req wp req) (bind_pure_st_ens wp ens)
val bind_pure_st_ (a:Type) (b:Type) (#[@@@ framing_implicit] wp:pure_wp a) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] req:a -> pure_pre) (#[@@@ framing_implicit] ens:a -> pure_post b) (f:eqtype_as_type unit -> PURE a wp) (g:(x:a -> repr b framed pre post (req x) (ens x))) : repr b framed pre post (bind_pure_st_req wp req) (bind_pure_st_ens wp ens)
let bind_pure_st_ (a:Type) (b:Type) (#[@@@ framing_implicit] wp:pure_wp a) (#framed:eqtype_as_type bool) (#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] req:a -> Type0) (#[@@@ framing_implicit] ens:a -> b -> Type0) (f:eqtype_as_type unit -> PURE a wp) (g:(x:a -> repr b framed pre post (req x) (ens x))) : repr b framed pre post (bind_pure_st_req wp req) (bind_pure_st_ens wp ens) = let c : Steel.Effect.repr b framed pre post (bind_pure_steel__req wp (fun x _ -> req x)) (bind_pure_steel__ens wp (fun x _ y _ -> ens x y)) =(Steel.Effect.bind_pure_steel_ a b #wp #framed #pre #post #(fun x _ -> req x) #(fun x _ y _ -> ens x y) f g) in FStar.Monotonic.Pure.elim_pure_wp_monotonicity #a wp; weaken_repr _ _ _ _ _ _ _ _ c () ()
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 39, "end_line": 231, "start_col": 0, "start_line": 198 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v) let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p let weaken_repr a framed (pre:pre_t) (post:post_t a) (req req':req_t pre) (ens ens':ens_t pre a post) (f:Steel.Effect.repr a framed pre post req ens) (_:squash (forall (h0:hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_:squash (forall (h0:hmem pre) x (h1:hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') = let focus_rmem_refl (r:vprop) (h:rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z:vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p:vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x. post x `equiv` (post x `star` emp) with ( equiv_star_emp_r (post x); equiv_sym (post x `star` emp) (post x) ); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f let return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : Tot (repr a true (return_pre (p x)) p True (fun v -> v == x)) = let k : Steel.Effect.repr a true (p x) p (fun _ -> True) (return_ens a x p) = Steel.Effect.return_ a x #p in weaken_repr _ _ _ _ _ _ _ _ k () () let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:Type0) (#[@@@ framing_implicit] ens_f:a -> Type0) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(a -> Type0)) (#[@@@ framing_implicit] ens_g:(a -> b -> Type0)) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _x1: squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _x2: squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) = let c = Steel.Effect.bind a b #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun x _ -> req_g x) #(fun x _ y _ -> ens_g x y) #frame_f #frame_g #post #_x1 #_x2 #pr #p1 #p2 f g in weaken_repr _ _ _ _ _ _ _ _ c () () let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:Type0) (#[@@@ framing_implicit] ens_f:a -> Type0) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:Type0) (#[@@@ framing_implicit] ens_g:a -> Type0) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _x1 : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash ( can_be_split pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash ( equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x))) (ensures fun _ -> True) = weaken_repr _ _ _ _ _ _ _ _ (Steel.Effect.subcomp a #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun _ -> req_g) #(fun _ x _ -> ens_g x) #frame #_x1 #True #p1 #p2 f) () ()
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> Prims.PURE a) -> g: (x: a -> Steel.ST.Effect.repr b framed pre post (req x) (ens x)) -> Steel.ST.Effect.repr b framed pre post (Steel.ST.Effect.bind_pure_st_req wp req) (Steel.ST.Effect.bind_pure_st_ens wp ens)
Prims.Tot
[ "total" ]
[]
[ "Prims.pure_wp", "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Prims.unit", "Steel.ST.Effect.repr", "Steel.ST.Effect.weaken_repr", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Prims.l_True", "Steel.Effect.Common.rmem", "Steel.ST.Effect.bind_pure_st_req", "Prims.l_and", "Prims.l_Exists", "Prims.l_not", "Prims.eq2", "Steel.ST.Effect.bind_pure_st_ens", "FStar.Monotonic.Pure.elim_pure_wp_monotonicity", "Steel.Effect.repr", "Steel.Effect.bind_pure_steel_" ]
[]
false
false
false
false
false
let bind_pure_st_ (a b: Type) (#[@@@ framing_implicit]wp: pure_wp a) (#framed: eqtype_as_type bool) (#[@@@ framing_implicit]pre: pre_t) (#[@@@ framing_implicit]post: post_t b) (#[@@@ framing_implicit]req: (a -> Type0)) (#[@@@ framing_implicit]ens: (a -> b -> Type0)) (f: (eqtype_as_type unit -> PURE a wp)) (g: (x: a -> repr b framed pre post (req x) (ens x))) : repr b framed pre post (bind_pure_st_req wp req) (bind_pure_st_ens wp ens) =
let c:Steel.Effect.repr b framed pre post (bind_pure_steel__req wp (fun x _ -> req x)) (bind_pure_steel__ens wp (fun x _ y _ -> ens x y)) = (Steel.Effect.bind_pure_steel_ a b #wp #framed #pre #post #(fun x _ -> req x) #(fun x _ y _ -> ens x y) f g) in FStar.Monotonic.Pure.elim_pure_wp_monotonicity #a wp; weaken_repr _ _ _ _ _ _ _ _ c () ()
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_dom
val fadd_dom:IX64.arity_ok_stdcall td
val fadd_dom:IX64.arity_ok_stdcall td
let fadd_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 182, "start_col": 0, "start_line": 179 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Inline.X64.Fadd_inline.t64_mod", "Vale.Inline.X64.Fadd_inline.t64_no_mod", "Prims.Nil" ]
[]
false
false
false
true
false
let fadd_dom:IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_bn
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 338, "start_col": 0, "start_line": 310 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_bn_st t ke modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Prims.bool", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb", "Hacl.Impl.RSAPSS.bn_lt_pow2", "Prims.unit", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Exponentiation.mk_bn_mod_exp_precompr2", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_vt_precomp", "Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n_lemma", "Prims.op_Subtraction", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "Hacl.Spec.Bignum.bn_lt_mask_lemma", "Hacl.Bignum.bn_lt_mask", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Multiply", "Hacl.Spec.Bignum.Definitions.blocks" ]
[]
false
false
false
false
false
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@@ inline_let ]let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then (Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false) else false in res
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_lemma
val add1_lemma : Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.add1_regs_modified Vale.Inline.X64.Fadd_inline.add1_xmms_modified Vale.Inline.X64.Fadd_inline.add1_pre Vale.Inline.X64.Fadd_inline.add1_post
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 107, "end_line": 107, "start_col": 0, "start_line": 107 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.add1_regs_modified Vale.Inline.X64.Fadd_inline.add1_xmms_modified Vale.Inline.X64.Fadd_inline.add1_pre Vale.Inline.X64.Fadd_inline.add1_post
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_t", "Vale.AsLowStar.ValeSig.vale_sig", "Vale.Inline.X64.Fadd_inline.dom", "Vale.Inline.X64.Fadd_inline.add1_regs_modified", "Vale.Inline.X64.Fadd_inline.add1_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.add1_pre", "Vale.Inline.X64.Fadd_inline.add1_post", "Vale.Inline.X64.Fadd_inline.add1_lemma'" ]
[]
false
false
false
true
false
let add1_lemma =
as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
false
Steel.ST.Effect.fst
Steel.ST.Effect.bind
val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:pure_pre) (#[@@@ framing_implicit] ens_f:pure_post a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:a -> pure_pre) (#[@@@ framing_implicit] ens_g:(a -> pure_post b)) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req a req_f ens_f pr req_g) (bind_ens a b ens_f ens_g)
val bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:pure_pre) (#[@@@ framing_implicit] ens_f:pure_post a) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:a -> pure_pre) (#[@@@ framing_implicit] ens_g:(a -> pure_post b)) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _ : squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) : repr b true (pre_f `star` frame_f) post (bind_req a req_f ens_f pr req_g) (bind_ens a b ens_f ens_g)
let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:Type0) (#[@@@ framing_implicit] ens_f:a -> Type0) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(a -> Type0)) (#[@@@ framing_implicit] ens_g:(a -> b -> Type0)) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _x1: squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _x2: squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) = let c = Steel.Effect.bind a b #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun x _ -> req_g x) #(fun x _ y _ -> ens_g x y) #frame_f #frame_g #post #_x1 #_x2 #pr #p1 #p2 f g in weaken_repr _ _ _ _ _ _ _ _ c () ()
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 41, "end_line": 153, "start_col": 0, "start_line": 109 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v) let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p let weaken_repr a framed (pre:pre_t) (post:post_t a) (req req':req_t pre) (ens ens':ens_t pre a post) (f:Steel.Effect.repr a framed pre post req ens) (_:squash (forall (h0:hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_:squash (forall (h0:hmem pre) x (h1:hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') = let focus_rmem_refl (r:vprop) (h:rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z:vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p:vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x. post x `equiv` (post x `star` emp) with ( equiv_star_emp_r (post x); equiv_sym (post x `star` emp) (post x) ); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f let return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : Tot (repr a true (return_pre (p x)) p True (fun v -> v == x)) = let k : Steel.Effect.repr a true (p x) p (fun _ -> True) (return_ens a x p) = Steel.Effect.return_ a x #p in weaken_repr _ _ _ _ _ _ _ _ k () ()
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> b: Type -> f: Steel.ST.Effect.repr a framed_f pre_f post_f req_f ens_f -> g: (x: a -> Steel.ST.Effect.repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x)) -> Steel.ST.Effect.repr b true (Steel.Effect.Common.star pre_f frame_f) post (Steel.ST.Effect.bind_req a req_f ens_f pr req_g) (Steel.ST.Effect.bind_ens a b ens_f ens_g)
Prims.Tot
[ "total" ]
[]
[ "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.maybe_emp", "Steel.Effect.Common.maybe_emp_dep", "Prims.prop", "Steel.Effect.Common.can_be_split_forall_dep", "Steel.Effect.Common.star", "Steel.Effect.Common.can_be_split_post", "Steel.ST.Effect.repr", "Steel.ST.Effect.weaken_repr", "Steel.Effect.bind_req", "Steel.Effect.Common.rmem", "Steel.ST.Effect.bind_req", "Steel.Effect.bind_ens", "Steel.ST.Effect.bind_ens", "Steel.Effect.repr", "Steel.Effect.Common.rmem'", "Steel.Effect.Common.valid_rmem", "Prims.l_and", "Prims.l_Forall", "Steel.Effect.Common.hmem", "Prims.l_imp", "FStar.Tactics.Effect.rewrite_with_tactic", "Steel.Effect.Common.frame_vc_norm", "Steel.Effect.Common.frame_equalities'", "Steel.Effect.Common.focus_rmem", "Steel.Effect.Common.mk_rmem", "Prims.l_Exists", "Steel.Effect.bind" ]
[]
false
false
false
false
false
let bind (a b: Type) (#framed_f #framed_g: eqtype_as_type bool) (#[@@@ framing_implicit]pre_f: pre_t) (#[@@@ framing_implicit]post_f: post_t a) (#[@@@ framing_implicit]req_f: Type0) (#[@@@ framing_implicit]ens_f: (a -> Type0)) (#[@@@ framing_implicit]pre_g: (a -> pre_t)) (#[@@@ framing_implicit]post_g: (a -> post_t b)) (#[@@@ framing_implicit]req_g: (a -> Type0)) (#[@@@ framing_implicit]ens_g: (a -> b -> Type0)) (#[@@@ framing_implicit]frame_f: vprop) (#[@@@ framing_implicit]frame_g: (a -> vprop)) (#[@@@ framing_implicit]post: post_t b) (#[@@@ framing_implicit]_x1: squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit]_x2: squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit]pr: (a -> prop)) (#[@@@ framing_implicit]p1: squash (can_be_split_forall_dep pr (fun x -> (post_f x) `star` frame_f) (fun x -> (pre_g x) `star` (frame_g x)))) (#[@@@ framing_implicit]p2: squash (can_be_split_post (fun x y -> (post_g x y) `star` (frame_g x)) post)) (f: repr a framed_f pre_f post_f req_f ens_f) (g: (x: a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) =
let c = Steel.Effect.bind a b #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun x _ -> req_g x) #(fun x _ y _ -> ens_g x y) #frame_f #frame_g #post #_x1 #_x2 #pr #p1 #p2 f g in weaken_repr _ _ _ _ _ _ _ _ c () ()
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ()))))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 60, "start_col": 0, "start_line": 52 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsVector.va_code_Mov128", "Vale.AES.X64.GCMencryptOpt.va_code_Ghash_extra_bytes", "Vale.X64.InsVector.va_code_Pshufb", "Vale.AES.X64.AES.va_code_AESEncryptBlock", "Vale.X64.InsVector.va_code_Pxor", "Vale.X64.InsVector.va_code_Store128_buffer", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ()))))))))))
false
Steel.ST.Effect.fst
Steel.ST.Effect.subcomp
val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:pure_pre) (#[@@@ framing_implicit] ens_f:pure_post a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:pure_pre) (#[@@@ framing_implicit] ens_g:pure_post a) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x))) (ensures fun _ -> True)
val subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:pure_pre) (#[@@@ framing_implicit] ens_f:pure_post a) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:pure_pre) (#[@@@ framing_implicit] ens_g:pure_post a) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _ : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash (can_be_split pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash (equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x))) (ensures fun _ -> True)
let subcomp (a:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:Type0) (#[@@@ framing_implicit] ens_f:a -> Type0) (#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a) (#[@@@ framing_implicit] req_g:Type0) (#[@@@ framing_implicit] ens_g:a -> Type0) (#[@@@ framing_implicit] frame:vprop) (#[@@@ framing_implicit] _x1 : squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit] p1:squash ( can_be_split pre_g (pre_f `star` frame))) (#[@@@ framing_implicit] p2:squash ( equiv_forall post_g (fun x -> post_f x `star` frame))) (f:repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x))) (ensures fun _ -> True) = weaken_repr _ _ _ _ _ _ _ _ (Steel.Effect.subcomp a #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun _ -> req_g) #(fun _ x _ -> ens_g x) #frame #_x1 #True #p1 #p2 f) () ()
{ "file_name": "lib/steel/Steel.ST.Effect.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 27, "end_line": 196, "start_col": 0, "start_line": 155 }
(* Copyright 2020 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Steel.ST.Effect friend Steel.Effect open Steel.Memory open FStar.Ghost module Mem = Steel.Memory module T = FStar.Tactics include Steel.Effect.Common open Steel.Effect #set-options "--warn_error -330" //turn off the experimental feature warning #set-options "--ide_id_info_off" let repr a framed pre post req ens : Type u#2 = Steel.Effect.repr a framed pre post (fun _ -> req) (fun _ v _ -> ens v) let equiv_star_emp_r (p:vprop) : Lemma ((p `star` emp) `equiv` p) = cm_identity p; assert ((emp `star` p) `equiv` p); star_commutative p emp; equiv_trans (p `star` emp) (emp `star` p) p let weaken_repr a framed (pre:pre_t) (post:post_t a) (req req':req_t pre) (ens ens':ens_t pre a post) (f:Steel.Effect.repr a framed pre post req ens) (_:squash (forall (h0:hmem pre). req' (mk_rmem _ h0) ==> req (mk_rmem _ h0))) (_:squash (forall (h0:hmem pre) x (h1:hmem (post x)). ens (mk_rmem _ h0) x (mk_rmem _ h1) ==> ens' (mk_rmem _ h0) x (mk_rmem _ h1))) : Tot (Steel.Effect.repr a framed pre post req' ens') = let focus_rmem_refl (r:vprop) (h:rmem r) : Lemma (ensures focus_rmem #r h r == h) [SMTPat (focus_rmem #r h r)] = focus_rmem_refl r h in let equiv_trans (x y z:vprop) : Lemma (requires equiv x y /\ equiv y z) (ensures equiv x z) [SMTPat (equiv x z); SMTPat (equiv x y)] = equiv_trans x y z in let cbs (p:vprop) : Lemma (p `can_be_split` (p `star` emp)) [SMTPat (p `can_be_split` (p `star` emp))] = star_commutative p emp; cm_identity p; equiv_sym (p `star` emp) p; equiv_can_be_split p (p `star` emp) in let epost () : Lemma (equiv_forall post (fun x -> star (post x) emp)) = introduce forall x. post x `equiv` (post x `star` emp) with ( equiv_star_emp_r (post x); equiv_sym (post x `star` emp) (post x) ); equiv_forall_elim post (fun x -> star (post x) emp) in epost (); Steel.Effect.subcomp_opaque a #framed #framed #pre #post #req #ens #pre #post #req' #ens' #emp #True #() #() #() f let return_ (a:Type) (x:a) (#[@@@ framing_implicit] p:a -> vprop) : Tot (repr a true (return_pre (p x)) p True (fun v -> v == x)) = let k : Steel.Effect.repr a true (p x) p (fun _ -> True) (return_ens a x p) = Steel.Effect.return_ a x #p in weaken_repr _ _ _ _ _ _ _ _ k () () let bind (a:Type) (b:Type) (#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool) (#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a) (#[@@@ framing_implicit] req_f:Type0) (#[@@@ framing_implicit] ens_f:a -> Type0) (#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:a -> post_t b) (#[@@@ framing_implicit] req_g:(a -> Type0)) (#[@@@ framing_implicit] ens_g:(a -> b -> Type0)) (#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:a -> vprop) (#[@@@ framing_implicit] post:post_t b) (#[@@@ framing_implicit] _x1: squash (maybe_emp framed_f frame_f)) (#[@@@ framing_implicit] _x2: squash (maybe_emp_dep framed_g frame_g)) (#[@@@ framing_implicit] pr:a -> prop) (#[@@@ framing_implicit] p1:squash (can_be_split_forall_dep pr (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g x))) (#[@@@ framing_implicit] p2:squash (can_be_split_post (fun x y -> post_g x y `star` frame_g x) post)) (f:repr a framed_f pre_f post_f req_f ens_f) (g:(x:a -> repr b framed_g (pre_g x) (post_g x) (req_g x) (ens_g x))) = let c = Steel.Effect.bind a b #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun x _ -> req_g x) #(fun x _ y _ -> ens_g x y) #frame_f #frame_g #post #_x1 #_x2 #pr #p1 #p2 f g in weaken_repr _ _ _ _ _ _ _ _ c () ()
{ "checked_file": "/", "dependencies": [ "Steel.Memory.fsti.checked", "Steel.Effect.Common.fsti.checked", "Steel.Effect.fst.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.Ghost.fsti.checked", "FStar.Classical.Sugar.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.Effect.fst" }
[ { "abbrev": false, "full_module": "Steel.Effect", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.Effect.Common", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics", "short_module": "T" }, { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "Steel.Memory", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Type -> f: Steel.ST.Effect.repr a framed_f pre_f post_f req_f ens_f -> Prims.Pure (Steel.ST.Effect.repr a framed_g pre_g post_g req_g ens_g)
Prims.Pure
[]
[]
[ "FStar.Pervasives.eqtype_as_type", "Prims.bool", "Steel.Effect.Common.pre_t", "Steel.Effect.Common.post_t", "Steel.Effect.Common.vprop", "Prims.squash", "Steel.Effect.Common.maybe_emp", "Steel.Effect.Common.can_be_split", "Steel.Effect.Common.star", "Steel.Effect.Common.equiv_forall", "Steel.ST.Effect.repr", "Steel.ST.Effect.weaken_repr", "Steel.Effect.Common.rmem", "Steel.Effect.subcomp", "Prims.l_True", "Prims.l_imp", "Prims.l_and", "Prims.l_Forall" ]
[]
false
false
false
false
false
let subcomp (a: Type) (#framed_f #framed_g: eqtype_as_type bool) (#[@@@ framing_implicit]pre_f: pre_t) (#[@@@ framing_implicit]post_f: post_t a) (#[@@@ framing_implicit]req_f: Type0) (#[@@@ framing_implicit]ens_f: (a -> Type0)) (#[@@@ framing_implicit]pre_g: pre_t) (#[@@@ framing_implicit]post_g: post_t a) (#[@@@ framing_implicit]req_g: Type0) (#[@@@ framing_implicit]ens_g: (a -> Type0)) (#[@@@ framing_implicit]frame: vprop) (#[@@@ framing_implicit]_x1: squash (maybe_emp framed_f frame)) (#[@@@ framing_implicit]p1: squash (can_be_split pre_g (pre_f `star` frame))) (#[@@@ framing_implicit]p2: squash (equiv_forall post_g (fun x -> (post_f x) `star` frame))) (f: repr a framed_f pre_f post_f req_f ens_f) : Pure (repr a framed_g pre_g post_g req_g ens_g) (requires req_g ==> (req_f /\ (forall x. ens_f x ==> ens_g x))) (ensures fun _ -> True) =
weaken_repr _ _ _ _ _ _ _ _ (Steel.Effect.subcomp a #framed_f #framed_g #pre_f #post_f #(fun _ -> req_f) #(fun _ x _ -> ens_f x) #pre_g #post_g #(fun _ -> req_g) #(fun _ x _ -> ens_g x) #frame #_x1 #True #p1 #p2 f) () ()
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_regs_modified
val fsub_regs_modified: MS.reg_64 -> bool
val fsub_regs_modified: MS.reg_64 -> bool
let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 12, "end_line": 334, "start_col": 0, "start_line": 331 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200"
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Vale.X64.Machine_s.reg_64 -> Prims.bool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Machine_s.reg_64", "Prims.op_BarBar", "Prims.op_Equality", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rR8", "Vale.X64.Machine_s.rR9", "Vale.X64.Machine_s.rR10", "Vale.X64.Machine_s.rR11", "Prims.bool" ]
[]
false
false
false
true
false
let fsub_regs_modified: MS.reg_64 -> bool =
fun (r: MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_fadd_t
val lowstar_fadd_t : Type0
let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 265, "start_col": 0, "start_line": 252 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.fadd_regs_modified", "Vale.Inline.X64.Fadd_inline.fadd_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_Fadd", "Vale.Inline.X64.Fadd_inline.fadd_dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Inline.X64.Fadd_inline.fadd_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.fadd_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.fadd_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
true
let lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([] <: list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_codegen_success_Gcm_extra_bytes
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
let va_codegen_success_Gcm_extra_bytes alg = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ())))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 73, "start_col": 0, "start_line": 64 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ())))))))))) val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRax", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.InsVector.va_codegen_success_Mov128", "Vale.AES.X64.GCMencryptOpt.va_codegen_success_Ghash_extra_bytes", "Vale.X64.InsVector.va_codegen_success_Pshufb", "Vale.AES.X64.AES.va_codegen_success_AESEncryptBlock", "Vale.X64.InsVector.va_codegen_success_Pxor", "Vale.X64.InsVector.va_codegen_success_Store128_buffer", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ())))))))))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_dom
val fsub_dom:IX64.arity_ok_stdcall td
val fsub_dom:IX64.arity_ok_stdcall td
let fsub_dom: IX64.arity_ok_stdcall td = let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 305, "start_col": 0, "start_line": 302 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Interop.X64.arity_ok_stdcall Vale.Interop.Base.td
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list", "Prims.Cons", "Vale.Inline.X64.Fadd_inline.t64_mod", "Vale.Inline.X64.Fadd_inline.t64_no_mod", "Prims.Nil" ]
[]
false
false
false
true
false
let fsub_dom:IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in assert_norm (List.length y = 3); y
false
DM4F_layered5.fst
DM4F_layered5.pure_bind_wp
val pure_bind_wp (#a #b: Type) (w1: ID5.wp a) (w2: (a -> ID5.wp b)) : ID5.wp b
val pure_bind_wp (#a #b: Type) (w1: ID5.wp a) (w2: (a -> ID5.wp b)) : ID5.wp b
let pure_bind_wp (#a #b : Type) (w1 : ID5.wp a) (w2 : a -> ID5.wp b) : ID5.wp b = ID5.bind_wp w1 w2
{ "file_name": "examples/layeredeffects/DM4F_layered5.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 19, "end_line": 25, "start_col": 0, "start_line": 24 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DM4F_layered5 (* Same as DM4F, but layered over a layered PURE without monotonicity *) open ID5 open DM4F_Utils
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "ID5.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.IO.fst.checked", "FStar.Ghost.fsti.checked", "DM4F_Utils.fst.checked" ], "interface_file": false, "source_file": "DM4F_layered5.fst" }
[ { "abbrev": false, "full_module": "DM4F_Utils", "short_module": null }, { "abbrev": false, "full_module": "ID5", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
w1: ID5.wp a -> w2: (_: a -> ID5.wp b) -> ID5.wp b
Prims.Tot
[ "total" ]
[]
[ "ID5.wp", "ID5.bind_wp" ]
[]
false
false
false
true
false
let pure_bind_wp (#a #b: Type) (w1: ID5.wp a) (w2: (a -> ID5.wp b)) : ID5.wp b =
ID5.bind_wp w1 w2
false
DM4F_layered5.fst
DM4F_layered5.st_monotonic
val st_monotonic (#st #a: _) (w: wp0 st a) : Type0
val st_monotonic (#st #a: _) (w: wp0 st a) : Type0
let st_monotonic #st #a (w : wp0 st a) : Type0 = //forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2 // ^ this version seems to be less SMT-friendly forall s0 p1 p2. (forall x s1. p1 x s1 ==> p2 x s1) ==> w s0 p1 ==> w s0 p2
{ "file_name": "examples/layeredeffects/DM4F_layered5.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 77, "end_line": 37, "start_col": 0, "start_line": 34 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DM4F_layered5 (* Same as DM4F, but layered over a layered PURE without monotonicity *) open ID5 open DM4F_Utils unfold let pure_bind_wp (#a #b : Type) (w1 : ID5.wp a) (w2 : a -> ID5.wp b) : ID5.wp b = ID5.bind_wp w1 w2 (* Simulating state effect in DM4F, hopefully doable by a tactic. *) type post_t st a = a -> st -> Type0 type wp0 (st:Type u#0) (a:Type u#ua) : Type u#(max 1 ua) = st -> post_t st a -> Type0
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "ID5.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.IO.fst.checked", "FStar.Ghost.fsti.checked", "DM4F_Utils.fst.checked" ], "interface_file": false, "source_file": "DM4F_layered5.fst" }
[ { "abbrev": false, "full_module": "DM4F_Utils", "short_module": null }, { "abbrev": false, "full_module": "ID5", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
w: DM4F_layered5.wp0 st a -> Type0
Prims.Tot
[ "total" ]
[]
[ "DM4F_layered5.wp0", "Prims.l_Forall", "Prims.logical", "Prims.l_imp" ]
[]
false
false
false
true
true
let st_monotonic #st #a (w: wp0 st a) : Type0 =
forall s0 p1 p2. (forall x s1. p1 x s1 ==> p2 x s1) ==> w s0 p1 ==> w s0 p2
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_Fsub_t
val lowstar_Fsub_t : Type0
let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 388, "start_col": 0, "start_line": 375 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Type0
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.as_lowstar_sig_t_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.fsub_regs_modified", "Vale.Inline.X64.Fadd_inline.fsub_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_Fsub", "Vale.Inline.X64.Fadd_inline.fsub_dom", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Vale.Inline.X64.Fadd_inline.fsub_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.fsub_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.fsub_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
true
let lowstar_Fsub_t =
assert_norm (List.length fsub_dom + List.length ([] <: list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_lemma
val fadd_lemma : Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.fadd_regs_modified Vale.Inline.X64.Fadd_inline.fadd_xmms_modified Vale.Inline.X64.Fadd_inline.fadd_pre Vale.Inline.X64.Fadd_inline.fadd_post
let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 107, "end_line": 246, "start_col": 0, "start_line": 246 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.fadd_regs_modified Vale.Inline.X64.Fadd_inline.fadd_xmms_modified Vale.Inline.X64.Fadd_inline.fadd_pre Vale.Inline.X64.Fadd_inline.fadd_post
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_t", "Vale.AsLowStar.ValeSig.vale_sig", "Vale.Inline.X64.Fadd_inline.fadd_dom", "Vale.Inline.X64.Fadd_inline.fadd_regs_modified", "Vale.Inline.X64.Fadd_inline.fadd_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.fadd_pre", "Vale.Inline.X64.Fadd_inline.fadd_post", "Vale.Inline.X64.Fadd_inline.fadd_lemma'" ]
[]
false
false
false
true
false
let fadd_lemma =
as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma'
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
let va_code_Gcm_blocks128 alg = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 89, "end_line": 286, "start_col": 0, "start_line": 280 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ())))))))))) val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_extra_bytes alg = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range 1 1)) = 1 in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret inout_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let (hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (())))))))))))))) val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1 "***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads)))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall (va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (()))) val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k = let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) (va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE)) //-- //-- Gcm_blocks128 val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRax", "Vale.AES.X64.AESopt2.va_code_Ghash_buffer", "Vale.AES.X64.GCMencryptOpt.va_code_Gctr_blocks128", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_fadd
val lowstar_fadd:lowstar_fadd_t
val lowstar_fadd:lowstar_fadd_t
let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 277, "start_col": 0, "start_line": 268 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Inline.X64.Fadd_inline.lowstar_fadd_t
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.wrap_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.fadd_regs_modified", "Vale.Inline.X64.Fadd_inline.fadd_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_Fadd", "Vale.Inline.X64.Fadd_inline.fadd_dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Inline.X64.Fadd_inline.fadd_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.fadd_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.fadd_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
false
let lowstar_fadd:lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([] <: list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.add1_lemma'
val add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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)))
val add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f)
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 104, "start_col": 0, "start_line": 80 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
code: Vale.X64.Decls.va_code -> _win: Prims.bool -> out: Vale.Inline.X64.Fadd_inline.b64 -> f1: Vale.Inline.X64.Fadd_inline.b64 -> f2: Vale.Inline.X64.Fadd_inline.uint64 -> va_s0: Vale.X64.Decls.va_state -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Prims.bool", "Vale.Inline.X64.Fadd_inline.b64", "Vale.Inline.X64.Fadd_inline.uint64", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal", "Vale.Arch.HeapTypes_s.TUInt64", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.Curve25519.X64.FastUtil.va_lemma_Fast_add1", "Vale.X64.MemoryAdapters.as_vale_buffer", "FStar.UInt64.v", "Vale.Inline.X64.Fadd_inline.add1_pre", "Prims.l_and", "Vale.X64.Decls.eval_code", "Vale.AsLowStar.ValeSig.vale_calling_conventions", "Vale.Inline.X64.Fadd_inline.add1_regs_modified", "Vale.Inline.X64.Fadd_inline.add1_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.add1_post", "Vale.X64.Memory.buffer_readable", "Vale.X64.State.vs_get_vale_heap", "Vale.X64.Memory.buffer_writeable", "Vale.X64.Memory.modifies", "Vale.X64.Memory.loc_union", "Vale.X64.Memory.loc_buffer", "Vale.X64.Memory.loc_none" ]
[]
false
false
false
false
false
let add1_lemma' (code: V.va_code) (_win: bool) (out f1: b64) (f2: uint64) (va_s0: V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f)
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.lowstar_Fsub
val lowstar_Fsub:lowstar_Fsub_t
val lowstar_Fsub:lowstar_Fsub_t
let lowstar_Fsub : lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 73, "end_line": 400, "start_col": 0, "start_line": 391 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *) [@__reduce__] let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.Inline.X64.Fadd_inline.lowstar_Fsub_t
Prims.Tot
[ "total" ]
[]
[ "Vale.Interop.X64.wrap_weak", "Vale.Inline.X64.Fadd_inline.arg_reg", "Vale.Inline.X64.Fadd_inline.fsub_regs_modified", "Vale.Inline.X64.Fadd_inline.fsub_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.code_Fsub", "Vale.Inline.X64.Fadd_inline.fsub_dom", "Vale.AsLowStar.Wrapper.pre_rel_generic", "Prims.Nil", "Vale.Interop.Base.arg", "Vale.Inline.X64.Fadd_inline.fsub_pre", "Vale.AsLowStar.Wrapper.post_rel_generic", "Vale.Inline.X64.Fadd_inline.fsub_post", "Vale.AsLowStar.Wrapper.mk_prediction", "Vale.Inline.X64.Fadd_inline.fsub_lemma", "Vale.Interop.Assumptions.win", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Prims.list" ]
[]
false
false
false
true
false
let lowstar_Fsub:lowstar_Fsub_t =
assert_norm (List.length fsub_dom + List.length ([] <: list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_codegen_success_Gcm_blocks
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
let va_codegen_success_Gcm_blocks alg offset = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and (va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and (va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and (va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register ()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and (va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 89, "end_line": 581, "start_col": 0, "start_line": 540 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ())))))))))) val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_extra_bytes alg = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range 1 1)) = 1 in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret inout_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let (hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (())))))))))))))) val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1 "***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads)))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall (va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (()))) val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k = let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) (va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE)) //-- //-- Gcm_blocks128 val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_blocks128 alg = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ()))))))))) val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_blocks128 alg = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Gctr_blocks128 alg) (va_ttrue ())))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_old_s))) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (())))))))))) val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b) (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_ok va_sM) /\ (label va_range1 "***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b) (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64) (va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32) (va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key (va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (()))) val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k = let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg)) = (va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) (va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE) (va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)) //-- //-- Gcm_blocks #push-options "--z3rlimit 1000" val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_blocks alg offset = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb (va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg) (va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse (va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons (va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons (va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block (va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ())))))))))))))))))))))))))))))))))))) val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 1000, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> offset: Prims.int -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Prims.int", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsBasic.va_codegen_success_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rR13", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRcx", "Vale.X64.InsBasic.va_codegen_success_AddLea64", "Vale.X64.Machine_s.rR9", "Vale.X64.Decls.va_const_opr64", "Vale.X64.InsStack.va_codegen_success_Load64_stack", "Vale.X64.Machine_s.rRbx", "Vale.X64.Decls.va_op_reg_opr64_reg64", "Vale.X64.Machine_s.rRsp", "Prims.op_Addition", "Vale.AES.X64.GCMencryptOpt.va_codegen_success_Gcm_blocks_auth", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdx", "Vale.X64.InsVector.va_codegen_success_Mov128", "Vale.X64.Decls.va_op_xmm_xmm", "Vale.X64.InsVector.va_codegen_success_Load128_buffer", "Vale.X64.Decls.va_op_heaplet_mem_heaplet", "Vale.X64.Machine_s.rR8", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.InsVector.va_codegen_success_Store128_buffer", "Vale.X64.Machine_s.rRbp", "Vale.Arch.HeapTypes_s.Secret", "Vale.AES.X64.AESopt.va_codegen_success_Load_one_lsb", "Vale.X64.InsVector.va_codegen_success_VPaddd", "Vale.AES.X64.AESGCM.va_codegen_success_AES_GCM_decrypt_6mult", "Vale.X64.Machine_s.rRax", "Vale.X64.Machine_s.rR14", "Vale.X64.InsVector.va_codegen_success_InitPshufbMask", "Vale.X64.Machine_s.rR12", "Vale.X64.InsVector.va_codegen_success_Pshufb", "Vale.AES.X64.GCMdecryptOpt.va_codegen_success_Gcm_blocks128", "Vale.X64.InsStack.va_codegen_success_Stack_lemma", "Vale.X64.InsBasic.va_codegen_success_Add64", "Vale.X64.Decls.va_opr_code_Stack", "Vale.X64.Decls.va_op_reg64_reg64", "Vale.X64.InsBasic.va_codegen_success_IMul64", "Vale.X64.Machine_s.rR10", "Vale.X64.InsBasic.va_codegen_success_And64", "Vale.AES.X64.GCMdecryptOpt.va_codegen_success_Gcm_extra_bytes", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rR15", "Vale.AES.X64.GCMencryptOpt.va_codegen_success_Gcm_make_length_quad", "Vale.AES.X64.AESopt2.va_codegen_success_Ghash_register", "Vale.AES.X64.GCMencryptOpt.va_codegen_success_Gctr_register", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and (va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and (va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret) (va_pbool_and (va_codegen_success_Mov64 ( va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdi ) (va_op_reg_opr64_reg64 rRsp ) (offset + 40)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and (va_codegen_success_Stack_lemma () ) (va_pbool_and ( va_codegen_success_Add64 ( va_op_dst_opr64_reg64 rR14 ) ( va_opr_code_Stack ( va_op_reg64_reg64 rRsp ) ( offset + 24 ) Public ) ) ( va_pbool_and ( va_codegen_success_IMul64 ( va_op_dst_opr64_reg64 rR14 ) ( va_const_opr64 16 ) ) ( va_pbool_and ( va_codegen_success_Load64_stack ( va_op_dst_opr64_reg64 rR13 ) ( va_op_reg_opr64_reg64 rRsp ) ( offset + 64 ) ) ( va_pbool_and ( va_pbool_and ( va_codegen_success_Load64_stack ( va_op_dst_opr64_reg64 rRax ) ( va_op_reg_opr64_reg64 rRsp ) ( offset + 56 ) ) ( va_pbool_and ( va_codegen_success_Mov64 ( va_op_dst_opr64_reg64 rR10 ) ( va_op_opr64_reg64 rR13 ) ) ( va_pbool_and ( va_codegen_success_And64 ( va_op_dst_opr64_reg64 rR10 ) ( va_const_opr64 15 ) ) ( va_codegen_success_Gcm_extra_bytes alg ) ) ) ) ( va_pbool_and ( va_codegen_success_Mov64 ( va_op_dst_opr64_reg64 rR11 ) ( va_op_opr64_reg64 rR15 ) ) ( va_pbool_and ( va_codegen_success_Gcm_make_length_quad () ) ( va_pbool_and ( va_codegen_success_Ghash_register () ) ( va_pbool_and ( va_codegen_success_Load128_buffer ( va_op_heaplet_mem_heaplet 3 ) ( va_op_xmm_xmm 0 ) ( va_op_reg_opr64_reg64 rRbp ) 0 Secret ) ( va_pbool_and ( va_codegen_success_Gctr_register alg ) ( va_ttrue () ) ) ) ) ) ) ) ) ) )) )))))))))))) )))))))))))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fadd_code_inline
val fadd_code_inline: Prims.unit -> FStar.All.ML int
val fadd_code_inline: Prims.unit -> FStar.All.ML int
let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 124, "end_line": 299, "start_col": 0, "start_line": 298 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.int
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.X64.Print_Inline_s.print_inline", "FStar.Pervasives.Native.None", "Prims.string", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Vale.Inline.X64.Fadd_inline.fadd_dom", "Vale.Inline.X64.Fadd_inline.fadd_names", "Vale.Inline.X64.Fadd_inline.code_Fadd", "Vale.Inline.X64.Fadd_inline.of_arg", "Vale.Inline.X64.Fadd_inline.fadd_regs_modified", "Vale.Inline.X64.Fadd_inline.fadd_comments", "Prims.int" ]
[]
false
true
false
false
false
let fadd_code_inline () : FStar.All.ML int =
PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_codegen_success_Gcm_blocks128
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
let va_codegen_success_Gcm_blocks128 alg = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 64, "end_line": 297, "start_col": 0, "start_line": 290 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ())))))))))) val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_extra_bytes alg = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range 1 1)) = 1 in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret inout_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let (hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (())))))))))))))) val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1 "***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads)))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall (va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (()))) val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k = let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) (va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE)) //-- //-- Gcm_blocks128 val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_blocks128 alg = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ()))))))))) val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsBasic.va_codegen_success_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRax", "Vale.AES.X64.AESopt2.va_codegen_success_Ghash_buffer", "Vale.AES.X64.GCMencryptOpt.va_codegen_success_Gctr_blocks128", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
false
DM4F_layered5.fst
DM4F_layered5.stronger
val stronger (#a: Type) (#st: Type0) (w1 w2: wp st a) : Type0
val stronger (#a: Type) (#st: Type0) (w1 w2: wp st a) : Type0
let stronger (#a:Type) (#st:Type0) (w1 w2 : wp st a) : Type0 = forall s0 p. w1 s0 p ==> w2 s0 p
{ "file_name": "examples/layeredeffects/DM4F_layered5.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 36, "end_line": 89, "start_col": 0, "start_line": 85 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DM4F_layered5 (* Same as DM4F, but layered over a layered PURE without monotonicity *) open ID5 open DM4F_Utils unfold let pure_bind_wp (#a #b : Type) (w1 : ID5.wp a) (w2 : a -> ID5.wp b) : ID5.wp b = ID5.bind_wp w1 w2 (* Simulating state effect in DM4F, hopefully doable by a tactic. *) type post_t st a = a -> st -> Type0 type wp0 (st:Type u#0) (a:Type u#ua) : Type u#(max 1 ua) = st -> post_t st a -> Type0 let st_monotonic #st #a (w : wp0 st a) : Type0 = //forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2 // ^ this version seems to be less SMT-friendly forall s0 p1 p2. (forall x s1. p1 x s1 ==> p2 x s1) ==> w s0 p1 ==> w s0 p2 type wp st a = w:(wp0 st a){st_monotonic w} open FStar.Monotonic.Pure type repr (a:Type u#ua) (st:Type0) (wp : wp u#ua st a) : Type u#(max 1 ua) = s0:st -> ID (a & st) (as_pure_wp (fun p -> wp s0 (curry p))) unfold let return_wp (#a:Type) (#st:Type0) (x:a) : wp st a = fun s0 p -> p x s0 let return (a:Type) (x:a) (st:Type0) : repr a st (return_wp x) = fun s0 -> (x, s0) unfold let bind_wp (#a:Type) (#b:Type) (#st:Type0) (w1 : wp st a) (w2 : a -> wp st b) : wp st b = fun s0 p -> w1 s0 (fun y s1 -> w2 y s1 p) let bind (a:Type) (b:Type) (st:Type0) (wp_c : wp st a) (wp_f : a -> wp st b) (c : repr a st wp_c) (f : (x:a -> repr b st (wp_f x))) : repr b st (bind_wp wp_c wp_f) = fun s0 -> //let (y, s1) = c s0 in //f y s1 // GM: argh! using the match above introduces noise in the VC, a true precondition // that becomes a pain since we don't have monotonicity nor even extensionality let r = c s0 in f (fst r) (snd r) let ite_wp #a #st (b:bool) (w1 w2 : wp st a) : wp st a = fun s0 p -> (b ==> w1 s0 p) /\ ((~b) ==> w2 s0 p) let if_then_else (a:Type) (st:Type0) (wpf wpg : wp st a) (f : repr a st wpf) (g : repr a st wpg) (b : bool) : Type = repr a st (ite_wp b wpf wpg)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "ID5.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.IO.fst.checked", "FStar.Ghost.fsti.checked", "DM4F_Utils.fst.checked" ], "interface_file": false, "source_file": "DM4F_layered5.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": false, "full_module": "DM4F_Utils", "short_module": null }, { "abbrev": false, "full_module": "ID5", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
w1: DM4F_layered5.wp st a -> w2: DM4F_layered5.wp st a -> Type0
Prims.Tot
[ "total" ]
[]
[ "DM4F_layered5.wp", "Prims.l_Forall", "DM4F_layered5.post_t", "Prims.l_imp" ]
[]
false
false
false
true
true
let stronger (#a: Type) (#st: Type0) (w1 w2: wp st a) : Type0 =
forall s0 p. w1 s0 p ==> w2 s0 p
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_code_inline
val fsub_code_inline: Prims.unit -> FStar.All.ML int
val fsub_code_inline: Prims.unit -> FStar.All.ML int
let fsub_code_inline () : FStar.All.ML int = PR.print_inline "fsub" 0 None (List.length fsub_dom) fsub_dom fsub_names code_Fsub of_arg fsub_regs_modified fsub_comments
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 124, "end_line": 422, "start_col": 0, "start_line": 421 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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 *) let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma' let code_Fsub = FH.va_code_Fsub () (* Here's the type expected for the fsub wrapper *) [@__reduce__] let lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) (* And here's the fsub wrapper itself *) let lowstar_Fsub : lowstar_Fsub_t = assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fsub_regs_modified fsub_xmms_modified code_Fsub fsub_dom (W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win)) let lowstar_Fsub_normal_t : normal lowstar_Fsub_t = as_normal_t #lowstar_Fsub_t lowstar_Fsub let fsub out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_Fsub_normal_t out f1 f2 () in () let fsub_comments : list string = ["Computes the field substraction of two field elements"] let fsub_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> ""
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
_: Prims.unit -> FStar.All.ML Prims.int
FStar.All.ML
[ "ml" ]
[]
[ "Prims.unit", "Vale.X64.Print_Inline_s.print_inline", "FStar.Pervasives.Native.None", "Prims.string", "FStar.List.Tot.Base.length", "Vale.Interop.Base.td", "Vale.Inline.X64.Fadd_inline.fsub_dom", "Vale.Inline.X64.Fadd_inline.fsub_names", "Vale.Inline.X64.Fadd_inline.code_Fsub", "Vale.Inline.X64.Fadd_inline.of_arg", "Vale.Inline.X64.Fadd_inline.fsub_regs_modified", "Vale.Inline.X64.Fadd_inline.fsub_comments", "Prims.int" ]
[]
false
true
false
false
false
let fsub_code_inline () : FStar.All.ML int =
PR.print_inline "fsub" 0 None (List.length fsub_dom) fsub_dom fsub_names code_Fsub of_arg fsub_regs_modified fsub_comments
false
Vale.AES.X64.GCMdecryptOpt.fst
Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks128
val va_qcode_Gcm_blocks128 (va_mods: va_mods_t) (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (h_LE: quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg))
val va_qcode_Gcm_blocks128 (va_mods: va_mods_t) (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (h_LE: quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg))
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_old_s))) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
{ "file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 91, "end_line": 318, "start_col": 0, "start_line": 300 }
module Vale.AES.X64.GCMdecryptOpt open Vale.Def.Prop_s open Vale.Def.Opaque_s open FStar.Seq open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.AES.AES_s open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.AES.GCM open Vale.AES.GHash_s open Vale.AES.GHash open Vale.AES.GCM_s open Vale.AES.X64.AES open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.Poly1305.Math open Vale.AES.GCM_helpers open Vale.AES.X64.GHash open Vale.AES.X64.GCTR open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsStack open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.AES.X64.GF128_Mul open Vale.X64.Stack open Vale.X64.CPU_Features_s open Vale.Math.Poly2.Bits_s open Vale.AES.X64.AESopt open Vale.AES.X64.AESGCM open Vale.AES.X64.AESopt2 open Vale.Lib.Meta open Vale.AES.X64.GCMencryptOpt open Vale.AES.OptPublic open Vale.Lib.Basic #reset-options "--z3rlimit 20 --max_ifuel 0" //-- Gcm_extra_bytes val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_extra_bytes alg = (va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_CNil ())))))))))) val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_extra_bytes alg = (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret) (va_ttrue ()))))))))) [@ "opaque_to_smt" va_qattr] let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range 1 1)) = 1 in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRax) 0 Secret inout_b 0) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let (hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1 "***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun (va_s:va_state) _ -> va_qAssert va_range1 "***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind va_range1 "***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1 "***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1 "***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (())))))))))))))) val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))) [@"opaque_to_smt"] let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE = let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1 "***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1 "***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label va_range1 "***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1 "***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1 "***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads)))))))) in assert_norm (va_qc.mods == va_mods); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0; (va_sM, va_fM) [@ va_qattr] let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length #quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply` FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes `op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16 `op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply` (Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall (va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (()))) val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@"opaque_to_smt"] let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE va_s0 va_k = let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))); va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) [@ "opaque_to_smt" va_qattr] let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) = (va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) (va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE)) //-- //-- Gcm_blocks128 val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code [@ "opaque_to_smt" va_qattr] let va_code_Gcm_blocks128 alg = (va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ()))))))))) val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool [@ "opaque_to_smt" va_qattr] let va_codegen_success_Gcm_blocks128 alg = (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Stack_i.fsti.checked", "Vale.X64.Stack.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsStack.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Poly1305.Math.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Lib.Meta.fsti.checked", "Vale.Lib.Basic.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.AES.X64.GHash.fsti.checked", "Vale.AES.X64.GF128_Mul.fsti.checked", "Vale.AES.X64.GCTR.fsti.checked", "Vale.AES.X64.GCMencryptOpt.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.X64.AESGCM.fsti.checked", "Vale.AES.X64.AES.fsti.checked", "Vale.AES.OptPublic.fsti.checked", "Vale.AES.GHash_s.fst.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_s.fst.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.GCM.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_common_s.fst.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.X64.GCMdecryptOpt.fst" }
[ { "abbrev": false, "full_module": "Vale.Lib.Basic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.OptPublic", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCMencryptOpt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Meta", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESGCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GF128_Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsStack", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Poly1305.Math", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_mods: Vale.X64.QuickCode.va_mods_t -> alg: Vale.AES.AES_common_s.algorithm -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> hkeys_b: Vale.X64.Memory.buffer128 -> h_LE: Vale.X64.Decls.quad32 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks128 alg)
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.QuickCode.va_mods_t", "Vale.AES.AES_common_s.algorithm", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.quad32", "Vale.X64.QuickCodes.qblock", "Prims.unit", "Prims.Cons", "Vale.X64.Decls.va_code", "Vale.X64.InsBasic.va_code_Mov64", "Vale.X64.Decls.va_op_dst_opr64_reg64", "Vale.X64.Machine_s.rRbx", "Vale.X64.Decls.va_op_opr64_reg64", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRax", "Vale.AES.X64.AESopt2.va_code_Ghash_buffer", "Vale.AES.X64.GCMencryptOpt.va_code_Gctr_blocks128", "Prims.Nil", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_state", "Vale.X64.QuickCodes.va_QSeq", "Vale.X64.QuickCodes.va_range1", "Vale.X64.InsBasic.va_quick_Mov64", "Vale.AES.X64.AESopt2.va_quick_Ghash_buffer", "Vale.Def.Types_s.reverse_bytes_quad32", "Vale.X64.Decls.va_get_xmm", "Vale.AES.X64.GCMencryptOpt.va_quick_Gctr_blocks128", "Vale.X64.QuickCodes.va_QEmpty", "Vale.X64.State.vale_state", "Vale.X64.QuickCodes.quickCodes", "Vale.X64.QuickCode.va_quickCode", "Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks128" ]
[]
false
false
false
false
false
let va_qcode_Gcm_blocks128 (va_mods: va_mods_t) (alg: algorithm) (in_b out_b: buffer128) (key: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (h_LE: quad32) : (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s: va_state) -> let va_old_s:va_state = va_s in va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_old_s))) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1 "***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****" (va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
false
Vale.Inline.X64.Fadd_inline.fst
Vale.Inline.X64.Fadd_inline.fsub_lemma
val fsub_lemma : Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.fsub_regs_modified Vale.Inline.X64.Fadd_inline.fsub_xmms_modified Vale.Inline.X64.Fadd_inline.fsub_pre Vale.Inline.X64.Fadd_inline.fsub_post
let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma'
{ "file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 107, "end_line": 369, "start_col": 0, "start_line": 369 }
module Vale.Inline.X64.Fadd_inline open FStar.Mul 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 module PR = Vale.X64.Print_Inline_s 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 *) let as_t (#a:Type) (x:normal a) : a = x let as_normal_t (#a:Type) (x:a) : normal a = x [@__reduce__] let b64 = buf_t TUInt64 TUInt64 [@__reduce__] let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq [@__reduce__] let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret}) [@__reduce__] let tuint64 = TD_Base TUInt64 [@__reduce__] let dom: IX64.arity_ok 3 td = let y = [t64_mod; t64_no_mod; tuint64] in assert_norm (List.length y = 3); y (* Need to rearrange the order of arguments *) [@__reduce__] let add1_pre : VSig.vale_pre dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) -> FU.va_req_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) [@__reduce__] let add1_post : VSig.vale_post dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) (va_s1:V.va_state) (f:V.va_fuel) -> FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f #set-options "--z3rlimit 50" let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let add1_xmms_modified = fun _ -> false [@__reduce__] let add1_lemma' (code:V.va_code) (_win:bool) (out:b64) (f1:b64) (f2:uint64) (va_s0:V.va_state) : Ghost (V.va_state & V.va_fuel) (requires add1_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 va_s0 va_s1 add1_regs_modified add1_xmms_modified /\ add1_post code out f1 f2 va_s0 va_s1 f /\ 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 out) /\ ME.buffer_writeable (as_vale_buffer out) /\ ME.buffer_writeable (as_vale_buffer f1) /\ 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 = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out; Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1; (va_s1, f) (* Prove that add1_lemma' has the required type *) let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma' let code_add1 = FU.va_code_Fast_add1 () let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with | 5 -> Some 0 // rdi | 4 -> Some 1 // rsi | 3 -> Some 2 // rdx | _ -> None let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with | 0 -> MS.rRdi | 1 -> MS.rRsi | 2 -> MS.rRdx let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg (* Here's the type expected for the add1 wrapper *) [@__reduce__] let lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) (* And here's the add1 wrapper itself *) let lowstar_add1 : lowstar_add1_t = assert_norm (List.length dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg add1_regs_modified add1_xmms_modified code_add1 dom (W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win)) let lowstar_add1_normal_t : normal lowstar_add1_t = as_normal_t #lowstar_add1_t lowstar_add1 open Vale.AsLowStar.MemoryHelpers let add_scalar out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); let (x, _) = lowstar_add1_normal_t out f1 f2 () in x let add1_comments : list string = ["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"] let add1_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let add1_code_inline () : FStar.All.ML int = PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments [@__reduce__] let fadd_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__] let fadd_pre : VSig.vale_pre fadd_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fadd_post : VSig.vale_post fadd_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_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 50" let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fadd_xmms_modified = fun _ -> false [@__reduce__] let fadd_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 fadd_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 va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\ fadd_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_Fadd code va_s0 (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 add1_lemma' has the required type *) let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma' let code_Fadd = FH.va_code_Fadd () (* Here's the type expected for the fadd wrapper *) [@__reduce__] let lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.as_lowstar_sig_t_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom [] _ _ // The boolean here doesn't matter (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) (* And here's the fadd wrapper itself *) let lowstar_fadd : lowstar_fadd_t = assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3); IX64.wrap_weak 3 arg_reg fadd_regs_modified fadd_xmms_modified code_Fadd fadd_dom (W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win)) let lowstar_fadd_normal_t : normal lowstar_fadd_t = as_normal_t #lowstar_fadd_t lowstar_fadd let fadd out f1 f2 = DV.length_eq (get_downview out); DV.length_eq (get_downview f1); DV.length_eq (get_downview f2); let (x, _) = lowstar_fadd_normal_t out f1 f2 () in () let fadd_comments : list string = ["Computes the field addition of two field elements"] let fadd_names (n:nat) = match n with | 0 -> "out" | 1 -> "f1" | 2 -> "f2" | _ -> "" let fadd_code_inline () : FStar.All.ML int = PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments [@__reduce__] let fsub_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__] let fsub_pre : VSig.vale_pre fsub_dom = fun (c:V.va_code) (out:b64) (f1:b64) (f2:b64) (va_s0:V.va_state) -> FH.va_req_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) [@__reduce__] let fsub_post : VSig.vale_post fsub_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 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f #set-options "--z3rlimit 200" let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) -> let open MS in if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true else false let fsub_xmms_modified = fun _ -> false [@__reduce__] 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 va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\ 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 code va_s0 (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)
{ "checked_file": "/", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.Print_Inline_s.fst.checked", "Vale.X64.MemoryAdapters.fsti.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.Decls.fsti.checked", "Vale.Interop.X64.fsti.checked", "Vale.Interop.Base.fst.checked", "Vale.Interop.Assumptions.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Curve25519.X64.FastWide.fsti.checked", "Vale.Curve25519.X64.FastUtil.fsti.checked", "Vale.Curve25519.X64.FastHybrid.fsti.checked", "Vale.AsLowStar.Wrapper.fsti.checked", "Vale.AsLowStar.ValeSig.fst.checked", "Vale.AsLowStar.MemoryHelpers.fsti.checked", "Vale.AsLowStar.LowStarSig.fst.checked", "prims.fst.checked", "LowStar.BufferView.Down.fsti.checked", "LowStar.Buffer.fst.checked", "FStar.UInt64.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.All.fst.checked" ], "interface_file": true, "source_file": "Vale.Inline.X64.Fadd_inline.fst" }
[ { "abbrev": false, "full_module": "Vale.AsLowStar.MemoryHelpers", "short_module": null }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastWide", "short_module": "FW" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastHybrid", "short_module": "FH" }, { "abbrev": true, "full_module": "Vale.Curve25519.X64.FastUtil", "short_module": "FU" }, { "abbrev": true, "full_module": "Vale.X64.Print_Inline_s", "short_module": "PR" }, { "abbrev": true, "full_module": "Vale.X64.Machine_s", "short_module": "MS" }, { "abbrev": true, "full_module": "Vale.X64.State", "short_module": "VS" }, { "abbrev": false, "full_module": "Vale.X64.MemoryAdapters", "short_module": null }, { "abbrev": true, "full_module": "Vale.AsLowStar.Wrapper", "short_module": "W" }, { "abbrev": true, "full_module": "Vale.Interop.Assumptions", "short_module": "IA" }, { "abbrev": true, "full_module": "Vale.X64.Decls", "short_module": "V" }, { "abbrev": true, "full_module": "Vale.X64.Memory", "short_module": "ME" }, { "abbrev": true, "full_module": "Vale.AsLowStar.LowStarSig", "short_module": "LSig" }, { "abbrev": true, "full_module": "Vale.AsLowStar.ValeSig", "short_module": "VSig" }, { "abbrev": true, "full_module": "Vale.Interop.X64", "short_module": "IX64" }, { "abbrev": false, "full_module": "Vale.Interop.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": true, "full_module": "LowStar.BufferView.Down", "short_module": "DV" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Curve25519.Fast_defs", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.Inline.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Vale.AsLowStar.ValeSig.vale_sig Vale.Inline.X64.Fadd_inline.fsub_regs_modified Vale.Inline.X64.Fadd_inline.fsub_xmms_modified Vale.Inline.X64.Fadd_inline.fsub_pre Vale.Inline.X64.Fadd_inline.fsub_post
Prims.Tot
[ "total" ]
[]
[ "Vale.Inline.X64.Fadd_inline.as_t", "Vale.AsLowStar.ValeSig.vale_sig", "Vale.Inline.X64.Fadd_inline.fsub_dom", "Vale.Inline.X64.Fadd_inline.fsub_regs_modified", "Vale.Inline.X64.Fadd_inline.fsub_xmms_modified", "Vale.X64.Machine_s.reg_xmm", "Vale.Inline.X64.Fadd_inline.fsub_pre", "Vale.Inline.X64.Fadd_inline.fsub_post", "Vale.Inline.X64.Fadd_inline.fsub_lemma'" ]
[]
false
false
false
true
false
let fsub_lemma =
as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma'
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.check_effect_annot
val check_effect_annot (g: env) (e: effect_annot) : T.Tac (effect_annot_typing g e)
val check_effect_annot (g: env) (e: effect_annot) : T.Tac (effect_annot_typing g e)
let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 50, "end_line": 94, "start_col": 0, "start_line": 89 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> e: Pulse.Syntax.Base.effect_annot -> FStar.Tactics.Effect.Tac (Pulse.Typing.effect_annot_typing g e)
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.effect_annot", "Pulse.Typing.effect_annot_typing", "Pulse.Syntax.Base.term", "Pulse.Checker.Pure.core_check_term", "FStar.Stubs.TypeChecker.Core.E_Total", "Pulse.Syntax.Base.tm_inames", "Pulse.Typing.typing" ]
[]
false
true
false
false
false
let check_effect_annot (g: env) (e: effect_annot) : T.Tac (effect_annot_typing g e) =
match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens = opens } -> CP.core_check_term g opens T.E_Total tm_inames
false
FStar.Bytes.fsti
FStar.Bytes.u8
val u8 : Prims.eqtype
let u8 = U8.t
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 40, "start_col": 7, "start_line": 40 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt8.t" ]
[]
false
false
false
true
false
let u8 =
U8.t
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_verify_compute_msg
val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 427, "start_col": 0, "start_line": 411 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame () inline_for_extraction noextract let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h skey /\ live h m /\ disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_compute_sgnt: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_compute_sgnt_st t ke modBits let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt = push_frame (); let h_init = ST.get () in [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in let m' = create nLen (uint #t 0) in let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_to_bytes_be k s sgnt; pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\ (eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st1 t ke a modBits let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = push_frame (); [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let m = create nLen (uint #t 0) in rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m; let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in pop_frame (); eq_b inline_for_extraction noextract let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h salt /\ live h msg /\ live h sgnt /\ live h skey /\ disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\ disjoint salt msg /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey)) (ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\ (b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_sign: #t:limb_t -> ke:BE.exp t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_st t ke a modBits let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt = let hLen = RM.hash_len a in Math.Lemmas.pow2_lt_compat 61 32; Math.Lemmas.pow2_lt_compat 125 32; //assert (max_size_t < Hash.max_input_length a); let b = saltLen <=. 0xfffffffful -! hLen -! 8ul && saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in if b then rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt else false inline_for_extraction noextract val bn_lt_pow2: #t:limb_t -> modBits:size_t{1 < v modBits} -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h m) (ensures fun h0 r h1 -> h0 == h1 /\ r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m)) let bn_lt_pow2 #t modBits m = if not ((modBits -! 1ul) %. 8ul =. 0ul) then true else begin let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in BB.unsafe_bool_of_limb0 get_bit end inline_for_extraction noextract let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> m_def:lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h pkey /\ live h m_def /\ live h s /\ disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\ (r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s)) inline_for_extraction noextract val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits let rsapss_verify_bn #t ke modBits eBits pkey m_def s = [@inline_let] let bits = size (bits t) in let nLen = blocks modBits bits in let eLen = blocks eBits bits in let n = sub pkey 0ul nLen in let r2 = sub pkey nLen nLen in let e = sub pkey (nLen +! nLen) eLen in let mask = BN.bn_lt_mask nLen s n in let h = ST.get () in SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n); let res = if BB.unsafe_bool_of_limb mask then begin Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits); SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n); let h0 = ST.get () in BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 m_def) (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); if bn_lt_pow2 modBits m_def then true else false end else false in res inline_for_extraction noextract let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = saltLen:size_t -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t (blocks modBits (size (bits t))) -> Stack bool (requires fun h -> live h msg /\ live h m /\ disjoint m msg /\ LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg)) (ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m)) inline_for_extraction noextract val rsapss_verify_bn_to_msg: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_verify_bn_to_msg_st t a modBits let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits == v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let m1 = sub m 0ul mLen in BN.bn_to_bytes_be emLen m1 em; let res = RP.pss_verify a saltLen msgLen msg emBits em in pop_frame (); res inline_for_extraction noextract let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)} -> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t))) -> sgnt:lbuffer uint8 (blocks modBits 8ul) -> m:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h sgnt /\ live h pkey /\ live h m /\ disjoint m sgnt /\ disjoint m pkey /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey)) (ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\ (r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt)) inline_for_extraction noextract val rsapss_verify_compute_msg: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_compute_msg_st t ke modBits
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_verify_compute_msg_st t ke modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.pkey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Prims.bool", "Prims.unit", "FStar.HyperStack.ST.pop_frame", "Hacl.Impl.RSAPSS.rsapss_verify_bn", "Hacl.Bignum.bn_from_bytes_be", "Prims._assert", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.mk_int", "Prims.pos", "Lib.IntTypes.numbytes", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let k = blocks modBits 8ul in let s = create nLen (uint #t 0) in LS.blocks_bits_lemma t (v modBits); LS.blocks_numb_lemma t (v modBits); assert (SD.blocks (v k) numb == v nLen); assert (numb * v nLen <= max_size_t); BN.bn_from_bytes_be k sgnt s; let b = rsapss_verify_bn #t ke modBits eBits pkey m s in pop_frame (); b
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.comp_typing_as_effect_annot_typing
val comp_typing_as_effect_annot_typing (#g: env) (#c: comp_st) (ct: comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c)
val comp_typing_as_effect_annot_typing (#g: env) (#c: comp_st) (ct: comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c)
let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 42, "end_line": 125, "start_col": 0, "start_line": 119 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing }
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ct: Pulse.Typing.comp_typing_u g c -> Pulse.Typing.effect_annot_typing g (Pulse.Syntax.Base.effect_annot_of_comp c)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.comp_st", "Pulse.Typing.comp_typing_u", "Pulse.Typing.st_comp_typing", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Typing.Metatheory.Base.iname_typing", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.observability", "Pulse.Typing.effect_annot_typing", "Pulse.Syntax.Base.effect_annot_of_comp", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Metatheory.Base.comp_typing_inversion" ]
[]
false
false
false
false
false
let comp_typing_as_effect_annot_typing (#g: env) (#c: comp_st) (ct: comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) =
let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.t_equiv
val t_equiv (#g #st #c: _) (d: st_typing g st c) (#c': comp) (eq: st_equiv g c c') : st_typing g st c'
val t_equiv (#g #st #c: _) (d: st_typing g st c) (#c': comp) (eq: st_equiv g c c') : st_typing g st c'
let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 31, "end_line": 248, "start_col": 0, "start_line": 240 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'')
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
d: Pulse.Typing.st_typing g st c -> eq: Pulse.Typing.st_equiv g c c' -> Pulse.Typing.st_typing g st c'
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp", "Pulse.Typing.st_typing", "Pulse.Typing.st_equiv", "Pulse.Checker.Base.st_equiv_trans", "Pulse.Typing.T_Equiv" ]
[]
false
false
false
false
false
let t_equiv #g #st #c (d: st_typing g st c) (#c': comp) (eq: st_equiv g c c') : st_typing g st c' =
match d with | T_Equiv _ _ _ _ d0 eq' -> (match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'') | _ -> T_Equiv _ _ _ _ d eq
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_bn
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 86, "start_col": 0, "start_line": 61 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_bn_st t ke modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Exponentiation.exp", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Hacl.Spec.RSAPSS.skey_len_pre", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.Definitions.lbignum", "Lib.IntTypes.op_Plus_Bang", "Lib.IntTypes.op_Star_Bang", "FStar.UInt32.__uint_to_t", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Spec.Bignum.Base.unsafe_bool_of_limb", "Prims.bool", "Prims.unit", "Lib.Buffer.mapT", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.IntTypes.logand", "Lib.IntTypes.SEC", "Hacl.Bignum.bn_eq_mask", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.Buffer.as_seq", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_vartime_precompr2", "Hacl.Spec.Bignum.Exponentiation.bn_mod_exp_consttime_precompr2", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Exponentiation.mk_bn_mod_exp_precompr2", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_vt_precomp", "Hacl.Bignum.Exponentiation.__proj__Mkexp__item__exp_ct_precomp", "Hacl.Spec.Bignum.Montgomery.bn_precomp_r2_mod_n_lemma", "Prims.op_Subtraction", "FStar.Math.Lemmas.pow2_le_compat", "FStar.Mul.op_Star", "Lib.Buffer.lbuffer_t", "Lib.Buffer.sub", "Lib.IntTypes.int_t", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThan", "Prims.op_LessThanOrEqual", "Prims.pow2", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Definitions.blocks", "Prims.pos" ]
[]
false
false
false
false
false
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@@ inline_let ]let bits:size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.post_hint_from_comp_typing
val post_hint_from_comp_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : post_hint_for_env g
val post_hint_from_comp_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : post_hint_for_env g
let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 3, "end_line": 143, "start_col": 0, "start_line": 128 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ct: Pulse.Typing.comp_typing_u g c -> Pulse.Typing.post_hint_for_env g
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.comp_st", "Pulse.Typing.comp_typing_u", "Pulse.Typing.st_comp_typing", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Typing.Metatheory.Base.iname_typing", "Pulse.Typing.universe_of", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Pulse.Syntax.Base.__proj__Mkst_comp__item__u", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.__proj__Mkst_comp__item__pre", "Pulse.Syntax.Base.tm_vprop", "Pulse.Syntax.Base.var", "Pulse.Typing.fresh_wrt", "Pulse.Syntax.Naming.freevars", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Syntax.Naming.open_term", "Pulse.Typing.post_hint_t", "Pulse.Typing.Mkpost_hint_t", "Pulse.Syntax.Base.effect_annot_of_comp", "Pulse.Syntax.Base.comp_res", "Pulse.Syntax.Base.comp_u", "Pulse.Syntax.Base.comp_post", "Pulse.Checker.Base.post_typing_as_abstraction", "Pulse.Typing.effect_annot_typing", "Pulse.Checker.Base.comp_typing_as_effect_annot_typing", "Pulse.Typing.post_hint_for_env", "FStar.Pervasives.dtuple4", "Pulse.Typing.Metatheory.Base.st_comp_typing_inversion", "FStar.Pervasives.Native.tuple2", "Pulse.Typing.Metatheory.Base.comp_typing_inversion" ]
[]
false
false
false
false
false
let post_hint_from_comp_typing #g #c ct =
let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing , pre_typing , x , post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p:post_hint_t = { g = g; effect_annot = _; effect_annot_typing = effect_annot_typing; ret_ty = comp_res c; u = comp_u c; ty_typing = ty_typing; post = comp_post c; x = x; post_typing_src = post_typing; post_typing = post_typing_as_abstraction post_typing } in p
false
FStar.Bytes.fsti
FStar.Bytes.u16
val u16 : Prims.eqtype
let u16 = U16.t
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 41, "start_col": 7, "start_line": 41 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt16.t" ]
[]
false
false
false
true
false
let u16 =
U16.t
false
FStar.Bytes.fsti
FStar.Bytes.lbytes32
val lbytes32 : l: FStar.UInt32.t -> Type0
let lbytes32 (l:UInt32.t) = b:bytes{len b = l}
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 46, "end_line": 82, "start_col": 0, "start_line": 82 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char unfold let u8 = U8.t unfold let u16 = U16.t unfold let u32 = U32.t (** Realized by uint8_t in C and int in OCaml (char does not have necessary operators...) *) unfold type byte = u8 (** Realized in C by a pair of a length field and uint8_t* in C Realized in OCaml by a string *) val bytes : t:Type0{hasEq t} val len : bytes -> u32 unfold let length b = FStar.UInt32.v (len b) (** representation for specs that need lemmas not defined here. *) val reveal: bytes -> GTot (S.seq byte) val length_reveal: x:bytes -> Lemma (ensures (S.length (reveal x) = length x)) [SMTPatOr [[SMTPat (S.length (reveal x))]; [SMTPat (len x)]]] val hide: s:S.seq byte{S.length s < pow2 32} -> GTot bytes val hide_reveal: x:bytes -> Lemma (ensures (hide (reveal x) = x)) [SMTPat (reveal x)] val reveal_hide: x:S.seq byte{S.length x < pow2 32} -> Lemma (ensures (reveal (hide x) == x)) [SMTPat (hide x)] type lbytes (l:nat) = b:bytes{length b = l} type kbytes (k:nat) = b:bytes{length b < pow2 k}
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
l: FStar.UInt32.t -> Type0
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t", "FStar.Bytes.bytes", "Prims.b2t", "Prims.op_Equality", "FStar.Bytes.len" ]
[]
false
false
false
true
true
let lbytes32 (l: UInt32.t) =
b: bytes{len b = l}
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.format_failed_goal
val format_failed_goal (g:env) (ctxt:list term) (goal:list term) : T.Tac string
val format_failed_goal (g:env) (ctxt:list term) (goal:list term) : T.Tac string
let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g)
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 21, "end_line": 50, "start_col": 0, "start_line": 34 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f())
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> ctxt: Prims.list Pulse.Syntax.Base.term -> goal: Prims.list Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.string
FStar.Tactics.Effect.Tac
[]
[]
[ "Pulse.Typing.Env.env", "Prims.list", "Pulse.Syntax.Base.term", "Prims.string", "FStar.Printf.sprintf", "Pulse.Typing.Env.env_to_string", "Prims.int", "FStar.String.concat", "FStar.List.Tot.Base.rev", "FStar.Pervasives.Native.tuple2", "FStar.Tactics.Util.fold_left", "FStar.Pervasives.Native.Mktuple2", "Prims.op_Addition", "Prims.Cons", "Prims.Nil", "FStar.Tactics.Util.map", "Pulse.Syntax.Printer.term_to_string" ]
[]
false
true
false
false
false
let format_failed_goal (g: env) (ctxt goal: list term) =
let terms_to_strings (ts: list term) = T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i + 1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts: list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n %s\nThe remaining conjuncts in the separation logic context available for use are:\n %s\nThe typing context is:\n %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g)
false
FStar.Bytes.fsti
FStar.Bytes.op_At_Bar
val op_At_Bar : b1: FStar.Bytes.bytes -> b2: FStar.Bytes.bytes -> Prims.Pure FStar.Bytes.bytes
let op_At_Bar = append
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 29, "end_line": 140, "start_col": 7, "start_line": 140 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char unfold let u8 = U8.t unfold let u16 = U16.t unfold let u32 = U32.t (** Realized by uint8_t in C and int in OCaml (char does not have necessary operators...) *) unfold type byte = u8 (** Realized in C by a pair of a length field and uint8_t* in C Realized in OCaml by a string *) val bytes : t:Type0{hasEq t} val len : bytes -> u32 unfold let length b = FStar.UInt32.v (len b) (** representation for specs that need lemmas not defined here. *) val reveal: bytes -> GTot (S.seq byte) val length_reveal: x:bytes -> Lemma (ensures (S.length (reveal x) = length x)) [SMTPatOr [[SMTPat (S.length (reveal x))]; [SMTPat (len x)]]] val hide: s:S.seq byte{S.length s < pow2 32} -> GTot bytes val hide_reveal: x:bytes -> Lemma (ensures (hide (reveal x) = x)) [SMTPat (reveal x)] val reveal_hide: x:S.seq byte{S.length x < pow2 32} -> Lemma (ensures (reveal (hide x) == x)) [SMTPat (hide x)] type lbytes (l:nat) = b:bytes{length b = l} type kbytes (k:nat) = b:bytes{length b < pow2 k} let lbytes32 (l:UInt32.t) = b:bytes{len b = l} val empty_bytes : lbytes 0 val empty_unique: b:bytes -> Lemma (length b = 0 ==> b = empty_bytes) [SMTPat (len b)] (** If you statically know the length, it is OK to read at arbitrary indexes *) val get: b:bytes -> pos:u32{U32.v pos < length b} -> Pure byte (requires True) (ensures (fun y -> y == S.index (reveal b) (U32.v pos))) unfold let op_String_Access = get unfold let index (b:bytes) (i:nat{i < length b}) = get b (U32.uint_to_t i) let equal b1 b2 = length b1 = length b2 /\ (forall (i:u32{U32.v i < length b1}).{:pattern (b1.[i]); (b2.[i])} b1.[i] == b2.[i]) val extensionality: b1:bytes -> b2:bytes -> Lemma (requires (equal b1 b2)) (ensures (b1 = b2)) (** creating byte values **) val create: len:u32 -> v:byte -> b:lbytes (U32.v len){forall (i:u32{U32.(i <^ len)}).{:pattern b.[i]} b.[i] == v} unfold let create_ (n:nat{FStar.UInt.size n U32.n}) v = create (U32.uint_to_t n) v val init: len:u32 -> f:(i:u32{U32.(i <^ len)} -> byte) -> b:lbytes (U32.v len){forall (i:u32{U32.(i <^ len)}).{:pattern b.[i]} b.[i] == f i} // this is a hack JROESCH val abyte (b:byte) : lbytes 1 (* admit () create 1ul b *) val twobytes (b:byte*byte) : lbytes 2 // init 2ul (fun i -> if i = 0ul then fst b else snd b) (** appending bytes **) val append: b1:bytes -> b2:bytes -> Pure bytes (requires (UInt.size (length b1 + length b2) U32.n))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b1: FStar.Bytes.bytes -> b2: FStar.Bytes.bytes -> Prims.Pure FStar.Bytes.bytes
Prims.Pure
[]
[]
[ "FStar.Bytes.append" ]
[]
false
false
false
false
false
let op_At_Bar =
append
false
Hacl.Impl.RSAPSS.fst
Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn
val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m = push_frame (); [@inline_let] let bits : size_pos = bits t in [@inline_let] let numb : size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@inline_let] let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
{ "file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 14, "end_line": 136, "start_col": 0, "start_line": 114 }
module Hacl.Impl.RSAPSS open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module ST = FStar.HyperStack.ST module Hash = Spec.Agile.Hash module SB = Hacl.Spec.Bignum module BB = Hacl.Spec.Bignum.Base module SD = Hacl.Spec.Bignum.Definitions module SM = Hacl.Spec.Bignum.Montgomery module SE = Hacl.Spec.Bignum.Exponentiation module BN = Hacl.Bignum module BE = Hacl.Bignum.Exponentiation module BM = Hacl.Bignum.Montgomery module S = Spec.RSAPSS module LS = Hacl.Spec.RSAPSS module LSeq = Lib.Sequence module RP = Hacl.Impl.RSAPSS.Padding module RM = Hacl.Impl.RSAPSS.MGF module RK = Hacl.Impl.RSAPSS.Keys #reset-options "--z3rlimit 150 --fuel 0 --ifuel 0" inline_for_extraction noextract let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t} inline_for_extraction noextract let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in eBits:size_t -> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)} -> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t))) -> m:lbignum t len -> m':lbignum t len -> s:lbignum t len -> Stack bool (requires fun h -> len == ke.BE.bn.BN.len /\ live h skey /\ live h m /\ live h s /\ live h m' /\ disjoint s m /\ disjoint s skey /\ disjoint m skey /\ disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\ LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\ bn_v h m < bn_v h (gsub skey 0ul len)) (ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\ (r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m)) inline_for_extraction noextract val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s = [@inline_let] let bits : size_pos = bits t in let nLen = blocks modBits (size bits) in let eLen = blocks eBits (size bits) in let dLen = blocks dBits (size bits) in let n = sub skey 0ul nLen in let r2 = sub skey nLen nLen in let e = sub skey (nLen +! nLen) eLen in let d = sub skey (nLen +! nLen +! eLen) dLen in Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits); let h0 = ST.get () in SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n); BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s; BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m'; let h1 = ST.get () in SD.bn_eval_inj (v nLen) (as_seq h1 s) (SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h0 m) (v dBits) (as_seq h0 d)); SD.bn_eval_inj (v nLen) (as_seq h1 m') (SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2) (as_seq h1 s) (v eBits) (as_seq h0 e)); let eq_m = BN.bn_eq_mask nLen m m' in mapT nLen s (logand eq_m) s; BB.unsafe_bool_of_limb eq_m inline_for_extraction noextract let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) = let len = blocks modBits (size (bits t)) in saltLen:size_t -> salt:lbuffer uint8 saltLen -> msgLen:size_t -> msg:lbuffer uint8 msgLen -> m:lbignum t len -> Stack unit (requires fun h -> live h salt /\ live h msg /\ live h m /\ disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\ as_seq h m == LSeq.create (v len) (uint #t 0) /\ LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg)) (ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\ as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg)) inline_for_extraction noextract val rsapss_sign_msg_to_bn: #t:limb_t -> a:Hash.hash_alg{S.hash_is_supported a} -> modBits:modBits_t t -> rsapss_sign_msg_to_bn_st t a modBits
{ "checked_file": "/", "dependencies": [ "Spec.RSAPSS.fst.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.RSAPSS.fst.checked", "Hacl.Spec.Bignum.Montgomery.fsti.checked", "Hacl.Spec.Bignum.Exponentiation.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Spec.Bignum.Base.fst.checked", "Hacl.Spec.Bignum.fsti.checked", "Hacl.Impl.RSAPSS.Padding.fst.checked", "Hacl.Impl.RSAPSS.MGF.fst.checked", "Hacl.Impl.RSAPSS.Keys.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.RSAPSS.fst" }
[ { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Keys", "short_module": "RK" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.MGF", "short_module": "RM" }, { "abbrev": true, "full_module": "Hacl.Impl.RSAPSS.Padding", "short_module": "RP" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Hacl.Spec.RSAPSS", "short_module": "LS" }, { "abbrev": true, "full_module": "Spec.RSAPSS", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Montgomery", "short_module": "SM" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "SD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum", "short_module": "SB" }, { "abbrev": true, "full_module": "Spec.Agile.Hash", "short_module": "Hash" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 150, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} -> modBits: Hacl.Impl.RSAPSS.modBits_t t -> Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn_st t a modBits
Prims.Tot
[ "total" ]
[]
[ "Hacl.Bignum.Definitions.limb_t", "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.RSAPSS.hash_is_supported", "Hacl.Impl.RSAPSS.modBits_t", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.Definitions.blocks", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.update_sub_f", "Hacl.Bignum.Definitions.limb", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "Hacl.Spec.Bignum.bn_from_bytes_be", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.Sequence.lseq", "Hacl.Bignum.bn_from_bytes_be", "Lib.IntTypes.mk_int", "Lib.IntTypes.numbytes", "Lib.Buffer.sub", "Lib.Buffer.lbuffer_t", "FStar.HyperStack.ST.get", "Prims._assert", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Prims.l_and", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Hacl.Spec.Bignum.Definitions.blocks", "Hacl.Spec.RSAPSS.blocks_numb_lemma", "Hacl.Spec.RSAPSS.blocks_bits_lemma", "Hacl.Impl.RSAPSS.Padding.pss_encode", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.create", "Lib.IntTypes.u8", "Prims.eq2", "Prims.op_Subtraction", "Prims.pow2", "Prims.op_Multiply", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.IntTypes.op_Subtraction_Bang", "Prims.pos", "FStar.HyperStack.ST.push_frame" ]
[]
false
false
false
false
false
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame (); [@@ inline_let ]let bits:size_pos = bits t in [@@ inline_let ]let numb:size_pos = numbytes t in let nLen = blocks modBits (size bits) in let emBits = modBits -! 1ul in let emLen = blocks emBits 8ul in [@@ inline_let ]let mLen = blocks emLen (size numb) in let em = create emLen (u8 0) in RP.pss_encode a saltLen salt msgLen msg emBits em; LS.blocks_bits_lemma t (v emBits); LS.blocks_numb_lemma t (v emBits); assert (SD.blocks (v emBits) bits = v mLen); assert (numb * v mLen <= max_size_t); assert (v mLen <= v nLen); let h' = ST.get () in update_sub_f h' m 0ul mLen (fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em)) (fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen)); pop_frame ()
false
FStar.Bytes.fsti
FStar.Bytes.length
val length : b: FStar.Bytes.bytes -> FStar.UInt.uint_t 32
let length b = FStar.UInt32.v (len b)
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 44, "end_line": 52, "start_col": 7, "start_line": 52 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char unfold let u8 = U8.t unfold let u16 = U16.t unfold let u32 = U32.t (** Realized by uint8_t in C and int in OCaml (char does not have necessary operators...) *) unfold type byte = u8 (** Realized in C by a pair of a length field and uint8_t* in C Realized in OCaml by a string *) val bytes : t:Type0{hasEq t} val len : bytes -> u32
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Bytes.bytes -> FStar.UInt.uint_t 32
Prims.Tot
[ "total" ]
[]
[ "FStar.Bytes.bytes", "FStar.UInt32.v", "FStar.Bytes.len", "FStar.UInt.uint_t" ]
[]
false
false
false
false
false
let length b =
FStar.UInt32.v (len b)
false
FStar.Bytes.fsti
FStar.Bytes.u32
val u32 : Prims.eqtype
let u32 = U32.t
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 22, "end_line": 42, "start_col": 7, "start_line": 42 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char unfold let u8 = U8.t
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
Prims.eqtype
Prims.Tot
[ "total" ]
[]
[ "FStar.UInt32.t" ]
[]
false
false
false
true
false
let u32 =
U32.t
false
FStar.Bytes.fsti
FStar.Bytes.op_String_Access
val op_String_Access : b: FStar.Bytes.bytes -> pos: FStar.Bytes.u32{FStar.UInt32.v pos < FStar.Bytes.length b} -> Prims.Pure FStar.Bytes.byte
let op_String_Access = get
{ "file_name": "ulib/FStar.Bytes.fsti", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 33, "end_line": 98, "start_col": 7, "start_line": 98 }
(* Copyright 2008-2017 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (* A standard library for manipulation of value bytes. This model is realized by Bytes.bytes in OCaml and by struct {uintX_t size; char *bytes} (or similar) in C. This file is essentially a specialized version of FStar.Seq, with lemmas and refinements taylored for typical operations on bytes, and with support for machine integers and C-extractible versions (which Seq does not provide.) @summary Value bytes standard library *) module FStar.Bytes module S = FStar.Seq module U = FStar.UInt module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module U64 = FStar.UInt64 module Str = FStar.String module Chr = FStar.Char unfold let u8 = U8.t unfold let u16 = U16.t unfold let u32 = U32.t (** Realized by uint8_t in C and int in OCaml (char does not have necessary operators...) *) unfold type byte = u8 (** Realized in C by a pair of a length field and uint8_t* in C Realized in OCaml by a string *) val bytes : t:Type0{hasEq t} val len : bytes -> u32 unfold let length b = FStar.UInt32.v (len b) (** representation for specs that need lemmas not defined here. *) val reveal: bytes -> GTot (S.seq byte) val length_reveal: x:bytes -> Lemma (ensures (S.length (reveal x) = length x)) [SMTPatOr [[SMTPat (S.length (reveal x))]; [SMTPat (len x)]]] val hide: s:S.seq byte{S.length s < pow2 32} -> GTot bytes val hide_reveal: x:bytes -> Lemma (ensures (hide (reveal x) = x)) [SMTPat (reveal x)] val reveal_hide: x:S.seq byte{S.length x < pow2 32} -> Lemma (ensures (reveal (hide x) == x)) [SMTPat (hide x)] type lbytes (l:nat) = b:bytes{length b = l} type kbytes (k:nat) = b:bytes{length b < pow2 k} let lbytes32 (l:UInt32.t) = b:bytes{len b = l} val empty_bytes : lbytes 0 val empty_unique: b:bytes -> Lemma (length b = 0 ==> b = empty_bytes) [SMTPat (len b)] (** If you statically know the length, it is OK to read at arbitrary indexes *) val get: b:bytes -> pos:u32{U32.v pos < length b} -> Pure byte (requires True) (ensures (fun y -> y == S.index (reveal b) (U32.v pos)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Modifies.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt64.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.UInt.fsti.checked", "FStar.String.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.Char.fsti.checked" ], "interface_file": false, "source_file": "FStar.Bytes.fsti" }
[ { "abbrev": true, "full_module": "FStar.Char", "short_module": "Chr" }, { "abbrev": true, "full_module": "FStar.String", "short_module": "Str" }, { "abbrev": true, "full_module": "FStar.UInt64", "short_module": "U64" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.UInt", "short_module": "U" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: FStar.Bytes.bytes -> pos: FStar.Bytes.u32{FStar.UInt32.v pos < FStar.Bytes.length b} -> Prims.Pure FStar.Bytes.byte
Prims.Pure
[]
[]
[ "FStar.Bytes.get" ]
[]
false
false
false
false
false
let op_String_Access =
get
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.k_elab_unit
val k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt
val k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt
let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 201, "start_col": 0, "start_line": 199 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing }
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> ctxt: Pulse.Syntax.Base.term -> Pulse.Checker.Base.continuation_elaborator g ctxt g ctxt
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.post_hint_opt", "Pulse.Typing.Combinators.st_typing_in_ctxt", "Pulse.Checker.Base.continuation_elaborator" ]
[]
false
false
false
false
false
let k_elab_unit (g: env) (ctxt: term) : continuation_elaborator g ctxt g ctxt =
fun p r -> r
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.comp_with_pre
val comp_with_pre : c: Pulse.Syntax.Base.comp_st -> pre: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.comp
let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre}
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 57, "end_line": 294, "start_col": 0, "start_line": 290 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
c: Pulse.Syntax.Base.comp_st -> pre: Pulse.Syntax.Base.term -> Pulse.Syntax.Base.comp
Prims.Tot
[ "total" ]
[]
[ "Pulse.Syntax.Base.comp_st", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.C_ST", "Pulse.Syntax.Base.Mkst_comp", "Pulse.Syntax.Base.__proj__Mkst_comp__item__u", "Pulse.Syntax.Base.__proj__Mkst_comp__item__res", "Pulse.Syntax.Base.__proj__Mkst_comp__item__post", "Pulse.Syntax.Base.C_STGhost", "Pulse.Syntax.Base.observability", "Pulse.Syntax.Base.C_STAtomic", "Pulse.Syntax.Base.comp" ]
[]
false
false
false
true
false
let comp_with_pre (c: comp_st) (pre: term) =
match c with | C_ST st -> C_ST ({ st with pre = pre }) | C_STGhost st -> C_STGhost ({ st with pre = pre }) | C_STAtomic i obs st -> C_STAtomic i obs ({ st with pre = pre })
false
DM4F_layered5.fst
DM4F_layered5.return_wp
val return_wp (#a: Type) (#st: Type0) (x: a) : wp st a
val return_wp (#a: Type) (#st: Type0) (x: a) : wp st a
let return_wp (#a:Type) (#st:Type0) (x:a) : wp st a = fun s0 p -> p x s0
{ "file_name": "examples/layeredeffects/DM4F_layered5.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 20, "end_line": 48, "start_col": 0, "start_line": 47 }
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module DM4F_layered5 (* Same as DM4F, but layered over a layered PURE without monotonicity *) open ID5 open DM4F_Utils unfold let pure_bind_wp (#a #b : Type) (w1 : ID5.wp a) (w2 : a -> ID5.wp b) : ID5.wp b = ID5.bind_wp w1 w2 (* Simulating state effect in DM4F, hopefully doable by a tactic. *) type post_t st a = a -> st -> Type0 type wp0 (st:Type u#0) (a:Type u#ua) : Type u#(max 1 ua) = st -> post_t st a -> Type0 let st_monotonic #st #a (w : wp0 st a) : Type0 = //forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2 // ^ this version seems to be less SMT-friendly forall s0 p1 p2. (forall x s1. p1 x s1 ==> p2 x s1) ==> w s0 p1 ==> w s0 p2 type wp st a = w:(wp0 st a){st_monotonic w} open FStar.Monotonic.Pure type repr (a:Type u#ua) (st:Type0) (wp : wp u#ua st a) : Type u#(max 1 ua) = s0:st -> ID (a & st) (as_pure_wp (fun p -> wp s0 (curry p)))
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "ID5.fst.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Monotonic.Pure.fst.checked", "FStar.IO.fst.checked", "FStar.Ghost.fsti.checked", "DM4F_Utils.fst.checked" ], "interface_file": false, "source_file": "DM4F_layered5.fst" }
[ { "abbrev": false, "full_module": "FStar.Monotonic.Pure", "short_module": null }, { "abbrev": false, "full_module": "DM4F_Utils", "short_module": null }, { "abbrev": false, "full_module": "ID5", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: a -> DM4F_layered5.wp st a
Prims.Tot
[ "total" ]
[]
[ "DM4F_layered5.wp" ]
[]
false
false
false
true
false
let return_wp (#a: Type) (#st: Type0) (x: a) : wp st a =
fun s0 p -> p x s0
false
Pulse.Checker.Base.fst
Pulse.Checker.Base.check_equiv_emp
val check_equiv_emp (g:env) (vp:term) : option (vprop_equiv g vp tm_emp)
val check_equiv_emp (g:env) (vp:term) : option (vprop_equiv g vp tm_emp)
let rec check_equiv_emp (g:env) (vp:term) : option (vprop_equiv g vp tm_emp) = match vp.t with | Tm_Emp -> Some (VE_Refl _ _) | Tm_Star vp1 vp2 -> (match check_equiv_emp g vp1, check_equiv_emp g vp2 with | Some d1, Some d2 -> let d3 : vprop_equiv g (tm_star vp1 vp2) (tm_star tm_emp tm_emp) = VE_Ctxt _ _ _ _ _ d1 d2 in let d4 : vprop_equiv g (tm_star tm_emp tm_emp) tm_emp = VE_Unit _ _ in Some (VE_Trans _ _ _ _ d3 d4) | _, _ -> None) | _ -> None
{ "file_name": "lib/steel/pulse/Pulse.Checker.Base.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 16, "end_line": 542, "start_col": 0, "start_line": 529 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Checker.Base module T = FStar.Tactics.V2 module RT = FStar.Reflection.Typing module Metatheory = Pulse.Typing.Metatheory module CP = Pulse.Checker.Pure module RU = Pulse.RuntimeUtils module FV = Pulse.Typing.FV module P = Pulse.Syntax.Printer open Pulse.Typing.Combinators open Pulse.Typing.Metatheory let debug (g:env) (f: unit -> T.Tac string) : T.Tac unit = if RU.debug_at_level (fstar_env g) "pulse.checker" then T.print (f()) let format_failed_goal (g:env) (ctxt:list term) (goal:list term) = let terms_to_strings (ts:list term)= T.map Pulse.Syntax.Printer.term_to_string ts in let numbered_list ss = let _, s = T.fold_left (fun (i, acc) s -> (i+1, Printf.sprintf "%d. %s" i s :: acc)) (1, []) ss in String.concat "\n " (List.rev s) in let format_terms (ts:list term) = numbered_list (terms_to_strings ts) in Printf.sprintf "Failed to prove the following goals:\n \ %s\n\ The remaining conjuncts in the separation logic context available for use are:\n \ %s\n\ The typing context is:\n \ %s\n" (format_terms goal) (format_terms ctxt) (env_to_string g) let mk_arrow ty t = RT.mk_arrow (elab_term ty) T.Q_Explicit (elab_term t) let mk_abs ty t = RT.(mk_abs (elab_term ty) T.Q_Explicit (elab_term t)) let intro_comp_typing (g:env) (c:comp_st) (pre_typing:tot_typing g (comp_pre c) tm_vprop) (i_typing:effect_annot_typing g (effect_annot_of_comp c)) (res_typing:universe_of g (comp_res c) (comp_u c)) (x:var { fresh_wrt x g (freevars (comp_post c)) }) (post_typing:tot_typing (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) tm_vprop) : T.Tac (comp_typing g c (universe_of_comp c)) = let intro_st_comp_typing (st:st_comp { comp_u c == st.u /\ comp_pre c == st.pre /\ comp_res c == st.res /\ comp_post c == st.post } ) : T.Tac (st_comp_typing g st) = STC g st x res_typing pre_typing post_typing in match c with | C_ST st -> let stc = intro_st_comp_typing st in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = intro_st_comp_typing st in CT_STAtomic _ i obs _ i_typing stc | C_STGhost st -> let stc = intro_st_comp_typing st in CT_STGhost _ _ stc irreducible let post_typing_as_abstraction (#g:env) (#x:var) (#ty:term) (#t:term { fresh_wrt x g (freevars t) }) (_:tot_typing (push_binding g x ppname_default ty) (open_term t x) tm_vprop) : FStar.Ghost.erased (RT.tot_typing (elab_env g) (mk_abs ty t) (mk_arrow ty tm_vprop)) = admit() let check_effect_annot (g:env) (e:effect_annot) : T.Tac (effect_annot_typing g e) = match e with | EffectAnnotSTT | EffectAnnotGhost -> () | EffectAnnotAtomic { opens } -> CP.core_check_term g opens T.E_Total tm_inames let intro_post_hint g effect_annot ret_ty_opt post = let x = fresh g in let ret_ty = match ret_ty_opt with | None -> tm_fstar RT.unit_ty FStar.Range.range_0 | Some t -> t in let ret_ty, _ = CP.instantiate_term_implicits g ret_ty in let (| u, ty_typing |) = CP.check_universe g ret_ty in let (| post, post_typing |) = CP.check_vprop (push_binding g x ppname_default ret_ty) (open_term_nv post (v_as_nv x)) in let post' = close_term post x in Pulse.Typing.FV.freevars_close_term post x 0; let effect_annot_typing = check_effect_annot g effect_annot in assume (open_term post' x == post); { g; effect_annot; effect_annot_typing; ret_ty; u; ty_typing; post=post'; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction #_ #_ #_ #post' post_typing } let comp_typing_as_effect_annot_typing (#g:env) (#c:comp_st) (ct:comp_typing_u g c) : effect_annot_typing g (effect_annot_of_comp c) = let _, iname_typing = Metatheory.comp_typing_inversion ct in match c with | C_ST _ -> () | C_STGhost _ -> () | C_STAtomic opens obs _ -> iname_typing let post_hint_from_comp_typing #g #c ct = let st_comp_typing, _ = Metatheory.comp_typing_inversion ct in let (| ty_typing, pre_typing, x, post_typing |) = Metatheory.st_comp_typing_inversion st_comp_typing in let effect_annot_typing = comp_typing_as_effect_annot_typing ct in let p : post_hint_t = { g; effect_annot=_; effect_annot_typing; ret_ty = comp_res c; u=comp_u c; ty_typing=ty_typing; post=comp_post c; x; post_typing_src=post_typing; post_typing=post_typing_as_abstraction post_typing } in p let comp_typing_from_post_hint (#g: env) (c: comp_st) (pre_typing: tot_typing g (comp_pre c) tm_vprop) (p:post_hint_for_env g { comp_post_matches_hint c (Some p) }) : T.Tac (comp_typing_u g c) = let x = fresh g in if x `Set.mem` freevars p.post //exclude this then fail g None "Impossible: unexpected freevar in post, please file a bug-report" else let post_typing = post_hint_typing g p x in intro_comp_typing g c pre_typing post_typing.effect_annot_typing post_typing.ty_typing x post_typing.post_typing let extend_post_hint g p x tx conjunct conjunct_typing = let g' = push_binding g x ppname_default tx in let y = fresh g' in let g'' = push_binding g' y ppname_default p.ret_ty in let p_post_typing_src : tot_typing (push_binding p.g p.x ppname_default p.ret_ty) (open_term p.post p.x) tm_vprop = p.post_typing_src in let p_post_typing_src'' : tot_typing g'' (open_term p.post y) tm_vprop = RU.magic () //weaken, rename in let conjunct_typing' : tot_typing g' conjunct tm_vprop = conjunct_typing in let conjunct_typing'' : tot_typing g'' (open_term conjunct y) tm_vprop = RU.magic () //weaken in let new_post = tm_star p.post conjunct in let new_post_typing : tot_typing g'' (open_term new_post y) tm_vprop = Pulse.Typing.star_typing p_post_typing_src'' conjunct_typing'' in assume (fresh_wrt y g'' (freevars new_post)); let new_post_abs_typing : Ghost.erased (RT.tot_typing (elab_env g'') (mk_abs p.ret_ty new_post) (mk_arrow p.ret_ty tm_vprop)) = post_typing_as_abstraction new_post_typing in { p with g=g'; post=new_post; x=y; post_typing_src=new_post_typing; post_typing=new_post_abs_typing } let k_elab_unit (g:env) (ctxt:term) : continuation_elaborator g ctxt g ctxt = fun p r -> r let k_elab_trans (#g0:env) (#g1:env { g1 `env_extends` g0 }) (#g2:env { g2 `env_extends` g1 }) (#ctxt0 #ctxt1 #ctxt2:term) (k0:continuation_elaborator g0 ctxt0 g1 ctxt1) (k1:continuation_elaborator g1 ctxt1 g2 ctxt2 { g1 `env_extends` g0}) : continuation_elaborator g0 ctxt0 g2 ctxt2 = fun post_hint res -> k0 post_hint (k1 post_hint res) let comp_st_with_post (c:comp_st) (post:term) : c':comp_st { st_comp_of_comp c' == ({ st_comp_of_comp c with post} <: st_comp) } = match c with | C_ST st -> C_ST { st with post } | C_STGhost st -> C_STGhost { st with post } | C_STAtomic i obs st -> C_STAtomic i obs {st with post} let ve_unit_r g (p:term) : vprop_equiv g (tm_star p tm_emp) p = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Unit _ _) let st_equiv_trans (#g:env) (#c0 #c1 #c2:comp) (d01:st_equiv g c0 c1) (d12:st_equiv g c1 c2) : option (st_equiv g c0 c2) = match d01 with | ST_VPropEquiv _f _c0 _c1 x c0_pre_typing c0_res_typing c0_post_typing eq_res_01 eq_pre_01 eq_post_01 -> ( let ST_VPropEquiv _f _c1 _c2 y c1_pre_typing c1_res_typing c1_post_typing eq_res_12 eq_pre_12 eq_post_12 = d12 in if x = y && eq_tm (comp_res c0) (comp_res c1) then Some ( ST_VPropEquiv g c0 c2 x c0_pre_typing c0_res_typing c0_post_typing (RT.Rel_trans _ _ _ _ _ eq_res_01 eq_res_12) (VE_Trans _ _ _ _ eq_pre_01 eq_pre_12) (VE_Trans _ _ _ _ eq_post_01 eq_post_12) ) else None ) | ST_TotEquiv g t1 t2 u typing eq -> let ST_TotEquiv _g _t1 t3 _ _ eq' = d12 in let eq'' = Ghost.hide (RT.Rel_trans _ _ _ _ _ eq eq') in Some (ST_TotEquiv g t1 t3 u typing eq'') let t_equiv #g #st #c (d:st_typing g st c) (#c':comp) (eq:st_equiv g c c') : st_typing g st c' = match d with | T_Equiv _ _ _ _ d0 eq' -> ( match st_equiv_trans eq' eq with | None -> T_Equiv _ _ _ _ d eq | Some eq'' -> T_Equiv _ _ _ _ d0 eq'' ) | _ -> T_Equiv _ _ _ _ d eq let st_equiv_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { freevars post `Set.subset` freevars (comp_post c)}) (veq: (x:var { fresh_wrt x g (freevars (comp_post c)) } -> vprop_equiv (push_binding g x ppname_default (comp_res c)) (open_term (comp_post c) x) (open_term post x))) : st_typing g t (comp_st_with_post c post) = if eq_tm post (comp_post c) then d else let c' = comp_st_with_post c post in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let veq = veq x in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) (VE_Refl _ _) veq in t_equiv d st_equiv let simplify_post (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (post:term { comp_post c == tm_star post tm_emp}) : st_typing g t (comp_st_with_post c post) = st_equiv_post d post (fun x -> ve_unit_r (push_binding g x ppname_default (comp_res c)) (open_term post x)) let simplify_lemma (c:comp_st) (c':comp_st) (post_hint:option post_hint_t) : Lemma (requires comp_post_matches_hint c post_hint /\ effect_annot_of_comp c == effect_annot_of_comp c' /\ comp_res c' == comp_res c /\ comp_u c' == comp_u c /\ comp_post c' == tm_star (comp_post c) tm_emp) (ensures comp_post_matches_hint (comp_st_with_post c' (comp_post c)) post_hint /\ comp_pre (comp_st_with_post c' (comp_post c)) == comp_pre c') = () let vprop_equiv_typing_bk (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g p ctxt) : tot_typing g p tm_vprop = let _, bk = vprop_equiv_typing d in bk ctxt_typing let comp_with_pre (c:comp_st) (pre:term) = match c with | C_ST st -> C_ST { st with pre } | C_STGhost st -> C_STGhost { st with pre } | C_STAtomic i obs st -> C_STAtomic i obs {st with pre} let st_equiv_pre (#g:env) (#t:st_term) (#c:comp_st) (d:st_typing g t c) (pre:term) (veq: vprop_equiv g (comp_pre c) pre) : st_typing g t (comp_with_pre c pre) = if eq_tm pre (comp_pre c) then d else let c' = comp_with_pre c pre in let (| u_of, pre_typing, x, post_typing |) = Metatheory.(st_comp_typing_inversion (fst (comp_typing_inversion (st_typing_correctness d)))) in let st_equiv : st_equiv g c c' = ST_VPropEquiv g c c' x pre_typing u_of post_typing (RT.Rel_refl _ _ _) veq (VE_Refl _ _) in t_equiv d st_equiv #push-options "--z3rlimit_factor 4 --ifuel 2 --fuel 0" let k_elab_equiv_continuation (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt #ctxt1 #ctxt2:term) (k:continuation_elaborator g1 ctxt g2 ctxt1) (d:vprop_equiv g2 ctxt1 ctxt2) : continuation_elaborator g1 ctxt g2 ctxt2 = fun post_hint res -> let (| st, c, st_d |) = res in let st_d : st_typing g2 st c = st_d in assert (comp_pre c == ctxt2); let st_d' : st_typing g2 st (comp_with_pre c ctxt1) = st_equiv_pre st_d _ (VE_Sym _ _ _ d) in k post_hint (| st, _, st_d' |) #pop-options let vprop_equiv_typing_fwd (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (#p:_) (d:vprop_equiv g ctxt p) : tot_typing g p tm_vprop = let fwd, _ = vprop_equiv_typing d in fwd ctxt_typing #push-options "--z3rlimit_factor 4 --ifuel 1 --fuel 0" let k_elab_equiv_prefix (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt2 #ctxt:term) (k:continuation_elaborator g1 ctxt1 g2 ctxt) (d:vprop_equiv g1 ctxt1 ctxt2) : continuation_elaborator g1 ctxt2 g2 ctxt = fun post_hint res -> let framing_token : frame_for_req_in_ctxt g1 ctxt2 ctxt1 = let d = VE_Trans _ _ _ _ (VE_Comm _ _ _) (VE_Trans _ _ _ _ (VE_Unit _ _) d) in (| tm_emp, emp_typing, d |) in let res = k post_hint res in let (| st, c, st_d |) = res in assert (comp_pre c == ctxt1); (| _, _, st_equiv_pre st_d _ d |) #pop-options let k_elab_equiv (#g1:env) (#g2:env { g2 `env_extends` g1 }) (#ctxt1 #ctxt1' #ctxt2 #ctxt2':term) (k:continuation_elaborator g1 ctxt1 g2 ctxt2) (d1:vprop_equiv g1 ctxt1 ctxt1') (d2:vprop_equiv g2 ctxt2 ctxt2') : continuation_elaborator g1 ctxt1' g2 ctxt2' = let k : continuation_elaborator g1 ctxt1 g2 ctxt2' = k_elab_equiv_continuation k d2 in let k : continuation_elaborator g1 ctxt1' g2 ctxt2' = k_elab_equiv_prefix k d1 in k #push-options "--query_stats --fuel 2 --ifuel 2 --split_queries no --z3rlimit_factor 20" open Pulse.PP let continuation_elaborator_with_bind (#g:env) (ctxt:term) (#c1:comp{stateful_comp c1}) (#e1:st_term) (e1_typing:st_typing g e1 c1) (ctxt_pre1_typing:tot_typing g (tm_star ctxt (comp_pre c1)) tm_vprop) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g (tm_star ctxt (comp_pre c1)) (push_binding g (snd x) (fst x) (comp_res c1)) (tm_star (open_term (comp_post c1) (snd x)) ctxt)) = let pre1 = comp_pre c1 in let res1 = comp_res c1 in let post1 = comp_post c1 in let ctxt_typing = star_typing_inversion_l ctxt_pre1_typing in // let p_prop = Metatheory.pure_typing_inversion pure_typing in let v_eq = VE_Comm g ctxt pre1 in let framing_token : frame_for_req_in_ctxt g (tm_star ctxt pre1) pre1 = (| ctxt, ctxt_typing, VE_Comm g pre1 ctxt |) in let (| c1, e1_typing |) = apply_frame ctxt_pre1_typing e1_typing framing_token in let (| u_of_1, pre_typing, _, _ |) = Metatheory.(st_comp_typing_inversion (fst <| comp_typing_inversion (st_typing_correctness e1_typing))) in let b = res1 in let ppname, x = x in let g' = push_binding g x ppname b in let post1_opened = open_term_nv post1 (v_as_nv x) in let k : continuation_elaborator g (tm_star ctxt pre1) g' (tm_star post1_opened ctxt) = fun post_hint res -> let (| e2, c2, e2_typing |) = res in assert (comp_post_matches_hint c2 post_hint); let e2_typing : st_typing g' e2 c2 = e2_typing in let e2_closed = close_st_term e2 x in assume (open_st_term e2_closed x == e2); assert (comp_pre c1 == (tm_star ctxt pre1)); assert (comp_post c1 == tm_star post1 ctxt); assert (comp_pre c2 == tm_star post1_opened ctxt); assert (open_term (comp_post c1) x == tm_star post1_opened (open_term ctxt x)); // ctxt is well-typed, hence ln assume (open_term ctxt x == ctxt); assert (open_term (comp_post c1) x == comp_pre c2); // we closed e2 with x assume (~ (x `Set.mem` freevars_st e2_closed)); if x `Set.mem` freevars (comp_post c2) then fail g' None "Impossible: freevar clash when constructing continuation elaborator for bind, please file a bug-report" else ( let t_typing, post_typing = Pulse.Typing.Combinators.bind_res_and_post_typing g c2 x post_hint in let g = push_context g "mk_bind" e1.range in // info_doc g None // [prefix 4 1 (doc_of_string "mk_bind e1 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e1)); // prefix 4 1 (doc_of_string "mk_bind c1 = ") (pp #comp c1); // prefix 4 1 (doc_of_string "mk_bind e2 = ") (doc_of_string (Pulse.Syntax.Printer.st_term_to_string e2)); // prefix 4 1 (doc_of_string "mk_bind c2 = ") (pp #comp c2)] // ; let (| e, c, e_typing |) = Pulse.Typing.Combinators.mk_bind g (tm_star ctxt pre1) e1 e2_closed c1 c2 (ppname, x) e1_typing u_of_1 e2_typing t_typing post_typing (Some? post_hint) in (| e, c, e_typing |) ) in k #pop-options module LN = Pulse.Typing.LN #push-options "--z3rlimit_factor 4 --fuel 1 --ifuel 1" let st_comp_typing_with_post_hint (#g:env) (#ctxt:_) (ctxt_typing:tot_typing g ctxt tm_vprop) (post_hint:post_hint_opt g { Some? post_hint }) (c:comp_st { comp_pre c == ctxt /\ comp_post_matches_hint c post_hint }) : st_comp_typing g (st_comp_of_comp c) = let st = st_comp_of_comp c in let Some ph = post_hint in let post_typing_src : tot_typing (push_binding ph.g ph.x ppname_default ph.ret_ty) (open_term ph.post ph.x) tm_vprop = ph.post_typing_src in let x = fresh g in assume (fresh_wrt x g (freevars ph.post)); assume (None? (lookup g ph.x)); let post_typing_src : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = if x = ph.x then post_typing_src else let open Pulse.Typing.Metatheory.Base in let tt : tot_typing (push_binding ph.g x ppname_default ph.ret_ty) (subst_term (open_term ph.post ph.x) (renaming ph.x x)) (subst_term tm_vprop (renaming ph.x x)) = tot_typing_renaming1 ph.g ph.x ph.ret_ty (open_term ph.post ph.x) tm_vprop post_typing_src x in assert (subst_term tm_vprop (renaming ph.x x) == tm_vprop); assume (subst_term (open_term ph.post ph.x) (renaming ph.x x) == open_term ph.post x); tt in let post_typing_src : tot_typing (push_binding g x ppname_default ph.ret_ty) (open_term ph.post x) tm_vprop = //weakening: TODO RU.magic () in let ty_typing : universe_of ph.g st.res st.u = ph.ty_typing in let ty_typing : universe_of g st.res st.u = Pulse.Typing.Metatheory.tot_typing_weakening_standard ph.g ty_typing g in assert (st.res == ph.ret_ty); assert (st.post == ph.post); STC g st x ty_typing ctxt_typing post_typing_src let continuation_elaborator_with_bind_fn (#g:env) (#ctxt:term) (ctxt_typing:tot_typing g ctxt tm_vprop) (#e1:st_term) (#c1:comp { C_Tot? c1 }) (b:binder{b.binder_ty == comp_res c1}) (e1_typing:st_typing g e1 c1) (x:nvar { None? (lookup g (snd x)) }) : T.Tac (continuation_elaborator g ctxt (push_binding g (snd x) ppname_default (comp_res c1)) ctxt) = let t1 = comp_res c1 in assert ((push_binding g (snd x) (fst x) t1) `env_extends` g); fun post_hint (| e2, c2, d2 |) -> if None? post_hint then T.fail "bind_fn: expects the post_hint to be set"; let ppname, x = x in let e2_closed = close_st_term e2 x in assume (open_st_term (close_st_term e2 x) x == e2); let e = wr c2 (Tm_Bind {binder=b; head=e1; body=e2_closed}) in let (| u, c1_typing |) = Pulse.Typing.Metatheory.Base.st_typing_correctness_ctot e1_typing in let c2_typing : comp_typing g c2 (universe_of_comp c2) = match c2 with | C_ST st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_ST _ _ stc | C_STAtomic i obs st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in let i_typing = CP.core_check_term g i T.E_Total tm_inames in CT_STAtomic _ _ obs _ i_typing stc | C_STGhost st -> let stc = st_comp_typing_with_post_hint ctxt_typing post_hint c2 in CT_STGhost _ _ stc in let d : st_typing g e c2 = T_BindFn g e1 e2_closed c1 c2 b x e1_typing u c1_typing d2 c2_typing in (| e, c2, d |)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Metatheory.Base.fsti.checked", "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.LN.fsti.checked", "Pulse.Typing.FV.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.RuntimeUtils.fsti.checked", "Pulse.Readback.fsti.checked", "Pulse.PP.fst.checked", "Pulse.Checker.Pure.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.String.fsti.checked", "FStar.Squash.fsti.checked", "FStar.Set.fsti.checked", "FStar.Reflection.V2.TermEq.fst.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Range.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.List.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.Base.fst" }
[ { "abbrev": true, "full_module": "Pulse.Typing.LN", "short_module": "LN" }, { "abbrev": false, "full_module": "Pulse.PP", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Metatheory", "short_module": null }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "Pulse.Checker.Pure", "short_module": "CP" }, { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.RuntimeUtils", "short_module": "RU" }, { "abbrev": true, "full_module": "Pulse.Typing.FV", "short_module": "FV" }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 1, "initial_ifuel": 1, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
g: Pulse.Typing.Env.env -> vp: Pulse.Syntax.Base.term -> FStar.Pervasives.Native.option (Pulse.Typing.vprop_equiv g vp Pulse.Syntax.Base.tm_emp)
Prims.Tot
[ "total" ]
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.__proj__Mkterm__item__t", "FStar.Pervasives.Native.Some", "Pulse.Typing.vprop_equiv", "Pulse.Syntax.Base.tm_emp", "Pulse.Typing.VE_Refl", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.option", "Pulse.Checker.Base.check_equiv_emp", "Pulse.Typing.VE_Trans", "Pulse.Syntax.Base.tm_star", "Pulse.Typing.VE_Unit", "Pulse.Typing.VE_Ctxt", "FStar.Pervasives.Native.None", "Pulse.Syntax.Base.term'" ]
[ "recursion" ]
false
false
false
false
false
let rec check_equiv_emp (g: env) (vp: term) : option (vprop_equiv g vp tm_emp) =
match vp.t with | Tm_Emp -> Some (VE_Refl _ _) | Tm_Star vp1 vp2 -> (match check_equiv_emp g vp1, check_equiv_emp g vp2 with | Some d1, Some d2 -> let d3:vprop_equiv g (tm_star vp1 vp2) (tm_star tm_emp tm_emp) = VE_Ctxt _ _ _ _ _ d1 d2 in let d4:vprop_equiv g (tm_star tm_emp tm_emp) tm_emp = VE_Unit _ _ in Some (VE_Trans _ _ _ _ d3 d4) | _, _ -> None) | _ -> None
false