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.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_ocmp | val machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool | val machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool | let machine_eval_ocmp (s:machine_state) (c:ocmp) : machine_state & bool =
let s = run (check (valid_ocmp_opaque c)) s in
let b = eval_ocmp_opaque s c in
let s = {s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b)::s.ms_trace} in
(s, b) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 8,
"end_line": 737,
"start_col": 0,
"start_line": 733
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace})
[@"opaque_to_smt"]
let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state =
machine_eval_code_ins_def i s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | s: Vale.X64.Machine_Semantics_s.machine_state -> c: Vale.X64.Machine_Semantics_s.ocmp
-> Vale.X64.Machine_Semantics_s.machine_state * Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.ocmp",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"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.havoc_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",
"Prims.Cons",
"Vale.X64.Machine_s.observation",
"Vale.X64.Machine_s.BranchPredicate",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"Vale.X64.Machine_Semantics_s.eval_ocmp_opaque",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.check",
"Vale.X64.Machine_Semantics_s.valid_ocmp_opaque",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool =
| let s = run (check (valid_ocmp_opaque c)) s in
let b = eval_ocmp_opaque s c in
let s = { s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b) :: s.ms_trace } in
(s, b) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_ins | val machine_eval_ins (i: ins) (s: machine_state) : machine_state | val machine_eval_ins (i: ins) (s: machine_state) : machine_state | let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 723,
"start_col": 0,
"start_line": 722
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state
-> Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st"
] | [] | false | false | false | true | false | let machine_eval_ins (i: ins) (s: machine_state) : machine_state =
| run (machine_eval_ins_st i) s | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.try_option | val try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit | val try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit | let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 422,
"start_col": 0,
"start_line": 419
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | o: FStar.Pervasives.Native.option a -> f: (_: a -> Vale.X64.Machine_Semantics_s.st Prims.unit)
-> Vale.X64.Machine_Semantics_s.st Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.option",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.fail"
] | [] | false | false | false | true | false | let try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit =
| match o with
| None -> fail
| Some x -> f x | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_code_ins | val machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state | val machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state | let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state =
machine_eval_code_ins_def i s | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 31,
"end_line": 731,
"start_col": 0,
"start_line": 730
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace}) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.machine_eval_code_ins_def",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state =
| machine_eval_code_ins_def i s | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_code_ins_def | val machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state | val machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state | let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace}) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 87,
"end_line": 728,
"start_col": 0,
"start_line": 725
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.Some",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"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",
"FStar.List.Tot.Base.op_At",
"Vale.X64.Machine_s.observation",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"Vale.X64.Machine_Semantics_s.machine_eval_ins",
"Prims.Nil",
"Prims.list",
"Vale.X64.Machine_Semantics_s.ins_obs",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state =
| let obs = ins_obs i s in
Some ({ machine_eval_ins i ({ s with ms_trace = [] }) with ms_trace = obs @ s.ms_trace }) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.bind_option | val bind_option (#a #b: Type) (v: option a) (f: (a -> option b)) : option b | val bind_option (#a #b: Type) (v: option a) (f: (a -> option b)) : option b | let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 480,
"start_col": 0,
"start_line": 477
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | v: FStar.Pervasives.Native.option a -> f: (_: a -> FStar.Pervasives.Native.option b)
-> FStar.Pervasives.Native.option b | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.None"
] | [] | false | false | false | true | false | let bind_option (#a #b: Type) (v: option a) (f: (a -> option b)) : option b =
| match v with
| None -> None
| Some x -> f x | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.obs_operand_explicit | val obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state)
: list observation | val obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state)
: list observation | let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 500,
"start_col": 0,
"start_line": 494
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
i: Vale.X64.Instruction_s.instr_operand_explicit ->
o: Vale.X64.Instruction_s.instr_operand_t i ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.operand_obs",
"Vale.X64.Machine_Semantics_s.operand_obs128",
"Prims.list",
"Vale.X64.Machine_s.observation"
] | [] | false | false | false | false | false | let obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state)
: list observation =
| match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.obs_operand_implicit | val obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation | val obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation | let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> [] | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 509,
"start_col": 0,
"start_line": 503
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | i: Vale.X64.Instruction_s.instr_operand_implicit -> s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_Semantics_s.operand_obs",
"Vale.X64.Machine_s.operand128",
"Vale.X64.Machine_Semantics_s.operand_obs128",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Prims.list"
] | [] | false | false | false | true | false | let obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation =
| match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> [] | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.operand_obs | val operand_obs (s: machine_state) (o: operand64) : list observation | val operand_obs (s: machine_state) (o: operand64) : list observation | let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 485,
"start_col": 0,
"start_line": 482
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | s: Vale.X64.Machine_Semantics_s.machine_state -> o: Vale.X64.Machine_s.operand64
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_s.nat64",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Machine_s.maddr",
"Vale.Arch.HeapTypes_s.taint",
"Prims.Cons",
"Vale.X64.Machine_s.MemAccess",
"Vale.X64.Machine_Semantics_s.eval_maddr",
"Prims.list"
] | [] | false | false | false | true | false | let operand_obs (s: machine_state) (o: operand64) : list observation =
| match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | false |
Pulse.Elaborate.fst | Pulse.Elaborate.elab_close_commute' | val elab_close_commute' (e:term)
(v:var)
(n:index)
: Lemma (RT.subst_term (elab_term e) [ RT.ND v n ] ==
elab_term (close_term' e v n)) | val elab_close_commute' (e:term)
(v:var)
(n:index)
: Lemma (RT.subst_term (elab_term e) [ RT.ND v n ] ==
elab_term (close_term' e v n)) | let rec elab_close_commute' (e:term)
(v:var)
(n:index)
: Lemma (ensures (
RT.subst_term (elab_term e) [ RT.ND v n ] ==
elab_term (close_term' e v n)))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
| Tm_Inv p ->
elab_close_commute' p v n
| Tm_Pure p ->
elab_close_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_close_commute' e1 v n;
elab_close_commute' e2 v n
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_close_commute' t.binder_ty v n;
elab_close_commute' body v (n + 1)
| Tm_FStar _ -> () | {
"file_name": "lib/steel/pulse/Pulse.Elaborate.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 113,
"start_col": 0,
"start_line": 88
} | (*
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.Elaborate
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Elaborate.Core
// let rec elab_term_bv_sort (t:term)
// : Lemma
// (ensures
// (R.Tv_Var? (R.inspect_ln (elab_term t)) \/
// R.Tv_BVar? (R.inspect_ln (elab_term t))) ==>
// (match R.inspect_ln (elab_term t) with
// | R.Tv_Var bv
// | R.Tv_BVar bv ->
// let vv = R.inspect_bv bv in
// vv.bv_sort == RT.tun))
// = admit()
#push-options "--fuel 10 --ifuel 10 --z3rlimit_factor 30 --query_stats --z3cliopt 'smt.qi.eager_threshold=100'"
let rec elab_open_commute' (e:term)
(v:term)
(n:index)
: Lemma (ensures
RT.subst_term (elab_term e) [ RT.DT n (elab_term v) ] ==
elab_term (open_term' e v n))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
// | Tm_PureApp e1 _ e2 ->
// elab_open_commute' e1 v n;
// elab_open_commute' e2 v n
| Tm_Inv p ->
elab_open_commute' p v n
| Tm_Pure p ->
elab_open_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_open_commute' e1 v n;
elab_open_commute' e2 v n
| Tm_ExistsSL u t body
| Tm_ForallSL u t body ->
elab_open_commute' t.binder_ty v n;
elab_open_commute' body v (n + 1)
| Tm_FStar t -> ()
let elab_comp_open_commute' (c:comp) (v:term) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.DT n (elab_term v) ] ==
elab_comp (open_comp' c v n))
= match c with
| C_Tot t -> elab_open_commute' t v n
| C_ST s
| C_STGhost s ->
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_open_commute' inames v n;
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1) | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Elaborate.Core.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Elaborate.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Naming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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": 10,
"initial_ifuel": 10,
"max_fuel": 10,
"max_ifuel": 10,
"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": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 30,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | e: Pulse.Syntax.Base.term -> v: Pulse.Syntax.Base.var -> n: Pulse.Syntax.Base.index
-> FStar.Pervasives.Lemma
(ensures
FStar.Reflection.Typing.subst_term (Pulse.Elaborate.Pure.elab_term e)
[FStar.Reflection.Typing.ND v n] ==
Pulse.Elaborate.Pure.elab_term (Pulse.Syntax.Naming.close_term' e v n)) (decreases e) | FStar.Pervasives.Lemma | [
"",
"lemma"
] | [] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.index",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Elaborate.elab_close_commute'",
"Prims.unit",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"Prims.op_Addition",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty",
"Pulse.Syntax.Base.host_term",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.Typing.subst_term",
"Pulse.Elaborate.Pure.elab_term",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.ND",
"Prims.Nil",
"Pulse.Syntax.Naming.close_term'",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec elab_close_commute' (e: term) (v: var) (n: index)
: Lemma (ensures (RT.subst_term (elab_term e) [RT.ND v n] == elab_term (close_term' e v n)))
(decreases e) =
| match e.t with
| Tm_Emp | Tm_Inames | Tm_EmpInames | Tm_VProp | Tm_Unknown -> ()
| Tm_Inv p -> elab_close_commute' p v n
| Tm_Pure p -> elab_close_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_close_commute' e1 v n;
elab_close_commute' e2 v n
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_close_commute' t.binder_ty v n;
elab_close_commute' body v (n + 1)
| Tm_FStar _ -> () | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.ins_obs | val ins_obs (ins: ins) (s: machine_state) : list observation | val ins_obs (ins: ins) (s: machine_state) : list observation | let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> [] | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 549,
"start_col": 0,
"start_line": 544
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | ins: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.obs_inouts",
"Vale.X64.Machine_s.operand64",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Machine_Semantics_s.operand_obs",
"Vale.X64.Machine_s.nat64",
"Prims.Nil",
"Vale.X64.Machine_s.observation"
] | [] | false | false | false | true | false | let ins_obs (ins: ins) (s: machine_state) : list observation =
| match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> [] | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_write_output_implicit | val instr_write_output_implicit
(i: instr_operand_implicit)
(v: instr_val_t (IOpIm i))
(s_orig s: machine_state)
: machine_state | val instr_write_output_implicit
(i: instr_operand_implicit)
(v: instr_val_t (IOpIm i))
(s_orig s: machine_state)
: machine_state | let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 61,
"end_line": 640,
"start_col": 0,
"start_line": 631
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
i: Vale.X64.Instruction_s.instr_operand_implicit ->
v: Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpIm i) ->
s_orig: Vale.X64.Machine_Semantics_s.machine_state ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_Semantics_s.state_or_fail",
"Vale.X64.Machine_Semantics_s.valid_dst_operand64",
"Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags''",
"Vale.X64.Machine_s.operand128",
"Vale.X64.Machine_Semantics_s.valid_dst_operand128",
"Vale.X64.Machine_Semantics_s.update_operand128_preserve_flags''",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"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.update_cf'",
"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",
"Vale.X64.Machine_Semantics_s.update_of'"
] | [] | false | false | false | false | false | let instr_write_output_implicit
(i: instr_operand_implicit)
(v: instr_val_t (IOpIm i))
(s_orig s: machine_state)
: machine_state =
| match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> { s with ms_flags = update_cf' s.ms_flags v }
| IOpFlagsOf -> { s with ms_flags = update_of' s.ms_flags v } | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.obs_args | val obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state)
: list observation | val obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state)
: list observation | let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 524,
"start_col": 0,
"start_line": 512
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> [] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
oprs: Vale.X64.Instruction_s.instr_operands_t_args args ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.List.Tot.Base.op_At",
"Vale.X64.Machine_Semantics_s.obs_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.obs_args",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.obs_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state)
: list observation =
| match args with
| [] -> []
| i :: args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s | false |
Pulse.Elaborate.fst | Pulse.Elaborate.elab_freevars_comp_eq | val elab_freevars_comp_eq (c: comp)
: Lemma (Set.equal (freevars_comp c) (RT.freevars (elab_comp c))) | val elab_freevars_comp_eq (c: comp)
: Lemma (Set.equal (freevars_comp c) (RT.freevars (elab_comp c))) | let elab_freevars_comp_eq (c:comp)
: Lemma (Set.equal (freevars_comp c) (RT.freevars (elab_comp c))) =
match c with
| C_Tot t -> elab_freevars_eq t
| C_ST st
| C_STGhost st ->
elab_freevars_eq st.res;
elab_freevars_eq st.pre;
elab_freevars_eq st.post
| C_STAtomic inames _ st ->
elab_freevars_eq inames;
elab_freevars_eq st.res;
elab_freevars_eq st.pre;
elab_freevars_eq st.post | {
"file_name": "lib/steel/pulse/Pulse.Elaborate.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 28,
"end_line": 218,
"start_col": 0,
"start_line": 204
} | (*
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.Elaborate
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Elaborate.Core
// let rec elab_term_bv_sort (t:term)
// : Lemma
// (ensures
// (R.Tv_Var? (R.inspect_ln (elab_term t)) \/
// R.Tv_BVar? (R.inspect_ln (elab_term t))) ==>
// (match R.inspect_ln (elab_term t) with
// | R.Tv_Var bv
// | R.Tv_BVar bv ->
// let vv = R.inspect_bv bv in
// vv.bv_sort == RT.tun))
// = admit()
#push-options "--fuel 10 --ifuel 10 --z3rlimit_factor 30 --query_stats --z3cliopt 'smt.qi.eager_threshold=100'"
let rec elab_open_commute' (e:term)
(v:term)
(n:index)
: Lemma (ensures
RT.subst_term (elab_term e) [ RT.DT n (elab_term v) ] ==
elab_term (open_term' e v n))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
// | Tm_PureApp e1 _ e2 ->
// elab_open_commute' e1 v n;
// elab_open_commute' e2 v n
| Tm_Inv p ->
elab_open_commute' p v n
| Tm_Pure p ->
elab_open_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_open_commute' e1 v n;
elab_open_commute' e2 v n
| Tm_ExistsSL u t body
| Tm_ForallSL u t body ->
elab_open_commute' t.binder_ty v n;
elab_open_commute' body v (n + 1)
| Tm_FStar t -> ()
let elab_comp_open_commute' (c:comp) (v:term) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.DT n (elab_term v) ] ==
elab_comp (open_comp' c v n))
= match c with
| C_Tot t -> elab_open_commute' t v n
| C_ST s
| C_STGhost s ->
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_open_commute' inames v n;
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
let rec elab_close_commute' (e:term)
(v:var)
(n:index)
: Lemma (ensures (
RT.subst_term (elab_term e) [ RT.ND v n ] ==
elab_term (close_term' e v n)))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
| Tm_Inv p ->
elab_close_commute' p v n
| Tm_Pure p ->
elab_close_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_close_commute' e1 v n;
elab_close_commute' e2 v n
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_close_commute' t.binder_ty v n;
elab_close_commute' body v (n + 1)
| Tm_FStar _ -> ()
let elab_comp_close_commute' (c:comp) (v:var) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.ND v n ] ==
elab_comp (close_comp' c v n))
(decreases c)
= match c with
| C_Tot t -> elab_close_commute' t v n
| C_ST s
| C_STGhost s ->
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_close_commute' inames v n;
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1)
let elab_open_commute (t:term) (x:var)
: Lemma (elab_term (open_term t x) == RT.open_term (elab_term t) x)
= RT.open_term_spec (elab_term t) x;
elab_open_commute' t (null_var x) 0
let elab_comp_close_commute (c:comp) (x:var)
: Lemma (elab_comp (close_comp c x) == RT.close_term (elab_comp c) x)
= RT.close_term_spec (elab_comp c) x;
elab_comp_close_commute' c x 0
let elab_comp_open_commute (c:comp) (x:term)
: Lemma (elab_comp (open_comp_with c x) == RT.open_with (elab_comp c) (elab_term x))
= RT.open_with_spec (elab_comp c) (elab_term x);
elab_comp_open_commute' c x 0
let rec elab_ln t i =
match t.t with
| Tm_Emp -> ()
| Tm_Inv p -> elab_ln p i
| Tm_Pure t -> elab_ln t i
| Tm_AddInv l r
| Tm_Star l r ->
elab_ln l i;
elab_ln r i
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_ln t.binder_ty i;
elab_ln body (i + 1)
| Tm_VProp
| Tm_Inames
| Tm_EmpInames
| Tm_Unknown
| Tm_FStar _ -> ()
let elab_ln_comp (c:comp) (i:int)
: Lemma (requires ln_c' c i)
(ensures RT.ln' (elab_comp c) i) =
match c with
| C_Tot t -> elab_ln t i
| C_ST st
| C_STGhost st ->
elab_ln st.res i;
elab_ln st.pre i;
elab_ln st.post (i + 1)
| C_STAtomic inames _ st ->
elab_ln inames i;
elab_ln st.res i;
elab_ln st.pre i;
elab_ln st.post (i + 1)
let rec elab_freevars_eq (e:term)
: Lemma (Set.equal (freevars e) (RT.freevars (elab_term e))) =
match e.t with
| Tm_Emp -> ()
| Tm_Inv p -> elab_freevars_eq p
| Tm_Pure t -> elab_freevars_eq t
| Tm_AddInv l r
| Tm_Star l r ->
elab_freevars_eq l;
elab_freevars_eq r
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_freevars_eq t.binder_ty;
elab_freevars_eq body
| Tm_VProp
| Tm_Inames
| Tm_EmpInames
| Tm_Unknown
| Tm_FStar _ -> () | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Elaborate.Core.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Elaborate.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Naming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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": 10,
"initial_ifuel": 10,
"max_fuel": 10,
"max_ifuel": 10,
"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": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 30,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp
-> FStar.Pervasives.Lemma
(ensures
FStar.Set.equal (Pulse.Syntax.Naming.freevars_comp c)
(FStar.Reflection.Typing.freevars (Pulse.Elaborate.Pure.elab_comp c))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.term",
"Pulse.Elaborate.elab_freevars_eq",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Prims.unit",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.observability",
"Prims.l_True",
"Prims.squash",
"FStar.Set.equal",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Naming.freevars_comp",
"FStar.Reflection.Typing.freevars",
"Pulse.Elaborate.Pure.elab_comp",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let elab_freevars_comp_eq (c: comp)
: Lemma (Set.equal (freevars_comp c) (RT.freevars (elab_comp c))) =
| match c with
| C_Tot t -> elab_freevars_eq t
| C_ST st
| C_STGhost st ->
elab_freevars_eq st.res;
elab_freevars_eq st.pre;
elab_freevars_eq st.post
| C_STAtomic inames _ st ->
elab_freevars_eq inames;
elab_freevars_eq st.res;
elab_freevars_eq st.pre;
elab_freevars_eq st.post | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.operand_obs128 | val operand_obs128 (s: machine_state) (op: operand128) : list observation | val operand_obs128 (s: machine_state) (op: operand128) : list observation | let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 63,
"end_line": 491,
"start_col": 0,
"start_line": 488
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | s: Vale.X64.Machine_Semantics_s.machine_state -> op: Vale.X64.Machine_s.operand128
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_s.operand128",
"Vale.X64.Machine_s.quad32",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Vale.X64.Machine_s.reg_xmm",
"Vale.X64.Machine_s.maddr",
"Vale.Arch.HeapTypes_s.taint",
"Prims.Cons",
"Vale.X64.Machine_s.MemAccess",
"Vale.X64.Machine_Semantics_s.eval_maddr",
"Prims.list"
] | [] | false | false | false | true | false | let operand_obs128 (s: machine_state) (op: operand128) : list observation =
| match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit | val instr_eval_operand_explicit
(i: instr_operand_explicit)
(o: instr_operand_t i)
(s: machine_state)
: option (instr_val_t (IOpEx i)) | val instr_eval_operand_explicit
(i: instr_operand_explicit)
(o: instr_operand_t i)
(s: machine_state)
: option (instr_val_t (IOpEx i)) | let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 555,
"start_col": 0,
"start_line": 552
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> [] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
i: Vale.X64.Instruction_s.instr_operand_explicit ->
o: Vale.X64.Instruction_s.instr_operand_t i ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpEx
i)) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint",
"FStar.Pervasives.Native.Some",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.IOpEx",
"Vale.X64.Machine_Semantics_s.eval_operand",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Vale.X64.Machine_Semantics_s.valid_src_operand128_and_taint",
"Vale.X64.Machine_Semantics_s.eval_mov128_op"
] | [] | false | false | false | false | false | let instr_eval_operand_explicit
(i: instr_operand_explicit)
(o: instr_operand_t i)
(s: machine_state)
: option (instr_val_t (IOpEx i)) =
| match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts | val instr_apply_eval_inouts
(outs inouts: list instr_out)
(args: list instr_operand)
(f: instr_inouts_t outs inouts args)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: option (instr_ret_t outs) | val instr_apply_eval_inouts
(outs inouts: list instr_out)
(args: list instr_operand)
(f: instr_inouts_t outs inouts args)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: option (instr_ret_t outs) | let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 82,
"end_line": 602,
"start_col": 0,
"start_line": 582
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
inouts: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
f: Vale.X64.Instruction_s.instr_inouts_t outs inouts args ->
oprs: Vale.X64.Instruction_s.instr_operands_t inouts args ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_ret_t outs) | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_inouts_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.instr_apply_eval_args",
"Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_implicit",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Machine_Semantics_s.bind_option",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Instruction_s.arrow",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec instr_apply_eval_inouts
(outs inouts: list instr_out)
(args: list instr_operand)
(f: instr_inouts_t outs inouts args)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: option (instr_ret_t outs) =
| match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i) :: inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i) :: inouts ->
let v, oprs =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_apply_eval_args | val instr_apply_eval_args
(outs: list instr_out)
(args: list instr_operand)
(f: instr_args_t outs args)
(oprs: instr_operands_t_args args)
(s: machine_state)
: option (instr_ret_t outs) | val instr_apply_eval_args
(outs: list instr_out)
(args: list instr_operand)
(f: instr_args_t outs args)
(oprs: instr_operands_t_args args)
(s: machine_state)
: option (instr_ret_t outs) | let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 73,
"end_line": 579,
"start_col": 0,
"start_line": 566
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
f: Vale.X64.Instruction_s.instr_args_t outs args ->
oprs: Vale.X64.Instruction_s.instr_operands_t_args args ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_ret_t outs) | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_args_t",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Machine_Semantics_s.bind_option",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Machine_Semantics_s.instr_apply_eval_args",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.coerce",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec instr_apply_eval_args
(outs: list instr_out)
(args: list instr_operand)
(f: instr_args_t outs args)
(oprs: instr_operands_t_args args)
(s: machine_state)
: option (instr_ret_t outs) =
| match args with
| [] -> f
| i :: args ->
let v, oprs =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_write_output_explicit | val instr_write_output_explicit
(i: instr_operand_explicit)
(v: instr_val_t (IOpEx i))
(o: instr_operand_t i)
(s_orig s: machine_state)
: machine_state | val instr_write_output_explicit
(i: instr_operand_explicit)
(v: instr_val_t (IOpEx i))
(o: instr_operand_t i)
(s_orig s: machine_state)
: machine_state | let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 101,
"end_line": 628,
"start_col": 0,
"start_line": 621
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false} | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
i: Vale.X64.Instruction_s.instr_operand_explicit ->
v: Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpEx i) ->
o: Vale.X64.Instruction_s.instr_operand_t i ->
s_orig: Vale.X64.Machine_Semantics_s.machine_state ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.IOpEx",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.state_or_fail",
"Vale.X64.Machine_Semantics_s.valid_dst_operand64",
"Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags''",
"Vale.X64.Machine_Semantics_s.valid_dst_operand128",
"Vale.X64.Machine_Semantics_s.update_operand128_preserve_flags''"
] | [] | false | false | false | false | false | let instr_write_output_explicit
(i: instr_operand_explicit)
(v: instr_val_t (IOpEx i))
(o: instr_operand_t i)
(s_orig s: machine_state)
: machine_state =
| match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit | val instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state)
: option (instr_val_t (IOpIm i)) | val instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state)
: option (instr_val_t (IOpIm i)) | let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 563,
"start_col": 0,
"start_line": 558
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | i: Vale.X64.Instruction_s.instr_operand_implicit -> s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpIm
i)) | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint",
"FStar.Pervasives.Native.Some",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.IOpIm",
"Vale.X64.Machine_Semantics_s.eval_operand",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Vale.X64.Machine_s.operand128",
"Vale.X64.Machine_Semantics_s.valid_src_operand128_and_taint",
"Vale.X64.Machine_Semantics_s.eval_mov128_op",
"Vale.X64.Machine_Semantics_s.cf",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"Vale.X64.Machine_Semantics_s.overflow"
] | [] | false | false | false | false | false | let instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state)
: option (instr_val_t (IOpIm i)) =
| match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.instr_write_outputs | val instr_write_outputs
(outs: list instr_out)
(args: list instr_operand)
(vs: instr_ret_t outs)
(oprs: instr_operands_t outs args)
(s_orig s: machine_state)
: machine_state | val instr_write_outputs
(outs: list instr_out)
(args: list instr_operand)
(vs: instr_ret_t outs)
(oprs: instr_operands_t outs args)
(s_orig s: machine_state)
: machine_state | let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
) | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 669,
"start_col": 0,
"start_line": 648
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
vs: Vale.X64.Instruction_s.instr_ret_t outs ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args ->
s_orig: Vale.X64.Machine_Semantics_s.machine_state ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.instr_write_output_explicit",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.instr_write_output_implicit",
"FStar.Pervasives.Native.Mktuple2"
] | [
"recursion"
] | false | false | false | false | false | let rec instr_write_outputs
(outs: list instr_out)
(args: list instr_operand)
(vs: instr_ret_t outs)
(oprs: instr_operands_t outs args)
(s_orig s: machine_state)
: machine_state =
| match outs with
| [] -> s
| (_, i) :: outs ->
(let (v: instr_val_t i), (vs: instr_ret_t outs) =
match outs with
| [] -> (vs, ())
| _ :: _ ->
let vs = coerce vs in
(fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s) | false |
Vale.X64.Leakage_Ins.fst | Vale.X64.Leakage_Ins.lemma_pop_leakage_free | val lemma_pop_leakage_free (ts: analysis_taints) (ins: S.ins)
: Lemma (requires BC.Pop? ins)
(ensures
(let b, ts' = check_if_pop_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts)) | val lemma_pop_leakage_free (ts: analysis_taints) (ins: S.ins)
: Lemma (requires BC.Pop? ins)
(ensures
(let b, ts' = check_if_pop_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts)) | let lemma_pop_leakage_free (ts:analysis_taints) (ins:S.ins) : Lemma
(requires BC.Pop? ins)
(ensures (
let (b, ts') = check_if_pop_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts
))
=
let (b, ts') = check_if_pop_consumes_fixed_time ins ts in
if b then
(
let code = Ins ins in
let lem (s1 s2:S.machine_state) (fuel:nat) : Lemma
(requires is_explicit_leakage_free_lhs code fuel ts.lts ts'.lts s1 s2)
(ensures is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)
[SMTPat (is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)]
=
allow_inversion maddr;
allow_inversion tmaddr;
let BC.Pop dst t_stk = ins in
let s1' = Some?.v (machine_eval_code code fuel s1) in
let s2' = Some?.v (machine_eval_code code fuel s2) in
let stack_op = OStack (MReg reg_Rsp 0, Public) in
let v1 = S.eval_operand stack_op s1 in
let v2 = S.eval_operand stack_op s2 in
if t_stk = Public then (
S.get_heap_val64_reveal ();
assert (v1 == v2)
);
Classical.forall_intro_3 (fun s x (stack1:S.machine_heap) -> Vale.Lib.Set.lemma_sel_restrict s stack1 x);
Classical.forall_intro_3 (fun s x (stack2:S.machine_heap) -> Vale.Lib.Set.lemma_sel_restrict s stack2 x)
in
()
) | {
"file_name": "vale/code/arch/x64/Vale.X64.Leakage_Ins.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 779,
"start_col": 0,
"start_line": 747
} | module Vale.X64.Leakage_Ins
open FStar.Mul
open Vale.Arch.MachineHeap_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.Instruction_s
module BC = Vale.X64.Bytes_Code_s
module S = Vale.X64.Machine_Semantics_s
open Vale.X64.Leakage_s
open Vale.X64.Leakage_Helpers
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
unfold let obs_args = S.obs_args
unfold let obs_inouts = S.obs_inouts
unfold let machine_eval_code = S.machine_eval_code
let reveal_machine_eval_code_ins (i:S.ins) (s:S.machine_state) : Lemma
(requires True)
(ensures S.machine_eval_code_ins i s == S.machine_eval_code_ins_def i s)
[SMTPat (S.machine_eval_code_ins i s)]
=
reveal_opaque (`%S.machine_eval_code_ins) S.machine_eval_code_ins
let rec check_if_consumes_fixed_time_args
(args:list instr_operand) (oprs:instr_operands_t_args args) (ts:analysis_taints)
: Pure bool
(requires True)
(ensures fun b -> b ==> (forall (s1 s2:S.machine_state).{:pattern (constTimeInvariant ts.lts s1 s2)}
constTimeInvariant ts.lts s1 s2 ==> obs_args args oprs s1 == obs_args args oprs s2))
=
allow_inversion maddr;
allow_inversion tmaddr;
match args with
| [] -> true
| (IOpEx i)::args ->
let ((o:instr_operand_t i), (oprs:instr_operands_t_args args)) = coerce oprs in
let b' =
match i with
| IOp64 -> operand_does_not_use_secrets #nat64 #reg_64 o ts
| IOpXmm -> operand_does_not_use_secrets #quad32 #reg_xmm o ts
in
let b'' = check_if_consumes_fixed_time_args args oprs ts in
b' && b''
| (IOpIm i)::args ->
let b' =
match i with
| IOp64One o -> operand_does_not_use_secrets o ts
| IOpXmmOne o -> operand_does_not_use_secrets o ts
| IOpFlagsCf -> true
| IOpFlagsOf -> true
in
let b'' = check_if_consumes_fixed_time_args args (coerce oprs) ts in
b' && b''
let check_if_consumes_fixed_time_outs_explicit
(i:instr_operand_explicit) (o:instr_operand_t i)
(ts:analysis_taints) (t_out:taint)
: bool
=
match i with
| IOp64 -> operand_does_not_use_secrets #nat64 #reg_64 o ts && operand_taint_allowed #nat64 #reg_64 o t_out
| IOpXmm -> operand_does_not_use_secrets #quad32 #reg_xmm o ts && operand_taint_allowed #quad32 #reg_xmm o t_out
let check_if_consumes_fixed_time_outs_implicit
(i:instr_operand_implicit) (ts:analysis_taints) (t_out:taint)
: bool
=
match i with
| IOp64One o -> operand_does_not_use_secrets o ts && operand_taint_allowed o t_out
| IOpXmmOne o -> operand_does_not_use_secrets o ts && operand_taint_allowed o t_out
| IOpFlagsCf -> true
| IOpFlagsOf -> true
let rec check_if_consumes_fixed_time_outs
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args)
(ts:analysis_taints) (t_out:taint)
: Pure bool
(requires True)
(ensures fun b -> b ==> (forall (s1 s2:S.machine_state).{:pattern (constTimeInvariant ts.lts s1 s2)}
constTimeInvariant ts.lts s1 s2 ==> obs_inouts outs args oprs s1 == obs_inouts outs args oprs s2))
=
allow_inversion maddr;
allow_inversion tmaddr;
allow_inversion operand64;
allow_inversion operand128;
match outs with
| [] -> check_if_consumes_fixed_time_args args oprs ts
| (_, IOpEx i)::outs ->
let ((o:instr_operand_t i), (oprs:instr_operands_t outs args)) = coerce oprs in
let b' = check_if_consumes_fixed_time_outs_explicit i o ts t_out in
let b'' = check_if_consumes_fixed_time_outs outs args oprs ts t_out in
b' && b''
| (_, IOpIm i)::outs ->
let b' = check_if_consumes_fixed_time_outs_implicit i ts t_out in
let b'' = check_if_consumes_fixed_time_outs outs args (coerce oprs) ts t_out in
b' && b''
#restart-solver
#reset-options "--z3rlimit 300"
let rec lemma_args_taint
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(ts:analysis_taints) (s1 s2:S.machine_state)
: Lemma
(requires
constTimeInvariant ts.lts s1 s2 /\
Some? (S.instr_apply_eval_args outs args f oprs s1) /\
Some? (S.instr_apply_eval_args outs args f oprs s2) /\
check_if_consumes_fixed_time_args args oprs ts /\
args_taint args oprs ts == Public)
(ensures
S.instr_apply_eval_args outs args f oprs s1 ==
S.instr_apply_eval_args outs args f oprs s2)
=
allow_inversion maddr;
allow_inversion tmaddr;
allow_inversion operand64;
allow_inversion operand128;
match args with
| [] -> ()
| i::args ->
let (v1, v2, oprs) : option (instr_val_t i) & option (instr_val_t i) & instr_operands_t_args args =
match i with
| IOpEx i ->
let (o, (oprs:instr_operands_t_args args)) = coerce oprs in
(
S.instr_eval_operand_explicit i o s1,
S.instr_eval_operand_explicit i o s2,
oprs)
| IOpIm i ->
let oprs = coerce oprs in (
S.instr_eval_operand_implicit i s1,
S.instr_eval_operand_implicit i s2,
oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
S.get_heap_val32_reveal ();
S.get_heap_val64_reveal ();
S.get_heap_val128_reveal ();
assert (v1 == v2);
let Some v = v1 in
lemma_args_taint outs args (f v) oprs ts s1 s2
#restart-solver
let rec lemma_inouts_taint
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(ts:analysis_taints) (s1 s2:S.machine_state)
: Lemma
(requires
constTimeInvariant ts.lts s1 s2 /\
Some? (S.instr_apply_eval_inouts outs inouts args f oprs s1) /\
Some? (S.instr_apply_eval_inouts outs inouts args f oprs s2) /\
check_if_consumes_fixed_time_outs inouts args oprs ts Public /\
inouts_taint inouts args oprs ts == Public)
(ensures
S.instr_apply_eval_inouts outs inouts args f oprs s1 ==
S.instr_apply_eval_inouts outs inouts args f oprs s2)
=
allow_inversion maddr;
allow_inversion tmaddr;
allow_inversion operand64;
allow_inversion operand128;
match inouts with
| [] -> lemma_args_taint outs args f oprs ts s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_inouts_taint outs inouts args (coerce f) oprs ts s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option (instr_val_t i) & option (instr_val_t i) & instr_operands_t inouts args =
match i with
| IOpEx i ->
let (o, (oprs:instr_operands_t inouts args)) = coerce oprs in
let oprs = coerce oprs in (
S.instr_eval_operand_explicit i o s1,
S.instr_eval_operand_explicit i o s2,
oprs)
| IOpIm i ->
let oprs = coerce oprs in (
S.instr_eval_operand_implicit i s1,
S.instr_eval_operand_implicit i s2,
oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
S.get_heap_val32_reveal ();
S.get_heap_val64_reveal ();
S.get_heap_val128_reveal ();
assert (v1 == v2);
let Some v = v1 in
lemma_inouts_taint outs inouts args (f v) oprs ts s1 s2
let instr_set_taint_explicit
(i:instr_operand_explicit) (o:instr_operand_t i) (ts:analysis_taints) (t:taint)
: analysis_taints =
match i with
| IOp64 -> set_taint 0 (o <: operand64) ts t
| IOpXmm -> set_taint 1 (o <: operand128) ts t
[@instr_attr]
let instr_set_taint_implicit (i:instr_operand_implicit) (ts:analysis_taints) (t:taint) : analysis_taints =
match i with
| IOp64One o -> set_taint 0 o ts t
| IOpXmmOne o -> set_taint 1 o ts t
| IOpFlagsCf -> set_taint_cf_and_flags ts t
| IOpFlagsOf -> set_taint_of_and_flags ts t
let rec instr_set_taints
(outs:list instr_out) (args:list instr_operand)
(oprs:instr_operands_t outs args) (ts:analysis_taints) (t:taint)
: analysis_taints =
match outs with
| [] -> ts
| (_, i)::outs ->
(
match i with
| IOpEx i ->
let oprs:instr_operand_t i & instr_operands_t outs args = coerce oprs in
instr_set_taints outs args (snd oprs) (instr_set_taint_explicit i (fst oprs) ts t) t
| IOpIm i -> instr_set_taints outs args (coerce oprs) (instr_set_taint_implicit i ts t) t
)
let rec lemma_instr_write_outputs_ok
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:S.machine_state)
: Lemma
(requires (S.instr_write_outputs outs args vs oprs s_orig s).S.ms_ok)
(ensures s.S.ms_ok)
=
match outs with
| [] -> ()
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs:instr_operand_t i & instr_operands_t outs args = coerce oprs in
let s' = S.instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_ok outs args vs (snd oprs) s_orig s'
| IOpIm i ->
let s' = S.instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_ok outs args vs (coerce oprs) s_orig s'
)
[@"opaque_to_smt"]
let update_heap32_val (ptr:int) (v:Vale.Def.Types_s.nat32) (i:int) : Vale.Def.Types_s.nat8 =
let open Vale.Def.Words_s in
let open Vale.Def.Words.Four_s in
let v = nat_to_four 8 v in
match (i - ptr) with
| 0 -> v.lo0
| 1 -> v.lo1
| 2 -> v.hi2
| 3 -> v.hi3
| _ -> 0
let valid_addr32 (ptr:int) (mem:S.machine_heap) : bool =
S.valid_addr (ptr + 0) mem &&
S.valid_addr (ptr + 1) mem &&
S.valid_addr (ptr + 2) mem &&
S.valid_addr (ptr + 3) mem
let lemma_update_heap32_val (ptr:int) (v:Vale.Def.Types_s.nat32) (mem:S.machine_heap) (i:int) : Lemma
(requires True)
(ensures (S.update_heap32 ptr v mem).[i] ==
(if ptr <= i && i < ptr + 4 then update_heap32_val ptr v i else mem.[i]))
[SMTPat ((S.update_heap32 ptr v mem).[i])]
=
S.update_heap32_reveal ();
reveal_opaque (`%update_heap32_val) update_heap32_val
let lemma_update_heap32_domain (ptr:int) (v:Vale.Def.Types_s.nat32) (mem:S.machine_heap) : Lemma
(requires valid_addr32 ptr mem)
(ensures Map.domain (S.update_heap32 ptr v mem) == Map.domain mem)
[SMTPat (Map.domain (S.update_heap32 ptr v mem))]
=
S.update_heap32_reveal ();
assert (Set.equal (Map.domain (S.update_heap32 ptr v mem)) (Map.domain mem))
[@"opaque_to_smt"]
let update_heap64_val (ptr:int) (v:nat64) (i:int) : Vale.Def.Types_s.nat8 =
let open Vale.Def.Words_s in
let open Vale.Def.Words.Two_s in
let open Vale.Def.Words.Four_s in
let v = nat_to_two 32 v in
let lo = nat_to_four 8 v.lo in
let hi = nat_to_four 8 v.hi in
match (i - ptr) with
| 0 -> lo.lo0
| 1 -> lo.lo1
| 2 -> lo.hi2
| 3 -> lo.hi3
| 4 -> hi.lo0
| 5 -> hi.lo1
| 6 -> hi.hi2
| 7 -> hi.hi3
| _ -> 0
let lemma_update_heap64_val (ptr:int) (v:nat64) (mem:S.machine_heap) (i:int) : Lemma
(requires True)
(ensures
(S.update_heap64 ptr v mem).[i] ==
(if ptr <= i && i < ptr + 8 then update_heap64_val ptr v i else mem.[i])
)
[SMTPat ((S.update_heap64 ptr v mem).[i])]
=
S.update_heap64_reveal ();
reveal_opaque (`%update_heap64_val) update_heap64_val
let lemma_update_heap64_domain (ptr:int) (v:nat64) (mem:S.machine_heap) : Lemma
(requires S.valid_addr64 ptr mem)
(ensures Map.domain (S.update_heap64 ptr v mem) == Map.domain mem)
[SMTPat (Map.domain (S.update_heap64 ptr v mem))]
=
reveal_opaque (`%S.valid_addr64) S.valid_addr64;
S.update_heap64_reveal ();
assert (Set.equal (Map.domain (S.update_heap64 ptr v mem)) (Map.domain mem))
[@"opaque_to_smt"]
let update_heap128_val (ptr:int) (v:Vale.Def.Types_s.quad32) (i:int) : Vale.Def.Types_s.nat8 =
let open Vale.Def.Words_s in
let j = i - ptr in
if 0 <= j && j < 4 then update_heap32_val (ptr + 0 ) v.lo0 i else
if 4 <= j && j < 8 then update_heap32_val (ptr + 4 ) v.lo1 i else
if 8 <= j && j < 12 then update_heap32_val (ptr + 8 ) v.hi2 i else
if 12 <= j && j < 16 then update_heap32_val (ptr + 12) v.hi3 i else
0
let valid_addr128 (ptr:int) (mem:S.machine_heap) : bool =
valid_addr32 (ptr + 0) mem &&
valid_addr32 (ptr + 4) mem &&
valid_addr32 (ptr + 8) mem &&
valid_addr32 (ptr + 12) mem
let lemma_update_heap128_val (ptr:int) (v:Vale.Def.Types_s.quad32) (mem:S.machine_heap) (i:int) : Lemma
(requires True)
(ensures
(S.update_heap128 ptr v mem).[i] ==
(if ptr <= i && i < ptr + 16 then update_heap128_val ptr v i else mem.[i])
)
[SMTPat ((S.update_heap128 ptr v mem).[i])]
=
S.update_heap128_reveal ();
reveal_opaque (`%update_heap128_val) update_heap128_val
let lemma_update_heap128_domain (ptr:int) (v:Vale.Def.Types_s.quad32) (mem:S.machine_heap) : Lemma
(requires valid_addr128 ptr mem)
(ensures Map.domain (S.update_heap128 ptr v mem) == Map.domain mem)
[SMTPat (S.update_heap128 ptr v mem)]
=
S.update_heap128_reveal ();
assert (Set.equal (Map.domain (S.update_heap128 ptr v mem)) (Map.domain mem))
let lemma_preserve_valid64 (m m':S.machine_heap) : Lemma
(requires Set.equal (Map.domain m) (Map.domain m'))
(ensures (forall (i:int).{:pattern (S.valid_addr64 i m')}
S.valid_addr64 i m ==> S.valid_addr64 i m'))
=
reveal_opaque (`%S.valid_addr64) S.valid_addr64
let lemma_preserve_valid128 (m m':S.machine_heap) : Lemma
(requires Set.equal (Map.domain m) (Map.domain m'))
(ensures (forall (i:int).{:pattern (S.valid_addr128 i m')}
S.valid_addr128 i m ==> S.valid_addr128 i m'))
=
reveal_opaque (`%S.valid_addr128) S.valid_addr128
let lemma_instr_set_taints_explicit
(i:instr_operand_explicit) (v1 v2:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(ts_orig ts:analysis_taints) (t_out:taint)
(s1_orig s1 s2_orig s2:S.machine_state)
: Lemma
(requires (
let s1' = S.instr_write_output_explicit i v1 o s1_orig s1 in
let s2' = S.instr_write_output_explicit i v2 o s2_orig s2 in
s1'.S.ms_ok /\ s2'.S.ms_ok /\
(t_out == Public ==> v1 == v2) /\
Set.equal (Map.domain (heap_get s1_orig.S.ms_heap)) (Map.domain (heap_get s1.S.ms_heap)) /\
Set.equal (Map.domain (heap_get s2_orig.S.ms_heap)) (Map.domain (heap_get s2.S.ms_heap)) /\
check_if_consumes_fixed_time_outs_explicit i o ts_orig t_out /\
publicValuesAreSame ts_orig.lts s1_orig s2_orig /\
publicValuesAreSame ts.lts s1 s2
))
(ensures (
let s1' = S.instr_write_output_explicit i v1 o s1_orig s1 in
let s2' = S.instr_write_output_explicit i v2 o s2_orig s2 in
let ts' = instr_set_taint_explicit i o ts t_out in
Set.equal (Map.domain (heap_get s1_orig.S.ms_heap)) (Map.domain (heap_get s1'.S.ms_heap)) /\
Set.equal (Map.domain (heap_get s2_orig.S.ms_heap)) (Map.domain (heap_get s2'.S.ms_heap)) /\
publicValuesAreSame ts'.lts s1' s2'
))
=
allow_inversion maddr;
allow_inversion tmaddr;
lemma_preserve_valid64 (heap_get s1_orig.S.ms_heap) (heap_get s1.S.ms_heap);
lemma_preserve_valid64 (heap_get s2_orig.S.ms_heap) (heap_get s2.S.ms_heap);
lemma_preserve_valid128 (heap_get s1_orig.S.ms_heap) (heap_get s1.S.ms_heap);
lemma_preserve_valid128 (heap_get s2_orig.S.ms_heap) (heap_get s2.S.ms_heap);
reveal_opaque (`%S.valid_addr128) S.valid_addr128;
()
let lemma_instr_set_taints_implicit
(i:instr_operand_implicit) (v1 v2:instr_val_t (IOpIm i))
(ts_orig ts:analysis_taints) (t_out:taint)
(s1_orig s1 s2_orig s2:S.machine_state)
: Lemma
(requires (
let s1' = S.instr_write_output_implicit i v1 s1_orig s1 in
let s2' = S.instr_write_output_implicit i v2 s2_orig s2 in
s1'.S.ms_ok /\ s2'.S.ms_ok /\
(t_out == Public ==> v1 == v2) /\
Set.equal (Map.domain (heap_get s1_orig.S.ms_heap)) (Map.domain (heap_get s1.S.ms_heap)) /\
Set.equal (Map.domain (heap_get s2_orig.S.ms_heap)) (Map.domain (heap_get s2.S.ms_heap)) /\
check_if_consumes_fixed_time_outs_implicit i ts_orig t_out /\
publicValuesAreSame ts_orig.lts s1_orig s2_orig /\
publicValuesAreSame ts.lts s1 s2
))
(ensures (
let s1' = S.instr_write_output_implicit i v1 s1_orig s1 in
let s2' = S.instr_write_output_implicit i v2 s2_orig s2 in
let ts' = instr_set_taint_implicit i ts t_out in
Set.equal (Map.domain (heap_get s1_orig.S.ms_heap)) (Map.domain (heap_get s1'.S.ms_heap)) /\
Set.equal (Map.domain (heap_get s2_orig.S.ms_heap)) (Map.domain (heap_get s2'.S.ms_heap)) /\
publicValuesAreSame ts'.lts s1' s2'
))
=
allow_inversion maddr;
allow_inversion tmaddr;
allow_inversion operand64;
allow_inversion operand128;
lemma_preserve_valid64 (heap_get s1_orig.S.ms_heap) (heap_get s1.S.ms_heap);
lemma_preserve_valid64 (heap_get s2_orig.S.ms_heap) (heap_get s2.S.ms_heap);
lemma_preserve_valid128 (heap_get s1_orig.S.ms_heap) (heap_get s1.S.ms_heap);
lemma_preserve_valid128 (heap_get s2_orig.S.ms_heap) (heap_get s2.S.ms_heap);
reveal_opaque (`%S.valid_addr128) S.valid_addr128;
()
#reset-options "--z3rlimit 80"
let rec lemma_instr_set_taints
(outs:list instr_out) (args:list instr_operand)
(vs1 vs2:instr_ret_t outs) (oprs:instr_operands_t outs args)
(ts_orig ts:analysis_taints) (t_out:taint)
(s1_orig s1 s2_orig s2:S.machine_state)
: Lemma
(requires (
let s1_state' = S.instr_write_outputs outs args vs1 oprs s1_orig s1 in
let s2_state' = S.instr_write_outputs outs args vs2 oprs s2_orig s2 in
s1_state'.S.ms_ok /\ s2_state'.S.ms_ok /\
(t_out == Public ==> vs1 == vs2) /\
Set.equal (Map.domain (heap_get s1_orig.S.ms_heap)) (Map.domain (heap_get s1.S.ms_heap)) /\
Set.equal (Map.domain (heap_get s2_orig.S.ms_heap)) (Map.domain (heap_get s2.S.ms_heap)) /\
check_if_consumes_fixed_time_outs outs args oprs ts_orig t_out /\
publicValuesAreSame ts_orig.lts s1_orig s2_orig /\
publicValuesAreSame ts.lts s1 s2
))
(ensures (
let s1' = S.instr_write_outputs outs args vs1 oprs s1_orig s1 in
let s2' = S.instr_write_outputs outs args vs2 oprs s2_orig s2 in
let ts' = instr_set_taints outs args oprs ts t_out in
publicValuesAreSame ts'.lts s1' s2'
))
=
match outs with
| [] -> ()
| (_, i)::outs ->
(
let ((v1:instr_val_t i), (vs1:instr_ret_t outs)) =
match outs with
| [] -> (vs1, ())
| _::_ -> let vs1 = coerce vs1 in (fst vs1, snd vs1)
in
let ((v2:instr_val_t i), (vs2:instr_ret_t outs)) =
match outs with
| [] -> (vs2, ())
| _::_ -> let vs2 = coerce vs2 in (fst vs2, snd vs2)
in
match i with
| IOpEx i ->
let (o, oprs):instr_operand_t i & instr_operands_t outs args = coerce oprs in
let s1' = S.instr_write_output_explicit i v1 o s1_orig s1 in
let s2' = S.instr_write_output_explicit i v2 o s2_orig s2 in
lemma_instr_write_outputs_ok outs args vs1 oprs s1_orig s1';
lemma_instr_write_outputs_ok outs args vs2 oprs s2_orig s2';
let ts' = instr_set_taint_explicit i o ts t_out in
lemma_instr_set_taints_explicit i v1 v2 o ts_orig ts t_out s1_orig s1 s2_orig s2;
lemma_instr_set_taints outs args vs1 vs2 oprs ts_orig ts' t_out s1_orig s1' s2_orig s2'
| IOpIm i ->
let s1' = S.instr_write_output_implicit i v1 s1_orig s1 in
let s2' = S.instr_write_output_implicit i v2 s2_orig s2 in
lemma_instr_write_outputs_ok outs args vs1 (coerce oprs) s1_orig s1';
lemma_instr_write_outputs_ok outs args vs2 (coerce oprs) s2_orig s2';
let ts' = instr_set_taint_implicit i ts t_out in
lemma_instr_set_taints_implicit i v1 v2 ts_orig ts t_out s1_orig s1 s2_orig s2;
lemma_instr_set_taints outs args vs1 vs2 (coerce oprs) ts_orig ts' t_out s1_orig s1' s2_orig s2'
)
let check_if_instr_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Instr? ins)
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Instr (InstrTypeRecord #outs #args #havoc_flags iins) oprs _ = ins in
let t = inouts_taint outs args oprs ts in
let b = check_if_consumes_fixed_time_outs outs args oprs ts t in
let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in
let flags = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> flags in
let cf = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> cf in
let ovf = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> ovf in
let ts = AnalysisTaints (LeakageTaints rs flags cf ovf) rts in
(b, instr_set_taints outs args oprs ts t)
let coerce_to_normal (#a:Type0) (x:a) : y:(normal a){x == y} = x
let check_if_xor_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Instr? ins /\ S.AnnotateXor64? (BC.Instr?.annotation ins))
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Instr (InstrTypeRecord #outs #args #havoc_flags iins) oprs (S.AnnotateXor64 eq) = ins in
let oprs:normal (instr_operands_t [inOut op64; out opFlagsCf; out opFlagsOf] [op64]) =
coerce_to_normal #(instr_operands_t [inOut op64; out opFlagsCf; out opFlagsOf] [op64]) oprs in
let (o1, (o2, ())) = oprs in
if o1 = o2 then
let t = Public in
let b = check_if_consumes_fixed_time_outs outs args oprs ts t in
let AnalysisTaints (LeakageTaints rs _ _ _) rts = ts in
let ts = AnalysisTaints (LeakageTaints rs Secret Public Public) rts in
(b, instr_set_taints outs args oprs ts t)
else
check_if_instr_consumes_fixed_time ins ts
let check_if_pxor_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Instr? ins /\ S.AnnotatePxor? (BC.Instr?.annotation ins))
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Instr (InstrTypeRecord #outs #args #havoc_flags iins) oprs (S.AnnotatePxor eq) = ins in
let oprs:normal (instr_operands_t [inOut opXmm] [opXmm]) =
coerce_to_normal #(instr_operands_t [inOut opXmm] [opXmm]) oprs in
let (o1, (o2, ())) = oprs in
if o1 = o2 then
let t = Public in
let b = check_if_consumes_fixed_time_outs outs args oprs ts t in
let AnalysisTaints (LeakageTaints rs ft cft oft) rts = ts in
let ts = AnalysisTaints (LeakageTaints rs ft cft oft) rts in
(b, instr_set_taints outs args oprs ts t)
else
check_if_instr_consumes_fixed_time ins ts
let check_if_vpxor_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Instr? ins /\ S.AnnotateVPxor? (BC.Instr?.annotation ins))
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Instr (InstrTypeRecord #outs #args #havoc_flags iins) oprs (S.AnnotateVPxor eq) = ins in
let oprs:normal (instr_operands_t [out opXmm] [opXmm; opXmm]) =
coerce_to_normal #(instr_operands_t [out opXmm] [opXmm; opXmm]) oprs in
let (_, (o2, (o3, ()))) = oprs in
if o2 = o3 then
let t = Public in
let b = check_if_consumes_fixed_time_outs outs args oprs ts t in
let AnalysisTaints (LeakageTaints rs ft cft oft) rts = ts in
let ts = AnalysisTaints (LeakageTaints rs ft cft oft) rts in
(b, instr_set_taints outs args oprs ts t)
else
check_if_instr_consumes_fixed_time ins ts
let check_if_alloc_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Alloc? ins)
(ensures ins_consumes_fixed_time ins ts)
=
(true, ts)
let check_if_dealloc_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Dealloc? ins)
(ensures ins_consumes_fixed_time ins ts)
=
(true, ts)
#reset-options "--initial_ifuel 3 --max_ifuel 3 --initial_fuel 4 --max_fuel 4 --z3rlimit 80"
let check_if_push_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Push? ins)
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Push src t_stk = ins in
let t_out = operand_taint 0 src ts in
(Public? (Vale.Lib.MapTree.sel ts.rts reg_Rsp) && operand_does_not_use_secrets src ts && (t_out = Public || t_stk = Secret), ts)
let check_if_pop_consumes_fixed_time (ins:S.ins) (ts:analysis_taints) : Pure (bool & analysis_taints)
(requires BC.Pop? ins)
(ensures ins_consumes_fixed_time ins ts)
=
let BC.Pop dst t_stk = ins in
let allowed = operand_taint_allowed dst t_stk in
(Public? (Vale.Lib.MapTree.sel ts.rts reg_Rsp) && operand_does_not_use_secrets dst ts && allowed, set_taint 0 dst ts t_stk)
let check_if_ins_consumes_fixed_time ins ts =
match ins with
| BC.Instr _ _ (S.AnnotateXor64 _) -> check_if_xor_consumes_fixed_time ins ts
| BC.Instr _ _ (S.AnnotatePxor _) -> check_if_pxor_consumes_fixed_time ins ts
| BC.Instr _ _ (S.AnnotateVPxor _) -> check_if_vpxor_consumes_fixed_time ins ts
| BC.Instr _ _ _ -> check_if_instr_consumes_fixed_time ins ts
| BC.Push _ _ -> check_if_push_consumes_fixed_time ins ts
| BC.Pop _ _ -> check_if_pop_consumes_fixed_time ins ts
| BC.Alloc _ -> check_if_alloc_consumes_fixed_time ins ts
| BC.Dealloc _ -> check_if_dealloc_consumes_fixed_time ins ts
#reset-options "--initial_ifuel 1 --max_ifuel 1 --initial_fuel 1 --max_fuel 1 --z3rlimit 100"
let lemma_instr_leakage_free (ts:analysis_taints) (ins:S.ins) : Lemma
(requires BC.Instr? ins)
(ensures (
let (b, ts') = check_if_instr_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts
))
=
let (b, ts') = check_if_instr_consumes_fixed_time ins ts in
if b then
(
let code = Ins ins in
let lem (s1 s2:S.machine_state) (fuel:nat) : Lemma
(requires is_explicit_leakage_free_lhs code fuel ts.lts ts'.lts s1 s2)
(ensures is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)
[SMTPat (is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)]
=
let BC.Instr (InstrTypeRecord #outs #args #havoc_flags i) oprs _ = ins in
let t_out = inouts_taint outs args oprs ts in
let s1 = {s1 with S.ms_trace = []} in
let s2 = {s2 with S.ms_trace = []} in
let Some vs1 = S.instr_apply_eval outs args (instr_eval i) oprs s1 in
let Some vs2 = S.instr_apply_eval outs args (instr_eval i) oprs s2 in
let s1' =
match havoc_flags with
| HavocFlags -> {s1 with S.ms_flags = S.havoc_flags}
| PreserveFlags -> s1
in
let s2' =
match havoc_flags with
| HavocFlags -> {s2 with S.ms_flags = S.havoc_flags}
| PreserveFlags -> s2
in
let AnalysisTaints (LeakageTaints rs flags cf ovf) rts = ts in
let flags = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> flags in
let cf = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> cf in
let ovf = match havoc_flags with | HavocFlags -> Secret | PreserveFlags -> ovf in
let ts_havoc = AnalysisTaints (LeakageTaints rs flags cf ovf) rts in
if t_out = Secret then
(
lemma_instr_set_taints outs args vs1 vs2 oprs ts ts_havoc t_out s1 s1' s2 s2';
()
)
else
(
let vs = vs1 in
lemma_inouts_taint outs outs args (instr_eval i) oprs ts s1 s2;
lemma_instr_set_taints outs args vs vs oprs ts ts_havoc t_out s1 s1' s2 s2';
()
)
in
// assert (isExplicitLeakageFree (Ins ins) ts ts');
()
)
let lemma_dealloc_leakage_free (ts:analysis_taints) (ins:S.ins) : Lemma
(requires BC.Dealloc? ins)
(ensures (
let (b, ts') = check_if_dealloc_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts
))
=
let (b, ts') = check_if_dealloc_consumes_fixed_time ins ts in
if b then
(
let code = Ins ins in
let lem (s1 s2:S.machine_state) (fuel:nat) : Lemma
(requires is_explicit_leakage_free_lhs code fuel ts.lts ts'.lts s1 s2)
(ensures is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)
[SMTPat (is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)]
=
let BC.Dealloc n = ins in
let s1' = Some?.v (machine_eval_code code fuel s1) in
let s2' = Some?.v (machine_eval_code code fuel s2) in
let S.Machine_stack _ stack1 = s1.S.ms_stack in
let S.Machine_stack _ stack2 = s2.S.ms_stack in
let S.Machine_stack _ stack1' = s1'.S.ms_stack in
let S.Machine_stack _ stack2' = s2'.S.ms_stack in
let aux (x:int) : Lemma
(requires publicStackValueIsSame stack1 stack2 s1.S.ms_stackTaint s2.S.ms_stackTaint x)
(ensures publicStackValueIsSame stack1' stack2' s1'.S.ms_stackTaint s2'.S.ms_stackTaint x)
=
Classical.forall_intro (fun s -> Vale.Lib.Set.lemma_sel_restrict s stack1 x);
Classical.forall_intro (fun s -> Vale.Lib.Set.lemma_sel_restrict s stack2 x)
in Classical.forall_intro (Classical.move_requires aux)
in
()
)
let lemma_push_leakage_free (ts:analysis_taints) (ins:S.ins) : Lemma
(requires BC.Push? ins)
(ensures (
let (b, ts') = check_if_push_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts
))
=
let (b, ts') = check_if_push_consumes_fixed_time ins ts in
if b then
(
let code = Ins ins in
let lem (s1 s2:S.machine_state) (fuel:nat) : Lemma
(requires is_explicit_leakage_free_lhs code fuel ts.lts ts'.lts s1 s2)
(ensures is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)
[SMTPat (is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)]
=
let BC.Push src t_stk = ins in
let t_out = operand_taint 0 src ts in
let s1' = Some?.v (machine_eval_code code fuel s1) in
let s2' = Some?.v (machine_eval_code code fuel s2) in
let S.Machine_stack _ stack1 = s1.S.ms_stack in
let S.Machine_stack _ stack2 = s2.S.ms_stack in
let S.Machine_stack _ stack1' = s1'.S.ms_stack in
let S.Machine_stack _ stack2' = s2'.S.ms_stack in
let ptr1 = S.eval_reg_64 rRsp s1 - 8 in
let ptr2 = S.eval_reg_64 rRsp s2 - 8 in
let v1 = S.eval_operand src s1 in
let v2 = S.eval_operand src s2 in
assert (ptr1 == ptr2);
if t_out = Secret then ()
else (
let aux () : Lemma (v1 == v2)
= match src with
| OConst _ | OReg _ -> ()
| OMem (_, _) | OStack (_, _) -> S.get_heap_val64_reveal ()
in
aux()
)
in
()
) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Leakage_s.fst.checked",
"Vale.X64.Leakage_Helpers.fst.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Lib.MapTree.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.X64.Leakage_Ins.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.X64.Leakage_Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Leakage_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Leakage_Helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Leakage_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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": 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": 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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ts: Vale.X64.Leakage_Helpers.analysis_taints -> ins: Vale.X64.Machine_Semantics_s.ins
-> FStar.Pervasives.Lemma (requires Pop? ins)
(ensures
(let _ = Vale.X64.Leakage_Ins.check_if_pop_consumes_fixed_time ins ts in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ b ts' = _ in
b ==>
Vale.X64.Leakage_s.isConstantTime (Vale.X64.Machine_s.Ins ins) (AnalysisTaints?.lts ts) /\
Vale.X64.Leakage_s.isLeakageFree (Vale.X64.Machine_s.Ins ins)
(AnalysisTaints?.lts ts)
(AnalysisTaints?.lts ts'))
<:
Type0)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Vale.X64.Leakage_Helpers.analysis_taints",
"Vale.X64.Machine_Semantics_s.ins",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.nat",
"Prims.unit",
"Vale.X64.Leakage_s.is_explicit_leakage_free_lhs",
"Vale.X64.Leakage_Helpers.__proj__AnalysisTaints__item__lts",
"Prims.squash",
"Vale.X64.Leakage_s.is_explicit_leakage_free_rhs",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.logical",
"Prims.Nil",
"Vale.X64.Machine_s.operand64",
"Vale.Arch.HeapTypes_s.taint",
"FStar.Classical.forall_intro_3",
"FStar.Set.set",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.eq2",
"Vale.Def.Words_s.nat8",
"FStar.Map.sel",
"FStar.Map.restrict",
"Vale.Lib.Set.lemma_sel_restrict",
"Vale.Def.Types_s.nat8",
"Prims.op_Equality",
"Vale.Arch.HeapTypes_s.Public",
"Prims._assert",
"Vale.Def.Types_s.nat64",
"Vale.Arch.MachineHeap_s.get_heap_val64_reveal",
"Vale.Def.Words_s.nat64",
"Vale.X64.Machine_Semantics_s.eval_operand",
"Vale.X64.Machine_s.operand",
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Machine_s.OStack",
"Vale.X64.Machine_s.nat64",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_s.maddr",
"Vale.X64.Machine_s.MReg",
"Vale.X64.Machine_s.reg_Rsp",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Vale.X64.Leakage_Ins.machine_eval_code",
"FStar.Pervasives.allow_inversion",
"Vale.X64.Machine_s.tmaddr",
"Vale.X64.Machine_s.precode",
"Vale.X64.Bytes_Code_s.instruction_t",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Bytes_Code_s.ocmp",
"Vale.X64.Machine_s.Ins",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Leakage_Ins.check_if_pop_consumes_fixed_time",
"Prims.b2t",
"Vale.X64.Bytes_Code_s.uu___is_Pop",
"Prims.l_imp",
"Prims.l_and",
"Vale.X64.Leakage_s.isConstantTime",
"Vale.X64.Leakage_s.isLeakageFree"
] | [] | false | false | true | false | false | let lemma_pop_leakage_free (ts: analysis_taints) (ins: S.ins)
: Lemma (requires BC.Pop? ins)
(ensures
(let b, ts' = check_if_pop_consumes_fixed_time ins ts in
b2t b ==> isConstantTime (Ins ins) ts.lts /\ isLeakageFree (Ins ins) ts.lts ts'.lts)) =
| let b, ts' = check_if_pop_consumes_fixed_time ins ts in
if b
then
(let code = Ins ins in
let lem (s1 s2: S.machine_state) (fuel: nat)
: Lemma (requires is_explicit_leakage_free_lhs code fuel ts.lts ts'.lts s1 s2)
(ensures is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)
[SMTPat (is_explicit_leakage_free_rhs code fuel ts.lts ts'.lts s1 s2)] =
allow_inversion maddr;
allow_inversion tmaddr;
let BC.Pop dst t_stk = ins in
let s1' = Some?.v (machine_eval_code code fuel s1) in
let s2' = Some?.v (machine_eval_code code fuel s2) in
let stack_op = OStack (MReg reg_Rsp 0, Public) in
let v1 = S.eval_operand stack_op s1 in
let v2 = S.eval_operand stack_op s2 in
if t_stk = Public
then
(S.get_heap_val64_reveal ();
assert (v1 == v2));
Classical.forall_intro_3 (fun s x (stack1: S.machine_heap) ->
Vale.Lib.Set.lemma_sel_restrict s stack1 x);
Classical.forall_intro_3 (fun s x (stack2: S.machine_heap) ->
Vale.Lib.Set.lemma_sel_restrict s stack2 x)
in
()) | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.obs_inouts | val obs_inouts
(inouts: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: list observation | val obs_inouts
(inouts: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: list observation | let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 40,
"end_line": 541,
"start_col": 0,
"start_line": 527
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
inouts: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
oprs: Vale.X64.Instruction_s.instr_operands_t inouts args ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.list Vale.X64.Machine_s.observation | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.obs_args",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Machine_s.observation",
"FStar.List.Tot.Base.op_At",
"Vale.X64.Machine_Semantics_s.obs_inouts",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.obs_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.obs_operand_implicit"
] | [
"recursion"
] | false | false | false | false | false | let rec obs_inouts
(inouts: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t inouts args)
(s: machine_state)
: list observation =
| match inouts with
| [] -> obs_args args oprs s
| (_, i) :: inouts ->
let v, oprs =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in
v @ obs_inouts inouts args oprs s | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.eval_instr | val eval_instr
(it: instr_t_record)
(oprs: instr_operands_t it.outs it.args)
(ann: instr_annotation it)
(s0: machine_state)
: option machine_state | val eval_instr
(it: instr_t_record)
(oprs: instr_operands_t it.outs it.args)
(ann: instr_annotation it)
(s0: machine_state)
: option machine_state | let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 80,
"end_line": 683,
"start_col": 0,
"start_line": 672
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
it: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs it) (InstrTypeRecord?.args it) ->
ann: Vale.X64.Machine_Semantics_s.instr_annotation it ->
s0: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"FStar.Option.mapTot",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"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.havoc_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.Pervasives.Native.option",
"Vale.X64.Machine_Semantics_s.instr_apply_eval",
"Vale.X64.Instruction_s.instr_eval"
] | [] | false | false | false | false | false | let eval_instr
(it: instr_t_record)
(oprs: instr_operands_t it.outs it.args)
(ann: instr_annotation it)
(s0: machine_state)
: option machine_state =
| let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> { s0 with ms_flags = havoc_flags }
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.be_to_n_2 | val be_to_n_2 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 30,
"start_col": 0,
"start_line": 30
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.be_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_be_to_n"
] | [] | false | false | false | false | false | let be_to_n_2 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) | false |
|
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_code | val machine_eval_code (c: code) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;c]) | val machine_eval_code (c: code) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;c]) | let rec machine_eval_code (c:code) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; c])
=
match c with
| Ins i ->
machine_eval_code_ins i s
| Block cs ->
machine_eval_codes cs fuel s
| IfElse cond ct cf ->
let (s', b) = machine_eval_ocmp s cond in
if b then machine_eval_code ct fuel s' else machine_eval_code cf fuel s'
| While cond body ->
machine_eval_while cond body fuel s
and machine_eval_codes (cs:codes) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; cs])
=
match cs with
| [] -> Some s
| c'::cs' -> (
match machine_eval_code c' fuel s with
| None -> None
| Some s' -> machine_eval_codes cs' fuel s'
)
and machine_eval_while (cond:ocmp) (body:code) (fuel:nat) (s0:machine_state) : Tot (option machine_state)
(decreases %[fuel; body])
=
if fuel = 0 then None else
let (s1, b) = machine_eval_ocmp s0 cond in
if not b then Some s1
else
match machine_eval_code body (fuel - 1) s1 with
| None -> None
| Some s2 ->
if not s2.ms_ok then Some s2 else // propagate failure immediately
machine_eval_while cond body (fuel - 1) s2 | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 777,
"start_col": 0,
"start_line": 743
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace})
[@"opaque_to_smt"]
let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state =
machine_eval_code_ins_def i s
let machine_eval_ocmp (s:machine_state) (c:ocmp) : machine_state & bool =
let s = run (check (valid_ocmp_opaque c)) s in
let b = eval_ocmp_opaque s c in
let s = {s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b)::s.ms_trace} in
(s, b)
(*
These functions return an option state
None case arises when the while loop runs out of fuel | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
c: Vale.X64.Machine_Semantics_s.code ->
fuel: Prims.nat ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state) | Prims.Tot | [
"total",
""
] | [
"machine_eval_code",
"machine_eval_codes",
"machine_eval_while"
] | [
"Vale.X64.Machine_Semantics_s.code",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Bytes_Code_s.instruction_t",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.machine_eval_code_ins",
"Prims.list",
"Vale.X64.Machine_s.precode",
"Vale.X64.Bytes_Code_s.ocmp",
"Vale.X64.Machine_Semantics_s.machine_eval_codes",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.machine_eval_code",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Machine_Semantics_s.machine_eval_ocmp",
"Vale.X64.Machine_Semantics_s.machine_eval_while"
] | [
"mutual recursion"
] | false | false | false | true | false | let rec machine_eval_code (c: code) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;c]) =
| match c with
| Ins i -> machine_eval_code_ins i s
| Block cs -> machine_eval_codes cs fuel s
| IfElse cond ct cf ->
let s', b = machine_eval_ocmp s cond in
if b then machine_eval_code ct fuel s' else machine_eval_code cf fuel s'
| While cond body -> machine_eval_while cond body fuel s | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_ins_st | val machine_eval_ins_st (ins: ins) : st unit | val machine_eval_ins_st (ins: ins) : st unit | let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 719,
"start_col": 0,
"start_line": 687
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | ins: Vale.X64.Machine_Semantics_s.ins -> Vale.X64.Machine_Semantics_s.st Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Machine_Semantics_s.op_let_Star",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.get",
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.apply_option",
"Vale.X64.Machine_Semantics_s.eval_instr",
"Vale.X64.Machine_Semantics_s.set",
"Vale.X64.Machine_s.operand64",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Machine_Semantics_s.check",
"Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint",
"Vale.X64.Machine_Semantics_s.update_rsp",
"Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags",
"Vale.X64.Machine_s.operand",
"Vale.Def.Words_s.nat64",
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Machine_s.OStack",
"Vale.X64.Machine_s.nat64",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_s.maddr",
"Vale.X64.Machine_s.MConst",
"Vale.X64.Machine_Semantics_s.st",
"Prims.int",
"Prims.op_Subtraction",
"Vale.X64.Machine_Semantics_s.eval_reg_64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_Semantics_s.eval_operand",
"Vale.X64.Machine_Semantics_s.free_stack",
"Prims.op_Modulus",
"Prims.op_Addition",
"Vale.Def.Words_s.pow2_64",
"Vale.X64.Machine_s.MReg",
"Vale.X64.Machine_s.Reg"
] | [] | false | false | false | true | false | let machine_eval_ins_st (ins: ins) : st unit =
| let* s = get in
match ins with
| BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
let* _ = check (valid_src_operand64_and_taint src) in
let new_src = eval_operand src s in
let new_rsp = eval_reg_64 rRsp s - 8 in
let* _ = update_rsp new_rsp in
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
let* _ = check (valid_src_operand64_and_taint stack_op) in
let new_dst = eval_operand stack_op s in
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in
let* _ = update_operand64_preserve_flags dst new_dst in
let* _ = free_stack (new_rsp - 8) new_rsp in
update_rsp new_rsp
| BC.Alloc n -> update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
let* _ = update_rsp new_rsp in
free_stack old_rsp new_rsp | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.be_to_n_1 | val be_to_n_1 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.be_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_be_to_n"
] | [] | false | false | false | false | false | let be_to_n_1 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.be_to_n_3 | val be_to_n_3 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.be_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_be_to_n"
] | [] | false | false | false | false | false | let be_to_n_3 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_3 | val parse32_bounded_integer_3
: (parser32 (parse_bounded_integer 3)) | val parse32_bounded_integer_3
: (parser32 (parse_bounded_integer 3)) | let parse32_bounded_integer_3 = parse32_bounded_integer' 3 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 81,
"start_col": 0,
"start_line": 81
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 3) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_3 =
| parse32_bounded_integer' 3 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.be_to_n_4 | val be_to_n_4 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 50,
"start_col": 0,
"start_line": 50
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.be_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_be_to_n"
] | [] | false | false | false | false | false | let be_to_n_4 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_2 | val parse32_bounded_integer_2
: (parser32 (parse_bounded_integer 2)) | val parse32_bounded_integer_2
: (parser32 (parse_bounded_integer 2)) | let parse32_bounded_integer_2 = parse32_bounded_integer' 2 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 80,
"start_col": 0,
"start_line": 80
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 2) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_2 =
| parse32_bounded_integer' 2 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_1 | val parse32_bounded_integer_1
: (parser32 (parse_bounded_integer 1)) | val parse32_bounded_integer_1
: (parser32 (parse_bounded_integer 1)) | let parse32_bounded_integer_1 = parse32_bounded_integer' 1 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 79,
"start_col": 0,
"start_line": 79
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 1) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_1 =
| parse32_bounded_integer' 1 | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_while | val machine_eval_while (cond: ocmp) (body: code) (fuel: nat) (s0: machine_state)
: Tot (option machine_state) (decreases %[fuel;body]) | val machine_eval_while (cond: ocmp) (body: code) (fuel: nat) (s0: machine_state)
: Tot (option machine_state) (decreases %[fuel;body]) | let rec machine_eval_code (c:code) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; c])
=
match c with
| Ins i ->
machine_eval_code_ins i s
| Block cs ->
machine_eval_codes cs fuel s
| IfElse cond ct cf ->
let (s', b) = machine_eval_ocmp s cond in
if b then machine_eval_code ct fuel s' else machine_eval_code cf fuel s'
| While cond body ->
machine_eval_while cond body fuel s
and machine_eval_codes (cs:codes) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; cs])
=
match cs with
| [] -> Some s
| c'::cs' -> (
match machine_eval_code c' fuel s with
| None -> None
| Some s' -> machine_eval_codes cs' fuel s'
)
and machine_eval_while (cond:ocmp) (body:code) (fuel:nat) (s0:machine_state) : Tot (option machine_state)
(decreases %[fuel; body])
=
if fuel = 0 then None else
let (s1, b) = machine_eval_ocmp s0 cond in
if not b then Some s1
else
match machine_eval_code body (fuel - 1) s1 with
| None -> None
| Some s2 ->
if not s2.ms_ok then Some s2 else // propagate failure immediately
machine_eval_while cond body (fuel - 1) s2 | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 777,
"start_col": 0,
"start_line": 743
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace})
[@"opaque_to_smt"]
let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state =
machine_eval_code_ins_def i s
let machine_eval_ocmp (s:machine_state) (c:ocmp) : machine_state & bool =
let s = run (check (valid_ocmp_opaque c)) s in
let b = eval_ocmp_opaque s c in
let s = {s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b)::s.ms_trace} in
(s, b)
(*
These functions return an option state
None case arises when the while loop runs out of fuel | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
cond: Vale.X64.Machine_Semantics_s.ocmp ->
body: Vale.X64.Machine_Semantics_s.code ->
fuel: Prims.nat ->
s0: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state) | Prims.Tot | [
"total",
""
] | [
"machine_eval_code",
"machine_eval_codes",
"machine_eval_while"
] | [
"Vale.X64.Machine_Semantics_s.ocmp",
"Vale.X64.Machine_Semantics_s.code",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.op_Equality",
"Prims.int",
"FStar.Pervasives.Native.None",
"Prims.bool",
"Prims.op_Negation",
"FStar.Pervasives.Native.Some",
"Vale.X64.Machine_Semantics_s.machine_eval_code",
"Prims.op_Subtraction",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.machine_eval_while",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Machine_Semantics_s.machine_eval_ocmp"
] | [
"mutual recursion"
] | false | false | false | true | false | let rec machine_eval_while (cond: ocmp) (body: code) (fuel: nat) (s0: machine_state)
: Tot (option machine_state) (decreases %[fuel;body]) =
| if fuel = 0
then None
else
let s1, b = machine_eval_ocmp s0 cond in
if not b
then Some s1
else
match machine_eval_code body (fuel - 1) s1 with
| None -> None
| Some s2 -> if not s2.ms_ok then Some s2 else machine_eval_while cond body (fuel - 1) s2 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.le_to_n_1 | val le_to_n_1 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 126,
"start_col": 0,
"start_line": 126
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.le_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_le_to_n"
] | [] | false | false | false | false | false | let le_to_n_1 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_4 | val parse32_bounded_integer_4
: (parser32 (parse_bounded_integer 4)) | val parse32_bounded_integer_4
: (parser32 (parse_bounded_integer 4)) | let parse32_bounded_integer_4 = parse32_bounded_integer' 4 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 82,
"start_col": 0,
"start_line": 82
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 4) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_4 =
| parse32_bounded_integer' 4 | false |
Vale.X64.Machine_Semantics_s.fst | Vale.X64.Machine_Semantics_s.machine_eval_codes | val machine_eval_codes (cs: codes) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;cs]) | val machine_eval_codes (cs: codes) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;cs]) | let rec machine_eval_code (c:code) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; c])
=
match c with
| Ins i ->
machine_eval_code_ins i s
| Block cs ->
machine_eval_codes cs fuel s
| IfElse cond ct cf ->
let (s', b) = machine_eval_ocmp s cond in
if b then machine_eval_code ct fuel s' else machine_eval_code cf fuel s'
| While cond body ->
machine_eval_while cond body fuel s
and machine_eval_codes (cs:codes) (fuel:nat) (s:machine_state) : Tot (option machine_state)
(decreases %[fuel; cs])
=
match cs with
| [] -> Some s
| c'::cs' -> (
match machine_eval_code c' fuel s with
| None -> None
| Some s' -> machine_eval_codes cs' fuel s'
)
and machine_eval_while (cond:ocmp) (body:code) (fuel:nat) (s0:machine_state) : Tot (option machine_state)
(decreases %[fuel; body])
=
if fuel = 0 then None else
let (s1, b) = machine_eval_ocmp s0 cond in
if not b then Some s1
else
match machine_eval_code body (fuel - 1) s1 with
| None -> None
| Some s2 ->
if not s2.ms_ok then Some s2 else // propagate failure immediately
machine_eval_while cond body (fuel - 1) s2 | {
"file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 777,
"start_col": 0,
"start_line": 743
} | module Vale.X64.Machine_Semantics_s
open FStar.Mul
open FStar.List.Tot
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
include Vale.Arch.MachineHeap_s
open Vale.Arch.HeapTypes_s
open Vale.Arch.Heap
open Vale.X64.Machine_s
open Vale.X64.CPU_Features_s
open Vale.Def.Words_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open FStar.Seq.Base
module BC = Vale.X64.Bytes_Code_s
//type uint64:eqtype = UInt64.t
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
//TODO: [@"opaque_to_smt"]
let equals_instr (x1 x2:instr_t_record) : Type0 =
squash (x1 == x2)
noeq type instr_annotation (it:instr_t_record) =
| AnnotateNone : instr_annotation it
| AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it
| AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it
| AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it
| AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it
| AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it
| AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it
| AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it
| AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it
| AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it
| AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it
| AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it
let ins = BC.instruction_t instr_annotation
let ocmp = BC.ocmp
let code = BC.code_t instr_annotation
let codes = BC.codes_t instr_annotation
noeq
type machine_stack =
| Machine_stack:
initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function
stack_mem:Map.t int nat8 -> // Stack contents
machine_stack
unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->))
type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t)
type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg
noeq
type machine_state = {
ms_ok: bool;
ms_regs: regs_t;
ms_flags: flags_t;
ms_heap: heap_impl;
ms_stack: machine_stack;
ms_stackTaint: memTaint_t;
ms_trace: list observation;
}
let get_fst_ocmp (o:ocmp) = match o with
| BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_snd_ocmp (o:ocmp) = match o with
| BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r
unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s
unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s)
unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap)
unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap)
unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 =
let Machine_stack _ mem = s in
get_heap_val64 ptr mem
unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 =
let Machine_stack _ mem = s in
get_heap_val128 ptr mem
[@va_qattr]
let eval_maddr (m:maddr) (s:machine_state) : int =
match m with
| MConst n -> n
| MReg r offset -> (eval_reg_int r s) + offset
| MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
let eval_operand (o:operand64) (s:machine_state) : nat64 =
match o with
| OConst n -> n
| OReg r -> eval_reg_64 r s
| OMem (m, _) -> eval_mem (eval_maddr m s) s
| OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 =
match o with
| OConst c -> c
| OReg i -> eval_reg_xmm i s
| OMem (m, _) -> eval_mem128 (eval_maddr m s) s
| OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
let eval_ocmp (s:machine_state) (c:ocmp) : bool =
match c with
| BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s
| BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s
| BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s
| BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s
| BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s
| BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
[@"opaque_to_smt"]
let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c
let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state =
{s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')}
let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state =
update_reg' (Reg 0 r) v s
let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state =
update_reg' (Reg 1 r) v s
//val mod_8: (n:nat{n < pow2_64}) -> nat8
//let mod_8 n = n % 0x100
(*
Check if the taint annotation of a memory operand matches the taint in the memory map.
Evaluation will fail in case of a mismatch.
This allows the taint analysis to learn information about the memory map from the annotation,
assuming that the code has been verified not to fail.
(Note that this only relates to memory maps, so non-memory operands need no annotation.)
*)
[@"opaque_to_smt"]
let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (b:bool{b <==>
(forall i.{:pattern (memTaint `Map.sel` i)}
(i >= addr /\ i < addr + n) ==> memTaint.[i] == t)})
(decreases n)
=
if n = 0 then true
else if memTaint.[addr] <> t then false
else match_n (addr + 1) (n - 1) memTaint t
[@"opaque_to_smt"]
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint)
: Tot (m:memTaint_t{(
forall i.{:pattern (m `Map.sel` i)}
((i >= addr /\ i < addr + n) ==> m.[i] == t) /\
((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))})
(decreases n)
=
if n = 0 then memTaint
else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma
(requires valid_addr64 ptr mh)
(ensures is_machine_heap_update mh (update_heap64 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
=
reveal_opaque (`%valid_addr64) valid_addr64;
update_heap64_reveal ();
()
let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
if valid_addr64 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap64 ptr v (heap_get s.ms_heap))
(update_n ptr 8 (heap_taint s.ms_heap) t)
}
else s
let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma
(requires valid_addr128 ptr mh)
(ensures is_machine_heap_update mh (update_heap128 ptr v mh))
[SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))]
=
let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma
(requires
valid_addr ptr mh /\
valid_addr (ptr + 1) mh /\
valid_addr (ptr + 2) mh /\
valid_addr (ptr + 3) mh
)
(ensures is_machine_heap_update mh (update_heap32 ptr v mh))
= update_heap32_reveal ()
in
let mem1 = update_heap32 ptr v.lo0 mh in
let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in
let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in
reveal_opaque (`%valid_addr128) valid_addr128;
update_heap128_reveal ();
lemma_is_machine_heap_update32 ptr v.lo0 mh;
lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1;
lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2;
lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
if valid_addr128 ptr (heap_get s.ms_heap) then
{ s with
ms_heap = heap_upd s.ms_heap
(update_heap128 ptr v (heap_get s.ms_heap))
(update_n ptr 16 (heap_taint s.ms_heap) t)
}
else s
unfold
let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap64 ptr v mem in
Machine_stack init_rsp mem
unfold
let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = s in
let mem = update_heap128 ptr v mem in
Machine_stack init_rsp mem
let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack64' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 8 s.ms_stackTaint t;
}
let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
{ s with
ms_stack = update_stack128' ptr v s.ms_stack;
ms_stackTaint = update_n ptr 16 s.ms_stackTaint t
}
unfold
let valid_src_stack64 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr64 ptr mem
unfold
let valid_src_stack128 (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
valid_addr128 ptr mem
let valid_src_operand (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> true
| OReg r -> true
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, t) ->
let ptr = eval_maddr m s in
valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t
| OStack (m, t) ->
let ptr = eval_maddr m s in
valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
let valid_ocmp (c:ocmp) (s:machine_state) : bool =
match c with
| BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
| BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
[@"opaque_to_smt"]
let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s
unfold
let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 8 <= init_rsp
unfold
let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool =
let Machine_stack init_rsp mem = st in
// We are allowed to store anywhere between rRsp and the initial stack pointer
ptr >= rsp && ptr + 16 <= init_rsp
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool =
match o with
| OConst n -> false
| OReg r -> not (rRsp = r)
| OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool =
match o with
| OConst _ -> false
| OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices
| OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap)
| OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg r -> update_reg_64' r v s
| OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i
| OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state =
update_operand64_preserve_flags'' o v s s
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state =
match o with
| OConst _ -> {s with ms_ok = false}
| OReg i -> update_reg_xmm' i v s
| OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t
| OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state =
update_operand128_preserve_flags'' o v s s
let flags_none (f:flag) : flag_val_t = None
let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none
// Default version havocs flags
let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state =
{ (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state =
let Machine_stack init_rsp mem = s.ms_stack in
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then
update_reg_64' rRsp new_rsp s
else
s
let cf (flags:flags_t) : flag_val_t =
flags fCarry
let overflow(flags:flags_t) : flag_val_t =
flags fOverflow
let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) =
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
let free_stack' (start finish:int) (st:machine_stack) : machine_stack =
let Machine_stack init_rsp mem = st in
let domain = Map.domain mem in
// Returns the domain, without elements between start and finish
let restricted_domain = Vale.Lib.Set.remove_between domain start finish in
// The new domain of the stack does not contain elements between start and finish
let new_mem = Map.restrict restricted_domain mem in
Machine_stack init_rsp new_mem
// Define a stateful monad to simplify defining the instruction semantics
let st (a:Type) = machine_state -> a & machine_state
unfold
let return (#a:Type) (x:a) : st a =
fun s -> (x, s)
unfold
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b =
fun s0 ->
let (x, s1) = m s0 in
let (y, s2) = f x s1 in
(y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
unfold
let get : st machine_state =
fun s -> (s, s)
unfold
let set (s:machine_state) : st unit =
fun _ -> ((), s)
unfold
let fail : st unit =
fun s -> ((), {s with ms_ok = false})
unfold
let check_imm (valid:bool) : st unit =
if valid then
return ()
else
fail
unfold
let check (valid: machine_state -> bool) : st unit =
let* s = get in
if valid s then
return ()
else
fail
unfold
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
match o with
| None -> fail
| Some x -> f x
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit =
try_option o f
unfold
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
// Monadic update operations
unfold
let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit =
check (valid_dst_operand64 dst);*
let* s = get in
set (update_operand64_preserve_flags' dst v s)
unfold
let update_rsp (i:int) : st unit =
// Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page
check (fun s -> i >= s.ms_stack.initial_rsp - 4096);*
check (fun s -> i <= s.ms_stack.initial_rsp);*
let* s = get in
set (update_rsp' i s)
let update_reg_64 (r:reg_64) (v:nat64) : st unit =
let* s = get in
set (update_reg_64' r v s)
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit =
let* s = get in
set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit =
let* s = get in
set ( update_reg_xmm' x v s )
let update_flags (new_flags:flags_t) : st unit =
let* s = get in
set ( { s with ms_flags = new_flags } )
let update_cf (new_cf:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
let update_of (new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_of' s.ms_flags new_of } )
let update_cf_of (new_cf new_of:bool) : st unit =
let* s = get in
set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
let free_stack (start finish:int) : st unit =
let* s = get in
set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b =
match v with
| None -> None
| Some x -> f x
let operand_obs (s:machine_state) (o:operand64) : list observation =
match o with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let operand_obs128 (s:machine_state) (op:operand128) : list observation =
match op with
| OConst _ | OReg _ -> []
| OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
[@instr_attr]
let obs_operand_explicit
(i:instr_operand_explicit)
(o:instr_operand_t i)
(s:machine_state) : list observation =
match i with
| IOp64 -> operand_obs s o
| IOpXmm -> operand_obs128 s o
[@instr_attr]
let obs_operand_implicit
(i:instr_operand_implicit)
(s:machine_state) : list observation =
match i with
| IOp64One o -> operand_obs s o
| IOpXmmOne o -> operand_obs128 s o
| IOpFlagsCf | IOpFlagsOf -> []
[@instr_attr]
let rec obs_args
(args:list instr_operand)
(oprs:instr_operands_t_args args)
(s:machine_state) : list observation =
match args with
| [] -> []
| i::args ->
match i with
| IOpEx i ->
let oprs = coerce oprs in
obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s
| IOpIm i ->
obs_operand_implicit i s @ obs_args args (coerce oprs) s
[@instr_attr]
let rec obs_inouts
(inouts:list instr_out)
(args:list instr_operand)
(oprs:instr_operands_t inouts args)
(s:machine_state) : list observation =
match inouts with
| [] -> obs_args args oprs s
| (_, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i ->
let oprs = coerce oprs in
(obs_operand_explicit i (fst oprs) s), snd oprs
| IOpIm i -> obs_operand_implicit i s, coerce oprs
in v @ obs_inouts inouts args oprs s
[@instr_attr]
let ins_obs (ins:ins) (s:machine_state) : list observation =
match ins with
| BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s
| BC.Push src _ -> operand_obs s src
| BC.Pop dst _ -> operand_obs s dst
| BC.Alloc _ | BC.Dealloc _ -> []
[@instr_attr]
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) =
match i with
| IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
[@instr_attr]
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) =
match i with
| IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None
| IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
| IOpFlagsCf -> cf s.ms_flags
| IOpFlagsOf -> overflow s.ms_flags
[@instr_attr]
let rec instr_apply_eval_args
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
: option (instr_ret_t outs) =
match args with
| [] -> f
| i::args ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
[@instr_attr]
let rec instr_apply_eval_inouts
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
: option (instr_ret_t outs) =
match inouts with
| [] -> instr_apply_eval_args outs args f oprs s
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
instr_apply_eval_inouts outs inouts args (coerce f) oprs s
| (InOut, i)::inouts ->
let (v, oprs) =
match i with
| IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs)
| IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs)
in
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
(*
Take the all the input operands for an instruction and:
- check that they are valid
- evaluate them
- apply the instruction's evaluator function f to the evaluated operands
*)
[@instr_attr]
let instr_apply_eval
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state)
: option (instr_ret_t outs) =
instr_apply_eval_inouts outs outs args f oprs s
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state =
if b then s' else {s with ms_ok = false}
[@instr_attr]
let instr_write_output_explicit
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64 ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmm ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
[@instr_attr]
let instr_write_output_implicit
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
: machine_state =
match i with
| IOp64One o ->
state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s)
| IOpXmmOne o ->
state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
| IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v}
| IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
(*
For each output operand:
- compute the location of the operand in s_orig
- check that the operand is valid and update the current state (in order that the operands appear in "outs")
*)
[@instr_attr]
let rec instr_write_outputs
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
: machine_state =
match outs with
| [] -> s
| (_, i)::outs ->
(
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
instr_write_outputs outs args vs (snd oprs) s_orig s
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
instr_write_outputs outs args vs (coerce oprs) s_orig s
)
[@instr_attr]
let eval_instr
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
: option machine_state =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
// Core definition of instruction semantics
[@instr_attr]
let machine_eval_ins_st (ins:ins) : st unit =
let* s = get in
match ins with
| BC.Instr it oprs ann ->
apply_option (eval_instr it oprs ann s) set
| BC.Push src t ->
check (valid_src_operand64_and_taint src);*
let new_src = eval_operand src s in // Evaluate value on initial state
let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer
update_rsp new_rsp;* // Actually modify the stack pointer
let o_new = OStack (MConst new_rsp, t) in
update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer
| BC.Pop dst t ->
let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in
check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer
let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack
let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer
update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand
free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped
update_rsp new_rsp // Finally, update the stack pointer
| BC.Alloc n ->
// We already check in update_rsp that the new stack pointer is valid
update_rsp (eval_reg_64 rRsp s - n)
| BC.Dealloc n ->
let old_rsp = eval_reg_64 rRsp s in
let new_rsp = old_rsp + n in
update_rsp new_rsp;*
// The deallocated stack memory should now be considered invalid
free_stack old_rsp new_rsp
[@instr_attr]
let machine_eval_ins (i:ins) (s:machine_state) : machine_state =
run (machine_eval_ins_st i) s
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state =
let obs = ins_obs i s in
// REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace
Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace})
[@"opaque_to_smt"]
let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state =
machine_eval_code_ins_def i s
let machine_eval_ocmp (s:machine_state) (c:ocmp) : machine_state & bool =
let s = run (check (valid_ocmp_opaque c)) s in
let b = eval_ocmp_opaque s c in
let s = {s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b)::s.ms_trace} in
(s, b)
(*
These functions return an option state
None case arises when the while loop runs out of fuel | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Lib.Set.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapTypes_s.fst.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.FunctionalExtensionality.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Machine_Semantics_s.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": "BC"
},
{
"abbrev": false,
"full_module": "FStar.Seq.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"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": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
cs: Vale.X64.Machine_Semantics_s.codes ->
fuel: Prims.nat ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.Tot (FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state) | Prims.Tot | [
"total",
""
] | [
"machine_eval_code",
"machine_eval_codes",
"machine_eval_while"
] | [
"Vale.X64.Machine_Semantics_s.codes",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.Some",
"Vale.X64.Bytes_Code_s.code_t",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Prims.list",
"Vale.X64.Machine_Semantics_s.machine_eval_code",
"FStar.Pervasives.Native.None",
"Vale.X64.Machine_Semantics_s.machine_eval_codes",
"FStar.Pervasives.Native.option"
] | [
"mutual recursion"
] | false | false | false | true | false | let rec machine_eval_codes (cs: codes) (fuel: nat) (s: machine_state)
: Tot (option machine_state) (decreases %[fuel;cs]) =
| match cs with
| [] -> Some s
| c' :: cs' ->
(match machine_eval_code c' fuel s with
| None -> None
| Some s' -> machine_eval_codes cs' fuel s') | false |
Vale.AES.X64.AESGCM.fsti | Vale.AES.X64.AESGCM.va_quick_AES_GCM_encrypt_6mult | val va_quick_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) | val va_quick_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) | let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) =
(va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64
rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words
round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b)) | {
"file_name": "obj/Vale.AES.X64.AESGCM.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 183,
"start_col": 0,
"start_line": 172
} | module Vale.AES.X64.AESGCM
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers
//open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.Arch.TypesNative
open Vale.X64.CPU_Features_s
open Vale.AES.X64.PolyOps
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESopt2
//-- AES_GCM_encrypt_6mult
val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 ->
in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg)
([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm
15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.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.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.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.X64.PolyOps.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.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_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_helpers.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.AESGCM.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"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": 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 |
alg: Vale.AES.AES_common_s.algorithm ->
h_LE: Vale.X64.Decls.quad32 ->
iv_b: Vale.X64.Memory.buffer128 ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key_words: 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
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.AESGCM.va_code_AES_GCM_encrypt_6mult alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.X64.AESGCM.va_code_AES_GCM_encrypt_6mult",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.X64.AESGCM.va_wp_AES_GCM_encrypt_6mult",
"Vale.AES.X64.AESGCM.va_wpProof_AES_GCM_encrypt_6mult",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) =
| (va_QProc (va_code_AES_GCM_encrypt_6mult alg)
([
va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx;
va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem
])
(va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b
hkeys_b)
(va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b
hkeys_b)) | false |
Vale.AES.X64.AESGCM.fsti | Vale.AES.X64.AESGCM.va_wp_AES_GCM_encrypt_6mult | val va_wp_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.X64.AESGCM.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 155,
"start_col": 0,
"start_line": 98
} | module Vale.AES.X64.AESGCM
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers
//open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.Arch.TypesNative
open Vale.X64.CPU_Features_s
open Vale.AES.X64.PolyOps
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESopt2
//-- AES_GCM_encrypt_6mult
val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.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.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.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.X64.PolyOps.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.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_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_helpers.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.AESGCM.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"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": 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 |
alg: Vale.AES.AES_common_s.algorithm ->
h_LE: Vale.X64.Decls.quad32 ->
iv_b: Vale.X64.Memory.buffer128 ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key_words: 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 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRbp",
"Prims.op_Subtraction",
"Vale.X64.Machine_s.rR9",
"Prims.l_or",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.eq2",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Prims.nat",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Memory.buffer_addr",
"Vale.AES.X64.AESopt.aes_reqs_offset",
"Vale.X64.Machine_s.rRcx",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Words_s.Mkfour",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.AES.GHash.hkeys_reqs_priv",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Prims.int",
"Prims.op_Modulus",
"Prims.l_imp",
"Prims.op_GreaterThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Division",
"Prims.l_Forall",
"Vale.X64.InsBasic.vale_heap",
"Vale.X64.Memory.nat64",
"Vale.X64.Flags.t",
"Vale.X64.Decls.modifies_buffer128",
"Vale.X64.Decls.modifies_buffer_specific128",
"Vale.Def.Types_s.nat64",
"Vale.AES.GCTR.gctr_partial",
"Vale.AES.GHash.ghash_incremental0",
"Vale.X64.Decls.buffer128_read",
"Vale.AES.GCTR.inc32lite",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_mem_heaplet",
"Vale.X64.Decls.va_upd_xmm",
"Vale.X64.Decls.va_upd_reg64",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Decls.va_upd_mem"
] | [] | false | false | false | true | true | let va_wp_AES_GCM_encrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0)
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0)
(va_get_reg64 rRdi 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 6 va_s0)
(va_get_reg64 rRsi va_s0)
out_b
(va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0)
(va_get_reg64 rRbp va_s0)
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
va_get_reg64 rRsi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
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 == va_get_reg64 rRdx va_s0 /\
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b) `op_Multiply` 16 < pow2_32 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 <
pow2_64 /\
aes_reqs_offset alg
key_words
round_keys
keys_b
(va_get_reg64 rRcx va_s0 + 128)
(va_get_mem_heaplet 0 va_s0)
(va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
pclmulqdq_enabled /\
h_LE ==
Vale.AES.AES_s.aes_encrypt_LE alg
key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\
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) /\ (va_get_reg64 rRdx va_s0) `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\
(va_get_reg64 rRdx va_s0 > 0 ==> (va_get_reg64 rRdx va_s0) `op_Division` 6 >= 3) /\
12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\
(forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64)
(va_x_rdx: nat64) (va_x_rcx: nat64) (va_x_rbx: nat64) (va_x_r11: nat64) (va_x_r12: nat64)
(va_x_r13: nat64) (va_x_r14: 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_xmm9: quad32)
(va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32)
(va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap6: vale_heap) (va_x_heap2: vale_heap)
(va_x_heap3: vale_heap) (va_x_efl: Vale.X64.Flags.t).
let va_sM =
va_upd_flags va_x_efl
(va_upd_mem_heaplet 3
va_x_heap3
(va_upd_mem_heaplet 2
va_x_heap2
(va_upd_mem_heaplet 6
va_x_heap6
(va_upd_xmm 15
va_x_xmm15
(va_upd_xmm 14
va_x_xmm14
(va_upd_xmm 13
va_x_xmm13
(va_upd_xmm 12
va_x_xmm12
(va_upd_xmm 11
va_x_xmm11
(va_upd_xmm 10
va_x_xmm10
(va_upd_xmm 9
va_x_xmm9
(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 rR14
va_x_r14
(va_upd_reg64
rR13
va_x_r13
(va_upd_reg64
rR12
va_x_r12
(va_upd_reg64
rR11
va_x_r11
(
va_upd_reg64
rRbx
va_x_rbx
(
va_upd_reg64
rRcx
va_x_rcx
(
va_upd_reg64
rRdx
va_x_rdx
(
va_upd_reg64
rRsi
va_x_rsi
(
va_upd_reg64
rRdi
va_x_rdi
(
va_upd_reg64
rRax
va_x_rax
(
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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\
Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0)
(va_get_mem_heaplet 3 va_sM)
1
8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\
Vale.AES.GCTR.gctr_partial alg
(va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b)
key_words
(va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) ==
Vale.AES.GHash.ghash_incremental0 h_LE
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\
l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==>
va_k va_sM (()))) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.le_to_n_2 | val le_to_n_2 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 136,
"start_col": 0,
"start_line": 136
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.le_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_le_to_n"
] | [] | false | false | false | false | false | let le_to_n_2 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) | false |
|
Vale.AES.X64.AESGCM.fsti | Vale.AES.X64.AESGCM.va_wp_AES_GCM_decrypt_6mult | val va_wp_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.X64.AESGCM.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 302,
"start_col": 0,
"start_line": 245
} | module Vale.AES.X64.AESGCM
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers
//open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.Arch.TypesNative
open Vale.X64.CPU_Features_s
open Vale.AES.X64.PolyOps
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESopt2
//-- AES_GCM_encrypt_6mult
val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 ->
in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg)
([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm
15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) =
(va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64
rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words
round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b))
//--
//-- AES_GCM_decrypt_6mult
val va_code_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_decrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_decrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.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.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.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.X64.PolyOps.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.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_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_helpers.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.AESGCM.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"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": 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 |
alg: Vale.AES.AES_common_s.algorithm ->
h_LE: Vale.X64.Decls.quad32 ->
iv_b: Vale.X64.Memory.buffer128 ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key_words: 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 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRbp",
"Prims.op_Subtraction",
"Vale.X64.Machine_s.rR9",
"Prims.l_or",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.eq2",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Prims.nat",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Memory.buffer_addr",
"Vale.AES.X64.AESopt.aes_reqs_offset",
"Vale.X64.Machine_s.rRcx",
"Vale.Def.Words_s.four",
"Vale.Def.Types_s.nat32",
"Vale.X64.Decls.va_get_xmm",
"Vale.Def.Words_s.Mkfour",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.AES.GHash.hkeys_reqs_priv",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Prims.int",
"Prims.op_Modulus",
"Prims.l_imp",
"Prims.op_GreaterThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_Division",
"Prims.l_Forall",
"Vale.X64.InsBasic.vale_heap",
"Vale.X64.Memory.nat64",
"Vale.X64.Flags.t",
"Vale.X64.Decls.modifies_buffer128",
"Vale.X64.Decls.modifies_buffer_specific128",
"Vale.Def.Types_s.nat64",
"Vale.AES.GCTR.gctr_partial",
"Vale.AES.GHash.ghash_incremental0",
"Vale.X64.Decls.buffer128_read",
"Vale.AES.GCTR.inc32lite",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_mem_heaplet",
"Vale.X64.Decls.va_upd_xmm",
"Vale.X64.Decls.va_upd_reg64",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Decls.va_upd_mem"
] | [] | false | false | false | true | true | let va_wp_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0)
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0)
(va_get_reg64 rRdi 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 6 va_s0)
(va_get_reg64 rRsi va_s0)
out_b
(va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0)
(va_get_reg64 rRbp va_s0)
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
va_get_reg64 rRsi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
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 == va_get_reg64 rRdx va_s0 /\
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b) `op_Multiply` 16 < pow2_32 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 <
pow2_64 /\
aes_reqs_offset alg
key_words
round_keys
keys_b
(va_get_reg64 rRcx va_s0 + 128)
(va_get_mem_heaplet 0 va_s0)
(va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
pclmulqdq_enabled /\
h_LE ==
Vale.AES.AES_s.aes_encrypt_LE alg
key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\
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) /\ (va_get_reg64 rRdx va_s0) `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\
(va_get_reg64 rRdx va_s0 > 0 ==> (va_get_reg64 rRdx va_s0) `op_Division` 6 >= 1) /\
12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\
(forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64)
(va_x_rdx: nat64) (va_x_rcx: nat64) (va_x_rbx: nat64) (va_x_r11: nat64) (va_x_r12: nat64)
(va_x_r13: nat64) (va_x_r14: 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_xmm9: quad32)
(va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32)
(va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap6: vale_heap) (va_x_heap2: vale_heap)
(va_x_heap3: vale_heap) (va_x_efl: Vale.X64.Flags.t).
let va_sM =
va_upd_flags va_x_efl
(va_upd_mem_heaplet 3
va_x_heap3
(va_upd_mem_heaplet 2
va_x_heap2
(va_upd_mem_heaplet 6
va_x_heap6
(va_upd_xmm 15
va_x_xmm15
(va_upd_xmm 14
va_x_xmm14
(va_upd_xmm 13
va_x_xmm13
(va_upd_xmm 12
va_x_xmm12
(va_upd_xmm 11
va_x_xmm11
(va_upd_xmm 10
va_x_xmm10
(va_upd_xmm 9
va_x_xmm9
(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 rR14
va_x_r14
(va_upd_reg64
rR13
va_x_r13
(va_upd_reg64
rR12
va_x_r12
(va_upd_reg64
rR11
va_x_r11
(
va_upd_reg64
rRbx
va_x_rbx
(
va_upd_reg64
rRcx
va_x_rcx
(
va_upd_reg64
rRdx
va_x_rdx
(
va_upd_reg64
rRsi
va_x_rsi
(
va_upd_reg64
rRdi
va_x_rdi
(
va_upd_reg64
rRax
va_x_rax
(
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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\
Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0)
(va_get_mem_heaplet 3 va_sM)
1
8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\
Vale.AES.GCTR.gctr_partial alg
(va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b)
key_words
(va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) ==
Vale.AES.GHash.ghash_incremental0 h_LE
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\
l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==>
va_k va_sM (()))) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.le_to_n_3 | val le_to_n_3 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 146,
"start_col": 0,
"start_line": 146
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.le_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_le_to_n"
] | [] | false | false | false | false | false | let le_to_n_3 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) | false |
|
Pulse.Elaborate.fst | Pulse.Elaborate.elab_comp_close_commute' | val elab_comp_close_commute' (c: comp) (v: var) (n: index)
: Lemma (ensures RT.subst_term (elab_comp c) [RT.ND v n] == elab_comp (close_comp' c v n))
(decreases c) | val elab_comp_close_commute' (c: comp) (v: var) (n: index)
: Lemma (ensures RT.subst_term (elab_comp c) [RT.ND v n] == elab_comp (close_comp' c v n))
(decreases c) | let elab_comp_close_commute' (c:comp) (v:var) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.ND v n ] ==
elab_comp (close_comp' c v n))
(decreases c)
= match c with
| C_Tot t -> elab_close_commute' t v n
| C_ST s
| C_STGhost s ->
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_close_commute' inames v n;
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1) | {
"file_name": "lib/steel/pulse/Pulse.Elaborate.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 42,
"end_line": 131,
"start_col": 0,
"start_line": 115
} | (*
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.Elaborate
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Elaborate.Core
// let rec elab_term_bv_sort (t:term)
// : Lemma
// (ensures
// (R.Tv_Var? (R.inspect_ln (elab_term t)) \/
// R.Tv_BVar? (R.inspect_ln (elab_term t))) ==>
// (match R.inspect_ln (elab_term t) with
// | R.Tv_Var bv
// | R.Tv_BVar bv ->
// let vv = R.inspect_bv bv in
// vv.bv_sort == RT.tun))
// = admit()
#push-options "--fuel 10 --ifuel 10 --z3rlimit_factor 30 --query_stats --z3cliopt 'smt.qi.eager_threshold=100'"
let rec elab_open_commute' (e:term)
(v:term)
(n:index)
: Lemma (ensures
RT.subst_term (elab_term e) [ RT.DT n (elab_term v) ] ==
elab_term (open_term' e v n))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
// | Tm_PureApp e1 _ e2 ->
// elab_open_commute' e1 v n;
// elab_open_commute' e2 v n
| Tm_Inv p ->
elab_open_commute' p v n
| Tm_Pure p ->
elab_open_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_open_commute' e1 v n;
elab_open_commute' e2 v n
| Tm_ExistsSL u t body
| Tm_ForallSL u t body ->
elab_open_commute' t.binder_ty v n;
elab_open_commute' body v (n + 1)
| Tm_FStar t -> ()
let elab_comp_open_commute' (c:comp) (v:term) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.DT n (elab_term v) ] ==
elab_comp (open_comp' c v n))
= match c with
| C_Tot t -> elab_open_commute' t v n
| C_ST s
| C_STGhost s ->
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_open_commute' inames v n;
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
let rec elab_close_commute' (e:term)
(v:var)
(n:index)
: Lemma (ensures (
RT.subst_term (elab_term e) [ RT.ND v n ] ==
elab_term (close_term' e v n)))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
| Tm_Inv p ->
elab_close_commute' p v n
| Tm_Pure p ->
elab_close_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_close_commute' e1 v n;
elab_close_commute' e2 v n
| Tm_ExistsSL _ t body
| Tm_ForallSL _ t body ->
elab_close_commute' t.binder_ty v n;
elab_close_commute' body v (n + 1)
| Tm_FStar _ -> () | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Elaborate.Core.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Elaborate.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Naming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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": 10,
"initial_ifuel": 10,
"max_fuel": 10,
"max_ifuel": 10,
"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": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 30,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp -> v: Pulse.Syntax.Base.var -> n: Pulse.Syntax.Base.index
-> FStar.Pervasives.Lemma
(ensures
FStar.Reflection.Typing.subst_term (Pulse.Elaborate.Pure.elab_comp c)
[FStar.Reflection.Typing.ND v n] ==
Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.close_comp' c v n)) (decreases c) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.index",
"Pulse.Syntax.Base.term",
"Pulse.Elaborate.elab_close_commute'",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Prims.op_Addition",
"Prims.unit",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.observability",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.Typing.subst_term",
"Pulse.Elaborate.Pure.elab_comp",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.ND",
"Prims.Nil",
"Pulse.Syntax.Naming.close_comp'",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let elab_comp_close_commute' (c: comp) (v: var) (n: index)
: Lemma (ensures RT.subst_term (elab_comp c) [RT.ND v n] == elab_comp (close_comp' c v n))
(decreases c) =
| match c with
| C_Tot t -> elab_close_commute' t v n
| C_ST s
| C_STGhost s ->
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_close_commute' inames v n;
elab_close_commute' s.res v n;
elab_close_commute' s.pre v n;
elab_close_commute' s.post v (n + 1) | false |
Vale.AES.X64.AESGCM.fsti | Vale.AES.X64.AESGCM.va_quick_AES_GCM_decrypt_6mult | val va_quick_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) | val va_quick_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) | let va_quick_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) =
(va_QProc (va_code_AES_GCM_decrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64
rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRax; va_Mod_mem]) (va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words
round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b)) | {
"file_name": "obj/Vale.AES.X64.AESGCM.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 330,
"start_col": 0,
"start_line": 319
} | module Vale.AES.X64.AESGCM
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers
//open Vale.Poly1305.Math // For lemma_poly_bits64()
open Vale.AES.GCM_helpers
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.Arch.TypesNative
open Vale.X64.CPU_Features_s
open Vale.AES.X64.PolyOps
open Vale.Math.Poly2_s
open Vale.Math.Poly2
open Vale.Math.Poly2.Bits_s
open Vale.Math.Poly2.Bits
open Vale.Math.Poly2.Lemmas
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.AES.GHash
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESopt2
//-- AES_GCM_encrypt_6mult
val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 ->
in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg)
([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm
15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@ "opaque_to_smt" va_qattr]
let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) =
(va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64
rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words
round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b))
//--
//-- AES_GCM_decrypt_6mult
val va_code_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_code
val va_codegen_success_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_pbool
val va_lemma_AES_GCM_decrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 ->
key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES_GCM_decrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32)))
(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 6 va_s0) (va_get_mem_heaplet 6
va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet
3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM
(va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM
(va_update_xmm 10 va_sM (va_update_xmm 9 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 rR14
va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))
[@ va_qattr]
let va_wp_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128)
(out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public
/\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi 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 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
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 /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/
in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64
/\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\
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
== va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b
`op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b
(va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b
(va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123
67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ 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) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\
(va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0
==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 <
pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64)
(va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64)
(va_x_r13:nat64) (va_x_r14: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_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32)
(va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32)
(va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3
va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15
va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12
(va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (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 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12
(va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx
(va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi
(va_upd_reg64 rRax va_x_rax (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 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2
va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b
(va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM ==
va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32)
(Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0)
(va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wpProof_AES_GCM_decrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 ->
in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b
key_words round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_decrypt_6mult alg)
([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm
15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9;
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 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.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.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.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Lemmas.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Math.Poly2.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.TypesNative.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.X64.PolyOps.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.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_helpers.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_helpers.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.X64.AESGCM.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"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.Math.Poly2.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.PolyOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.TypesNative",
"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.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"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.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.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"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": "FStar.Mul",
"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": 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 |
alg: Vale.AES.AES_common_s.algorithm ->
h_LE: Vale.X64.Decls.quad32 ->
iv_b: Vale.X64.Memory.buffer128 ->
in_b: Vale.X64.Memory.buffer128 ->
out_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key_words: 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
-> Vale.X64.QuickCode.va_quickCode Prims.unit
(Vale.AES.X64.AESGCM.va_code_AES_GCM_decrypt_6mult alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.QuickCode.va_QProc",
"Prims.unit",
"Vale.AES.X64.AESGCM.va_code_AES_GCM_decrypt_6mult",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Vale.AES.X64.AESGCM.va_wp_AES_GCM_decrypt_6mult",
"Vale.AES.X64.AESGCM.va_wpProof_AES_GCM_decrypt_6mult",
"Vale.X64.QuickCode.va_quickCode"
] | [] | false | false | false | false | false | let va_quick_AES_GCM_decrypt_6mult
(alg: algorithm)
(h_LE: quad32)
(iv_b in_b out_b scratch_b: buffer128)
(key_words: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
: (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) =
| (va_QProc (va_code_AES_GCM_decrypt_6mult alg)
([
va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; 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 rR14; va_Mod_reg64 rR13;
va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx;
va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem
])
(va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b
hkeys_b)
(va_wpProof_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b
hkeys_b)) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.le_to_n_4 | val le_to_n_4 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 156,
"start_col": 0,
"start_line": 156
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.le_to_n_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_le_to_n"
] | [] | false | false | false | false | false | let le_to_n_4 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_le_1 | val parse32_bounded_integer_le_1
: parser32 (parse_bounded_integer_le 1) | val parse32_bounded_integer_le_1
: parser32 (parse_bounded_integer_le 1) | let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 185,
"start_col": 0,
"start_line": 185
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 1) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_le_1 =
| parse32_bounded_integer_le' 1 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2 | val parse32_bounded_integer_le_2
: parser32 (parse_bounded_integer_le 2) | val parse32_bounded_integer_le_2
: parser32 (parse_bounded_integer_le 2) | let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 186,
"start_col": 0,
"start_line": 186
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 2) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_le_2 =
| parse32_bounded_integer_le' 2 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4 | val parse32_bounded_integer_le_4
: parser32 (parse_bounded_integer_le 4) | val parse32_bounded_integer_le_4
: parser32 (parse_bounded_integer_le 4) | let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 188,
"start_col": 0,
"start_line": 188
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 4) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_le_4 =
| parse32_bounded_integer_le' 4 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_le_3 | val parse32_bounded_integer_le_3
: parser32 (parse_bounded_integer_le 3) | val parse32_bounded_integer_le_3
: parser32 (parse_bounded_integer_le 3) | let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 64,
"end_line": 187,
"start_col": 0,
"start_line": 187
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 3) | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le'"
] | [] | false | false | false | false | false | let parse32_bounded_integer_le_3 =
| parse32_bounded_integer_le' 3 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer' | val parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) | val parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) | let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 33,
"end_line": 77,
"start_col": 0,
"start_line": 71
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.SLow.Combinators.make_total_constant_size_parser32",
"FStar.UInt32.uint_to_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"LowParse.SLow.BoundedInt.decode32_bounded_integer",
"Prims.unit",
"LowParse.Spec.BoundedInt.decode_bounded_integer_injective",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer"
] | [] | false | false | false | false | false | let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
| [@@ inline_let ]let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz
(U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.decode32_bounded_integer_1 | val decode32_bounded_integer_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)}) | val decode32_bounded_integer_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)}) | let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 26,
"start_col": 0,
"start_line": 23
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 1
-> y:
LowParse.Spec.BoundedInt.bounded_integer 1
{y == LowParse.Spec.BoundedInt.decode_bounded_integer 1 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.be_to_n_1",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let decode32_bounded_integer_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == decode_bounded_integer 1 (B32.reveal b)}) =
| be_to_n_1 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.decode32_bounded_integer_2 | val decode32_bounded_integer_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)}) | val decode32_bounded_integer_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)}) | let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 36,
"start_col": 0,
"start_line": 33
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 2
-> y:
LowParse.Spec.BoundedInt.bounded_integer 2
{y == LowParse.Spec.BoundedInt.decode_bounded_integer 2 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.be_to_n_2",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let decode32_bounded_integer_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == decode_bounded_integer 2 (B32.reveal b)}) =
| be_to_n_2 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_be_1 | val n_to_be_1 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 86,
"start_col": 0,
"start_line": 86
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_be_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_be"
] | [] | false | false | false | false | false | let n_to_be_1 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.decode32_bounded_integer_3 | val decode32_bounded_integer_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)}) | val decode32_bounded_integer_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)}) | let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 46,
"start_col": 0,
"start_line": 43
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 3
-> y:
LowParse.Spec.BoundedInt.bounded_integer 3
{y == LowParse.Spec.BoundedInt.decode_bounded_integer 3 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.be_to_n_3",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let decode32_bounded_integer_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == decode_bounded_integer 3 (B32.reveal b)}) =
| be_to_n_3 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_3 | val serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3)) | val serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3)) | let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 20,
"end_line": 112,
"start_col": 0,
"start_line": 109
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 3) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_be_3",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_3:(serializer32 (serialize_bounded_integer 3)) =
| (fun (input: bounded_integer 3) -> n_to_be_3 input) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_2 | val serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2)) | val serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2)) | let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 20,
"end_line": 102,
"start_col": 0,
"start_line": 99
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 2) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_be_2",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_2:(serializer32 (serialize_bounded_integer 2)) =
| (fun (input: bounded_integer 2) -> n_to_be_2 input) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.decode32_bounded_integer | val decode32_bounded_integer (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)})
) | val decode32_bounded_integer (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)})
) | let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 35,
"end_line": 68,
"start_col": 0,
"start_line": 59
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size -> b: FStar.Bytes.lbytes sz
-> y:
LowParse.Spec.BoundedInt.bounded_integer sz
{y == LowParse.Spec.BoundedInt.decode_bounded_integer sz (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.SLow.BoundedInt.decode32_bounded_integer_1",
"LowParse.SLow.BoundedInt.decode32_bounded_integer_2",
"LowParse.SLow.BoundedInt.decode32_bounded_integer_3",
"LowParse.SLow.BoundedInt.decode32_bounded_integer_4",
"FStar.Bytes.lbytes",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let decode32_bounded_integer (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == decode_bounded_integer sz (B32.reveal b)})
) =
| match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.decode32_bounded_integer_4 | val decode32_bounded_integer_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)}) | val decode32_bounded_integer_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)}) | let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 56,
"start_col": 0,
"start_line": 53
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 4
-> y:
LowParse.Spec.BoundedInt.bounded_integer 4
{y == LowParse.Spec.BoundedInt.decode_bounded_integer 4 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.be_to_n_4",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.decode_bounded_integer",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let decode32_bounded_integer_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == decode_bounded_integer 4 (B32.reveal b)}) =
| be_to_n_4 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_1 | val serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1)) | val serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1)) | let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 20,
"end_line": 92,
"start_col": 0,
"start_line": 89
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 1) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_be_1",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_1:(serializer32 (serialize_bounded_integer 1)) =
| (fun (input: bounded_integer 1) -> n_to_be_1 input) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.bounded_integer_of_le_32_1 | val bounded_integer_of_le_32_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)}) | val bounded_integer_of_le_32_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)}) | let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 132,
"start_col": 0,
"start_line": 129
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 1
-> y:
LowParse.Spec.BoundedInt.bounded_integer 1
{y == LowParse.Spec.BoundedInt.bounded_integer_of_le 1 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.le_to_n_1",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let bounded_integer_of_le_32_1 (b: B32.lbytes 1)
: Tot (y: bounded_integer 1 {y == bounded_integer_of_le 1 (B32.reveal b)}) =
| le_to_n_1 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_be_4 | val n_to_be_4 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 116,
"start_col": 0,
"start_line": 116
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_be_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_be"
] | [] | false | false | false | false | false | let n_to_be_4 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) | false |
|
Vale.X64.Stack_i.fsti | Vale.X64.Stack_i.modifies_stack | val modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 | val modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 | let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h' | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 25,
"start_col": 0,
"start_line": 21
} | module Vale.X64.Stack_i
open FStar.Mul
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val init_rsp (h:vale_stack) : (n:nat64{n >= 4096}) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Stack_i.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
lo_rsp: Prims.nat ->
hi_rsp: Prims.nat ->
h: Vale.X64.Stack_i.vale_stack ->
h': Vale.X64.Stack_i.vale_stack
-> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.X64.Stack_i.vale_stack",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Stack_i.valid_src_stack64",
"Prims.op_BarBar",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_GreaterThanOrEqual",
"Prims.eq2",
"Vale.X64.Memory.nat64",
"Vale.X64.Stack_i.load_stack64",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | true | false | let modifies_stack (lo_rsp hi_rsp: nat) (h h': vale_stack) : Vale.Def.Prop_s.prop0 =
| forall addr. {:pattern (load_stack64 addr h')\/(valid_src_stack64 addr h')}
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\ load_stack64 addr h == load_stack64 addr h' | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_4 | val serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4)) | val serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4)) | let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 20,
"end_line": 122,
"start_col": 0,
"start_line": 119
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 4) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_be_4",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_4:(serializer32 (serialize_bounded_integer 4)) =
| (fun (input: bounded_integer 4) -> n_to_be_4 input) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_be_3 | val n_to_be_3 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 106,
"start_col": 0,
"start_line": 106
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_be_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_be"
] | [] | false | false | false | false | false | let n_to_be_3 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) | false |
|
Vale.X64.Stack_i.fsti | Vale.X64.Stack_i.valid_stack_slot64 | val valid_stack_slot64 : ptr: Prims.int ->
h: Vale.X64.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.X64.Memory.memtaint
-> Prims.logical | let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 65,
"end_line": 113,
"start_col": 0,
"start_line": 112
} | module Vale.X64.Stack_i
open FStar.Mul
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_rsp (free_stack64 start finish h) == init_rsp h)
[SMTPat (init_rsp (free_stack64 start finish h))]
val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_rsp (store_stack64 ptr v h) == init_rsp h)
[SMTPat (init_rsp (store_stack64 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))] | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Stack_i.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
ptr: Prims.int ->
h: Vale.X64.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.X64.Memory.memtaint
-> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Vale.X64.Stack_i.vale_stack",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Memory.memtaint",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Stack_i.valid_src_stack64",
"Vale.X64.Stack_i.valid_taint_stack64",
"Prims.logical"
] | [] | false | false | false | true | true | let valid_stack_slot64 (ptr: int) (h: vale_stack) (t: taint) (stackTaint: memtaint) =
| valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | false |
|
Vale.X64.Stack_i.fsti | Vale.X64.Stack_i.valid_src_stack64s | val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 | val valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 | let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 30,
"start_col": 0,
"start_line": 27
} | module Vale.X64.Stack_i
open FStar.Mul
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h' | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Stack_i.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 | base: Prims.nat -> num_slots: Prims.nat -> h: Vale.X64.Stack_i.vale_stack -> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.X64.Stack_i.vale_stack",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Vale.X64.Stack_i.valid_src_stack64",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | true | false | let valid_src_stack64s (base num_slots: nat) (h: vale_stack) : Vale.Def.Prop_s.prop0 =
| forall addr. {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.bounded_integer_of_le_32_2 | val bounded_integer_of_le_32_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)}) | val bounded_integer_of_le_32_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)}) | let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 142,
"start_col": 0,
"start_line": 139
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 2
-> y:
LowParse.Spec.BoundedInt.bounded_integer 2
{y == LowParse.Spec.BoundedInt.bounded_integer_of_le 2 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.le_to_n_2",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let bounded_integer_of_le_32_2 (b: B32.lbytes 2)
: Tot (y: bounded_integer 2 {y == bounded_integer_of_le 2 (B32.reveal b)}) =
| le_to_n_2 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_be_2 | val n_to_be_2 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 96,
"start_col": 0,
"start_line": 96
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_be_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_be"
] | [] | false | false | false | false | false | let n_to_be_2 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.bounded_integer_of_le_32_4 | val bounded_integer_of_le_32_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)}) | val bounded_integer_of_le_32_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)}) | let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 162,
"start_col": 0,
"start_line": 159
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 4
-> y:
LowParse.Spec.BoundedInt.bounded_integer 4
{y == LowParse.Spec.BoundedInt.bounded_integer_of_le 4 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.le_to_n_4",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let bounded_integer_of_le_32_4 (b: B32.lbytes 4)
: Tot (y: bounded_integer 4 {y == bounded_integer_of_le 4 (B32.reveal b)}) =
| le_to_n_4 b | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.bounded_integer_of_le_32_3 | val bounded_integer_of_le_32_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)}) | val bounded_integer_of_le_32_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)}) | let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 152,
"start_col": 0,
"start_line": 149
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b: FStar.Bytes.lbytes 3
-> y:
LowParse.Spec.BoundedInt.bounded_integer 3
{y == LowParse.Spec.BoundedInt.bounded_integer_of_le 3 (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"FStar.Bytes.lbytes",
"LowParse.SLow.BoundedInt.le_to_n_3",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let bounded_integer_of_le_32_3 (b: B32.lbytes 3)
: Tot (y: bounded_integer 3 {y == bounded_integer_of_le 3 (B32.reveal b)}) =
| le_to_n_3 b | false |
Vale.X64.Stack_i.fsti | Vale.X64.Stack_i.valid_stack_slot64s | val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 | val valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 | let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/
(valid_stack_slot64 addr h t stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 71,
"end_line": 119,
"start_col": 0,
"start_line": 115
} | module Vale.X64.Stack_i
open FStar.Mul
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_rsp (free_stack64 start finish h) == init_rsp h)
[SMTPat (init_rsp (free_stack64 start finish h))]
val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_rsp (store_stack64 ptr v h) == init_rsp h)
[SMTPat (init_rsp (store_stack64 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Stack_i.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
base: Prims.nat ->
num_slots: Prims.nat ->
h: Vale.X64.Stack_i.vale_stack ->
t: Vale.Arch.HeapTypes_s.taint ->
stackTaint: Vale.X64.Memory.memtaint
-> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.X64.Stack_i.vale_stack",
"Vale.Arch.HeapTypes_s.taint",
"Vale.X64.Memory.memtaint",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.op_Equality",
"Prims.op_Modulus",
"Prims.op_Subtraction",
"Prims.l_and",
"Vale.X64.Stack_i.valid_src_stack64",
"Vale.X64.Stack_i.valid_taint_stack64",
"Vale.X64.Stack_i.valid_stack_slot64",
"Vale.Def.Prop_s.prop0"
] | [] | false | false | false | true | false | let valid_stack_slot64s (base num_slots: nat) (h: vale_stack) (t: taint) (stackTaint: memtaint)
: Vale.Def.Prop_s.prop0 =
| forall addr.
{:pattern
(valid_src_stack64 addr h)\/(valid_taint_stack64 addr t stackTaint)\/(valid_stack_slot64 addr
h
t
stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | false |
Vale.X64.Stack_i.fsti | Vale.X64.Stack_i.modifies_stacktaint | val modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 | val modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 | let modifies_stacktaint (lo_rsp hi_rsp:nat) (h h':memtaint) : Vale.Def.Prop_s.prop0 =
forall addr t. {:pattern (valid_taint_stack64 addr t h') }
(addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_taint_stack64 addr t h == valid_taint_stack64 addr t h' | {
"file_name": "vale/code/arch/x64/Vale.X64.Stack_i.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 124,
"start_col": 0,
"start_line": 121
} | module Vale.X64.Stack_i
open FStar.Mul
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.Def.Prop_s
val vale_stack : Type u#0
val valid_src_stack64 (ptr:int) (h:vale_stack) : GTot bool
val load_stack64 (ptr:int) (h:vale_stack) : GTot nat64
val store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : GTot vale_stack
val free_stack64 (start:int) (finish:int) (h:vale_stack) : GTot vale_stack
val valid_src_stack128 (ptr:int) (h:vale_stack) : GTot bool
val load_stack128 (ptr:int) (h:vale_stack) : GTot quad32
val store_stack128 (ptr:int) (v:quad32) (h:vale_stack) : GTot vale_stack
val init_rsp (h:vale_stack) : (n:nat64{n >= 4096})
let modifies_stack (lo_rsp hi_rsp:nat) (h h':vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (load_stack64 addr h') \/ (valid_src_stack64 addr h') }
valid_src_stack64 addr h /\ (addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_src_stack64 addr h' /\
load_stack64 addr h == load_stack64 addr h'
let valid_src_stack64s (base num_slots:nat) (h:vale_stack) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h
(* Validity preservation *)
val lemma_store_stack_same_valid64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures valid_src_stack64 i (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_valid64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures valid_src_stack64 ptr (free_stack64 start finish h))
[SMTPat (valid_src_stack64 ptr (free_stack64 start finish h))]
(* Validity update *)
val lemma_store_new_valid64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(valid_src_stack64 ptr (store_stack64 ptr v h))
[SMTPat (valid_src_stack64 ptr (store_stack64 ptr v h))]
(* Classic select/update lemmas *)
val lemma_correct_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(load_stack64 ptr (store_stack64 ptr v h) == v)
[SMTPat (load_stack64 ptr (store_stack64 ptr v h))]
val lemma_frame_store_load_stack64 (ptr:int) (v:nat64) (h:vale_stack) (i:int) : Lemma
(requires valid_src_stack64 i h /\
(i >= ptr + 8 \/ i + 8 <= ptr))
(ensures (load_stack64 i (store_stack64 ptr v h) == load_stack64 i h))
[SMTPat (load_stack64 i (store_stack64 ptr v h))]
val lemma_free_stack_same_load64 (start:int) (finish:int) (ptr:int) (h:vale_stack) : Lemma
(requires valid_src_stack64 ptr h /\
(ptr >= finish \/ ptr + 8 <= start))
(ensures load_stack64 ptr h == load_stack64 ptr (free_stack64 start finish h))
[SMTPat (load_stack64 ptr (free_stack64 start finish h))]
(* Free composition *)
val lemma_compose_free_stack64 (start:int) (inter:int) (finish:int) (h:vale_stack) : Lemma
(requires start <= inter /\ inter <= finish)
(ensures free_stack64 inter finish (free_stack64 start inter h) == free_stack64 start finish h)
[SMTPat (free_stack64 inter finish (free_stack64 start inter h))]
(* Preservation of the initial stack pointer *)
val lemma_same_init_rsp_free_stack64 (start:int) (finish:int) (h:vale_stack) : Lemma
(init_rsp (free_stack64 start finish h) == init_rsp h)
[SMTPat (init_rsp (free_stack64 start finish h))]
val lemma_same_init_rsp_store_stack64 (ptr:int) (v:nat64) (h:vale_stack) : Lemma
(init_rsp (store_stack64 ptr v h) == init_rsp h)
[SMTPat (init_rsp (store_stack64 ptr v h))]
// Taint for the stack
val valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot prop0
val store_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : GTot memtaint
val lemma_valid_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack64 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack128 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires valid_taint_stack128 ptr t stackTaint)
(ensures forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 16 ==> Map.sel stackTaint i == t)
val lemma_valid_taint_stack64_reveal (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(requires forall i.{:pattern Map.sel stackTaint i} i >= ptr /\ i < ptr + 8 ==> Map.sel stackTaint i == t)
(ensures valid_taint_stack64 ptr t stackTaint)
val lemma_correct_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) : Lemma
(valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 ptr t (store_taint_stack64 ptr t stackTaint))]
val lemma_frame_store_load_taint_stack64 (ptr:int) (t:taint) (stackTaint:memtaint) (i:int) (t':taint) : Lemma
(requires i >= ptr + 8 \/ i + 8 <= ptr)
(ensures valid_taint_stack64 i t' stackTaint == valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))
[SMTPat (valid_taint_stack64 i t' (store_taint_stack64 ptr t stackTaint))]
let valid_stack_slot64 (ptr:int) (h:vale_stack) (t:taint) (stackTaint:memtaint) =
valid_src_stack64 ptr h /\ valid_taint_stack64 ptr t stackTaint
let valid_stack_slot64s (base num_slots:nat) (h:vale_stack) (t:taint) (stackTaint:memtaint) : Vale.Def.Prop_s.prop0 =
forall addr . {:pattern (valid_src_stack64 addr h) \/ (valid_taint_stack64 addr t stackTaint) \/
(valid_stack_slot64 addr h t stackTaint)}
(base <= addr) && (addr < base + num_slots * 8) && (addr - base) % 8 = 0 ==>
valid_src_stack64 addr h /\ valid_taint_stack64 addr t stackTaint | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.X64.Stack_i.fsti"
} | [
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"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": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 |
lo_rsp: Prims.nat ->
hi_rsp: Prims.nat ->
h: Vale.X64.Memory.memtaint ->
h': Vale.X64.Memory.memtaint
-> Vale.Def.Prop_s.prop0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Vale.X64.Memory.memtaint",
"Prims.l_Forall",
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_BarBar",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_GreaterThanOrEqual",
"Prims.eq2",
"Vale.Def.Prop_s.prop0",
"Vale.X64.Stack_i.valid_taint_stack64"
] | [] | false | false | false | true | false | let modifies_stacktaint (lo_rsp hi_rsp: nat) (h h': memtaint) : Vale.Def.Prop_s.prop0 =
| forall addr t. {:pattern (valid_taint_stack64 addr t h')}
(addr + 8 <= lo_rsp || addr >= hi_rsp) ==>
valid_taint_stack64 addr t h == valid_taint_stack64 addr t h' | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_le_2 | val n_to_le_2 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 213,
"start_col": 0,
"start_line": 213
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_le_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_le"
] | [] | false | false | false | false | false | let n_to_le_2 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_u16_le | val parse32_u16_le : parser32 parse_u16_le | val parse32_u16_le : parser32 parse_u16_le | let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 195,
"start_col": 0,
"start_line": 190
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 LowParse.Spec.BoundedInt.parse_u16_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.Combinators.parse32_synth'",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u16_le",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2"
] | [] | false | false | false | true | false | let parse32_u16_le =
| parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_integer_le' | val parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) | val parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) | let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 33,
"end_line": 183,
"start_col": 0,
"start_line": 177
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.SLow.Combinators.make_total_constant_size_parser32",
"FStar.UInt32.uint_to_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"LowParse.SLow.BoundedInt.bounded_integer_of_le_32",
"Prims.unit",
"LowParse.Spec.BoundedInt.bounded_integer_of_le_injective",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le"
] | [] | false | false | false | false | false | let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
| [@@ inline_let ]let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz
(U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.bounded_integer_of_le_32 | val bounded_integer_of_le_32 (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)})) | val bounded_integer_of_le_32 (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)})) | let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4 | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 35,
"end_line": 174,
"start_col": 0,
"start_line": 165
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | sz: LowParse.Spec.BoundedInt.integer_size -> b: FStar.Bytes.lbytes sz
-> y:
LowParse.Spec.BoundedInt.bounded_integer sz
{y == LowParse.Spec.BoundedInt.bounded_integer_of_le sz (FStar.Bytes.reveal b)} | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.SLow.BoundedInt.bounded_integer_of_le_32_1",
"LowParse.SLow.BoundedInt.bounded_integer_of_le_32_2",
"LowParse.SLow.BoundedInt.bounded_integer_of_le_32_3",
"LowParse.SLow.BoundedInt.bounded_integer_of_le_32_4",
"FStar.Bytes.lbytes",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.eq2",
"LowParse.Spec.BoundedInt.bounded_integer_of_le",
"FStar.Bytes.reveal"
] | [] | false | false | false | false | false | let bounded_integer_of_le_32 (sz: integer_size)
: Tot
(b: B32.lbytes sz -> Tot (y: bounded_integer sz {y == bounded_integer_of_le sz (B32.reveal b)})) =
| match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4 | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_u16_le | val serialize32_u16_le : serializer32 serialize_u16_le | val serialize32_u16_le : serializer32 serialize_u16_le | let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 239,
"start_col": 0,
"start_line": 232
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 LowParse.Spec.BoundedInt.serialize_u16_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.Combinators.serialize32_synth'",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt16.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u16_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2",
"LowParse.Spec.BoundedInt.synth_u16_le_recip"
] | [] | false | false | false | true | false | let serialize32_u16_le =
| serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip () | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_u32_le | val parse32_u32_le : parser32 parse_u32_le | val parse32_u32_le : parser32 parse_u32_le | let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 202,
"start_col": 0,
"start_line": 197
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 LowParse.Spec.BoundedInt.parse_u32_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.Combinators.parse32_synth'",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u32_le",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4"
] | [] | false | false | false | true | false | let parse32_u32_le =
| parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_1 | val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) | val serialize32_bounded_integer_le_1 : serializer32 (serialize_bounded_integer_le 1) | let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 209,
"start_col": 0,
"start_line": 208
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 1) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_le_1",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_le_1 =
| fun (x: bounded_integer 1) -> n_to_le_1 x | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_u32_le | val serialize32_u32_le : serializer32 serialize_u32_le | val serialize32_u32_le : serializer32 serialize_u32_le | let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 248,
"start_col": 0,
"start_line": 241
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 LowParse.Spec.BoundedInt.serialize_u32_le | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.Combinators.serialize32_synth'",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.synth_u32_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4",
"LowParse.Spec.BoundedInt.synth_u32_le_recip"
] | [] | false | false | false | true | false | let serialize32_u32_le =
| serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip () | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_2 | val parse32_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 36,
"end_line": 275,
"start_col": 0,
"start_line": 273
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 65536 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.parse32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | false | false | false | false | false | let parse32_bounded_int32_2 min max =
| parse32_bounded_int32' min max 2ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_le_1 | val n_to_le_1 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 206,
"start_col": 0,
"start_line": 206
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_le_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_le"
] | [] | false | false | false | false | false | let n_to_le_1 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_le_3 | val n_to_le_3 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 220,
"start_col": 0,
"start_line": 220
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_le_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_le"
] | [] | false | false | false | false | false | let n_to_le_3 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_3 | val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) | val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) | let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 223,
"start_col": 0,
"start_line": 222
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 3) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_le_3",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_le_3 =
| fun (x: bounded_integer 3) -> n_to_le_3 x | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.n_to_le_4 | val n_to_le_4 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 112,
"end_line": 227,
"start_col": 0,
"start_line": 227
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4 | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_attr",
"Prims.string",
"Prims.Nil",
"FStar.Pervasives.iota",
"FStar.Pervasives.zeta",
"FStar.Pervasives.primops",
"LowParse.SLow.Endianness.n_to_le_t",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.Endianness.Instances.bounded_integer",
"LowParse.SLow.Endianness.mk_n_to_le"
] | [] | false | false | false | false | false | let n_to_le_4 =
| norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) | false |
|
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_1 | val parse32_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 36,
"end_line": 271,
"start_col": 0,
"start_line": 269
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 256 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.SLow.BoundedInt.parse32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | false | false | false | false | false | let parse32_bounded_int32_1 min max =
| parse32_bounded_int32' min max 1ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2 | val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) | val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) | let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 216,
"start_col": 0,
"start_line": 215
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 2) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_le_2",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_le_2 =
| fun (x: bounded_integer 2) -> n_to_le_2 x | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_le_2 | val parse32_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_le_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_le_2
min max
= parse32_bounded_int32_le' min max 2ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 348,
"start_col": 0,
"start_line": 346
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul
let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul
let serialize32_bounded_int32_3
min max
= serialize32_bounded_int32' min max 3ul
let serialize32_bounded_int32_4
min max
= serialize32_bounded_int32' min max 4ul
inline_for_extraction
let parse32_bounded_int32_le'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_le_1
min max
= parse32_bounded_int32_le' min max 1ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 65536 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.parse32_bounded_int32_le'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | false | false | false | false | false | let parse32_bounded_int32_le_2 min max =
| parse32_bounded_int32_le' min max 2ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_int32_1 | val serialize32_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | val serialize32_bounded_int32_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 40,
"end_line": 308,
"start_col": 0,
"start_line": 306
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 256 }
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.SLow.BoundedInt.serialize32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32",
"LowParse.Spec.BoundedInt.serialize_bounded_int32"
] | [] | false | false | false | false | false | let serialize32_bounded_int32_1 min max =
| serialize32_bounded_int32' min max 1ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_4 | val parse32_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_4
(min32: U32.t)
(max32: U32.t { 16777216 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 36,
"end_line": 283,
"start_col": 0,
"start_line": 281
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 16777216 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.parse32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | false | false | false | false | false | let parse32_bounded_int32_4 min max =
| parse32_bounded_int32' min max 4ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4 | val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) | val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) | let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 13,
"end_line": 230,
"start_col": 0,
"start_line": 229
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 4) | Prims.Tot | [
"total"
] | [] | [
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.SLow.BoundedInt.n_to_le_4",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le"
] | [] | false | false | false | false | false | let serialize32_bounded_integer_le_4 =
| fun (x: bounded_integer 4) -> n_to_le_4 x | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_int32_3 | val serialize32_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | val serialize32_bounded_int32_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | let serialize32_bounded_int32_3
min max
= serialize32_bounded_int32' min max 3ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 40,
"end_line": 316,
"start_col": 0,
"start_line": 314
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul
let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 16777216 }
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.serialize32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32",
"LowParse.Spec.BoundedInt.serialize_bounded_int32"
] | [] | false | false | false | false | false | let serialize32_bounded_int32_3 min max =
| serialize32_bounded_int32' min max 3ul | false |
Pulse.Elaborate.fst | Pulse.Elaborate.elab_comp_open_commute' | val elab_comp_open_commute' (c: comp) (v: term) (n: index)
: Lemma
(ensures RT.subst_term (elab_comp c) [RT.DT n (elab_term v)] == elab_comp (open_comp' c v n)) | val elab_comp_open_commute' (c: comp) (v: term) (n: index)
: Lemma
(ensures RT.subst_term (elab_comp c) [RT.DT n (elab_term v)] == elab_comp (open_comp' c v n)) | let elab_comp_open_commute' (c:comp) (v:term) (n:index)
: Lemma (ensures
RT.subst_term (elab_comp c) [ RT.DT n (elab_term v) ] ==
elab_comp (open_comp' c v n))
= match c with
| C_Tot t -> elab_open_commute' t v n
| C_ST s
| C_STGhost s ->
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_open_commute' inames v n;
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1) | {
"file_name": "lib/steel/pulse/Pulse.Elaborate.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 41,
"end_line": 86,
"start_col": 0,
"start_line": 71
} | (*
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.Elaborate
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Typing
open Pulse.Elaborate.Core
// let rec elab_term_bv_sort (t:term)
// : Lemma
// (ensures
// (R.Tv_Var? (R.inspect_ln (elab_term t)) \/
// R.Tv_BVar? (R.inspect_ln (elab_term t))) ==>
// (match R.inspect_ln (elab_term t) with
// | R.Tv_Var bv
// | R.Tv_BVar bv ->
// let vv = R.inspect_bv bv in
// vv.bv_sort == RT.tun))
// = admit()
#push-options "--fuel 10 --ifuel 10 --z3rlimit_factor 30 --query_stats --z3cliopt 'smt.qi.eager_threshold=100'"
let rec elab_open_commute' (e:term)
(v:term)
(n:index)
: Lemma (ensures
RT.subst_term (elab_term e) [ RT.DT n (elab_term v) ] ==
elab_term (open_term' e v n))
(decreases e)
= match e.t with
| Tm_Emp
| Tm_Inames
| Tm_EmpInames
| Tm_VProp
| Tm_Unknown -> ()
// | Tm_PureApp e1 _ e2 ->
// elab_open_commute' e1 v n;
// elab_open_commute' e2 v n
| Tm_Inv p ->
elab_open_commute' p v n
| Tm_Pure p ->
elab_open_commute' p v n
| Tm_AddInv e1 e2
| Tm_Star e1 e2 ->
elab_open_commute' e1 v n;
elab_open_commute' e2 v n
| Tm_ExistsSL u t body
| Tm_ForallSL u t body ->
elab_open_commute' t.binder_ty v n;
elab_open_commute' body v (n + 1)
| Tm_FStar t -> () | {
"checked_file": "/",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Elaborate.Core.fst.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Elaborate.fst"
} | [
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Naming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"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",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"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": 10,
"initial_ifuel": 10,
"max_fuel": 10,
"max_ifuel": 10,
"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": [
"smt.qi.eager_threshold=100"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 30,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Pulse.Syntax.Base.comp -> v: Pulse.Syntax.Base.term -> n: Pulse.Syntax.Base.index
-> FStar.Pervasives.Lemma
(ensures
FStar.Reflection.Typing.subst_term (Pulse.Elaborate.Pure.elab_comp c)
[FStar.Reflection.Typing.DT n (Pulse.Elaborate.Pure.elab_term v)] ==
Pulse.Elaborate.Pure.elab_comp (Pulse.Syntax.Naming.open_comp' c v n)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.index",
"Pulse.Elaborate.elab_open_commute'",
"Pulse.Syntax.Base.st_comp",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Prims.op_Addition",
"Prims.unit",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.observability",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.Typing.subst_term",
"Pulse.Elaborate.Pure.elab_comp",
"Prims.Cons",
"FStar.Reflection.Typing.subst_elt",
"FStar.Reflection.Typing.DT",
"Pulse.Elaborate.Pure.elab_term",
"Prims.Nil",
"Pulse.Syntax.Naming.open_comp'",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let elab_comp_open_commute' (c: comp) (v: term) (n: index)
: Lemma
(ensures RT.subst_term (elab_comp c) [RT.DT n (elab_term v)] == elab_comp (open_comp' c v n)) =
| match c with
| C_Tot t -> elab_open_commute' t v n
| C_ST s
| C_STGhost s ->
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1)
| C_STAtomic inames _ s ->
elab_open_commute' inames v n;
elab_open_commute' s.res v n;
elab_open_commute' s.pre v n;
elab_open_commute' s.post v (n + 1) | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_int32_le_1 | val serialize32_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) | val serialize32_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32))) | let serialize32_bounded_int32_le_1
min max
= serialize32_bounded_int32_le' min max 1ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 43,
"end_line": 384,
"start_col": 0,
"start_line": 382
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul
let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul
let serialize32_bounded_int32_3
min max
= serialize32_bounded_int32' min max 3ul
let serialize32_bounded_int32_4
min max
= serialize32_bounded_int32' min max 4ul
inline_for_extraction
let parse32_bounded_int32_le'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_le_1
min max
= parse32_bounded_int32_le' min max 1ul
let parse32_bounded_int32_le_2
min max
= parse32_bounded_int32_le' min max 2ul
let parse32_bounded_int32_le_3
min max
= parse32_bounded_int32_le' min max 3ul
let parse32_bounded_int32_le_4
min max
= parse32_bounded_int32_le' min max 4ul
inline_for_extraction
let serialize32_bounded_int32_le'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32_le (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer_le sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
#push-options "--z3rlimit 40"
#restart-solver // somehow needed | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 40,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 256 }
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32_le (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.SLow.BoundedInt.serialize32_bounded_int32_le'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le",
"LowParse.Spec.BoundedInt.serialize_bounded_int32_le"
] | [] | false | false | false | false | false | let serialize32_bounded_int32_le_1 min max =
| serialize32_bounded_int32_le' min max 1ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_int32_2 | val serialize32_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | val serialize32_bounded_int32_2
(min32: U32.t)
(max32: U32.t { 256 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 65536 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 40,
"end_line": 312,
"start_col": 0,
"start_line": 310
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 256 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 65536 }
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.serialize32_bounded_int32'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32",
"LowParse.Spec.BoundedInt.serialize_bounded_int32"
] | [] | false | false | false | false | false | let serialize32_bounded_int32_2 min max =
| serialize32_bounded_int32' min max 2ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.serialize32_bounded_int32' | val serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | val serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) | let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 304,
"start_col": 0,
"start_line": 286
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 } ->
sz32:
FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_int32 (FStar.UInt32.v
min32)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.SLow.Combinators.serialize32_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.Spec.Combinators.serialize_filter",
"LowParse.Spec.BoundedInt.serialize_bounded_integer",
"LowParse.SLow.Combinators.serialize32_filter",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer",
"FStar.UInt.uint_t",
"LowParse.SLow.Base.serializer32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32",
"LowParse.Spec.BoundedInt.serialize_bounded_int32"
] | [] | false | false | false | false | false | let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32))) =
| [@@ inline_let ]let sz = U32.v sz32 in
[@@ inline_let ]let min = U32.v min32 in
[@@ inline_let ]let max = U32.v max32 in
serialize32_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max))
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
() | false |
Test.Vectors.Chacha20Poly1305.fst | Test.Vectors.Chacha20Poly1305.input9 | val input9:(b: B.buffer UInt8.t {B.length b = 1024 /\ B.recallable b /\ B.disjoint b aad9}) | val input9:(b: B.buffer UInt8.t {B.length b = 1024 /\ B.recallable b /\ B.disjoint b aad9}) | let input9: (b: B.buffer UInt8.t { B.length b = 1024 /\ B.recallable b /\ B.disjoint b aad9 }) =
B.recall aad9;[@inline_let] let l = [ 0x42uy; 0x93uy; 0xe4uy; 0xebuy; 0x97uy; 0xb0uy; 0x57uy; 0xbfuy; 0x1auy; 0x8buy; 0x1fuy; 0xe4uy; 0x5fuy; 0x36uy; 0x20uy; 0x3cuy; 0xefuy; 0x0auy; 0xa9uy; 0x48uy; 0x5fuy; 0x5fuy; 0x37uy; 0x22uy; 0x3auy; 0xdeuy; 0xe3uy; 0xaeuy; 0xbeuy; 0xaduy; 0x07uy; 0xccuy; 0xb1uy; 0xf6uy; 0xf5uy; 0xf9uy; 0x56uy; 0xdduy; 0xe7uy; 0x16uy; 0x1euy; 0x7fuy; 0xdfuy; 0x7auy; 0x9euy; 0x75uy; 0xb7uy; 0xc7uy; 0xbeuy; 0xbeuy; 0x8auy; 0x36uy; 0x04uy; 0xc0uy; 0x10uy; 0xf4uy; 0x95uy; 0x20uy; 0x03uy; 0xecuy; 0xdcuy; 0x05uy; 0xa1uy; 0x7duy; 0xc4uy; 0xa9uy; 0x2cuy; 0x82uy; 0xd0uy; 0xbcuy; 0x8buy; 0xc5uy; 0xc7uy; 0x45uy; 0x50uy; 0xf6uy; 0xa2uy; 0x1auy; 0xb5uy; 0x46uy; 0x3buy; 0x73uy; 0x02uy; 0xa6uy; 0x83uy; 0x4buy; 0x73uy; 0x82uy; 0x58uy; 0x5euy; 0x3buy; 0x65uy; 0x2fuy; 0x0euy; 0xfduy; 0x2buy; 0x59uy; 0x16uy; 0xceuy; 0xa1uy; 0x60uy; 0x9cuy; 0xe8uy; 0x3auy; 0x99uy; 0xeduy; 0x8duy; 0x5auy; 0xcfuy; 0xf6uy; 0x83uy; 0xafuy; 0xbauy; 0xd7uy; 0x73uy; 0x73uy; 0x40uy; 0x97uy; 0x3duy; 0xcauy; 0xefuy; 0x07uy; 0x57uy; 0xe6uy; 0xd9uy; 0x70uy; 0x0euy; 0x95uy; 0xaeuy; 0xa6uy; 0x8duy; 0x04uy; 0xccuy; 0xeeuy; 0xf7uy; 0x09uy; 0x31uy; 0x77uy; 0x12uy; 0xa3uy; 0x23uy; 0x97uy; 0x62uy; 0xb3uy; 0x7buy; 0x32uy; 0xfbuy; 0x80uy; 0x14uy; 0x48uy; 0x81uy; 0xc3uy; 0xe5uy; 0xeauy; 0x91uy; 0x39uy; 0x52uy; 0x81uy; 0xa2uy; 0x4fuy; 0xe4uy; 0xb3uy; 0x09uy; 0xffuy; 0xdeuy; 0x5euy; 0xe9uy; 0x58uy; 0x84uy; 0x6euy; 0xf9uy; 0x3duy; 0xdfuy; 0x25uy; 0xeauy; 0xaduy; 0xaeuy; 0xe6uy; 0x9auy; 0xd1uy; 0x89uy; 0x55uy; 0xd3uy; 0xdeuy; 0x6cuy; 0x52uy; 0xdbuy; 0x70uy; 0xfeuy; 0x37uy; 0xceuy; 0x44uy; 0x0auy; 0xa8uy; 0x25uy; 0x5fuy; 0x92uy; 0xc1uy; 0x33uy; 0x4auy; 0x4fuy; 0x9buy; 0x62uy; 0x35uy; 0xffuy; 0xceuy; 0xc0uy; 0xa9uy; 0x60uy; 0xceuy; 0x52uy; 0x00uy; 0x97uy; 0x51uy; 0x35uy; 0x26uy; 0x2euy; 0xb9uy; 0x36uy; 0xa9uy; 0x87uy; 0x6euy; 0x1euy; 0xccuy; 0x91uy; 0x78uy; 0x53uy; 0x98uy; 0x86uy; 0x5buy; 0x9cuy; 0x74uy; 0x7duy; 0x88uy; 0x33uy; 0xe1uy; 0xdfuy; 0x37uy; 0x69uy; 0x2buy; 0xbbuy; 0xf1uy; 0x4duy; 0xf4uy; 0xd1uy; 0xf1uy; 0x39uy; 0x93uy; 0x17uy; 0x51uy; 0x19uy; 0xe3uy; 0x19uy; 0x1euy; 0x76uy; 0x37uy; 0x25uy; 0xfbuy; 0x09uy; 0x27uy; 0x6auy; 0xabuy; 0x67uy; 0x6fuy; 0x14uy; 0x12uy; 0x64uy; 0xe7uy; 0xc4uy; 0x07uy; 0xdfuy; 0x4duy; 0x17uy; 0xbbuy; 0x6duy; 0xe0uy; 0xe9uy; 0xb9uy; 0xabuy; 0xcauy; 0x10uy; 0x68uy; 0xafuy; 0x7euy; 0xb7uy; 0x33uy; 0x54uy; 0x73uy; 0x07uy; 0x6euy; 0xf7uy; 0x81uy; 0x97uy; 0x9cuy; 0x05uy; 0x6fuy; 0x84uy; 0x5fuy; 0xd2uy; 0x42uy; 0xfbuy; 0x38uy; 0xcfuy; 0xd1uy; 0x2fuy; 0x14uy; 0x30uy; 0x88uy; 0x98uy; 0x4duy; 0x5auy; 0xa9uy; 0x76uy; 0xd5uy; 0x4fuy; 0x3euy; 0x70uy; 0x6cuy; 0x85uy; 0x76uy; 0xd7uy; 0x01uy; 0xa0uy; 0x1auy; 0xc8uy; 0x4euy; 0xaauy; 0xacuy; 0x78uy; 0xfeuy; 0x46uy; 0xdeuy; 0x6auy; 0x05uy; 0x46uy; 0xa7uy; 0x43uy; 0x0cuy; 0xb9uy; 0xdeuy; 0xb9uy; 0x68uy; 0xfbuy; 0xceuy; 0x42uy; 0x99uy; 0x07uy; 0x4duy; 0x0buy; 0x3buy; 0x5auy; 0x30uy; 0x35uy; 0xa8uy; 0xf9uy; 0x3auy; 0x73uy; 0xefuy; 0x0fuy; 0xdbuy; 0x1euy; 0x16uy; 0x42uy; 0xc4uy; 0xbauy; 0xaeuy; 0x58uy; 0xaauy; 0xf8uy; 0xe5uy; 0x75uy; 0x2fuy; 0x1buy; 0x15uy; 0x5cuy; 0xfduy; 0x0auy; 0x97uy; 0xd0uy; 0xe4uy; 0x37uy; 0x83uy; 0x61uy; 0x5fuy; 0x43uy; 0xa6uy; 0xc7uy; 0x3fuy; 0x38uy; 0x59uy; 0xe6uy; 0xebuy; 0xa3uy; 0x90uy; 0xc3uy; 0xaauy; 0xaauy; 0x5auy; 0xd3uy; 0x34uy; 0xd4uy; 0x17uy; 0xc8uy; 0x65uy; 0x3euy; 0x57uy; 0xbcuy; 0x5euy; 0xdduy; 0x9euy; 0xb7uy; 0xf0uy; 0x2euy; 0x5buy; 0xb2uy; 0x1fuy; 0x8auy; 0x08uy; 0x0duy; 0x45uy; 0x91uy; 0x0buy; 0x29uy; 0x53uy; 0x4fuy; 0x4cuy; 0x5auy; 0x73uy; 0x56uy; 0xfeuy; 0xafuy; 0x41uy; 0x01uy; 0x39uy; 0x0auy; 0x24uy; 0x3cuy; 0x7euy; 0xbeuy; 0x4euy; 0x53uy; 0xf3uy; 0xebuy; 0x06uy; 0x66uy; 0x51uy; 0x28uy; 0x1duy; 0xbduy; 0x41uy; 0x0auy; 0x01uy; 0xabuy; 0x16uy; 0x47uy; 0x27uy; 0x47uy; 0x47uy; 0xf7uy; 0xcbuy; 0x46uy; 0x0auy; 0x70uy; 0x9euy; 0x01uy; 0x9cuy; 0x09uy; 0xe1uy; 0x2auy; 0x00uy; 0x1auy; 0xd8uy; 0xd4uy; 0x79uy; 0x9duy; 0x80uy; 0x15uy; 0x8euy; 0x53uy; 0x2auy; 0x65uy; 0x83uy; 0x78uy; 0x3euy; 0x03uy; 0x00uy; 0x07uy; 0x12uy; 0x1fuy; 0x33uy; 0x3euy; 0x7buy; 0x13uy; 0x37uy; 0xf1uy; 0xc3uy; 0xefuy; 0xb7uy; 0xc1uy; 0x20uy; 0x3cuy; 0x3euy; 0x67uy; 0x66uy; 0x5duy; 0x88uy; 0xa7uy; 0x7duy; 0x33uy; 0x50uy; 0x77uy; 0xb0uy; 0x28uy; 0x8euy; 0xe7uy; 0x2cuy; 0x2euy; 0x7auy; 0xf4uy; 0x3cuy; 0x8duy; 0x74uy; 0x83uy; 0xafuy; 0x8euy; 0x87uy; 0x0fuy; 0xe4uy; 0x50uy; 0xffuy; 0x84uy; 0x5cuy; 0x47uy; 0x0cuy; 0x6auy; 0x49uy; 0xbfuy; 0x42uy; 0x86uy; 0x77uy; 0x15uy; 0x48uy; 0xa5uy; 0x90uy; 0x5duy; 0x93uy; 0xd6uy; 0x2auy; 0x11uy; 0xd5uy; 0xd5uy; 0x11uy; 0xaauy; 0xceuy; 0xe7uy; 0x6fuy; 0xa5uy; 0xb0uy; 0x09uy; 0x2cuy; 0x8duy; 0xd3uy; 0x92uy; 0xf0uy; 0x5auy; 0x2auy; 0xdauy; 0x5buy; 0x1euy; 0xd5uy; 0x9auy; 0xc4uy; 0xc4uy; 0xf3uy; 0x49uy; 0x74uy; 0x41uy; 0xcauy; 0xe8uy; 0xc1uy; 0xf8uy; 0x44uy; 0xd6uy; 0x3cuy; 0xaeuy; 0x6cuy; 0x1duy; 0x9auy; 0x30uy; 0x04uy; 0x4duy; 0x27uy; 0x0euy; 0xb1uy; 0x5fuy; 0x59uy; 0xa2uy; 0x24uy; 0xe8uy; 0xe1uy; 0x98uy; 0xc5uy; 0x6auy; 0x4cuy; 0xfeuy; 0x41uy; 0xd2uy; 0x27uy; 0x42uy; 0x52uy; 0xe1uy; 0xe9uy; 0x7duy; 0x62uy; 0xe4uy; 0x88uy; 0x0fuy; 0xaduy; 0xb2uy; 0x70uy; 0xcbuy; 0x9duy; 0x4cuy; 0x27uy; 0x2euy; 0x76uy; 0x1euy; 0x1auy; 0x63uy; 0x65uy; 0xf5uy; 0x3buy; 0xf8uy; 0x57uy; 0x69uy; 0xebuy; 0x5buy; 0x38uy; 0x26uy; 0x39uy; 0x33uy; 0x25uy; 0x45uy; 0x3euy; 0x91uy; 0xb8uy; 0xd8uy; 0xc7uy; 0xd5uy; 0x42uy; 0xc0uy; 0x22uy; 0x31uy; 0x74uy; 0xf4uy; 0xbcuy; 0x0cuy; 0x23uy; 0xf1uy; 0xcauy; 0xc1uy; 0x8duy; 0xd7uy; 0xbeuy; 0xc9uy; 0x62uy; 0xe4uy; 0x08uy; 0x1auy; 0xcfuy; 0x36uy; 0xd5uy; 0xfeuy; 0x55uy; 0x21uy; 0x59uy; 0x91uy; 0x87uy; 0x87uy; 0xdfuy; 0x06uy; 0xdbuy; 0xdfuy; 0x96uy; 0x45uy; 0x58uy; 0xdauy; 0x05uy; 0xcduy; 0x50uy; 0x4duy; 0xd2uy; 0x7duy; 0x05uy; 0x18uy; 0x73uy; 0x6auy; 0x8duy; 0x11uy; 0x85uy; 0xa6uy; 0x88uy; 0xe8uy; 0xdauy; 0xe6uy; 0x30uy; 0x33uy; 0xa4uy; 0x89uy; 0x31uy; 0x75uy; 0xbeuy; 0x69uy; 0x43uy; 0x84uy; 0x43uy; 0x50uy; 0x87uy; 0xdduy; 0x71uy; 0x36uy; 0x83uy; 0xc3uy; 0x78uy; 0x74uy; 0x24uy; 0x0auy; 0xeduy; 0x7buy; 0xdbuy; 0xa4uy; 0x24uy; 0x0buy; 0xb9uy; 0x7euy; 0x5duy; 0xffuy; 0xdeuy; 0xb1uy; 0xefuy; 0x61uy; 0x5auy; 0x45uy; 0x33uy; 0xf6uy; 0x17uy; 0x07uy; 0x08uy; 0x98uy; 0x83uy; 0x92uy; 0x0fuy; 0x23uy; 0x6duy; 0xe6uy; 0xaauy; 0x17uy; 0x54uy; 0xaduy; 0x6auy; 0xc8uy; 0xdbuy; 0x26uy; 0xbeuy; 0xb8uy; 0xb6uy; 0x08uy; 0xfauy; 0x68uy; 0xf1uy; 0xd7uy; 0x79uy; 0x6fuy; 0x18uy; 0xb4uy; 0x9euy; 0x2duy; 0x3fuy; 0x1buy; 0x64uy; 0xafuy; 0x8duy; 0x06uy; 0x0euy; 0x49uy; 0x28uy; 0xe0uy; 0x5duy; 0x45uy; 0x68uy; 0x13uy; 0x87uy; 0xfauy; 0xdeuy; 0x40uy; 0x7buy; 0xd2uy; 0xc3uy; 0x94uy; 0xd5uy; 0xe1uy; 0xd9uy; 0xc2uy; 0xafuy; 0x55uy; 0x89uy; 0xebuy; 0xb4uy; 0x12uy; 0x59uy; 0xa8uy; 0xd4uy; 0xc5uy; 0x29uy; 0x66uy; 0x38uy; 0xe6uy; 0xacuy; 0x22uy; 0x22uy; 0xd9uy; 0x64uy; 0x9buy; 0x34uy; 0x0auy; 0x32uy; 0x9fuy; 0xc2uy; 0xbfuy; 0x17uy; 0x6cuy; 0x3fuy; 0x71uy; 0x7auy; 0x38uy; 0x6buy; 0x98uy; 0xfbuy; 0x49uy; 0x36uy; 0x89uy; 0xc9uy; 0xe2uy; 0xd6uy; 0xc7uy; 0x5duy; 0xd0uy; 0x69uy; 0x5fuy; 0x23uy; 0x35uy; 0xc9uy; 0x30uy; 0xe2uy; 0xfduy; 0x44uy; 0x58uy; 0x39uy; 0xd7uy; 0x97uy; 0xfbuy; 0x5cuy; 0x00uy; 0xd5uy; 0x4fuy; 0x7auy; 0x1auy; 0x95uy; 0x8buy; 0x62uy; 0x4buy; 0xceuy; 0xe5uy; 0x91uy; 0x21uy; 0x7buy; 0x30uy; 0x00uy; 0xd6uy; 0xdduy; 0x6duy; 0x02uy; 0x86uy; 0x49uy; 0x0fuy; 0x3cuy; 0x1auy; 0x27uy; 0x3cuy; 0xd3uy; 0x0euy; 0x71uy; 0xf2uy; 0xffuy; 0xf5uy; 0x2fuy; 0x87uy; 0xacuy; 0x67uy; 0x59uy; 0x81uy; 0xa3uy; 0xf7uy; 0xf8uy; 0xd6uy; 0x11uy; 0x0cuy; 0x84uy; 0xa9uy; 0x03uy; 0xeeuy; 0x2auy; 0xc4uy; 0xf3uy; 0x22uy; 0xabuy; 0x7cuy; 0xe2uy; 0x25uy; 0xf5uy; 0x67uy; 0xa3uy; 0xe4uy; 0x11uy; 0xe0uy; 0x59uy; 0xb3uy; 0xcauy; 0x87uy; 0xa0uy; 0xaeuy; 0xc9uy; 0xa6uy; 0x62uy; 0x1buy; 0x6euy; 0x4duy; 0x02uy; 0x6buy; 0x07uy; 0x9duy; 0xfduy; 0xd0uy; 0x92uy; 0x06uy; 0xe1uy; 0xb2uy; 0x9auy; 0x4auy; 0x1fuy; 0x1fuy; 0x13uy; 0x49uy; 0x99uy; 0x97uy; 0x08uy; 0xdeuy; 0x7fuy; 0x98uy; 0xafuy; 0x51uy; 0x98uy; 0xeeuy; 0x2cuy; 0xcbuy; 0xf0uy; 0x0buy; 0xc6uy; 0xb6uy; 0xb7uy; 0x2duy; 0x9auy; 0xb1uy; 0xacuy; 0xa6uy; 0xe3uy; 0x15uy; 0x77uy; 0x9duy; 0x6buy; 0x1auy; 0xe4uy; 0xfcuy; 0x8buy; 0xf2uy; 0x17uy; 0x59uy; 0x08uy; 0x04uy; 0x58uy; 0x81uy; 0x9duy; 0x1buy; 0x1buy; 0x69uy; 0x55uy; 0xc2uy; 0xb4uy; 0x3cuy; 0x1fuy; 0x50uy; 0xf1uy; 0x7fuy; 0x77uy; 0x90uy; 0x4cuy; 0x66uy; 0x40uy; 0x5auy; 0xc0uy; 0x33uy; 0x1fuy; 0xcbuy; 0x05uy; 0x6duy; 0x5cuy; 0x06uy; 0x87uy; 0x52uy; 0xa2uy; 0x8fuy; 0x26uy; 0xd5uy; 0x4fuy; ] in
assert_norm (List.Tot.length l = 1024);
B.gcmalloc_of_list HyperStack.root l | {
"file_name": "providers/test/vectors/Test.Vectors.Chacha20Poly1305.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 394,
"start_col": 0,
"start_line": 391
} | module Test.Vectors.Chacha20Poly1305
module B = LowStar.Buffer
#set-options "--max_fuel 0 --max_ifuel 0"
let key0: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x1cuy; 0x92uy; 0x40uy; 0xa5uy; 0xebuy; 0x55uy; 0xd3uy; 0x8auy; 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x04uy; 0xf6uy; 0xb5uy; 0xf0uy; 0x47uy; 0x39uy; 0x17uy; 0xc1uy; 0x40uy; 0x2buy; 0x80uy; 0x09uy; 0x9duy; 0xcauy; 0x5cuy; 0xbcuy; 0x20uy; 0x70uy; 0x75uy; 0xc0uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key0_len: (x:UInt32.t { UInt32.v x = B.length key0 }) =
32ul
let nonce0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x01uy; 0x02uy; 0x03uy; 0x04uy; 0x05uy; 0x06uy; 0x07uy; 0x08uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce0_len: (x:UInt32.t { UInt32.v x = B.length nonce0 }) =
12ul
let aad0: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf3uy; 0x33uy; 0x88uy; 0x86uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x4euy; 0x91uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad0_len: (x:UInt32.t { UInt32.v x = B.length aad0 }) =
12ul
let input0: (b: B.buffer UInt8.t { B.length b = 265 /\ B.recallable b /\ B.disjoint b aad0 }) =
B.recall aad0;[@inline_let] let l = [ 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x72uy; 0x65uy; 0x20uy; 0x64uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x76uy; 0x61uy; 0x6cuy; 0x69uy; 0x64uy; 0x20uy; 0x66uy; 0x6fuy; 0x72uy; 0x20uy; 0x61uy; 0x20uy; 0x6duy; 0x61uy; 0x78uy; 0x69uy; 0x6duy; 0x75uy; 0x6duy; 0x20uy; 0x6fuy; 0x66uy; 0x20uy; 0x73uy; 0x69uy; 0x78uy; 0x20uy; 0x6duy; 0x6fuy; 0x6euy; 0x74uy; 0x68uy; 0x73uy; 0x20uy; 0x61uy; 0x6euy; 0x64uy; 0x20uy; 0x6duy; 0x61uy; 0x79uy; 0x20uy; 0x62uy; 0x65uy; 0x20uy; 0x75uy; 0x70uy; 0x64uy; 0x61uy; 0x74uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x72uy; 0x65uy; 0x70uy; 0x6cuy; 0x61uy; 0x63uy; 0x65uy; 0x64uy; 0x2cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x6fuy; 0x62uy; 0x73uy; 0x6fuy; 0x6cuy; 0x65uy; 0x74uy; 0x65uy; 0x64uy; 0x20uy; 0x62uy; 0x79uy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x64uy; 0x6fuy; 0x63uy; 0x75uy; 0x6duy; 0x65uy; 0x6euy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x74uy; 0x20uy; 0x61uy; 0x6euy; 0x79uy; 0x20uy; 0x74uy; 0x69uy; 0x6duy; 0x65uy; 0x2euy; 0x20uy; 0x49uy; 0x74uy; 0x20uy; 0x69uy; 0x73uy; 0x20uy; 0x69uy; 0x6euy; 0x61uy; 0x70uy; 0x70uy; 0x72uy; 0x6fuy; 0x70uy; 0x72uy; 0x69uy; 0x61uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x75uy; 0x73uy; 0x65uy; 0x20uy; 0x49uy; 0x6euy; 0x74uy; 0x65uy; 0x72uy; 0x6euy; 0x65uy; 0x74uy; 0x2duy; 0x44uy; 0x72uy; 0x61uy; 0x66uy; 0x74uy; 0x73uy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x72uy; 0x65uy; 0x66uy; 0x65uy; 0x72uy; 0x65uy; 0x6euy; 0x63uy; 0x65uy; 0x20uy; 0x6duy; 0x61uy; 0x74uy; 0x65uy; 0x72uy; 0x69uy; 0x61uy; 0x6cuy; 0x20uy; 0x6fuy; 0x72uy; 0x20uy; 0x74uy; 0x6fuy; 0x20uy; 0x63uy; 0x69uy; 0x74uy; 0x65uy; 0x20uy; 0x74uy; 0x68uy; 0x65uy; 0x6duy; 0x20uy; 0x6fuy; 0x74uy; 0x68uy; 0x65uy; 0x72uy; 0x20uy; 0x74uy; 0x68uy; 0x61uy; 0x6euy; 0x20uy; 0x61uy; 0x73uy; 0x20uy; 0x2fuy; 0xe2uy; 0x80uy; 0x9cuy; 0x77uy; 0x6fuy; 0x72uy; 0x6buy; 0x20uy; 0x69uy; 0x6euy; 0x20uy; 0x70uy; 0x72uy; 0x6fuy; 0x67uy; 0x72uy; 0x65uy; 0x73uy; 0x73uy; 0x2euy; 0x2fuy; 0xe2uy; 0x80uy; 0x9duy; ] in
assert_norm (List.Tot.length l = 265);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input0_len: (x:UInt32.t { UInt32.v x = B.length input0 }) =
265ul
let output0: (b: B.buffer UInt8.t { B.length b = 281 /\ B.recallable b }) =
[@inline_let] let l = [ 0x64uy; 0xa0uy; 0x86uy; 0x15uy; 0x75uy; 0x86uy; 0x1auy; 0xf4uy; 0x60uy; 0xf0uy; 0x62uy; 0xc7uy; 0x9buy; 0xe6uy; 0x43uy; 0xbduy; 0x5euy; 0x80uy; 0x5cuy; 0xfduy; 0x34uy; 0x5cuy; 0xf3uy; 0x89uy; 0xf1uy; 0x08uy; 0x67uy; 0x0auy; 0xc7uy; 0x6cuy; 0x8cuy; 0xb2uy; 0x4cuy; 0x6cuy; 0xfcuy; 0x18uy; 0x75uy; 0x5duy; 0x43uy; 0xeeuy; 0xa0uy; 0x9euy; 0xe9uy; 0x4euy; 0x38uy; 0x2duy; 0x26uy; 0xb0uy; 0xbduy; 0xb7uy; 0xb7uy; 0x3cuy; 0x32uy; 0x1buy; 0x01uy; 0x00uy; 0xd4uy; 0xf0uy; 0x3buy; 0x7fuy; 0x35uy; 0x58uy; 0x94uy; 0xcfuy; 0x33uy; 0x2fuy; 0x83uy; 0x0euy; 0x71uy; 0x0buy; 0x97uy; 0xceuy; 0x98uy; 0xc8uy; 0xa8uy; 0x4auy; 0xbduy; 0x0buy; 0x94uy; 0x81uy; 0x14uy; 0xaduy; 0x17uy; 0x6euy; 0x00uy; 0x8duy; 0x33uy; 0xbduy; 0x60uy; 0xf9uy; 0x82uy; 0xb1uy; 0xffuy; 0x37uy; 0xc8uy; 0x55uy; 0x97uy; 0x97uy; 0xa0uy; 0x6euy; 0xf4uy; 0xf0uy; 0xefuy; 0x61uy; 0xc1uy; 0x86uy; 0x32uy; 0x4euy; 0x2buy; 0x35uy; 0x06uy; 0x38uy; 0x36uy; 0x06uy; 0x90uy; 0x7buy; 0x6auy; 0x7cuy; 0x02uy; 0xb0uy; 0xf9uy; 0xf6uy; 0x15uy; 0x7buy; 0x53uy; 0xc8uy; 0x67uy; 0xe4uy; 0xb9uy; 0x16uy; 0x6cuy; 0x76uy; 0x7buy; 0x80uy; 0x4duy; 0x46uy; 0xa5uy; 0x9buy; 0x52uy; 0x16uy; 0xcduy; 0xe7uy; 0xa4uy; 0xe9uy; 0x90uy; 0x40uy; 0xc5uy; 0xa4uy; 0x04uy; 0x33uy; 0x22uy; 0x5euy; 0xe2uy; 0x82uy; 0xa1uy; 0xb0uy; 0xa0uy; 0x6cuy; 0x52uy; 0x3euy; 0xafuy; 0x45uy; 0x34uy; 0xd7uy; 0xf8uy; 0x3fuy; 0xa1uy; 0x15uy; 0x5buy; 0x00uy; 0x47uy; 0x71uy; 0x8cuy; 0xbcuy; 0x54uy; 0x6auy; 0x0duy; 0x07uy; 0x2buy; 0x04uy; 0xb3uy; 0x56uy; 0x4euy; 0xeauy; 0x1buy; 0x42uy; 0x22uy; 0x73uy; 0xf5uy; 0x48uy; 0x27uy; 0x1auy; 0x0buy; 0xb2uy; 0x31uy; 0x60uy; 0x53uy; 0xfauy; 0x76uy; 0x99uy; 0x19uy; 0x55uy; 0xebuy; 0xd6uy; 0x31uy; 0x59uy; 0x43uy; 0x4euy; 0xceuy; 0xbbuy; 0x4euy; 0x46uy; 0x6duy; 0xaeuy; 0x5auy; 0x10uy; 0x73uy; 0xa6uy; 0x72uy; 0x76uy; 0x27uy; 0x09uy; 0x7auy; 0x10uy; 0x49uy; 0xe6uy; 0x17uy; 0xd9uy; 0x1duy; 0x36uy; 0x10uy; 0x94uy; 0xfauy; 0x68uy; 0xf0uy; 0xffuy; 0x77uy; 0x98uy; 0x71uy; 0x30uy; 0x30uy; 0x5buy; 0xeauy; 0xbauy; 0x2euy; 0xdauy; 0x04uy; 0xdfuy; 0x99uy; 0x7buy; 0x71uy; 0x4duy; 0x6cuy; 0x6fuy; 0x2cuy; 0x29uy; 0xa6uy; 0xaduy; 0x5cuy; 0xb4uy; 0x02uy; 0x2buy; 0x02uy; 0x70uy; 0x9buy; 0xeeuy; 0xaduy; 0x9duy; 0x67uy; 0x89uy; 0x0cuy; 0xbbuy; 0x22uy; 0x39uy; 0x23uy; 0x36uy; 0xfeuy; 0xa1uy; 0x85uy; 0x1fuy; 0x38uy; ] in
assert_norm (List.Tot.length l = 281);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output0_len: (x:UInt32.t { UInt32.v x = B.length output0 }) =
281ul
let key1: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4cuy; 0xf5uy; 0x96uy; 0x83uy; 0x38uy; 0xe6uy; 0xaeuy; 0x7fuy; 0x2duy; 0x29uy; 0x25uy; 0x76uy; 0xd5uy; 0x75uy; 0x27uy; 0x86uy; 0x91uy; 0x9auy; 0x27uy; 0x7auy; 0xfbuy; 0x46uy; 0xc5uy; 0xefuy; 0x94uy; 0x81uy; 0x79uy; 0x57uy; 0x14uy; 0x59uy; 0x40uy; 0x68uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key1_len: (x:UInt32.t { UInt32.v x = B.length key1 }) =
32ul
let nonce1: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xcauy; 0xbfuy; 0x33uy; 0x71uy; 0x32uy; 0x45uy; 0x77uy; 0x8euy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce1_len: (x:UInt32.t { UInt32.v x = B.length nonce1 }) =
12ul
let aad1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad1_len: (x:UInt32.t { UInt32.v x = B.length aad1 }) =
0ul
let input1: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad1 }) =
B.recall aad1;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input1_len: (x:UInt32.t { UInt32.v x = B.length input1 }) =
0ul
let output1: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xe0uy; 0x1euy; 0x9euy; 0x2cuy; 0x91uy; 0xaauy; 0xe1uy; 0xdbuy; 0x5duy; 0x99uy; 0x3fuy; 0x8auy; 0xf7uy; 0x69uy; 0x92uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output1_len: (x:UInt32.t { UInt32.v x = B.length output1 }) =
16ul
let key2: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x2duy; 0xb0uy; 0x5duy; 0x40uy; 0xc8uy; 0xeduy; 0x44uy; 0x88uy; 0x34uy; 0xd1uy; 0x13uy; 0xafuy; 0x57uy; 0xa1uy; 0xebuy; 0x3auy; 0x2auy; 0x80uy; 0x51uy; 0x36uy; 0xecuy; 0x5buy; 0xbcuy; 0x08uy; 0x93uy; 0x84uy; 0x21uy; 0xb5uy; 0x13uy; 0x88uy; 0x3cuy; 0x0duy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key2_len: (x:UInt32.t { UInt32.v x = B.length key2 }) =
32ul
let nonce2: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x3duy; 0x86uy; 0xb5uy; 0x6buy; 0xc8uy; 0xa3uy; 0x1fuy; 0x1duy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce2_len: (x:UInt32.t { UInt32.v x = B.length nonce2 }) =
12ul
let aad2: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) =
[@inline_let] let l = [ 0x33uy; 0x10uy; 0x41uy; 0x12uy; 0x1fuy; 0xf3uy; 0xd2uy; 0x6buy; ] in
assert_norm (List.Tot.length l = 8);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad2_len: (x:UInt32.t { UInt32.v x = B.length aad2 }) =
8ul
let input2: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b /\ B.disjoint b aad2 }) =
B.recall aad2;[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input2_len: (x:UInt32.t { UInt32.v x = B.length input2 }) =
0ul
let output2: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xdduy; 0x6buy; 0x3buy; 0x82uy; 0xceuy; 0x5auy; 0xbduy; 0xd6uy; 0xa9uy; 0x35uy; 0x83uy; 0xd8uy; 0x8cuy; 0x3duy; 0x85uy; 0x77uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output2_len: (x:UInt32.t { UInt32.v x = B.length output2 }) =
16ul
let key3: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x4buy; 0x28uy; 0x4buy; 0xa3uy; 0x7buy; 0xbeuy; 0xe9uy; 0xf8uy; 0x31uy; 0x80uy; 0x82uy; 0xd7uy; 0xd8uy; 0xe8uy; 0xb5uy; 0xa1uy; 0xe2uy; 0x18uy; 0x18uy; 0x8auy; 0x9cuy; 0xfauy; 0xa3uy; 0x3duy; 0x25uy; 0x71uy; 0x3euy; 0x40uy; 0xbcuy; 0x54uy; 0x7auy; 0x3euy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key3_len: (x:UInt32.t { UInt32.v x = B.length key3 }) =
32ul
let nonce3: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xd2uy; 0x32uy; 0x1fuy; 0x29uy; 0x28uy; 0xc6uy; 0xc4uy; 0xc4uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce3_len: (x:UInt32.t { UInt32.v x = B.length nonce3 }) =
12ul
let aad3: (b: B.buffer UInt8.t { B.length b = 8 /\ B.recallable b }) =
[@inline_let] let l = [ 0x6auy; 0xe2uy; 0xaduy; 0x3fuy; 0x88uy; 0x39uy; 0x5auy; 0x40uy; ] in
assert_norm (List.Tot.length l = 8);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad3_len: (x:UInt32.t { UInt32.v x = B.length aad3 }) =
8ul
let input3: (b: B.buffer UInt8.t { B.length b = 1 /\ B.recallable b /\ B.disjoint b aad3 }) =
B.recall aad3;[@inline_let] let l = [ 0xa4uy; ] in
assert_norm (List.Tot.length l = 1);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input3_len: (x:UInt32.t { UInt32.v x = B.length input3 }) =
1ul
let output3: (b: B.buffer UInt8.t { B.length b = 17 /\ B.recallable b }) =
[@inline_let] let l = [ 0xb7uy; 0x1buy; 0xb0uy; 0x73uy; 0x59uy; 0xb0uy; 0x84uy; 0xb2uy; 0x6duy; 0x8euy; 0xabuy; 0x94uy; 0x31uy; 0xa1uy; 0xaeuy; 0xacuy; 0x89uy; ] in
assert_norm (List.Tot.length l = 17);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output3_len: (x:UInt32.t { UInt32.v x = B.length output3 }) =
17ul
let key4: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x66uy; 0xcauy; 0x9cuy; 0x23uy; 0x2auy; 0x4buy; 0x4buy; 0x31uy; 0x0euy; 0x92uy; 0x89uy; 0x8buy; 0xf4uy; 0x93uy; 0xc7uy; 0x87uy; 0x98uy; 0xa3uy; 0xd8uy; 0x39uy; 0xf8uy; 0xf4uy; 0xa7uy; 0x01uy; 0xc0uy; 0x2euy; 0x0auy; 0xa6uy; 0x7euy; 0x5auy; 0x78uy; 0x87uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key4_len: (x:UInt32.t { UInt32.v x = B.length key4 }) =
32ul
let nonce4: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x20uy; 0x1cuy; 0xaauy; 0x5fuy; 0x9cuy; 0xbfuy; 0x92uy; 0x30uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce4_len: (x:UInt32.t { UInt32.v x = B.length nonce4 }) =
12ul
let aad4: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad4_len: (x:UInt32.t { UInt32.v x = B.length aad4 }) =
0ul
let input4: (b: B.buffer UInt8.t { B.length b = 1 /\ B.recallable b /\ B.disjoint b aad4 }) =
B.recall aad4;[@inline_let] let l = [ 0x2duy; ] in
assert_norm (List.Tot.length l = 1);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input4_len: (x:UInt32.t { UInt32.v x = B.length input4 }) =
1ul
let output4: (b: B.buffer UInt8.t { B.length b = 17 /\ B.recallable b }) =
[@inline_let] let l = [ 0xbfuy; 0xe1uy; 0x5buy; 0x0buy; 0xdbuy; 0x6buy; 0xf5uy; 0x5euy; 0x6cuy; 0x5duy; 0x84uy; 0x44uy; 0x39uy; 0x81uy; 0xc1uy; 0x9cuy; 0xacuy; ] in
assert_norm (List.Tot.length l = 17);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output4_len: (x:UInt32.t { UInt32.v x = B.length output4 }) =
17ul
let key5: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x68uy; 0x7buy; 0x8duy; 0x8euy; 0xe3uy; 0xc4uy; 0xdduy; 0xaeuy; 0xdfuy; 0x72uy; 0x7fuy; 0x53uy; 0x72uy; 0x25uy; 0x1euy; 0x78uy; 0x91uy; 0xcbuy; 0x69uy; 0x76uy; 0x1fuy; 0x49uy; 0x93uy; 0xf9uy; 0x6fuy; 0x21uy; 0xccuy; 0x39uy; 0x9cuy; 0xaduy; 0xb1uy; 0x01uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key5_len: (x:UInt32.t { UInt32.v x = B.length key5 }) =
32ul
let nonce5: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xdfuy; 0x51uy; 0x84uy; 0x82uy; 0x42uy; 0x0cuy; 0x75uy; 0x9cuy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce5_len: (x:UInt32.t { UInt32.v x = B.length nonce5 }) =
12ul
let aad5: (b: B.buffer UInt8.t { B.length b = 7 /\ B.recallable b }) =
[@inline_let] let l = [ 0x70uy; 0xd3uy; 0x33uy; 0xf3uy; 0x8buy; 0x18uy; 0x0buy; ] in
assert_norm (List.Tot.length l = 7);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad5_len: (x:UInt32.t { UInt32.v x = B.length aad5 }) =
7ul
let input5: (b: B.buffer UInt8.t { B.length b = 129 /\ B.recallable b /\ B.disjoint b aad5 }) =
B.recall aad5;[@inline_let] let l = [ 0x33uy; 0x2fuy; 0x94uy; 0xc1uy; 0xa4uy; 0xefuy; 0xccuy; 0x2auy; 0x5buy; 0xa6uy; 0xe5uy; 0x8fuy; 0x1duy; 0x40uy; 0xf0uy; 0x92uy; 0x3cuy; 0xd9uy; 0x24uy; 0x11uy; 0xa9uy; 0x71uy; 0xf9uy; 0x37uy; 0x14uy; 0x99uy; 0xfauy; 0xbeuy; 0xe6uy; 0x80uy; 0xdeuy; 0x50uy; 0xc9uy; 0x96uy; 0xd4uy; 0xb0uy; 0xecuy; 0x9euy; 0x17uy; 0xecuy; 0xd2uy; 0x5euy; 0x72uy; 0x99uy; 0xfcuy; 0x0auy; 0xe1uy; 0xcbuy; 0x48uy; 0xd2uy; 0x85uy; 0xdduy; 0x2fuy; 0x90uy; 0xe0uy; 0x66uy; 0x3buy; 0xe6uy; 0x20uy; 0x74uy; 0xbeuy; 0x23uy; 0x8fuy; 0xcbuy; 0xb4uy; 0xe4uy; 0xdauy; 0x48uy; 0x40uy; 0xa6uy; 0xd1uy; 0x1buy; 0xc7uy; 0x42uy; 0xceuy; 0x2fuy; 0x0cuy; 0xa6uy; 0x85uy; 0x6euy; 0x87uy; 0x37uy; 0x03uy; 0xb1uy; 0x7cuy; 0x25uy; 0x96uy; 0xa3uy; 0x05uy; 0xd8uy; 0xb0uy; 0xf4uy; 0xeduy; 0xeauy; 0xc2uy; 0xf0uy; 0x31uy; 0x98uy; 0x6cuy; 0xd1uy; 0x14uy; 0x25uy; 0xc0uy; 0xcbuy; 0x01uy; 0x74uy; 0xd0uy; 0x82uy; 0xf4uy; 0x36uy; 0xf5uy; 0x41uy; 0xd5uy; 0xdcuy; 0xcauy; 0xc5uy; 0xbbuy; 0x98uy; 0xfeuy; 0xfcuy; 0x69uy; 0x21uy; 0x70uy; 0xd8uy; 0xa4uy; 0x4buy; 0xc8uy; 0xdeuy; 0x8fuy; ] in
assert_norm (List.Tot.length l = 129);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input5_len: (x:UInt32.t { UInt32.v x = B.length input5 }) =
129ul
let output5: (b: B.buffer UInt8.t { B.length b = 145 /\ B.recallable b }) =
[@inline_let] let l = [ 0x8buy; 0x06uy; 0xd3uy; 0x31uy; 0xb0uy; 0x93uy; 0x45uy; 0xb1uy; 0x75uy; 0x6euy; 0x26uy; 0xf9uy; 0x67uy; 0xbcuy; 0x90uy; 0x15uy; 0x81uy; 0x2cuy; 0xb5uy; 0xf0uy; 0xc6uy; 0x2buy; 0xc7uy; 0x8cuy; 0x56uy; 0xd1uy; 0xbfuy; 0x69uy; 0x6cuy; 0x07uy; 0xa0uy; 0xdauy; 0x65uy; 0x27uy; 0xc9uy; 0x90uy; 0x3duy; 0xefuy; 0x4buy; 0x11uy; 0x0fuy; 0x19uy; 0x07uy; 0xfduy; 0x29uy; 0x92uy; 0xd9uy; 0xc8uy; 0xf7uy; 0x99uy; 0x2euy; 0x4auy; 0xd0uy; 0xb8uy; 0x2cuy; 0xdcuy; 0x93uy; 0xf5uy; 0x9euy; 0x33uy; 0x78uy; 0xd1uy; 0x37uy; 0xc3uy; 0x66uy; 0xd7uy; 0x5euy; 0xbcuy; 0x44uy; 0xbfuy; 0x53uy; 0xa5uy; 0xbcuy; 0xc4uy; 0xcbuy; 0x7buy; 0x3auy; 0x8euy; 0x7fuy; 0x02uy; 0xbduy; 0xbbuy; 0xe7uy; 0xcauy; 0xa6uy; 0x6cuy; 0x6buy; 0x93uy; 0x21uy; 0x93uy; 0x10uy; 0x61uy; 0xe7uy; 0x69uy; 0xd0uy; 0x78uy; 0xf3uy; 0x07uy; 0x5auy; 0x1auy; 0x8fuy; 0x73uy; 0xaauy; 0xb1uy; 0x4euy; 0xd3uy; 0xdauy; 0x4fuy; 0xf3uy; 0x32uy; 0xe1uy; 0x66uy; 0x3euy; 0x6cuy; 0xc6uy; 0x13uy; 0xbauy; 0x06uy; 0x5buy; 0xfcuy; 0x6auy; 0xe5uy; 0x6fuy; 0x60uy; 0xfbuy; 0x07uy; 0x40uy; 0xb0uy; 0x8cuy; 0x9duy; 0x84uy; 0x43uy; 0x6buy; 0xc1uy; 0xf7uy; 0x8duy; 0x8duy; 0x31uy; 0xf7uy; 0x7auy; 0x39uy; 0x4duy; 0x8fuy; 0x9auy; 0xebuy; ] in
assert_norm (List.Tot.length l = 145);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output5_len: (x:UInt32.t { UInt32.v x = B.length output5 }) =
145ul
let key6: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x8duy; 0xb8uy; 0x91uy; 0x48uy; 0xf0uy; 0xe7uy; 0x0auy; 0xbduy; 0xf9uy; 0x3fuy; 0xcduy; 0xd9uy; 0xa0uy; 0x1euy; 0x42uy; 0x4cuy; 0xe7uy; 0xdeuy; 0x25uy; 0x3duy; 0xa3uy; 0xd7uy; 0x05uy; 0x80uy; 0x8duy; 0xf2uy; 0x82uy; 0xacuy; 0x44uy; 0x16uy; 0x51uy; 0x01uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key6_len: (x:UInt32.t { UInt32.v x = B.length key6 }) =
32ul
let nonce6: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xdeuy; 0x7buy; 0xefuy; 0xc3uy; 0x65uy; 0x1buy; 0x68uy; 0xb0uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce6_len: (x:UInt32.t { UInt32.v x = B.length nonce6 }) =
12ul
let aad6: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad6_len: (x:UInt32.t { UInt32.v x = B.length aad6 }) =
0ul
let input6: (b: B.buffer UInt8.t { B.length b = 256 /\ B.recallable b /\ B.disjoint b aad6 }) =
B.recall aad6;[@inline_let] let l = [ 0x9buy; 0x18uy; 0xdbuy; 0xdduy; 0x9auy; 0x0fuy; 0x3euy; 0xa5uy; 0x15uy; 0x17uy; 0xdeuy; 0xdfuy; 0x08uy; 0x9duy; 0x65uy; 0x0auy; 0x67uy; 0x30uy; 0x12uy; 0xe2uy; 0x34uy; 0x77uy; 0x4buy; 0xc1uy; 0xd9uy; 0xc6uy; 0x1fuy; 0xabuy; 0xc6uy; 0x18uy; 0x50uy; 0x17uy; 0xa7uy; 0x9duy; 0x3cuy; 0xa6uy; 0xc5uy; 0x35uy; 0x8cuy; 0x1cuy; 0xc0uy; 0xa1uy; 0x7cuy; 0x9fuy; 0x03uy; 0x89uy; 0xcauy; 0xe1uy; 0xe6uy; 0xe9uy; 0xd4uy; 0xd3uy; 0x88uy; 0xdbuy; 0xb4uy; 0x51uy; 0x9duy; 0xecuy; 0xb4uy; 0xfcuy; 0x52uy; 0xeeuy; 0x6duy; 0xf1uy; 0x75uy; 0x42uy; 0xc6uy; 0xfduy; 0xbduy; 0x7auy; 0x8euy; 0x86uy; 0xfcuy; 0x44uy; 0xb3uy; 0x4fuy; 0xf3uy; 0xeauy; 0x67uy; 0x5auy; 0x41uy; 0x13uy; 0xbauy; 0xb0uy; 0xdcuy; 0xe1uy; 0xd3uy; 0x2auy; 0x7cuy; 0x22uy; 0xb3uy; 0xcauy; 0xacuy; 0x6auy; 0x37uy; 0x98uy; 0x3euy; 0x1duy; 0x40uy; 0x97uy; 0xf7uy; 0x9buy; 0x1duy; 0x36uy; 0x6buy; 0xb3uy; 0x28uy; 0xbduy; 0x60uy; 0x82uy; 0x47uy; 0x34uy; 0xaauy; 0x2fuy; 0x7duy; 0xe9uy; 0xa8uy; 0x70uy; 0x81uy; 0x57uy; 0xd4uy; 0xb9uy; 0x77uy; 0x0auy; 0x9duy; 0x29uy; 0xa7uy; 0x84uy; 0x52uy; 0x4fuy; 0xc2uy; 0x4auy; 0x40uy; 0x3buy; 0x3cuy; 0xd4uy; 0xc9uy; 0x2auy; 0xdbuy; 0x4auy; 0x53uy; 0xc4uy; 0xbeuy; 0x80uy; 0xe9uy; 0x51uy; 0x7fuy; 0x8fuy; 0xc7uy; 0xa2uy; 0xceuy; 0x82uy; 0x5cuy; 0x91uy; 0x1euy; 0x74uy; 0xd9uy; 0xd0uy; 0xbduy; 0xd5uy; 0xf3uy; 0xfduy; 0xdauy; 0x4duy; 0x25uy; 0xb4uy; 0xbbuy; 0x2duy; 0xacuy; 0x2fuy; 0x3duy; 0x71uy; 0x85uy; 0x7buy; 0xcfuy; 0x3cuy; 0x7buy; 0x3euy; 0x0euy; 0x22uy; 0x78uy; 0x0cuy; 0x29uy; 0xbfuy; 0xe4uy; 0xf4uy; 0x57uy; 0xb3uy; 0xcbuy; 0x49uy; 0xa0uy; 0xfcuy; 0x1euy; 0x05uy; 0x4euy; 0x16uy; 0xbcuy; 0xd5uy; 0xa8uy; 0xa3uy; 0xeeuy; 0x05uy; 0x35uy; 0xc6uy; 0x7cuy; 0xabuy; 0x60uy; 0x14uy; 0x55uy; 0x1auy; 0x8euy; 0xc5uy; 0x88uy; 0x5duy; 0xd5uy; 0x81uy; 0xc2uy; 0x81uy; 0xa5uy; 0xc4uy; 0x60uy; 0xdbuy; 0xafuy; 0x77uy; 0x91uy; 0xe1uy; 0xceuy; 0xa2uy; 0x7euy; 0x7fuy; 0x42uy; 0xe3uy; 0xb0uy; 0x13uy; 0x1cuy; 0x1fuy; 0x25uy; 0x60uy; 0x21uy; 0xe2uy; 0x40uy; 0x5fuy; 0x99uy; 0xb7uy; 0x73uy; 0xecuy; 0x9buy; 0x2buy; 0xf0uy; 0x65uy; 0x11uy; 0xc8uy; 0xd0uy; 0x0auy; 0x9fuy; 0xd3uy; ] in
assert_norm (List.Tot.length l = 256);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input6_len: (x:UInt32.t { UInt32.v x = B.length input6 }) =
256ul
let output6: (b: B.buffer UInt8.t { B.length b = 272 /\ B.recallable b }) =
[@inline_let] let l = [ 0x85uy; 0x04uy; 0xc2uy; 0xeduy; 0x8duy; 0xfduy; 0x97uy; 0x5cuy; 0xd2uy; 0xb7uy; 0xe2uy; 0xc1uy; 0x6buy; 0xa3uy; 0xbauy; 0xf8uy; 0xc9uy; 0x50uy; 0xc3uy; 0xc6uy; 0xa5uy; 0xe3uy; 0xa4uy; 0x7cuy; 0xc3uy; 0x23uy; 0x49uy; 0x5euy; 0xa9uy; 0xb9uy; 0x32uy; 0xebuy; 0x8auy; 0x7cuy; 0xcauy; 0xe5uy; 0xecuy; 0xfbuy; 0x7cuy; 0xc0uy; 0xcbuy; 0x7duy; 0xdcuy; 0x2cuy; 0x9duy; 0x92uy; 0x55uy; 0x21uy; 0x0auy; 0xc8uy; 0x43uy; 0x63uy; 0x59uy; 0x0auy; 0x31uy; 0x70uy; 0x82uy; 0x67uy; 0x41uy; 0x03uy; 0xf8uy; 0xdfuy; 0xf2uy; 0xacuy; 0xa7uy; 0x02uy; 0xd4uy; 0xd5uy; 0x8auy; 0x2duy; 0xc8uy; 0x99uy; 0x19uy; 0x66uy; 0xd0uy; 0xf6uy; 0x88uy; 0x2cuy; 0x77uy; 0xd9uy; 0xd4uy; 0x0duy; 0x6cuy; 0xbduy; 0x98uy; 0xdeuy; 0xe7uy; 0x7fuy; 0xaduy; 0x7euy; 0x8auy; 0xfbuy; 0xe9uy; 0x4buy; 0xe5uy; 0xf7uy; 0xe5uy; 0x50uy; 0xa0uy; 0x90uy; 0x3fuy; 0xd6uy; 0x22uy; 0x53uy; 0xe3uy; 0xfeuy; 0x1buy; 0xccuy; 0x79uy; 0x3buy; 0xecuy; 0x12uy; 0x47uy; 0x52uy; 0xa7uy; 0xd6uy; 0x04uy; 0xe3uy; 0x52uy; 0xe6uy; 0x93uy; 0x90uy; 0x91uy; 0x32uy; 0x73uy; 0x79uy; 0xb8uy; 0xd0uy; 0x31uy; 0xdeuy; 0x1fuy; 0x9fuy; 0x2fuy; 0x05uy; 0x38uy; 0x54uy; 0x2fuy; 0x35uy; 0x04uy; 0x39uy; 0xe0uy; 0xa7uy; 0xbauy; 0xc6uy; 0x52uy; 0xf6uy; 0x37uy; 0x65uy; 0x4cuy; 0x07uy; 0xa9uy; 0x7euy; 0xb3uy; 0x21uy; 0x6fuy; 0x74uy; 0x8cuy; 0xc9uy; 0xdeuy; 0xdbuy; 0x65uy; 0x1buy; 0x9buy; 0xaauy; 0x60uy; 0xb1uy; 0x03uy; 0x30uy; 0x6buy; 0xb2uy; 0x03uy; 0xc4uy; 0x1cuy; 0x04uy; 0xf8uy; 0x0fuy; 0x64uy; 0xafuy; 0x46uy; 0xe4uy; 0x65uy; 0x99uy; 0x49uy; 0xe2uy; 0xeauy; 0xceuy; 0x78uy; 0x00uy; 0xd8uy; 0x8buy; 0xd5uy; 0x2euy; 0xcfuy; 0xfcuy; 0x40uy; 0x49uy; 0xe8uy; 0x58uy; 0xdcuy; 0x34uy; 0x9cuy; 0x8cuy; 0x61uy; 0xbfuy; 0x0auy; 0x8euy; 0xecuy; 0x39uy; 0xa9uy; 0x30uy; 0x05uy; 0x5auy; 0xd2uy; 0x56uy; 0x01uy; 0xc7uy; 0xdauy; 0x8fuy; 0x4euy; 0xbbuy; 0x43uy; 0xa3uy; 0x3auy; 0xf9uy; 0x15uy; 0x2auy; 0xd0uy; 0xa0uy; 0x7auy; 0x87uy; 0x34uy; 0x82uy; 0xfeuy; 0x8auy; 0xd1uy; 0x2duy; 0x5euy; 0xc7uy; 0xbfuy; 0x04uy; 0x53uy; 0x5fuy; 0x3buy; 0x36uy; 0xd4uy; 0x25uy; 0x5cuy; 0x34uy; 0x7auy; 0x8duy; 0xd5uy; 0x05uy; 0xceuy; 0x72uy; 0xcauy; 0xefuy; 0x7auy; 0x4buy; 0xbcuy; 0xb0uy; 0x10uy; 0x5cuy; 0x96uy; 0x42uy; 0x3auy; 0x00uy; 0x98uy; 0xcduy; 0x15uy; 0xe8uy; 0xb7uy; 0x53uy; ] in
assert_norm (List.Tot.length l = 272);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output6_len: (x:UInt32.t { UInt32.v x = B.length output6 }) =
272ul
let key7: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0xf2uy; 0xaauy; 0x4fuy; 0x99uy; 0xfduy; 0x3euy; 0xa8uy; 0x53uy; 0xc1uy; 0x44uy; 0xe9uy; 0x81uy; 0x18uy; 0xdcuy; 0xf5uy; 0xf0uy; 0x3euy; 0x44uy; 0x15uy; 0x59uy; 0xe0uy; 0xc5uy; 0x44uy; 0x86uy; 0xc3uy; 0x91uy; 0xa8uy; 0x75uy; 0xc0uy; 0x12uy; 0x46uy; 0xbauy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key7_len: (x:UInt32.t { UInt32.v x = B.length key7 }) =
32ul
let nonce7: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0x0euy; 0x0duy; 0x57uy; 0xbbuy; 0x7buy; 0x40uy; 0x54uy; 0x02uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce7_len: (x:UInt32.t { UInt32.v x = B.length nonce7 }) =
12ul
let aad7: (b: B.buffer UInt8.t { B.length b = 0 /\ B.recallable b }) =
[@inline_let] let l = [ ] in
assert_norm (List.Tot.length l = 0);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad7_len: (x:UInt32.t { UInt32.v x = B.length aad7 }) =
0ul
let input7: (b: B.buffer UInt8.t { B.length b = 512 /\ B.recallable b /\ B.disjoint b aad7 }) =
B.recall aad7;[@inline_let] let l = [ 0xc3uy; 0x09uy; 0x94uy; 0x62uy; 0xe6uy; 0x46uy; 0x2euy; 0x10uy; 0xbeuy; 0x00uy; 0xe4uy; 0xfcuy; 0xf3uy; 0x40uy; 0xa3uy; 0xe2uy; 0x0fuy; 0xc2uy; 0x8buy; 0x28uy; 0xdcuy; 0xbauy; 0xb4uy; 0x3cuy; 0xe4uy; 0x21uy; 0x58uy; 0x61uy; 0xcduy; 0x8buy; 0xcduy; 0xfbuy; 0xacuy; 0x94uy; 0xa1uy; 0x45uy; 0xf5uy; 0x1cuy; 0xe1uy; 0x12uy; 0xe0uy; 0x3buy; 0x67uy; 0x21uy; 0x54uy; 0x5euy; 0x8cuy; 0xaauy; 0xcfuy; 0xdbuy; 0xb4uy; 0x51uy; 0xd4uy; 0x13uy; 0xdauy; 0xe6uy; 0x83uy; 0x89uy; 0xb6uy; 0x92uy; 0xe9uy; 0x21uy; 0x76uy; 0xa4uy; 0x93uy; 0x7duy; 0x0euy; 0xfduy; 0x96uy; 0x36uy; 0x03uy; 0x91uy; 0x43uy; 0x5cuy; 0x92uy; 0x49uy; 0x62uy; 0x61uy; 0x7buy; 0xebuy; 0x43uy; 0x89uy; 0xb8uy; 0x12uy; 0x20uy; 0x43uy; 0xd4uy; 0x47uy; 0x06uy; 0x84uy; 0xeeuy; 0x47uy; 0xe9uy; 0x8auy; 0x73uy; 0x15uy; 0x0fuy; 0x72uy; 0xcfuy; 0xeduy; 0xceuy; 0x96uy; 0xb2uy; 0x7fuy; 0x21uy; 0x45uy; 0x76uy; 0xebuy; 0x26uy; 0x28uy; 0x83uy; 0x6auy; 0xaduy; 0xaauy; 0xa6uy; 0x81uy; 0xd8uy; 0x55uy; 0xb1uy; 0xa3uy; 0x85uy; 0xb3uy; 0x0cuy; 0xdfuy; 0xf1uy; 0x69uy; 0x2duy; 0x97uy; 0x05uy; 0x2auy; 0xbcuy; 0x7cuy; 0x7buy; 0x25uy; 0xf8uy; 0x80uy; 0x9duy; 0x39uy; 0x25uy; 0xf3uy; 0x62uy; 0xf0uy; 0x66uy; 0x5euy; 0xf4uy; 0xa0uy; 0xcfuy; 0xd8uy; 0xfduy; 0x4fuy; 0xb1uy; 0x1fuy; 0x60uy; 0x3auy; 0x08uy; 0x47uy; 0xafuy; 0xe1uy; 0xf6uy; 0x10uy; 0x77uy; 0x09uy; 0xa7uy; 0x27uy; 0x8fuy; 0x9auy; 0x97uy; 0x5auy; 0x26uy; 0xfauy; 0xfeuy; 0x41uy; 0x32uy; 0x83uy; 0x10uy; 0xe0uy; 0x1duy; 0xbfuy; 0x64uy; 0x0duy; 0xf4uy; 0x1cuy; 0x32uy; 0x35uy; 0xe5uy; 0x1buy; 0x36uy; 0xefuy; 0xd4uy; 0x4auy; 0x93uy; 0x4duy; 0x00uy; 0x7cuy; 0xecuy; 0x02uy; 0x07uy; 0x8buy; 0x5duy; 0x7duy; 0x1buy; 0x0euy; 0xd1uy; 0xa6uy; 0xa5uy; 0x5duy; 0x7duy; 0x57uy; 0x88uy; 0xa8uy; 0xccuy; 0x81uy; 0xb4uy; 0x86uy; 0x4euy; 0xb4uy; 0x40uy; 0xe9uy; 0x1duy; 0xc3uy; 0xb1uy; 0x24uy; 0x3euy; 0x7fuy; 0xccuy; 0x8auy; 0x24uy; 0x9buy; 0xdfuy; 0x6duy; 0xf0uy; 0x39uy; 0x69uy; 0x3euy; 0x4cuy; 0xc0uy; 0x96uy; 0xe4uy; 0x13uy; 0xdauy; 0x90uy; 0xdauy; 0xf4uy; 0x95uy; 0x66uy; 0x8buy; 0x17uy; 0x17uy; 0xfeuy; 0x39uy; 0x43uy; 0x25uy; 0xaauy; 0xdauy; 0xa0uy; 0x43uy; 0x3cuy; 0xb1uy; 0x41uy; 0x02uy; 0xa3uy; 0xf0uy; 0xa7uy; 0x19uy; 0x59uy; 0xbcuy; 0x1duy; 0x7duy; 0x6cuy; 0x6duy; 0x91uy; 0x09uy; 0x5cuy; 0xb7uy; 0x5buy; 0x01uy; 0xd1uy; 0x6fuy; 0x17uy; 0x21uy; 0x97uy; 0xbfuy; 0x89uy; 0x71uy; 0xa5uy; 0xb0uy; 0x6euy; 0x07uy; 0x45uy; 0xfduy; 0x9duy; 0xeauy; 0x07uy; 0xf6uy; 0x7auy; 0x9fuy; 0x10uy; 0x18uy; 0x22uy; 0x30uy; 0x73uy; 0xacuy; 0xd4uy; 0x6buy; 0x72uy; 0x44uy; 0xeduy; 0xd9uy; 0x19uy; 0x9buy; 0x2duy; 0x4auy; 0x41uy; 0xdduy; 0xd1uy; 0x85uy; 0x5euy; 0x37uy; 0x19uy; 0xeduy; 0xd2uy; 0x15uy; 0x8fuy; 0x5euy; 0x91uy; 0xdbuy; 0x33uy; 0xf2uy; 0xe4uy; 0xdbuy; 0xffuy; 0x98uy; 0xfbuy; 0xa3uy; 0xb5uy; 0xcauy; 0x21uy; 0x69uy; 0x08uy; 0xe7uy; 0x8auy; 0xdfuy; 0x90uy; 0xffuy; 0x3euy; 0xe9uy; 0x20uy; 0x86uy; 0x3cuy; 0xe9uy; 0xfcuy; 0x0buy; 0xfeuy; 0x5cuy; 0x61uy; 0xaauy; 0x13uy; 0x92uy; 0x7fuy; 0x7buy; 0xecuy; 0xe0uy; 0x6duy; 0xa8uy; 0x23uy; 0x22uy; 0xf6uy; 0x6buy; 0x77uy; 0xc4uy; 0xfeuy; 0x40uy; 0x07uy; 0x3buy; 0xb6uy; 0xf6uy; 0x8euy; 0x5fuy; 0xd4uy; 0xb9uy; 0xb7uy; 0x0fuy; 0x21uy; 0x04uy; 0xefuy; 0x83uy; 0x63uy; 0x91uy; 0x69uy; 0x40uy; 0xa3uy; 0x48uy; 0x5cuy; 0xd2uy; 0x60uy; 0xf9uy; 0x4fuy; 0x6cuy; 0x47uy; 0x8buy; 0x3buy; 0xb1uy; 0x9fuy; 0x8euy; 0xeeuy; 0x16uy; 0x8auy; 0x13uy; 0xfcuy; 0x46uy; 0x17uy; 0xc3uy; 0xc3uy; 0x32uy; 0x56uy; 0xf8uy; 0x3cuy; 0x85uy; 0x3auy; 0xb6uy; 0x3euy; 0xaauy; 0x89uy; 0x4fuy; 0xb3uy; 0xdfuy; 0x38uy; 0xfduy; 0xf1uy; 0xe4uy; 0x3auy; 0xc0uy; 0xe6uy; 0x58uy; 0xb5uy; 0x8fuy; 0xc5uy; 0x29uy; 0xa2uy; 0x92uy; 0x4auy; 0xb6uy; 0xa0uy; 0x34uy; 0x7fuy; 0xabuy; 0xb5uy; 0x8auy; 0x90uy; 0xa1uy; 0xdbuy; 0x4duy; 0xcauy; 0xb6uy; 0x2cuy; 0x41uy; 0x3cuy; 0xf7uy; 0x2buy; 0x21uy; 0xc3uy; 0xfduy; 0xf4uy; 0x17uy; 0x5cuy; 0xb5uy; 0x33uy; 0x17uy; 0x68uy; 0x2buy; 0x08uy; 0x30uy; 0xf3uy; 0xf7uy; 0x30uy; 0x3cuy; 0x96uy; 0xe6uy; 0x6auy; 0x20uy; 0x97uy; 0xe7uy; 0x4duy; 0x10uy; 0x5fuy; 0x47uy; 0x5fuy; 0x49uy; 0x96uy; 0x09uy; 0xf0uy; 0x27uy; 0x91uy; 0xc8uy; 0xf8uy; 0x5auy; 0x2euy; 0x79uy; 0xb5uy; 0xe2uy; 0xb8uy; 0xe8uy; 0xb9uy; 0x7buy; 0xd5uy; 0x10uy; 0xcbuy; 0xffuy; 0x5duy; 0x14uy; 0x73uy; 0xf3uy; ] in
assert_norm (List.Tot.length l = 512);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input7_len: (x:UInt32.t { UInt32.v x = B.length input7 }) =
512ul
let output7: (b: B.buffer UInt8.t { B.length b = 528 /\ B.recallable b }) =
[@inline_let] let l = [ 0x14uy; 0xf6uy; 0x41uy; 0x37uy; 0xa6uy; 0xd4uy; 0x27uy; 0xcduy; 0xdbuy; 0x06uy; 0x3euy; 0x9auy; 0x4euy; 0xabuy; 0xd5uy; 0xb1uy; 0x1euy; 0x6buy; 0xd2uy; 0xbcuy; 0x11uy; 0xf4uy; 0x28uy; 0x93uy; 0x63uy; 0x54uy; 0xefuy; 0xbbuy; 0x5euy; 0x1duy; 0x3auy; 0x1duy; 0x37uy; 0x3cuy; 0x0auy; 0x6cuy; 0x1euy; 0xc2uy; 0xd1uy; 0x2cuy; 0xb5uy; 0xa3uy; 0xb5uy; 0x7buy; 0xb8uy; 0x8fuy; 0x25uy; 0xa6uy; 0x1buy; 0x61uy; 0x1cuy; 0xecuy; 0x28uy; 0x58uy; 0x26uy; 0xa4uy; 0xa8uy; 0x33uy; 0x28uy; 0x25uy; 0x5cuy; 0x45uy; 0x05uy; 0xe5uy; 0x6cuy; 0x99uy; 0xe5uy; 0x45uy; 0xc4uy; 0xa2uy; 0x03uy; 0x84uy; 0x03uy; 0x73uy; 0x1euy; 0x8cuy; 0x49uy; 0xacuy; 0x20uy; 0xdduy; 0x8duy; 0xb3uy; 0xc4uy; 0xf5uy; 0xe7uy; 0x4fuy; 0xf1uy; 0xeduy; 0xa1uy; 0x98uy; 0xdeuy; 0xa4uy; 0x96uy; 0xdduy; 0x2fuy; 0xabuy; 0xabuy; 0x97uy; 0xcfuy; 0x3euy; 0xd2uy; 0x9euy; 0xb8uy; 0x13uy; 0x07uy; 0x28uy; 0x29uy; 0x19uy; 0xafuy; 0xfduy; 0xf2uy; 0x49uy; 0x43uy; 0xeauy; 0x49uy; 0x26uy; 0x91uy; 0xc1uy; 0x07uy; 0xd6uy; 0xbbuy; 0x81uy; 0x75uy; 0x35uy; 0x0duy; 0x24uy; 0x7fuy; 0xc8uy; 0xdauy; 0xd4uy; 0xb7uy; 0xebuy; 0xe8uy; 0x5cuy; 0x09uy; 0xa2uy; 0x2fuy; 0xdcuy; 0x28uy; 0x7duy; 0x3auy; 0x03uy; 0xfauy; 0x94uy; 0xb5uy; 0x1duy; 0x17uy; 0x99uy; 0x36uy; 0xc3uy; 0x1cuy; 0x18uy; 0x34uy; 0xe3uy; 0x9fuy; 0xf5uy; 0x55uy; 0x7cuy; 0xb0uy; 0x60uy; 0x9duy; 0xffuy; 0xacuy; 0xd4uy; 0x61uy; 0xf2uy; 0xaduy; 0xf8uy; 0xceuy; 0xc7uy; 0xbeuy; 0x5cuy; 0xd2uy; 0x95uy; 0xa8uy; 0x4buy; 0x77uy; 0x13uy; 0x19uy; 0x59uy; 0x26uy; 0xc9uy; 0xb7uy; 0x8fuy; 0x6auy; 0xcbuy; 0x2duy; 0x37uy; 0x91uy; 0xeauy; 0x92uy; 0x9cuy; 0x94uy; 0x5buy; 0xdauy; 0x0buy; 0xceuy; 0xfeuy; 0x30uy; 0x20uy; 0xf8uy; 0x51uy; 0xaduy; 0xf2uy; 0xbeuy; 0xe7uy; 0xc7uy; 0xffuy; 0xb3uy; 0x33uy; 0x91uy; 0x6auy; 0xc9uy; 0x1auy; 0x41uy; 0xc9uy; 0x0fuy; 0xf3uy; 0x10uy; 0x0euy; 0xfduy; 0x53uy; 0xffuy; 0x6cuy; 0x16uy; 0x52uy; 0xd9uy; 0xf3uy; 0xf7uy; 0x98uy; 0x2euy; 0xc9uy; 0x07uy; 0x31uy; 0x2cuy; 0x0cuy; 0x72uy; 0xd7uy; 0xc5uy; 0xc6uy; 0x08uy; 0x2auy; 0x7buy; 0xdauy; 0xbduy; 0x7euy; 0x02uy; 0xeauy; 0x1auy; 0xbbuy; 0xf2uy; 0x04uy; 0x27uy; 0x61uy; 0x28uy; 0x8euy; 0xf5uy; 0x04uy; 0x03uy; 0x1fuy; 0x4cuy; 0x07uy; 0x55uy; 0x82uy; 0xecuy; 0x1euy; 0xd7uy; 0x8buy; 0x2fuy; 0x65uy; 0x56uy; 0xd1uy; 0xd9uy; 0x1euy; 0x3cuy; 0xe9uy; 0x1fuy; 0x5euy; 0x98uy; 0x70uy; 0x38uy; 0x4auy; 0x8cuy; 0x49uy; 0xc5uy; 0x43uy; 0xa0uy; 0xa1uy; 0x8buy; 0x74uy; 0x9duy; 0x4cuy; 0x62uy; 0x0duy; 0x10uy; 0x0cuy; 0xf4uy; 0x6cuy; 0x8fuy; 0xe0uy; 0xaauy; 0x9auy; 0x8duy; 0xb7uy; 0xe0uy; 0xbeuy; 0x4cuy; 0x87uy; 0xf1uy; 0x98uy; 0x2fuy; 0xccuy; 0xeduy; 0xc0uy; 0x52uy; 0x29uy; 0xdcuy; 0x83uy; 0xf8uy; 0xfcuy; 0x2cuy; 0x0euy; 0xa8uy; 0x51uy; 0x4duy; 0x80uy; 0x0duy; 0xa3uy; 0xfeuy; 0xd8uy; 0x37uy; 0xe7uy; 0x41uy; 0x24uy; 0xfcuy; 0xfbuy; 0x75uy; 0xe3uy; 0x71uy; 0x7buy; 0x57uy; 0x45uy; 0xf5uy; 0x97uy; 0x73uy; 0x65uy; 0x63uy; 0x14uy; 0x74uy; 0xb8uy; 0x82uy; 0x9fuy; 0xf8uy; 0x60uy; 0x2fuy; 0x8auy; 0xf2uy; 0x4euy; 0xf1uy; 0x39uy; 0xdauy; 0x33uy; 0x91uy; 0xf8uy; 0x36uy; 0xe0uy; 0x8duy; 0x3fuy; 0x1fuy; 0x3buy; 0x56uy; 0xdcuy; 0xa0uy; 0x8fuy; 0x3cuy; 0x9duy; 0x71uy; 0x52uy; 0xa7uy; 0xb8uy; 0xc0uy; 0xa5uy; 0xc6uy; 0xa2uy; 0x73uy; 0xdauy; 0xf4uy; 0x4buy; 0x74uy; 0x5buy; 0x00uy; 0x3duy; 0x99uy; 0xd7uy; 0x96uy; 0xbauy; 0xe6uy; 0xe1uy; 0xa6uy; 0x96uy; 0x38uy; 0xaduy; 0xb3uy; 0xc0uy; 0xd2uy; 0xbauy; 0x91uy; 0x6buy; 0xf9uy; 0x19uy; 0xdduy; 0x3buy; 0xbeuy; 0xbeuy; 0x9cuy; 0x20uy; 0x50uy; 0xbauy; 0xa1uy; 0xd0uy; 0xceuy; 0x11uy; 0xbduy; 0x95uy; 0xd8uy; 0xd1uy; 0xdduy; 0x33uy; 0x85uy; 0x74uy; 0xdcuy; 0xdbuy; 0x66uy; 0x76uy; 0x44uy; 0xdcuy; 0x03uy; 0x74uy; 0x48uy; 0x35uy; 0x98uy; 0xb1uy; 0x18uy; 0x47uy; 0x94uy; 0x7duy; 0xffuy; 0x62uy; 0xe4uy; 0x58uy; 0x78uy; 0xabuy; 0xeduy; 0x95uy; 0x36uy; 0xd9uy; 0x84uy; 0x91uy; 0x82uy; 0x64uy; 0x41uy; 0xbbuy; 0x58uy; 0xe6uy; 0x1cuy; 0x20uy; 0x6duy; 0x15uy; 0x6buy; 0x13uy; 0x96uy; 0xe8uy; 0x35uy; 0x7fuy; 0xdcuy; 0x40uy; 0x2cuy; 0xe9uy; 0xbcuy; 0x8auy; 0x4fuy; 0x92uy; 0xecuy; 0x06uy; 0x2duy; 0x50uy; 0xdfuy; 0x93uy; 0x5duy; 0x65uy; 0x5auy; 0xa8uy; 0xfcuy; 0x20uy; 0x50uy; 0x14uy; 0xa9uy; 0x8auy; 0x7euy; 0x1duy; 0x08uy; 0x1fuy; 0xe2uy; 0x99uy; 0xd0uy; 0xbeuy; 0xfbuy; 0x3auy; 0x21uy; 0x9duy; 0xaduy; 0x86uy; 0x54uy; 0xfduy; 0x0duy; 0x98uy; 0x1cuy; 0x5auy; 0x6fuy; 0x1fuy; 0x9auy; 0x40uy; 0xcduy; 0xa2uy; 0xffuy; 0x6auy; 0xf1uy; 0x54uy; ] in
assert_norm (List.Tot.length l = 528);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output7_len: (x:UInt32.t { UInt32.v x = B.length output7 }) =
528ul
let key8: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0xeauy; 0xbcuy; 0x56uy; 0x99uy; 0xe3uy; 0x50uy; 0xffuy; 0xc5uy; 0xccuy; 0x1auy; 0xd7uy; 0xc1uy; 0x57uy; 0x72uy; 0xeauy; 0x86uy; 0x5buy; 0x89uy; 0x88uy; 0x61uy; 0x3duy; 0x2fuy; 0x9buy; 0xb2uy; 0xe7uy; 0x9cuy; 0xecuy; 0x74uy; 0x6euy; 0x3euy; 0xf4uy; 0x3buy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key8_len: (x:UInt32.t { UInt32.v x = B.length key8 }) =
32ul
let nonce8: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xefuy; 0x2duy; 0x63uy; 0xeeuy; 0x6buy; 0x80uy; 0x8buy; 0x78uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce8_len: (x:UInt32.t { UInt32.v x = B.length nonce8 }) =
12ul
let aad8: (b: B.buffer UInt8.t { B.length b = 9 /\ B.recallable b }) =
[@inline_let] let l = [ 0x5auy; 0x27uy; 0xffuy; 0xebuy; 0xdfuy; 0x84uy; 0xb2uy; 0x9euy; 0xefuy; ] in
assert_norm (List.Tot.length l = 9);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad8_len: (x:UInt32.t { UInt32.v x = B.length aad8 }) =
9ul
let input8: (b: B.buffer UInt8.t { B.length b = 513 /\ B.recallable b /\ B.disjoint b aad8 }) =
B.recall aad8;[@inline_let] let l = [ 0xe6uy; 0xc3uy; 0xdbuy; 0x63uy; 0x55uy; 0x15uy; 0xe3uy; 0x5buy; 0xb7uy; 0x4buy; 0x27uy; 0x8buy; 0x5auy; 0xdduy; 0xc2uy; 0xe8uy; 0x3auy; 0x6buy; 0xd7uy; 0x81uy; 0x96uy; 0x35uy; 0x97uy; 0xcauy; 0xd7uy; 0x68uy; 0xe8uy; 0xefuy; 0xceuy; 0xabuy; 0xdauy; 0x09uy; 0x6euy; 0xd6uy; 0x8euy; 0xcbuy; 0x55uy; 0xb5uy; 0xe1uy; 0xe5uy; 0x57uy; 0xfduy; 0xc4uy; 0xe3uy; 0xe0uy; 0x18uy; 0x4fuy; 0x85uy; 0xf5uy; 0x3fuy; 0x7euy; 0x4buy; 0x88uy; 0xc9uy; 0x52uy; 0x44uy; 0x0fuy; 0xeauy; 0xafuy; 0x1fuy; 0x71uy; 0x48uy; 0x9fuy; 0x97uy; 0x6duy; 0xb9uy; 0x6fuy; 0x00uy; 0xa6uy; 0xdeuy; 0x2buy; 0x77uy; 0x8buy; 0x15uy; 0xaduy; 0x10uy; 0xa0uy; 0x2buy; 0x7buy; 0x41uy; 0x90uy; 0x03uy; 0x2duy; 0x69uy; 0xaeuy; 0xccuy; 0x77uy; 0x7cuy; 0xa5uy; 0x9duy; 0x29uy; 0x22uy; 0xc2uy; 0xeauy; 0xb4uy; 0x00uy; 0x1auy; 0xd2uy; 0x7auy; 0x98uy; 0x8auy; 0xf9uy; 0xf7uy; 0x82uy; 0xb0uy; 0xabuy; 0xd8uy; 0xa6uy; 0x94uy; 0x8duy; 0x58uy; 0x2fuy; 0x01uy; 0x9euy; 0x00uy; 0x20uy; 0xfcuy; 0x49uy; 0xdcuy; 0x0euy; 0x03uy; 0xe8uy; 0x45uy; 0x10uy; 0xd6uy; 0xa8uy; 0xdauy; 0x55uy; 0x10uy; 0x9auy; 0xdfuy; 0x67uy; 0x22uy; 0x8buy; 0x43uy; 0xabuy; 0x00uy; 0xbbuy; 0x02uy; 0xc8uy; 0xdduy; 0x7buy; 0x97uy; 0x17uy; 0xd7uy; 0x1duy; 0x9euy; 0x02uy; 0x5euy; 0x48uy; 0xdeuy; 0x8euy; 0xcfuy; 0x99uy; 0x07uy; 0x95uy; 0x92uy; 0x3cuy; 0x5fuy; 0x9fuy; 0xc5uy; 0x8auy; 0xc0uy; 0x23uy; 0xaauy; 0xd5uy; 0x8cuy; 0x82uy; 0x6euy; 0x16uy; 0x92uy; 0xb1uy; 0x12uy; 0x17uy; 0x07uy; 0xc3uy; 0xfbuy; 0x36uy; 0xf5uy; 0x6cuy; 0x35uy; 0xd6uy; 0x06uy; 0x1fuy; 0x9fuy; 0xa7uy; 0x94uy; 0xa2uy; 0x38uy; 0x63uy; 0x9cuy; 0xb0uy; 0x71uy; 0xb3uy; 0xa5uy; 0xd2uy; 0xd8uy; 0xbauy; 0x9fuy; 0x08uy; 0x01uy; 0xb3uy; 0xffuy; 0x04uy; 0x97uy; 0x73uy; 0x45uy; 0x1buy; 0xd5uy; 0xa9uy; 0x9cuy; 0x80uy; 0xafuy; 0x04uy; 0x9auy; 0x85uy; 0xdbuy; 0x32uy; 0x5buy; 0x5duy; 0x1auy; 0xc1uy; 0x36uy; 0x28uy; 0x10uy; 0x79uy; 0xf1uy; 0x3cuy; 0xbfuy; 0x1auy; 0x41uy; 0x5cuy; 0x4euy; 0xdfuy; 0xb2uy; 0x7cuy; 0x79uy; 0x3buy; 0x7auy; 0x62uy; 0x3duy; 0x4buy; 0xc9uy; 0x9buy; 0x2auy; 0x2euy; 0x7cuy; 0xa2uy; 0xb1uy; 0x11uy; 0x98uy; 0xa7uy; 0x34uy; 0x1auy; 0x00uy; 0xf3uy; 0xd1uy; 0xbcuy; 0x18uy; 0x22uy; 0xbauy; 0x02uy; 0x56uy; 0x62uy; 0x31uy; 0x10uy; 0x11uy; 0x6duy; 0xe0uy; 0x54uy; 0x9duy; 0x40uy; 0x1fuy; 0x26uy; 0x80uy; 0x41uy; 0xcauy; 0x3fuy; 0x68uy; 0x0fuy; 0x32uy; 0x1duy; 0x0auy; 0x8euy; 0x79uy; 0xd8uy; 0xa4uy; 0x1buy; 0x29uy; 0x1cuy; 0x90uy; 0x8euy; 0xc5uy; 0xe3uy; 0xb4uy; 0x91uy; 0x37uy; 0x9auy; 0x97uy; 0x86uy; 0x99uy; 0xd5uy; 0x09uy; 0xc5uy; 0xbbuy; 0xa3uy; 0x3fuy; 0x21uy; 0x29uy; 0x82uy; 0x14uy; 0x5cuy; 0xabuy; 0x25uy; 0xfbuy; 0xf2uy; 0x4fuy; 0x58uy; 0x26uy; 0xd4uy; 0x83uy; 0xaauy; 0x66uy; 0x89uy; 0x67uy; 0x7euy; 0xc0uy; 0x49uy; 0xe1uy; 0x11uy; 0x10uy; 0x7fuy; 0x7auy; 0xdauy; 0x29uy; 0x04uy; 0xffuy; 0xf0uy; 0xcbuy; 0x09uy; 0x7cuy; 0x9duy; 0xfauy; 0x03uy; 0x6fuy; 0x81uy; 0x09uy; 0x31uy; 0x60uy; 0xfbuy; 0x08uy; 0xfauy; 0x74uy; 0xd3uy; 0x64uy; 0x44uy; 0x7cuy; 0x55uy; 0x85uy; 0xecuy; 0x9cuy; 0x6euy; 0x25uy; 0xb7uy; 0x6cuy; 0xc5uy; 0x37uy; 0xb6uy; 0x83uy; 0x87uy; 0x72uy; 0x95uy; 0x8buy; 0x9duy; 0xe1uy; 0x69uy; 0x5cuy; 0x31uy; 0x95uy; 0x42uy; 0xa6uy; 0x2cuy; 0xd1uy; 0x36uy; 0x47uy; 0x1fuy; 0xecuy; 0x54uy; 0xabuy; 0xa2uy; 0x1cuy; 0xd8uy; 0x00uy; 0xccuy; 0xbcuy; 0x0duy; 0x65uy; 0xe2uy; 0x67uy; 0xbfuy; 0xbcuy; 0xeauy; 0xeeuy; 0x9euy; 0xe4uy; 0x36uy; 0x95uy; 0xbeuy; 0x73uy; 0xd9uy; 0xa6uy; 0xd9uy; 0x0fuy; 0xa0uy; 0xccuy; 0x82uy; 0x76uy; 0x26uy; 0xaduy; 0x5buy; 0x58uy; 0x6cuy; 0x4euy; 0xabuy; 0x29uy; 0x64uy; 0xd3uy; 0xd9uy; 0xa9uy; 0x08uy; 0x8cuy; 0x1duy; 0xa1uy; 0x4fuy; 0x80uy; 0xd8uy; 0x3fuy; 0x94uy; 0xfbuy; 0xd3uy; 0x7buy; 0xfcuy; 0xd1uy; 0x2buy; 0xc3uy; 0x21uy; 0xebuy; 0xe5uy; 0x1cuy; 0x84uy; 0x23uy; 0x7fuy; 0x4buy; 0xfauy; 0xdbuy; 0x34uy; 0x18uy; 0xa2uy; 0xc2uy; 0xe5uy; 0x13uy; 0xfeuy; 0x6cuy; 0x49uy; 0x81uy; 0xd2uy; 0x73uy; 0xe7uy; 0xe2uy; 0xd7uy; 0xe4uy; 0x4fuy; 0x4buy; 0x08uy; 0x6euy; 0xb1uy; 0x12uy; 0x22uy; 0x10uy; 0x9duy; 0xacuy; 0x51uy; 0x1euy; 0x17uy; 0xd9uy; 0x8auy; 0x0buy; 0x42uy; 0x88uy; 0x16uy; 0x81uy; 0x37uy; 0x7cuy; 0x6auy; 0xf7uy; 0xefuy; 0x2duy; 0xe3uy; 0xd9uy; 0xf8uy; 0x5fuy; 0xe0uy; 0x53uy; 0x27uy; 0x74uy; 0xb9uy; 0xe2uy; 0xd6uy; 0x1cuy; 0x80uy; 0x2cuy; 0x52uy; 0x65uy; ] in
assert_norm (List.Tot.length l = 513);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let input8_len: (x:UInt32.t { UInt32.v x = B.length input8 }) =
513ul
let output8: (b: B.buffer UInt8.t { B.length b = 529 /\ B.recallable b }) =
[@inline_let] let l = [ 0xfduy; 0x81uy; 0x8duy; 0xd0uy; 0x3duy; 0xb4uy; 0xd5uy; 0xdfuy; 0xd3uy; 0x42uy; 0x47uy; 0x5auy; 0x6duy; 0x19uy; 0x27uy; 0x66uy; 0x4buy; 0x2euy; 0x0cuy; 0x27uy; 0x9cuy; 0x96uy; 0x4cuy; 0x72uy; 0x02uy; 0xa3uy; 0x65uy; 0xc3uy; 0xb3uy; 0x6fuy; 0x2euy; 0xbduy; 0x63uy; 0x8auy; 0x4auy; 0x5duy; 0x29uy; 0xa2uy; 0xd0uy; 0x28uy; 0x48uy; 0xc5uy; 0x3duy; 0x98uy; 0xa3uy; 0xbcuy; 0xe0uy; 0xbeuy; 0x3buy; 0x3fuy; 0xe6uy; 0x8auy; 0xa4uy; 0x7fuy; 0x53uy; 0x06uy; 0xfauy; 0x7fuy; 0x27uy; 0x76uy; 0x72uy; 0x31uy; 0xa1uy; 0xf5uy; 0xd6uy; 0x0cuy; 0x52uy; 0x47uy; 0xbauy; 0xcduy; 0x4fuy; 0xd7uy; 0xebuy; 0x05uy; 0x48uy; 0x0duy; 0x7cuy; 0x35uy; 0x4auy; 0x09uy; 0xc9uy; 0x76uy; 0x71uy; 0x02uy; 0xa3uy; 0xfbuy; 0xb7uy; 0x1auy; 0x65uy; 0xb7uy; 0xeduy; 0x98uy; 0xc6uy; 0x30uy; 0x8auy; 0x00uy; 0xaeuy; 0xa1uy; 0x31uy; 0xe5uy; 0xb5uy; 0x9euy; 0x6duy; 0x62uy; 0xdauy; 0xdauy; 0x07uy; 0x0fuy; 0x38uy; 0x38uy; 0xd3uy; 0xcbuy; 0xc1uy; 0xb0uy; 0xaduy; 0xecuy; 0x72uy; 0xecuy; 0xb1uy; 0xa2uy; 0x7buy; 0x59uy; 0xf3uy; 0x3duy; 0x2buy; 0xefuy; 0xcduy; 0x28uy; 0x5buy; 0x83uy; 0xccuy; 0x18uy; 0x91uy; 0x88uy; 0xb0uy; 0x2euy; 0xf9uy; 0x29uy; 0x31uy; 0x18uy; 0xf9uy; 0x4euy; 0xe9uy; 0x0auy; 0x91uy; 0x92uy; 0x9fuy; 0xaeuy; 0x2duy; 0xaduy; 0xf4uy; 0xe6uy; 0x1auy; 0xe2uy; 0xa4uy; 0xeeuy; 0x47uy; 0x15uy; 0xbfuy; 0x83uy; 0x6euy; 0xd7uy; 0x72uy; 0x12uy; 0x3buy; 0x2duy; 0x24uy; 0xe9uy; 0xb2uy; 0x55uy; 0xcbuy; 0x3cuy; 0x10uy; 0xf0uy; 0x24uy; 0x8auy; 0x4auy; 0x02uy; 0xeauy; 0x90uy; 0x25uy; 0xf0uy; 0xb4uy; 0x79uy; 0x3auy; 0xefuy; 0x6euy; 0xf5uy; 0x52uy; 0xdfuy; 0xb0uy; 0x0auy; 0xcduy; 0x24uy; 0x1cuy; 0xd3uy; 0x2euy; 0x22uy; 0x74uy; 0xeauy; 0x21uy; 0x6fuy; 0xe9uy; 0xbduy; 0xc8uy; 0x3euy; 0x36uy; 0x5buy; 0x19uy; 0xf1uy; 0xcauy; 0x99uy; 0x0auy; 0xb4uy; 0xa7uy; 0x52uy; 0x1auy; 0x4euy; 0xf2uy; 0xaduy; 0x8duy; 0x56uy; 0x85uy; 0xbbuy; 0x64uy; 0x89uy; 0xbauy; 0x26uy; 0xf9uy; 0xc7uy; 0xe1uy; 0x89uy; 0x19uy; 0x22uy; 0x77uy; 0xc3uy; 0xa8uy; 0xfcuy; 0xffuy; 0xaduy; 0xfeuy; 0xb9uy; 0x48uy; 0xaeuy; 0x12uy; 0x30uy; 0x9fuy; 0x19uy; 0xfbuy; 0x1buy; 0xefuy; 0x14uy; 0x87uy; 0x8auy; 0x78uy; 0x71uy; 0xf3uy; 0xf4uy; 0xb7uy; 0x00uy; 0x9cuy; 0x1duy; 0xb5uy; 0x3duy; 0x49uy; 0x00uy; 0x0cuy; 0x06uy; 0xd4uy; 0x50uy; 0xf9uy; 0x54uy; 0x45uy; 0xb2uy; 0x5buy; 0x43uy; 0xdbuy; 0x6duy; 0xcfuy; 0x1auy; 0xe9uy; 0x7auy; 0x7auy; 0xcfuy; 0xfcuy; 0x8auy; 0x4euy; 0x4duy; 0x0buy; 0x07uy; 0x63uy; 0x28uy; 0xd8uy; 0xe7uy; 0x08uy; 0x95uy; 0xdfuy; 0xa6uy; 0x72uy; 0x93uy; 0x2euy; 0xbbuy; 0xa0uy; 0x42uy; 0x89uy; 0x16uy; 0xf1uy; 0xd9uy; 0x0cuy; 0xf9uy; 0xa1uy; 0x16uy; 0xfduy; 0xd9uy; 0x03uy; 0xb4uy; 0x3buy; 0x8auy; 0xf5uy; 0xf6uy; 0xe7uy; 0x6buy; 0x2euy; 0x8euy; 0x4cuy; 0x3duy; 0xe2uy; 0xafuy; 0x08uy; 0x45uy; 0x03uy; 0xffuy; 0x09uy; 0xb6uy; 0xebuy; 0x2duy; 0xc6uy; 0x1buy; 0x88uy; 0x94uy; 0xacuy; 0x3euy; 0xf1uy; 0x9fuy; 0x0euy; 0x0euy; 0x2buy; 0xd5uy; 0x00uy; 0x4duy; 0x3fuy; 0x3buy; 0x53uy; 0xaeuy; 0xafuy; 0x1cuy; 0x33uy; 0x5fuy; 0x55uy; 0x6euy; 0x8duy; 0xafuy; 0x05uy; 0x7auy; 0x10uy; 0x34uy; 0xc9uy; 0xf4uy; 0x66uy; 0xcbuy; 0x62uy; 0x12uy; 0xa6uy; 0xeeuy; 0xe8uy; 0x1cuy; 0x5duy; 0x12uy; 0x86uy; 0xdbuy; 0x6fuy; 0x1cuy; 0x33uy; 0xc4uy; 0x1cuy; 0xdauy; 0x82uy; 0x2duy; 0x3buy; 0x59uy; 0xfeuy; 0xb1uy; 0xa4uy; 0x59uy; 0x41uy; 0x86uy; 0xd0uy; 0xefuy; 0xaeuy; 0xfbuy; 0xdauy; 0x6duy; 0x11uy; 0xb8uy; 0xcauy; 0xe9uy; 0x6euy; 0xffuy; 0xf7uy; 0xa9uy; 0xd9uy; 0x70uy; 0x30uy; 0xfcuy; 0x53uy; 0xe2uy; 0xd7uy; 0xa2uy; 0x4euy; 0xc7uy; 0x91uy; 0xd9uy; 0x07uy; 0x06uy; 0xaauy; 0xdduy; 0xb0uy; 0x59uy; 0x28uy; 0x1duy; 0x00uy; 0x66uy; 0xc5uy; 0x54uy; 0xc2uy; 0xfcuy; 0x06uy; 0xdauy; 0x05uy; 0x90uy; 0x52uy; 0x1duy; 0x37uy; 0x66uy; 0xeeuy; 0xf0uy; 0xb2uy; 0x55uy; 0x8auy; 0x5duy; 0xd2uy; 0x38uy; 0x86uy; 0x94uy; 0x9buy; 0xfcuy; 0x10uy; 0x4cuy; 0xa1uy; 0xb9uy; 0x64uy; 0x3euy; 0x44uy; 0xb8uy; 0x5fuy; 0xb0uy; 0x0cuy; 0xecuy; 0xe0uy; 0xc9uy; 0xe5uy; 0x62uy; 0x75uy; 0x3fuy; 0x09uy; 0xd5uy; 0xf5uy; 0xd9uy; 0x26uy; 0xbauy; 0x9euy; 0xd2uy; 0xf4uy; 0xb9uy; 0x48uy; 0x0auy; 0xbcuy; 0xa2uy; 0xd6uy; 0x7cuy; 0x36uy; 0x11uy; 0x7duy; 0x26uy; 0x81uy; 0x89uy; 0xcfuy; 0xa4uy; 0xaduy; 0x73uy; 0x0euy; 0xeeuy; 0xccuy; 0x06uy; 0xa9uy; 0xdbuy; 0xb1uy; 0xfduy; 0xfbuy; 0x09uy; 0x7fuy; 0x90uy; 0x42uy; 0x37uy; 0x2fuy; 0xe1uy; 0x9cuy; 0x0fuy; 0x6fuy; 0xcfuy; 0x43uy; 0xb5uy; 0xd9uy; 0x90uy; 0xe1uy; 0x85uy; 0xf5uy; 0xa8uy; 0xaeuy; ] in
assert_norm (List.Tot.length l = 529);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let output8_len: (x:UInt32.t { UInt32.v x = B.length output8 }) =
529ul
let key9: (b: B.buffer UInt8.t { B.length b = 32 /\ B.recallable b }) =
[@inline_let] let l = [ 0x47uy; 0x11uy; 0xebuy; 0x86uy; 0x2buy; 0x2cuy; 0xabuy; 0x44uy; 0x34uy; 0xdauy; 0x7fuy; 0x57uy; 0x03uy; 0x39uy; 0x0cuy; 0xafuy; 0x2cuy; 0x14uy; 0xfduy; 0x65uy; 0x23uy; 0xe9uy; 0x8euy; 0x74uy; 0xd5uy; 0x08uy; 0x68uy; 0x08uy; 0xe7uy; 0xb4uy; 0x72uy; 0xd7uy; ] in
assert_norm (List.Tot.length l = 32);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let key9_len: (x:UInt32.t { UInt32.v x = B.length key9 }) =
32ul
let nonce9: (b: B.buffer UInt8.t { B.length b = 12 /\ B.recallable b }) =
[@inline_let] let l = [ 0x00uy; 0x00uy; 0x00uy; 0x00uy; 0xdbuy; 0x92uy; 0x0fuy; 0x7fuy; 0x17uy; 0x54uy; 0x0cuy; 0x30uy; ] in
assert_norm (List.Tot.length l = 12);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let nonce9_len: (x:UInt32.t { UInt32.v x = B.length nonce9 }) =
12ul
let aad9: (b: B.buffer UInt8.t { B.length b = 16 /\ B.recallable b }) =
[@inline_let] let l = [ 0xd2uy; 0xa1uy; 0x70uy; 0xdbuy; 0x7auy; 0xf8uy; 0xfauy; 0x27uy; 0xbauy; 0x73uy; 0x0fuy; 0xbfuy; 0x3duy; 0x1euy; 0x82uy; 0xb2uy; ] in
assert_norm (List.Tot.length l = 16);
B.gcmalloc_of_list HyperStack.root l
inline_for_extraction let aad9_len: (x:UInt32.t { UInt32.v x = B.length aad9 }) =
16ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Test.Vectors.Chacha20Poly1305.fst"
} | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test.Vectors",
"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": 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": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | b:
LowStar.Buffer.buffer FStar.UInt8.t
{ LowStar.Monotonic.Buffer.length b = 1024 /\ LowStar.Monotonic.Buffer.recallable b /\
LowStar.Monotonic.Buffer.disjoint b Test.Vectors.Chacha20Poly1305.aad9 } | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.gcmalloc_of_list",
"FStar.UInt8.t",
"FStar.Monotonic.HyperHeap.root",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.trivial_preorder",
"Prims.l_and",
"Prims.eq2",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.Pervasives.normalize_term",
"FStar.List.Tot.Base.length",
"Prims.b2t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.recallable",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.op_Equality",
"Prims.int",
"LowStar.Buffer.buffer",
"LowStar.Monotonic.Buffer.disjoint",
"Test.Vectors.Chacha20Poly1305.aad9",
"Prims.list",
"Prims.Cons",
"FStar.UInt8.__uint_to_t",
"Prims.Nil",
"LowStar.Monotonic.Buffer.recall"
] | [] | false | false | false | false | false | let input9:(b: B.buffer UInt8.t {B.length b = 1024 /\ B.recallable b /\ B.disjoint b aad9}) =
| B.recall aad9;
[@@ inline_let ]let l =
[
0x42uy; 0x93uy; 0xe4uy; 0xebuy; 0x97uy; 0xb0uy; 0x57uy; 0xbfuy; 0x1auy; 0x8buy; 0x1fuy; 0xe4uy;
0x5fuy; 0x36uy; 0x20uy; 0x3cuy; 0xefuy; 0x0auy; 0xa9uy; 0x48uy; 0x5fuy; 0x5fuy; 0x37uy; 0x22uy;
0x3auy; 0xdeuy; 0xe3uy; 0xaeuy; 0xbeuy; 0xaduy; 0x07uy; 0xccuy; 0xb1uy; 0xf6uy; 0xf5uy; 0xf9uy;
0x56uy; 0xdduy; 0xe7uy; 0x16uy; 0x1euy; 0x7fuy; 0xdfuy; 0x7auy; 0x9euy; 0x75uy; 0xb7uy; 0xc7uy;
0xbeuy; 0xbeuy; 0x8auy; 0x36uy; 0x04uy; 0xc0uy; 0x10uy; 0xf4uy; 0x95uy; 0x20uy; 0x03uy; 0xecuy;
0xdcuy; 0x05uy; 0xa1uy; 0x7duy; 0xc4uy; 0xa9uy; 0x2cuy; 0x82uy; 0xd0uy; 0xbcuy; 0x8buy; 0xc5uy;
0xc7uy; 0x45uy; 0x50uy; 0xf6uy; 0xa2uy; 0x1auy; 0xb5uy; 0x46uy; 0x3buy; 0x73uy; 0x02uy; 0xa6uy;
0x83uy; 0x4buy; 0x73uy; 0x82uy; 0x58uy; 0x5euy; 0x3buy; 0x65uy; 0x2fuy; 0x0euy; 0xfduy; 0x2buy;
0x59uy; 0x16uy; 0xceuy; 0xa1uy; 0x60uy; 0x9cuy; 0xe8uy; 0x3auy; 0x99uy; 0xeduy; 0x8duy; 0x5auy;
0xcfuy; 0xf6uy; 0x83uy; 0xafuy; 0xbauy; 0xd7uy; 0x73uy; 0x73uy; 0x40uy; 0x97uy; 0x3duy; 0xcauy;
0xefuy; 0x07uy; 0x57uy; 0xe6uy; 0xd9uy; 0x70uy; 0x0euy; 0x95uy; 0xaeuy; 0xa6uy; 0x8duy; 0x04uy;
0xccuy; 0xeeuy; 0xf7uy; 0x09uy; 0x31uy; 0x77uy; 0x12uy; 0xa3uy; 0x23uy; 0x97uy; 0x62uy; 0xb3uy;
0x7buy; 0x32uy; 0xfbuy; 0x80uy; 0x14uy; 0x48uy; 0x81uy; 0xc3uy; 0xe5uy; 0xeauy; 0x91uy; 0x39uy;
0x52uy; 0x81uy; 0xa2uy; 0x4fuy; 0xe4uy; 0xb3uy; 0x09uy; 0xffuy; 0xdeuy; 0x5euy; 0xe9uy; 0x58uy;
0x84uy; 0x6euy; 0xf9uy; 0x3duy; 0xdfuy; 0x25uy; 0xeauy; 0xaduy; 0xaeuy; 0xe6uy; 0x9auy; 0xd1uy;
0x89uy; 0x55uy; 0xd3uy; 0xdeuy; 0x6cuy; 0x52uy; 0xdbuy; 0x70uy; 0xfeuy; 0x37uy; 0xceuy; 0x44uy;
0x0auy; 0xa8uy; 0x25uy; 0x5fuy; 0x92uy; 0xc1uy; 0x33uy; 0x4auy; 0x4fuy; 0x9buy; 0x62uy; 0x35uy;
0xffuy; 0xceuy; 0xc0uy; 0xa9uy; 0x60uy; 0xceuy; 0x52uy; 0x00uy; 0x97uy; 0x51uy; 0x35uy; 0x26uy;
0x2euy; 0xb9uy; 0x36uy; 0xa9uy; 0x87uy; 0x6euy; 0x1euy; 0xccuy; 0x91uy; 0x78uy; 0x53uy; 0x98uy;
0x86uy; 0x5buy; 0x9cuy; 0x74uy; 0x7duy; 0x88uy; 0x33uy; 0xe1uy; 0xdfuy; 0x37uy; 0x69uy; 0x2buy;
0xbbuy; 0xf1uy; 0x4duy; 0xf4uy; 0xd1uy; 0xf1uy; 0x39uy; 0x93uy; 0x17uy; 0x51uy; 0x19uy; 0xe3uy;
0x19uy; 0x1euy; 0x76uy; 0x37uy; 0x25uy; 0xfbuy; 0x09uy; 0x27uy; 0x6auy; 0xabuy; 0x67uy; 0x6fuy;
0x14uy; 0x12uy; 0x64uy; 0xe7uy; 0xc4uy; 0x07uy; 0xdfuy; 0x4duy; 0x17uy; 0xbbuy; 0x6duy; 0xe0uy;
0xe9uy; 0xb9uy; 0xabuy; 0xcauy; 0x10uy; 0x68uy; 0xafuy; 0x7euy; 0xb7uy; 0x33uy; 0x54uy; 0x73uy;
0x07uy; 0x6euy; 0xf7uy; 0x81uy; 0x97uy; 0x9cuy; 0x05uy; 0x6fuy; 0x84uy; 0x5fuy; 0xd2uy; 0x42uy;
0xfbuy; 0x38uy; 0xcfuy; 0xd1uy; 0x2fuy; 0x14uy; 0x30uy; 0x88uy; 0x98uy; 0x4duy; 0x5auy; 0xa9uy;
0x76uy; 0xd5uy; 0x4fuy; 0x3euy; 0x70uy; 0x6cuy; 0x85uy; 0x76uy; 0xd7uy; 0x01uy; 0xa0uy; 0x1auy;
0xc8uy; 0x4euy; 0xaauy; 0xacuy; 0x78uy; 0xfeuy; 0x46uy; 0xdeuy; 0x6auy; 0x05uy; 0x46uy; 0xa7uy;
0x43uy; 0x0cuy; 0xb9uy; 0xdeuy; 0xb9uy; 0x68uy; 0xfbuy; 0xceuy; 0x42uy; 0x99uy; 0x07uy; 0x4duy;
0x0buy; 0x3buy; 0x5auy; 0x30uy; 0x35uy; 0xa8uy; 0xf9uy; 0x3auy; 0x73uy; 0xefuy; 0x0fuy; 0xdbuy;
0x1euy; 0x16uy; 0x42uy; 0xc4uy; 0xbauy; 0xaeuy; 0x58uy; 0xaauy; 0xf8uy; 0xe5uy; 0x75uy; 0x2fuy;
0x1buy; 0x15uy; 0x5cuy; 0xfduy; 0x0auy; 0x97uy; 0xd0uy; 0xe4uy; 0x37uy; 0x83uy; 0x61uy; 0x5fuy;
0x43uy; 0xa6uy; 0xc7uy; 0x3fuy; 0x38uy; 0x59uy; 0xe6uy; 0xebuy; 0xa3uy; 0x90uy; 0xc3uy; 0xaauy;
0xaauy; 0x5auy; 0xd3uy; 0x34uy; 0xd4uy; 0x17uy; 0xc8uy; 0x65uy; 0x3euy; 0x57uy; 0xbcuy; 0x5euy;
0xdduy; 0x9euy; 0xb7uy; 0xf0uy; 0x2euy; 0x5buy; 0xb2uy; 0x1fuy; 0x8auy; 0x08uy; 0x0duy; 0x45uy;
0x91uy; 0x0buy; 0x29uy; 0x53uy; 0x4fuy; 0x4cuy; 0x5auy; 0x73uy; 0x56uy; 0xfeuy; 0xafuy; 0x41uy;
0x01uy; 0x39uy; 0x0auy; 0x24uy; 0x3cuy; 0x7euy; 0xbeuy; 0x4euy; 0x53uy; 0xf3uy; 0xebuy; 0x06uy;
0x66uy; 0x51uy; 0x28uy; 0x1duy; 0xbduy; 0x41uy; 0x0auy; 0x01uy; 0xabuy; 0x16uy; 0x47uy; 0x27uy;
0x47uy; 0x47uy; 0xf7uy; 0xcbuy; 0x46uy; 0x0auy; 0x70uy; 0x9euy; 0x01uy; 0x9cuy; 0x09uy; 0xe1uy;
0x2auy; 0x00uy; 0x1auy; 0xd8uy; 0xd4uy; 0x79uy; 0x9duy; 0x80uy; 0x15uy; 0x8euy; 0x53uy; 0x2auy;
0x65uy; 0x83uy; 0x78uy; 0x3euy; 0x03uy; 0x00uy; 0x07uy; 0x12uy; 0x1fuy; 0x33uy; 0x3euy; 0x7buy;
0x13uy; 0x37uy; 0xf1uy; 0xc3uy; 0xefuy; 0xb7uy; 0xc1uy; 0x20uy; 0x3cuy; 0x3euy; 0x67uy; 0x66uy;
0x5duy; 0x88uy; 0xa7uy; 0x7duy; 0x33uy; 0x50uy; 0x77uy; 0xb0uy; 0x28uy; 0x8euy; 0xe7uy; 0x2cuy;
0x2euy; 0x7auy; 0xf4uy; 0x3cuy; 0x8duy; 0x74uy; 0x83uy; 0xafuy; 0x8euy; 0x87uy; 0x0fuy; 0xe4uy;
0x50uy; 0xffuy; 0x84uy; 0x5cuy; 0x47uy; 0x0cuy; 0x6auy; 0x49uy; 0xbfuy; 0x42uy; 0x86uy; 0x77uy;
0x15uy; 0x48uy; 0xa5uy; 0x90uy; 0x5duy; 0x93uy; 0xd6uy; 0x2auy; 0x11uy; 0xd5uy; 0xd5uy; 0x11uy;
0xaauy; 0xceuy; 0xe7uy; 0x6fuy; 0xa5uy; 0xb0uy; 0x09uy; 0x2cuy; 0x8duy; 0xd3uy; 0x92uy; 0xf0uy;
0x5auy; 0x2auy; 0xdauy; 0x5buy; 0x1euy; 0xd5uy; 0x9auy; 0xc4uy; 0xc4uy; 0xf3uy; 0x49uy; 0x74uy;
0x41uy; 0xcauy; 0xe8uy; 0xc1uy; 0xf8uy; 0x44uy; 0xd6uy; 0x3cuy; 0xaeuy; 0x6cuy; 0x1duy; 0x9auy;
0x30uy; 0x04uy; 0x4duy; 0x27uy; 0x0euy; 0xb1uy; 0x5fuy; 0x59uy; 0xa2uy; 0x24uy; 0xe8uy; 0xe1uy;
0x98uy; 0xc5uy; 0x6auy; 0x4cuy; 0xfeuy; 0x41uy; 0xd2uy; 0x27uy; 0x42uy; 0x52uy; 0xe1uy; 0xe9uy;
0x7duy; 0x62uy; 0xe4uy; 0x88uy; 0x0fuy; 0xaduy; 0xb2uy; 0x70uy; 0xcbuy; 0x9duy; 0x4cuy; 0x27uy;
0x2euy; 0x76uy; 0x1euy; 0x1auy; 0x63uy; 0x65uy; 0xf5uy; 0x3buy; 0xf8uy; 0x57uy; 0x69uy; 0xebuy;
0x5buy; 0x38uy; 0x26uy; 0x39uy; 0x33uy; 0x25uy; 0x45uy; 0x3euy; 0x91uy; 0xb8uy; 0xd8uy; 0xc7uy;
0xd5uy; 0x42uy; 0xc0uy; 0x22uy; 0x31uy; 0x74uy; 0xf4uy; 0xbcuy; 0x0cuy; 0x23uy; 0xf1uy; 0xcauy;
0xc1uy; 0x8duy; 0xd7uy; 0xbeuy; 0xc9uy; 0x62uy; 0xe4uy; 0x08uy; 0x1auy; 0xcfuy; 0x36uy; 0xd5uy;
0xfeuy; 0x55uy; 0x21uy; 0x59uy; 0x91uy; 0x87uy; 0x87uy; 0xdfuy; 0x06uy; 0xdbuy; 0xdfuy; 0x96uy;
0x45uy; 0x58uy; 0xdauy; 0x05uy; 0xcduy; 0x50uy; 0x4duy; 0xd2uy; 0x7duy; 0x05uy; 0x18uy; 0x73uy;
0x6auy; 0x8duy; 0x11uy; 0x85uy; 0xa6uy; 0x88uy; 0xe8uy; 0xdauy; 0xe6uy; 0x30uy; 0x33uy; 0xa4uy;
0x89uy; 0x31uy; 0x75uy; 0xbeuy; 0x69uy; 0x43uy; 0x84uy; 0x43uy; 0x50uy; 0x87uy; 0xdduy; 0x71uy;
0x36uy; 0x83uy; 0xc3uy; 0x78uy; 0x74uy; 0x24uy; 0x0auy; 0xeduy; 0x7buy; 0xdbuy; 0xa4uy; 0x24uy;
0x0buy; 0xb9uy; 0x7euy; 0x5duy; 0xffuy; 0xdeuy; 0xb1uy; 0xefuy; 0x61uy; 0x5auy; 0x45uy; 0x33uy;
0xf6uy; 0x17uy; 0x07uy; 0x08uy; 0x98uy; 0x83uy; 0x92uy; 0x0fuy; 0x23uy; 0x6duy; 0xe6uy; 0xaauy;
0x17uy; 0x54uy; 0xaduy; 0x6auy; 0xc8uy; 0xdbuy; 0x26uy; 0xbeuy; 0xb8uy; 0xb6uy; 0x08uy; 0xfauy;
0x68uy; 0xf1uy; 0xd7uy; 0x79uy; 0x6fuy; 0x18uy; 0xb4uy; 0x9euy; 0x2duy; 0x3fuy; 0x1buy; 0x64uy;
0xafuy; 0x8duy; 0x06uy; 0x0euy; 0x49uy; 0x28uy; 0xe0uy; 0x5duy; 0x45uy; 0x68uy; 0x13uy; 0x87uy;
0xfauy; 0xdeuy; 0x40uy; 0x7buy; 0xd2uy; 0xc3uy; 0x94uy; 0xd5uy; 0xe1uy; 0xd9uy; 0xc2uy; 0xafuy;
0x55uy; 0x89uy; 0xebuy; 0xb4uy; 0x12uy; 0x59uy; 0xa8uy; 0xd4uy; 0xc5uy; 0x29uy; 0x66uy; 0x38uy;
0xe6uy; 0xacuy; 0x22uy; 0x22uy; 0xd9uy; 0x64uy; 0x9buy; 0x34uy; 0x0auy; 0x32uy; 0x9fuy; 0xc2uy;
0xbfuy; 0x17uy; 0x6cuy; 0x3fuy; 0x71uy; 0x7auy; 0x38uy; 0x6buy; 0x98uy; 0xfbuy; 0x49uy; 0x36uy;
0x89uy; 0xc9uy; 0xe2uy; 0xd6uy; 0xc7uy; 0x5duy; 0xd0uy; 0x69uy; 0x5fuy; 0x23uy; 0x35uy; 0xc9uy;
0x30uy; 0xe2uy; 0xfduy; 0x44uy; 0x58uy; 0x39uy; 0xd7uy; 0x97uy; 0xfbuy; 0x5cuy; 0x00uy; 0xd5uy;
0x4fuy; 0x7auy; 0x1auy; 0x95uy; 0x8buy; 0x62uy; 0x4buy; 0xceuy; 0xe5uy; 0x91uy; 0x21uy; 0x7buy;
0x30uy; 0x00uy; 0xd6uy; 0xdduy; 0x6duy; 0x02uy; 0x86uy; 0x49uy; 0x0fuy; 0x3cuy; 0x1auy; 0x27uy;
0x3cuy; 0xd3uy; 0x0euy; 0x71uy; 0xf2uy; 0xffuy; 0xf5uy; 0x2fuy; 0x87uy; 0xacuy; 0x67uy; 0x59uy;
0x81uy; 0xa3uy; 0xf7uy; 0xf8uy; 0xd6uy; 0x11uy; 0x0cuy; 0x84uy; 0xa9uy; 0x03uy; 0xeeuy; 0x2auy;
0xc4uy; 0xf3uy; 0x22uy; 0xabuy; 0x7cuy; 0xe2uy; 0x25uy; 0xf5uy; 0x67uy; 0xa3uy; 0xe4uy; 0x11uy;
0xe0uy; 0x59uy; 0xb3uy; 0xcauy; 0x87uy; 0xa0uy; 0xaeuy; 0xc9uy; 0xa6uy; 0x62uy; 0x1buy; 0x6euy;
0x4duy; 0x02uy; 0x6buy; 0x07uy; 0x9duy; 0xfduy; 0xd0uy; 0x92uy; 0x06uy; 0xe1uy; 0xb2uy; 0x9auy;
0x4auy; 0x1fuy; 0x1fuy; 0x13uy; 0x49uy; 0x99uy; 0x97uy; 0x08uy; 0xdeuy; 0x7fuy; 0x98uy; 0xafuy;
0x51uy; 0x98uy; 0xeeuy; 0x2cuy; 0xcbuy; 0xf0uy; 0x0buy; 0xc6uy; 0xb6uy; 0xb7uy; 0x2duy; 0x9auy;
0xb1uy; 0xacuy; 0xa6uy; 0xe3uy; 0x15uy; 0x77uy; 0x9duy; 0x6buy; 0x1auy; 0xe4uy; 0xfcuy; 0x8buy;
0xf2uy; 0x17uy; 0x59uy; 0x08uy; 0x04uy; 0x58uy; 0x81uy; 0x9duy; 0x1buy; 0x1buy; 0x69uy; 0x55uy;
0xc2uy; 0xb4uy; 0x3cuy; 0x1fuy; 0x50uy; 0xf1uy; 0x7fuy; 0x77uy; 0x90uy; 0x4cuy; 0x66uy; 0x40uy;
0x5auy; 0xc0uy; 0x33uy; 0x1fuy; 0xcbuy; 0x05uy; 0x6duy; 0x5cuy; 0x06uy; 0x87uy; 0x52uy; 0xa2uy;
0x8fuy; 0x26uy; 0xd5uy; 0x4fuy
]
in
assert_norm (List.Tot.length l = 1024);
B.gcmalloc_of_list HyperStack.root l | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_le_3 | val parse32_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_le_3
(min32: U32.t)
(max32: U32.t { 65536 <= U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 16777216 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_le_3
min max
= parse32_bounded_int32_le' min max 3ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 352,
"start_col": 0,
"start_line": 350
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul
let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul
let serialize32_bounded_int32_3
min max
= serialize32_bounded_int32' min max 3ul
let serialize32_bounded_int32_4
min max
= serialize32_bounded_int32' min max 4ul
inline_for_extraction
let parse32_bounded_int32_le'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_le_1
min max
= parse32_bounded_int32_le' min max 1ul
let parse32_bounded_int32_le_2
min max
= parse32_bounded_int32_le' min max 2ul | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 65536 <= FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 16777216 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThan",
"LowParse.SLow.BoundedInt.parse32_bounded_int32_le'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | false | false | false | false | false | let parse32_bounded_int32_le_3 min max =
| parse32_bounded_int32_le' min max 3ul | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32' | val parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | val parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) | let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
() | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 6,
"end_line": 267,
"start_col": 0,
"start_line": 251
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"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.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 4294967296 } ->
sz32:
FStar.UInt32.t{LowParse.Spec.BoundedInt.log256' (FStar.UInt32.v max32) == FStar.UInt32.v sz32}
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32 (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"LowParse.Spec.BoundedInt.log256'",
"LowParse.SLow.Combinators.parse32_synth",
"LowParse.Spec.Combinators.parse_filter_kind",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.Combinators.parse_filter_refine",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.in_bounds",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.Combinators.parse_filter",
"LowParse.Spec.BoundedInt.parse_bounded_integer",
"LowParse.SLow.Combinators.parse32_filter",
"LowParse.SLow.BoundedInt.parse32_bounded_integer",
"Prims.op_Negation",
"Prims.op_BarBar",
"FStar.UInt32.lt",
"Prims.bool",
"FStar.UInt.uint_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.parse_bounded_int32"
] | [] | false | false | false | false | false | let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t{0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296})
(sz32: U32.t{log256' (U32.v max32) == U32.v sz32})
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32))) =
| [@@ inline_let ]let sz = U32.v sz32 in
[@@ inline_let ]let min = U32.v min32 in
[@@ inline_let ]let max = U32.v max32 in
parse32_synth ((parse_bounded_integer sz) `parse_filter` (in_bounds min max))
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz)
(in_bounds min max)
(fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
() | false |
LowParse.SLow.BoundedInt.fst | LowParse.SLow.BoundedInt.parse32_bounded_int32_le_1 | val parse32_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | val parse32_bounded_int32_le_1
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 256 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32))) | let parse32_bounded_int32_le_1
min max
= parse32_bounded_int32_le' min max 1ul | {
"file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 39,
"end_line": 344,
"start_col": 0,
"start_line": 342
} | module LowParse.SLow.BoundedInt
open LowParse.SLow.Combinators
#set-options "--split_queries no"
#set-options "--z3rlimit 20"
module Seq = FStar.Seq
module U8 = FStar.UInt8
module U16 = FStar.UInt16
module U32 = FStar.UInt32
module B32 = FStar.Bytes
module E = LowParse.SLow.Endianness
module EI = LowParse.Spec.Endianness.Instances
module Cast = FStar.Int.Cast
friend LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let decode32_bounded_integer_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } )
= be_to_n_1 b
inline_for_extraction
noextract
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let decode32_bounded_integer_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } )
= be_to_n_2 b
inline_for_extraction
noextract
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let decode32_bounded_integer_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } )
= be_to_n_3 b
inline_for_extraction
noextract
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let decode32_bounded_integer_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } )
= be_to_n_4 b
inline_for_extraction
let decode32_bounded_integer
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } )
)
= match sz with
| 1 -> decode32_bounded_integer_1
| 2 -> decode32_bounded_integer_2
| 3 -> decode32_bounded_integer_3
| 4 -> decode32_bounded_integer_4
inline_for_extraction
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
[@inline_let]
let _ = decode_bounded_integer_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(decode_bounded_integer sz)
()
(decode32_bounded_integer sz)
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
inline_for_extraction
noextract
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
inline_for_extraction
let serialize32_bounded_integer_1
: (serializer32 (serialize_bounded_integer 1))
= (fun (input: bounded_integer 1) ->
n_to_be_1 input)
inline_for_extraction
noextract
let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2)
inline_for_extraction
let serialize32_bounded_integer_2
: (serializer32 (serialize_bounded_integer 2))
= (fun (input: bounded_integer 2) ->
n_to_be_2 input)
inline_for_extraction
noextract
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
inline_for_extraction
let serialize32_bounded_integer_3
: (serializer32 (serialize_bounded_integer 3))
= (fun (input: bounded_integer 3) ->
n_to_be_3 input)
inline_for_extraction
noextract
let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4)
inline_for_extraction
let serialize32_bounded_integer_4
: (serializer32 (serialize_bounded_integer 4))
= (fun (input: bounded_integer 4) ->
n_to_be_4 input)
inline_for_extraction
noextract
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
inline_for_extraction
let bounded_integer_of_le_32_1
(b: B32.lbytes 1)
: Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } )
= le_to_n_1 b
inline_for_extraction
noextract
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
inline_for_extraction
let bounded_integer_of_le_32_2
(b: B32.lbytes 2)
: Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } )
= le_to_n_2 b
inline_for_extraction
noextract
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
inline_for_extraction
let bounded_integer_of_le_32_3
(b: B32.lbytes 3)
: Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } )
= le_to_n_3 b
inline_for_extraction
noextract
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
inline_for_extraction
let bounded_integer_of_le_32_4
(b: B32.lbytes 4)
: Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } )
= le_to_n_4 b
inline_for_extraction
let bounded_integer_of_le_32
(sz: integer_size)
: Tot ((b: B32.lbytes sz) ->
Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } )
)
= match sz with
| 1 -> bounded_integer_of_le_32_1
| 2 -> bounded_integer_of_le_32_2
| 3 -> bounded_integer_of_le_32_3
| 4 -> bounded_integer_of_le_32_4
inline_for_extraction
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
[@inline_let]
let _ = bounded_integer_of_le_injective sz in
make_total_constant_size_parser32 sz (U32.uint_to_t sz)
(bounded_integer_of_le sz)
()
(bounded_integer_of_le_32 sz)
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
let parse32_u16_le =
parse32_synth'
_
synth_u16_le
parse32_bounded_integer_le_2
()
let parse32_u32_le =
parse32_synth'
_
synth_u32_le
parse32_bounded_integer_le_4
()
inline_for_extraction
noextract
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) ->
n_to_le_1 x
inline_for_extraction
noextract
let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) ->
n_to_le_2 x
inline_for_extraction
noextract
let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) ->
n_to_le_3 x
inline_for_extraction
noextract
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) ->
n_to_le_4 x
let serialize32_u16_le =
serialize32_synth'
_
synth_u16_le
_
serialize32_bounded_integer_le_2
synth_u16_le_recip
()
let serialize32_u32_le =
serialize32_synth'
_
synth_u32_le
_
serialize32_bounded_integer_le_4
synth_u32_le_recip
()
inline_for_extraction
let parse32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
()
let parse32_bounded_int32_1
min max
= parse32_bounded_int32' min max 1ul
let parse32_bounded_int32_2
min max
= parse32_bounded_int32' min max 2ul
let parse32_bounded_int32_3
min max
= parse32_bounded_int32' min max 3ul
let parse32_bounded_int32_4
min max
= parse32_bounded_int32' min max 4ul
inline_for_extraction
let serialize32_bounded_int32'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (serializer32 (serialize_bounded_int32 (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
serialize32_synth
(parse_bounded_integer sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
_
(serialize32_filter (serialize32_bounded_integer sz) (in_bounds min max))
(fun x -> x)
(fun x -> x)
()
let serialize32_bounded_int32_1
min max
= serialize32_bounded_int32' min max 1ul
let serialize32_bounded_int32_2
min max
= serialize32_bounded_int32' min max 2ul
let serialize32_bounded_int32_3
min max
= serialize32_bounded_int32' min max 3ul
let serialize32_bounded_int32_4
min max
= serialize32_bounded_int32' min max 4ul
inline_for_extraction
let parse32_bounded_int32_le'
(min32: U32.t)
(max32: U32.t { 0 < U32.v max32 /\ U32.v min32 <= U32.v max32 /\ U32.v max32 < 4294967296 })
(sz32: U32.t { log256' (U32.v max32) == U32.v sz32 })
: Tot (parser32 (parse_bounded_int32_le (U32.v min32) (U32.v max32)))
= [@inline_let]
let sz = U32.v sz32 in
[@inline_let]
let min = U32.v min32 in
[@inline_let]
let max = U32.v max32 in
parse32_synth
(parse_bounded_integer_le sz `parse_filter` in_bounds min max)
(fun x -> (x <: bounded_int32 min max))
(fun x -> x)
(parse32_filter (parse32_bounded_integer_le sz) (in_bounds min max) (fun x -> not (x `U32.lt` min32 || max32 `U32.lt` x)))
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.Instances.fst.checked",
"LowParse.Spec.BoundedInt.fst.checked",
"LowParse.SLow.Endianness.fst.checked",
"LowParse.SLow.Combinators.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Bytes.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.SLow.BoundedInt.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowParse.Spec.Endianness.Instances",
"short_module": "EI"
},
{
"abbrev": true,
"full_module": "LowParse.SLow.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.Bytes",
"short_module": "B32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min32: FStar.UInt32.t ->
max32:
FStar.UInt32.t
{ 0 < FStar.UInt32.v max32 /\ FStar.UInt32.v min32 <= FStar.UInt32.v max32 /\
FStar.UInt32.v max32 < 256 }
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_int32_le (FStar.UInt32.v min32
)
(FStar.UInt32.v max32)) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"LowParse.SLow.BoundedInt.parse32_bounded_int32_le'",
"FStar.UInt32.__uint_to_t",
"LowParse.SLow.Base.parser32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_kind",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.parse_bounded_int32_le"
] | [] | false | false | false | false | false | let parse32_bounded_int32_le_1 min max =
| parse32_bounded_int32_le' min max 1ul | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.