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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.qmont_reduction | val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order) | val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order) | let qmont_reduction res x =
push_frame ();
let n = create_felem () in
make_order n;
let h0 = ST.get () in
BM.bn_mont_reduction Hacl.Bignum256.bn_inst n (u64 0xccd1c8aaee00bc4f) x res;
SM.bn_qmont_reduction_lemma (as_seq h0 x) (as_seq h0 n);
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 140,
"start_col": 0,
"start_line": 132
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order
[@CInline]
let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame ()
[@CInline]
let qadd res x y =
let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame ()
val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.widefelem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Bignum.widefelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.bn_qmont_reduction_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Lib.IntTypes.size",
"Hacl.Bignum.Montgomery.bn_mont_reduction",
"Hacl.Bignum256.t_limbs",
"Hacl.Bignum256.bn_inst",
"Lib.IntTypes.u64",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Constants.make_order",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let qmont_reduction res x =
| push_frame ();
let n = create_felem () in
make_order n;
let h0 = ST.get () in
BM.bn_mont_reduction Hacl.Bignum256.bn_inst n (u64 0xccd1c8aaee00bc4f) x res;
SM.bn_qmont_reduction_lemma (as_seq h0 x) (as_seq h0 n);
pop_frame () | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_nil | val valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | val valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) | let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 51,
"end_line": 25,
"start_col": 0,
"start_line": 13
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Slice.live_slice h sl /\ FStar.UInt32.v pos <= FStar.UInt32.v (Mkslice?.len sl))
(ensures
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist 0 p)
h
sl
pos
[]
pos) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Spec.VCList.parse_nlist_eq",
"LowParse.Slice.bytes_of_slice_from",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.l_and",
"LowParse.Slice.live_slice",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos)) =
| valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos) | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.alloca | val alloca:
#index: Type0 ->
c:block index ->
i:index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
alloca_st #index c i t t' | val alloca:
#index: Type0 ->
c:block index ->
i:index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
alloca_st #index c i t t' | let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 553,
"start_col": 0,
"start_line": 462
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Hacl.Streaming.Interface.block index ->
i: index ->
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)}
-> Hacl.Streaming.Functor.alloca_st c i t t' | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Prims.unit",
"Prims._assert",
"FStar.HyperStack.ST.same_refs_in_non_tip_regions",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.loc_region_only",
"FStar.Monotonic.HyperStack.get_tip",
"Hacl.Streaming.Functor.footprint",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.uint8",
"Hacl.Streaming.Functor.seen",
"FStar.Seq.Base.empty",
"Hacl.Streaming.Functor.invariant",
"Hacl.Streaming.Functor.invariant_s",
"Hacl.Streaming.Spec.split_at_last_init",
"Hacl.Streaming.Interface.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.Seq.Base.length",
"FStar.UInt32.v",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_len",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_s",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Functor.reveal_key",
"Prims.op_LessThanOrEqual",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Block__item__max_input_len",
"Hacl.Streaming.Functor.state",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"Hacl.Streaming.Interface.__proj__Block__item__init_s",
"Hacl.Streaming.Functor.optional_reveal",
"LowStar.Monotonic.Buffer.modifies_only_not_unused_in",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_zero",
"Hacl.Streaming.Functor.optional_frame",
"LowStar.Monotonic.Buffer.loc_union",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"LowStar.Monotonic.Buffer.loc_buffer",
"Lib.IntTypes.uint8",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__init",
"FStar.Ghost.hide",
"Hacl.Streaming.Functor.footprint_s",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"Hacl.Streaming.Functor.state_s",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_invariant",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.loc_unused_in_not_unused_in_disjoint",
"Hacl.Streaming.Functor.State",
"FStar.UInt64.t",
"FStar.Int.Cast.uint32_to_uint64",
"Hacl.Streaming.Functor.optional_footprint",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"Hacl.Streaming.Interface.__proj__Stateful__item__copy",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Hacl.Streaming.Interface.__proj__Stateful__item__alloca",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"Lib.IntTypes.u8",
"FStar.Pervasives.allow_inversion",
"Hacl.Streaming.Interface.key_management",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_in",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant_loc_in_footprint"
] | [] | false | false | false | false | false | let alloca #index c i t t' k =
| [@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let h0 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
let h1 = ST.get () in
assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
B.loc_unused_in_not_unused_in_disjoint h1;
(let open B in modifies_only_not_unused_in loc_none h0 h1);
c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
let h2 = ST.get () in
assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
B.loc_unused_in_not_unused_in_disjoint h2;
(let open B in modifies_only_not_unused_in loc_none h1 h2);
c.key.frame_invariant B.loc_none k h1 h2;
let k':optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
let h3 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h3;
(let open B in modifies_only_not_unused_in loc_none h2 h3);
c.key.frame_invariant B.loc_none k h2 h3;
c.state.frame_invariant B.loc_none block_state h2 h3;
assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
assert (c.key.invariant #i h3 k');
assert (c.key.invariant #i h3 k);
assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
let h4 = ST.get () in
assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
B.loc_unused_in_not_unused_in_disjoint h4;
(let open B in modifies_only_not_unused_in loc_none h2 h4);
assert (c.key.invariant #i h4 k');
c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> G.hide (c.key.v i h0 k)
in
let h5 = ST.get () in
assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@@ inline_let ]let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
let h6 = ST.get () in
(let open B in modifies_only_not_unused_in loc_none h5 h6);
(let open B in modifies_only_not_unused_in loc_none h0 h6);
c.key.frame_invariant B.loc_none k h5 h6;
c.state.frame_invariant B.loc_none block_state h5 h6;
optional_frame B.loc_none k' h5 h6;
assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
let h7 = ST.get () in
assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
c.update_multi_zero i (c.state.v i h7 block_state) 0;
B.modifies_only_not_unused_in B.loc_none h0 h7;
assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
let h8 = ST.get () in
assert (U64.v total_len <= U64.v (c.max_input_len i));
(let key_v = reveal_key c i h8 p in
let init_input = c.init_input_s i key_v in
split_at_last_init c i init_input;
assert (invariant_s c i h8 s));
assert (invariant c i h8 p);
assert (seen c i h8 p == S.empty);
assert B.(modifies loc_none h0 h8);
assert (B.fresh_loc (footprint c i h8 p) h0 h8);
assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
assert (ST.same_refs_in_non_tip_regions h0 h8);
p | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.bn_is_lt_order_mask4 | val bn_is_lt_order_mask4: f:felem -> Stack uint64
(requires fun h -> live h f)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
(if as_nat h0 f < S.order then v r = ones_v U64 else v r = 0)) | val bn_is_lt_order_mask4: f:felem -> Stack uint64
(requires fun h -> live h f)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
(if as_nat h0 f < S.order then v r = ones_v U64 else v r = 0)) | let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 49,
"start_col": 0,
"start_line": 41
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u64",
"Lib.IntTypes.uint64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Prims._assert",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.v",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Hacl.Impl.P256.Bignum.as_nat",
"Spec.P256.PointOps.order",
"Prims.bool",
"Prims.op_LessThan",
"Lib.IntTypes.int_t",
"Hacl.Impl.P256.Bignum.bn_sub4",
"Hacl.Impl.P256.Constants.make_order",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let bn_is_lt_order_mask4 f =
| let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.from_qmont | val from_qmont: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res /\
as_nat h x < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res < S.order /\
as_nat h1 res == qmont_as_nat h0 x) | val from_qmont: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res /\
as_nat h x < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res < S.order /\
as_nat h1 res == qmont_as_nat h0 x) | let from_qmont res x =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
update_sub tmp 0ul 4ul x;
BD.bn_eval_update_sub 4 (as_seq h0 x) 8;
let h1 = ST.get () in
assert (wide_as_nat h1 tmp = as_nat h0 x);
assert_norm (S.order < S.order * S.order);
qmont_reduction res tmp;
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 154,
"start_col": 0,
"start_line": 144
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order
[@CInline]
let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame ()
[@CInline]
let qadd res x y =
let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame ()
val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order)
[@CInline]
let qmont_reduction res x =
push_frame ();
let n = create_felem () in
make_order n;
let h0 = ST.get () in
BM.bn_mont_reduction Hacl.Bignum256.bn_inst n (u64 0xccd1c8aaee00bc4f) x res;
SM.bn_qmont_reduction_lemma (as_seq h0 x) (as_seq h0 n);
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.P256.Scalar.qmont_reduction",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_LessThan",
"Spec.P256.PointOps.order",
"FStar.Mul.op_Star",
"Prims._assert",
"Prims.op_Equality",
"Prims.nat",
"Hacl.Impl.P256.Bignum.wide_as_nat",
"Hacl.Impl.P256.Bignum.as_nat",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Spec.Bignum.Definitions.bn_eval_update_sub",
"Lib.IntTypes.U64",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Lib.IntTypes.size",
"Lib.Buffer.update_sub",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.P256.Bignum.widefelem",
"Hacl.Impl.P256.Bignum.create_widefelem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let from_qmont res x =
| push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
update_sub tmp 0ul 4ul x;
BD.bn_eval_update_sub 4 (as_seq h0 x) 8;
let h1 = ST.get () in
assert (wide_as_nat h1 tmp = as_nat h0 x);
assert_norm (S.order < S.order * S.order);
qmont_reduction res tmp;
pop_frame () | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.qmod_short | val qmod_short: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == as_nat h0 x % S.order) | val qmod_short: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == as_nat h0 x % S.order) | let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 108,
"start_col": 0,
"start_line": 99
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.P256.Scalar.qmod_short_lemma",
"Hacl.Impl.P256.Bignum.as_nat",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"Hacl.Impl.P256.Bignum.bn_cmovznz4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Hacl.Impl.P256.Bignum.bn_sub4",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Constants.make_order",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let qmod_short res x =
| push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame () | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.update_small_functional_correctness | val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1))) | val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1))) | let update_small_functional_correctness #index c i t t' p data len h0 h1 =
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state buf total_len0 seen0 key = s0 in
let seen0 = G.reveal seen0 in
let i = Ghost.reveal i in
let key_v0 = optional_reveal #_ #i #c.km #c.key h0 key in
let init_v0 = c.init_input_s i key_v0 in
let all_seen0 = S.append init_v0 seen0 in
let blocks0, rest0 = split_at_last c i all_seen0 in
let State block_state buf total_len1 seen1 key = s1 in
let seen1 = G.reveal seen1 in
let i = Ghost.reveal i in
let key_v1 = optional_reveal #_ #i #c.km #c.key h1 key in
assert(key_v1 == key_v0);
let init_v1 = c.init_input_s i key_v1 in
assert(init_v1 == init_v0);
let all_seen1 = S.append init_v1 seen1 in
let blocks1, rest1 = split_at_last c i all_seen1 in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
let data_v0 = B.as_seq h0 data in
split_at_last_small c i all_seen0 data_v0;
// The first problematic condition
assert(blocks1 `S.equal` blocks0);
assert(c.state.v i h1 block_state == c.update_multi_s i (c.init_s i key_v1) 0 blocks1);
// The second problematic condition
assert(S.equal (S.slice (B.as_seq h1 buf) 0 (Seq.length rest1)) rest1) | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 1111,
"start_col": 0,
"start_line": 1075
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options
#push-options "--z3rlimit 200"
let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let reset #index c i t t' state key =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
(**) let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i; // This is only used in types and proofs
[@inline_let]
let block_state: c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
(**) let h2 = ST.get () in
(**) optional_frame #_ #i #c.km #c.key (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) k' h1 h2;
(**) c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) key h1 h2;
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % UInt32.v (Block?.block_len c i) = 0);
(**) assert (reveal_key c i h1 state == reveal_key c i h2 state);
(**) c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
(**) c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
(**) stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased ->
G.hide (c.key.v i h1 key)
in
(**) let h2 = ST.get () in
(**) assert(preserves_freeable c i state h1 h2);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp: state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
(**) let h3 = ST.get () in
(**) c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
(**) c.key.frame_invariant B.(loc_buffer state) key h2 h3;
(**) optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
(**) stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
(**) assert(preserves_freeable c i state h2 h3);
// This seems to cause insurmountable difficulties. Puzzled.
ST.lemma_equal_domains_trans h1 h2 h3;
// AR: 07/22: same old `Seq.equal` and `==` story
(**) assert (Seq.equal (seen c i h3 state) Seq.empty);
(**) assert (footprint c i h1 state == footprint c i h3 state);
(**) assert (B.(modifies (footprint c i h1 state) h1 h3));
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h3 state in
(**) let all_seen_ = all_seen c i h3 state in
// SH (11/22): the proof fails if we don't introduce the call to [split_at_last]
(**) let blocks, rest = split_at_last c i all_seen_ in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert (invariant_s c i h3 (B.get h3 state 0))
(**) end;
(**) assert(preserves_freeable c i state h1 h3)
#pop-options
/// Some helpers to minimize modulo-reasoning
/// =========================================
val split_at_last_num_blocks_lem (#index : Type0) (c: block index) (i: index) (b: nat):
Lemma (
let n_blocks = split_at_last_num_blocks c i b in
let blocks = n_blocks * U32.v (c.blocks_state_len i) in
0 <= blocks /\ blocks <= b)
let split_at_last_num_blocks_lem #index c i b = ()
/// The ``rest`` function below allows computing, based ``total_len`` stored in
/// the state, the length of useful data currently stored in ``buf``.
/// Unsurprisingly, there's a fair amount of modulo reasoning here because of
/// 64-bit-to-32-bit conversions, so we do them once and for all in a helper.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest #index (c: block index) (i: index)
(total_len: UInt64.t): (x:UInt32.t {
let n = split_at_last_num_blocks c i (U64.v total_len) in
let l = U32.v (c.blocks_state_len i) in
0 <= n * l /\ n * l <= U64.v total_len /\
U32.v x = U64.v total_len - (n * l)})
=
let open FStar.Int.Cast in
[@inline_let] let l = uint32_to_uint64 (c.blocks_state_len i) in
[@inline_let] let r = total_len `U64.rem` l in
(**) let total_len_v : Ghost.erased nat = U64.v total_len in
(**) let l_v : Ghost.erased nat = U64.v l in
(**) let r_v : Ghost.erased nat = U64.v r in
(**) assert(Ghost.reveal r_v = total_len_v - ((total_len_v / l_v) * l_v));
(**) Math.Lemmas.euclidean_division_definition total_len_v l_v;
(**) assert(Ghost.reveal r_v = total_len_v % l_v);
(**) assert(r_v < l_v);
if U64.(r =^ uint_to_t 0) && U64.(total_len >^ uint_to_t 0) then
begin
(**) split_at_last_num_blocks_lem c i (U64.v total_len);
c.blocks_state_len i
end
else
begin
[@inline_let] let r' = FStar.Int.Cast.uint64_to_uint32 r in
(**) FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32);
(**) calc (==) {
(**) U32.v r';
(**) (==) { }
(**) U64.v r % pow2 32;
(**) (==) { FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32) }
(**) U64.v r;
(**) (==) { FStar.Math.Lemmas.euclidean_division_definition (U64.v total_len) (U64.v (uint32_to_uint64 (c.blocks_state_len i))) }
(**) U64.v total_len % U64.v (uint32_to_uint64 (c.blocks_state_len i) );
(**) (==) { }
(**) U64.v total_len % U32.v (c.blocks_state_len i);
(**) };
(**) assert(
(**) let n = split_at_last_num_blocks c i (U64.v total_len) in
(**) let l = U32.v (c.blocks_state_len i) in
(**) U32.v r' = U64.v total_len - (n * l));
r'
end
#pop-options
/// The ``nblocks`` function below allows computing, given ``total_len`` stored in
/// the state, the number of blocks of data which have been processed (the remaining
/// unprocessed data being left in ``buf``).
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let nblocks #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.blocks_state_len i) in
U32.v x * l <= U32.v len /\
U32.v x = split_at_last_num_blocks c i (U32.v len) })
=
let open FStar.Int.Cast in
[@inline_let] let l = c.blocks_state_len i in
[@inline_let] let r = rest c i (uint32_to_uint64 len) in
(**) let len_v : Ghost.erased nat = U32.v len in
(**) let l_v : Ghost.erased nat = U32.v l in
(**) let r_v : Ghost.erased nat = U32.v r in
(**) let n_s : Ghost.erased nat = split_at_last_num_blocks c i len_v in
(**) assert(Ghost.reveal len_v = n_s * l_v + r_v);
(**) Math.Lemmas.nat_times_nat_is_nat n_s l_v;
(**) assert(U32.v r <= U32.v len);
[@inline_let] let blocks = len `U32.sub` r in
(**) let blocks_v : Ghost.erased nat = U32.v blocks in
(**) assert(blocks_v % l_v = 0);
[@inline_let] let n = blocks `U32.div` l in
(**) let n_v : Ghost.erased nat = U32.v n in
(**) assert(n_v * l_v = Ghost.reveal blocks_v);
(**) split_at_last_num_blocks_spec c i len_v n_v r_v;
n
#pop-options
/// The ``rest`` function to call on the unprocessed data length in the ``finish``
/// function.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest_finish #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
0 <= n * l /\ n * l <= U32.v len /\
U32.v x = U32.v len - (n * l)})
=
[@inline_let] let l = c.block_len i in
[@inline_let] let r = len `U32.rem` l in
(**) split_at_last_num_blocks_lem c i (U32.v len);
if U32.(r =^ uint_to_t 0) && U32.(len >^ uint_to_t 0) then
begin
(**) begin
(**) let l = U32.v (c.block_len i) in
(**) let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
(**) Math.Lemmas.nat_times_nat_is_nat n l
(**) end;
c.block_len i
end
else
r
#pop-options
/// We always add 32-bit lengths to 64-bit lengths. Having a helper for that allows
/// doing modulo reasoning once and for all.
inline_for_extraction noextract
let add_len #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t):
Pure UInt64.t
(requires U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures fun x -> U64.v x = U64.v total_len + U32.v len /\ U64.v x <= U64.v (c.max_input_len i))
=
total_len `U64.add` Int.Cast.uint32_to_uint64 len
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let add_len_small #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t): Lemma
(requires
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i total_len) /\
U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures (rest c i (add_len c i total_len len) = rest c i total_len `U32.add` len))
=
let total_len_v = U64.v total_len in
let l = U32.v (c.blocks_state_len i) in
let b = total_len_v + U32.v len in
let n = split_at_last_num_blocks c i total_len_v in
let r = U32.v (rest c i total_len) in
assert(total_len_v = n * l + r);
let r' = U32.v (rest c i total_len) + U32.v len in
assert(r' <= l);
assert(r' = 0 ==> b = 0);
Math.Lemmas.euclidean_division_definition b l;
assert(b = n * l + r');
split_at_last_num_blocks_spec c i b n r'
#pop-options
/// Beginning of the three sub-cases (see Hacl.Streaming.Spec)
/// ==========================================================
noextract
let total_len_h #index (c: block index) (i: index) h (p: state' c i) =
State?.total_len (B.deref h p)
noextract
let split_at_last_all_seen #index (c: block index) (i: index) h (p: state' c i) =
let all_seen = all_seen c i h p in
let blocks, rest = split_at_last c i all_seen in
blocks, rest
inline_for_extraction noextract
val update_small:
#index:Type0 ->
(c: block index) ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)))
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
/// SH: The proof obligations for update_small have problem succeeding in command
/// line mode: hence the restart-solver instruction, the crazy rlimit and the
/// intermediate lemma. Interestingly (and frustratingly), the proof succeeds
/// quite quickly locally on command-line with this rlimit, but fails with a lower
/// one. Besides, the lemma is needed only for the CI regression.
let split_at_last_rest_eq (#index : Type0) (c: block index)
(i: index)
(t:Type0 { t == c.state.s i })
(t':Type0 { t' == optional_key i c.km c.key })
(s: state c i t t') (h0: HS.mem) :
Lemma
(requires (
invariant c i h0 s))
(ensures (
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
Seq.length r == U32.v sz)) =
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
()
/// Particularly difficult proof. Z3 profiling indicates that a pattern goes off
/// the rails. So I disabled all of the known "bad" patterns, then did the proof
/// by hand. Fortunately, there were only two stateful operations. The idea was
/// to do all ofthe modifies-reasoning in the two lemmas above, then disable the
/// bad pattern for the main function.
///
/// This style is a little tedious, because it requires a little bit of digging
/// to understand what needs to hold in order to be able to prove that e.g. the
/// sequence remains unmodified from h0 to h2, but this seems more robust?
val modifies_footprint:
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
s:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State _ buf_ _ _ _ = B.deref h0 s in (
update_pre c i s data len h0 /\
B.(modifies (loc_buffer buf_) h0 h1))))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 s in
let State bs1 buf1 _ _ k1 = B.deref h1 s in (
footprint c i h0 s == footprint c i h1 s /\
preserves_freeable c i s h0 h1 /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1 /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_addr_of_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.state.footprint h1 bs1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_buffer s) (c.state.footprint h1 bs1)) /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer s) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer s) loc_none) /\
True)))))
let modifies_footprint c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf0 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_buffer buf0) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_buffer buf0) k0 h0 h1
val modifies_footprint':
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
p:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h0 p /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h0 bs0)) /\
B.(loc_disjoint (loc_addr_of_buffer p) (loc_addr_of_buffer buf0)) /\
c.state.invariant h0 bs0 /\
(if c.km = Runtime then
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h0 k0)) /\
c.key.invariant #i h0 k0
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none)) /\
B.(modifies (loc_buffer p) h0 h1)) /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h1 p /\
footprint c i h0 p == footprint c i h1 p /\
preserves_freeable c i p h0 h1 /\
B.(loc_disjoint (loc_addr_of_buffer p) (footprint_s c i h1 (B.deref h1 p))) /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h1 bs1)) /\
B.(loc_disjoint (loc_buffer p) (c.state.footprint #i h1 bs1)) /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer p) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none))))))
let modifies_footprint' c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let _ = c.state.frame_invariant #i in
let _ = c.key.frame_invariant #i in
let _ = allow_inversion key_management in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf1 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_addr_of_buffer p) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_addr_of_buffer p) k0 h0 h1
/// Small helper which we use to factor out functional correctness proof obligations.
/// It states that a state was correctly updated to process some data between two
/// memory snapshots (the key is the same, the seen data was updated, etc.).
///
/// Note that we don't specify anything about the buffer and the block_state: they
/// might have been updated differently depending on the case.
unfold val state_is_updated :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Type0)
#push-options "--z3cliopt smt.arith.nl=false"
let state_is_updated #index c i t t' p data len h0 h1 =
// Functional conditions about the memory updates
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
block_state1 == block_state0 /\
buf1 == buf0 /\
U64.v total_len1 == U64.v total_len0 + U32.v len /\
key1 == key0 /\
seen1 `S.equal` (seen0 `S.append` (B.as_seq h0 data)) /\
optional_reveal #index #i #c.km #c.key h1 key1 == optional_reveal #index #i #c.km #c.key h0 key0
#pop-options
/// The functional part of the invariant
unfold val invariant_s_funct :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Pure Type0 (requires
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
state_is_updated c i t t' s data len h0 h1)
(ensures (fun _ -> True)))
let invariant_s_funct #index c i t t' p data len h0 h1 =
let blocks, rest = split_at_last_all_seen c i h1 p in
let s = B.get h1 p 0 in
let State block_state buf_ total_len seen key = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 key in
let init_s = c.init_s i key_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
c.state.v i h1 block_state == c.update_multi_s i init_s 0 blocks /\
S.equal (S.slice (B.as_seq h1 buf_) 0 (Seq.length rest)) rest
/// We isolate the functional correctness proof obligations for [update_small]
val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Hacl.Streaming.Interface.block index -> i: FStar.Ghost.erased index
-> (let i = FStar.Ghost.reveal i in
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)} ->
s: Hacl.Streaming.Functor.state c i t t' ->
data: LowStar.Buffer.buffer Hacl.Streaming.Spec.uint8 ->
len: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
Hacl.Streaming.Functor.update_pre c i s data len h0 /\
FStar.UInt32.v (Block?.init_input_len c i) +
FStar.Seq.Base.length (Hacl.Streaming.Functor.seen c i h0 s) +
FStar.UInt32.v len <=
FStar.UInt64.v (Block?.max_input_len c i) /\
FStar.UInt32.v len <=
FStar.UInt32.v (Block?.blocks_state_len c i) -
FStar.UInt32.v (Hacl.Streaming.Functor.rest c
i
(Hacl.Streaming.Functor.total_len_h c i h0 s)) /\
Hacl.Streaming.Functor.state_is_updated c (FStar.Ghost.hide i) t t' s data len h0 h1 /\
(let s0 = LowStar.Monotonic.Buffer.get h0 s 0 in
let s1 = LowStar.Monotonic.Buffer.get h1 s 0 in
let _ = s0 in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ block_state0 buf0 total_len0 _ _ =
_
in
let _ = s1 in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ block_state1 _ _ _ _ = _ in
let sz = Hacl.Streaming.Functor.rest c i total_len0 in
let buf = buf0 in
let data_v0 = LowStar.Monotonic.Buffer.as_seq h0 data in
let buf_beg_v0 =
FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h0 buf)
0
(FStar.UInt32.v sz)
in
let buf_part_v1 =
FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h1 buf)
0
(FStar.UInt32.v sz + FStar.UInt32.v len)
in
buf_part_v1 == FStar.Seq.Base.append buf_beg_v0 data_v0 /\
Stateful?.v (Block?.state c) i h1 block_state1 ==
Stateful?.v (Block?.state c) i h0 block_state0)
<:
Prims.logical)
<:
Prims.logical))
(ensures
Hacl.Streaming.Functor.invariant_s_funct c (FStar.Ghost.hide i) t t' s data len h0 h1)
) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"FStar.Ghost.erased",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"FStar.Ghost.reveal",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Spec.uint8",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"FStar.UInt64.t",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.bytes",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"LowStar.Monotonic.Buffer.as_seq",
"FStar.Seq.Base.length",
"Prims.unit",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_s",
"Hacl.Streaming.Interface.__proj__Block__item__init_s",
"Hacl.Streaming.Spec.split_at_last_small",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"FStar.Math.Lemmas.modulo_lemma",
"Hacl.Streaming.Interface.__proj__Block__item__block_len",
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Spec.split_at_last",
"Hacl.Streaming.Interface.uint8",
"FStar.Seq.Base.append",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_len",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_s",
"Hacl.Streaming.Functor.optional_reveal",
"FStar.Ghost.hide",
"Hacl.Streaming.Functor.state_s",
"LowStar.Monotonic.Buffer.get"
] | [] | false | false | false | false | false | let update_small_functional_correctness #index c i t t' p data len h0 h1 =
| let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state buf total_len0 seen0 key = s0 in
let seen0 = G.reveal seen0 in
let i = Ghost.reveal i in
let key_v0 = optional_reveal #_ #i #c.km #c.key h0 key in
let init_v0 = c.init_input_s i key_v0 in
let all_seen0 = S.append init_v0 seen0 in
let blocks0, rest0 = split_at_last c i all_seen0 in
let State block_state buf total_len1 seen1 key = s1 in
let seen1 = G.reveal seen1 in
let i = Ghost.reveal i in
let key_v1 = optional_reveal #_ #i #c.km #c.key h1 key in
assert (key_v1 == key_v0);
let init_v1 = c.init_input_s i key_v1 in
assert (init_v1 == init_v0);
let all_seen1 = S.append init_v1 seen1 in
let blocks1, rest1 = split_at_last c i all_seen1 in
Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
assert (0 % U32.v (Block?.block_len c i) = 0);
Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
assert (0 % U32.v (Block?.blocks_state_len c i) = 0);
let data_v0 = B.as_seq h0 data in
split_at_last_small c i all_seen0 data_v0;
assert (blocks1 `S.equal` blocks0);
assert (c.state.v i h1 block_state == c.update_multi_s i (c.init_s i key_v1) 0 blocks1);
assert (S.equal (S.slice (B.as_seq h1 buf) 0 (Seq.length rest1)) rest1) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_cons_not | val valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) | val valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) | let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 63,
"end_line": 149,
"start_col": 0,
"start_line": 131
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires n > 0 /\ ~(LowParse.Low.Base.Spec.valid p h sl pos))
(ensures ~(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Classical.move_requires",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.unit",
"Prims.op_Addition",
"LowParse.Low.VCList.valid_nlist_cons",
"Prims.l_not",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ (~(valid p h sl pos))))
(ensures (~(valid (parse_nlist n p) h sl pos))) =
| Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.update_round | val update_round:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\ (
let r = rest c i (total_len_h c i h0 s) in
U32.v len + U32.v r = U32.v (c.blocks_state_len i) /\
r <> 0ul))
(ensures fun h0 _ h1 ->
update_post c i s data len h0 h1 /\
begin
let blocks, rest = split_at_last_all_seen c i h0 s in
let blocks', rest' = split_at_last_all_seen c i h1 s in
blocks' `S.equal` blocks /\
rest' `S.equal` S.append rest (B.as_seq h0 data) /\
S.length rest' = U32.v (c.blocks_state_len i)
end)) | val update_round:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\ (
let r = rest c i (total_len_h c i h0 s) in
U32.v len + U32.v r = U32.v (c.blocks_state_len i) /\
r <> 0ul))
(ensures fun h0 _ h1 ->
update_post c i s data len h0 h1 /\
begin
let blocks, rest = split_at_last_all_seen c i h0 s in
let blocks', rest' = split_at_last_all_seen c i h1 s in
blocks' `S.equal` blocks /\
rest' `S.equal` S.append rest (B.as_seq h0 data) /\
S.length rest' = U32.v (c.blocks_state_len i)
end)) | let update_round #index c i t t' p data len =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.update_multi_associative i in
let open LowStar.BufferOps in
(**) let h0 = ST.get() in
update_small #index c i t t' p data len;
(**) let h1 = ST.get() in
(**) split_at_last_small c i (all_seen c i h0 p) (B.as_seq h0 data);
(**) begin // For some reason, the proof fails if we don't call those
(**) let blocks, rest = split_at_last_all_seen c i h0 p in
(**) let blocks', rest' = split_at_last_all_seen c i h1 p in
(**) ()
(**) end | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 10,
"end_line": 1485,
"start_col": 0,
"start_line": 1471
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options
#push-options "--z3rlimit 200"
let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let reset #index c i t t' state key =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
(**) let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i; // This is only used in types and proofs
[@inline_let]
let block_state: c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
(**) let h2 = ST.get () in
(**) optional_frame #_ #i #c.km #c.key (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) k' h1 h2;
(**) c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) key h1 h2;
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % UInt32.v (Block?.block_len c i) = 0);
(**) assert (reveal_key c i h1 state == reveal_key c i h2 state);
(**) c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
(**) c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
(**) stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased ->
G.hide (c.key.v i h1 key)
in
(**) let h2 = ST.get () in
(**) assert(preserves_freeable c i state h1 h2);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp: state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
(**) let h3 = ST.get () in
(**) c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
(**) c.key.frame_invariant B.(loc_buffer state) key h2 h3;
(**) optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
(**) stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
(**) assert(preserves_freeable c i state h2 h3);
// This seems to cause insurmountable difficulties. Puzzled.
ST.lemma_equal_domains_trans h1 h2 h3;
// AR: 07/22: same old `Seq.equal` and `==` story
(**) assert (Seq.equal (seen c i h3 state) Seq.empty);
(**) assert (footprint c i h1 state == footprint c i h3 state);
(**) assert (B.(modifies (footprint c i h1 state) h1 h3));
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h3 state in
(**) let all_seen_ = all_seen c i h3 state in
// SH (11/22): the proof fails if we don't introduce the call to [split_at_last]
(**) let blocks, rest = split_at_last c i all_seen_ in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert (invariant_s c i h3 (B.get h3 state 0))
(**) end;
(**) assert(preserves_freeable c i state h1 h3)
#pop-options
/// Some helpers to minimize modulo-reasoning
/// =========================================
val split_at_last_num_blocks_lem (#index : Type0) (c: block index) (i: index) (b: nat):
Lemma (
let n_blocks = split_at_last_num_blocks c i b in
let blocks = n_blocks * U32.v (c.blocks_state_len i) in
0 <= blocks /\ blocks <= b)
let split_at_last_num_blocks_lem #index c i b = ()
/// The ``rest`` function below allows computing, based ``total_len`` stored in
/// the state, the length of useful data currently stored in ``buf``.
/// Unsurprisingly, there's a fair amount of modulo reasoning here because of
/// 64-bit-to-32-bit conversions, so we do them once and for all in a helper.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest #index (c: block index) (i: index)
(total_len: UInt64.t): (x:UInt32.t {
let n = split_at_last_num_blocks c i (U64.v total_len) in
let l = U32.v (c.blocks_state_len i) in
0 <= n * l /\ n * l <= U64.v total_len /\
U32.v x = U64.v total_len - (n * l)})
=
let open FStar.Int.Cast in
[@inline_let] let l = uint32_to_uint64 (c.blocks_state_len i) in
[@inline_let] let r = total_len `U64.rem` l in
(**) let total_len_v : Ghost.erased nat = U64.v total_len in
(**) let l_v : Ghost.erased nat = U64.v l in
(**) let r_v : Ghost.erased nat = U64.v r in
(**) assert(Ghost.reveal r_v = total_len_v - ((total_len_v / l_v) * l_v));
(**) Math.Lemmas.euclidean_division_definition total_len_v l_v;
(**) assert(Ghost.reveal r_v = total_len_v % l_v);
(**) assert(r_v < l_v);
if U64.(r =^ uint_to_t 0) && U64.(total_len >^ uint_to_t 0) then
begin
(**) split_at_last_num_blocks_lem c i (U64.v total_len);
c.blocks_state_len i
end
else
begin
[@inline_let] let r' = FStar.Int.Cast.uint64_to_uint32 r in
(**) FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32);
(**) calc (==) {
(**) U32.v r';
(**) (==) { }
(**) U64.v r % pow2 32;
(**) (==) { FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32) }
(**) U64.v r;
(**) (==) { FStar.Math.Lemmas.euclidean_division_definition (U64.v total_len) (U64.v (uint32_to_uint64 (c.blocks_state_len i))) }
(**) U64.v total_len % U64.v (uint32_to_uint64 (c.blocks_state_len i) );
(**) (==) { }
(**) U64.v total_len % U32.v (c.blocks_state_len i);
(**) };
(**) assert(
(**) let n = split_at_last_num_blocks c i (U64.v total_len) in
(**) let l = U32.v (c.blocks_state_len i) in
(**) U32.v r' = U64.v total_len - (n * l));
r'
end
#pop-options
/// The ``nblocks`` function below allows computing, given ``total_len`` stored in
/// the state, the number of blocks of data which have been processed (the remaining
/// unprocessed data being left in ``buf``).
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let nblocks #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.blocks_state_len i) in
U32.v x * l <= U32.v len /\
U32.v x = split_at_last_num_blocks c i (U32.v len) })
=
let open FStar.Int.Cast in
[@inline_let] let l = c.blocks_state_len i in
[@inline_let] let r = rest c i (uint32_to_uint64 len) in
(**) let len_v : Ghost.erased nat = U32.v len in
(**) let l_v : Ghost.erased nat = U32.v l in
(**) let r_v : Ghost.erased nat = U32.v r in
(**) let n_s : Ghost.erased nat = split_at_last_num_blocks c i len_v in
(**) assert(Ghost.reveal len_v = n_s * l_v + r_v);
(**) Math.Lemmas.nat_times_nat_is_nat n_s l_v;
(**) assert(U32.v r <= U32.v len);
[@inline_let] let blocks = len `U32.sub` r in
(**) let blocks_v : Ghost.erased nat = U32.v blocks in
(**) assert(blocks_v % l_v = 0);
[@inline_let] let n = blocks `U32.div` l in
(**) let n_v : Ghost.erased nat = U32.v n in
(**) assert(n_v * l_v = Ghost.reveal blocks_v);
(**) split_at_last_num_blocks_spec c i len_v n_v r_v;
n
#pop-options
/// The ``rest`` function to call on the unprocessed data length in the ``finish``
/// function.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest_finish #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
0 <= n * l /\ n * l <= U32.v len /\
U32.v x = U32.v len - (n * l)})
=
[@inline_let] let l = c.block_len i in
[@inline_let] let r = len `U32.rem` l in
(**) split_at_last_num_blocks_lem c i (U32.v len);
if U32.(r =^ uint_to_t 0) && U32.(len >^ uint_to_t 0) then
begin
(**) begin
(**) let l = U32.v (c.block_len i) in
(**) let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
(**) Math.Lemmas.nat_times_nat_is_nat n l
(**) end;
c.block_len i
end
else
r
#pop-options
/// We always add 32-bit lengths to 64-bit lengths. Having a helper for that allows
/// doing modulo reasoning once and for all.
inline_for_extraction noextract
let add_len #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t):
Pure UInt64.t
(requires U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures fun x -> U64.v x = U64.v total_len + U32.v len /\ U64.v x <= U64.v (c.max_input_len i))
=
total_len `U64.add` Int.Cast.uint32_to_uint64 len
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let add_len_small #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t): Lemma
(requires
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i total_len) /\
U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures (rest c i (add_len c i total_len len) = rest c i total_len `U32.add` len))
=
let total_len_v = U64.v total_len in
let l = U32.v (c.blocks_state_len i) in
let b = total_len_v + U32.v len in
let n = split_at_last_num_blocks c i total_len_v in
let r = U32.v (rest c i total_len) in
assert(total_len_v = n * l + r);
let r' = U32.v (rest c i total_len) + U32.v len in
assert(r' <= l);
assert(r' = 0 ==> b = 0);
Math.Lemmas.euclidean_division_definition b l;
assert(b = n * l + r');
split_at_last_num_blocks_spec c i b n r'
#pop-options
/// Beginning of the three sub-cases (see Hacl.Streaming.Spec)
/// ==========================================================
noextract
let total_len_h #index (c: block index) (i: index) h (p: state' c i) =
State?.total_len (B.deref h p)
noextract
let split_at_last_all_seen #index (c: block index) (i: index) h (p: state' c i) =
let all_seen = all_seen c i h p in
let blocks, rest = split_at_last c i all_seen in
blocks, rest
inline_for_extraction noextract
val update_small:
#index:Type0 ->
(c: block index) ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)))
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
/// SH: The proof obligations for update_small have problem succeeding in command
/// line mode: hence the restart-solver instruction, the crazy rlimit and the
/// intermediate lemma. Interestingly (and frustratingly), the proof succeeds
/// quite quickly locally on command-line with this rlimit, but fails with a lower
/// one. Besides, the lemma is needed only for the CI regression.
let split_at_last_rest_eq (#index : Type0) (c: block index)
(i: index)
(t:Type0 { t == c.state.s i })
(t':Type0 { t' == optional_key i c.km c.key })
(s: state c i t t') (h0: HS.mem) :
Lemma
(requires (
invariant c i h0 s))
(ensures (
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
Seq.length r == U32.v sz)) =
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
()
/// Particularly difficult proof. Z3 profiling indicates that a pattern goes off
/// the rails. So I disabled all of the known "bad" patterns, then did the proof
/// by hand. Fortunately, there were only two stateful operations. The idea was
/// to do all ofthe modifies-reasoning in the two lemmas above, then disable the
/// bad pattern for the main function.
///
/// This style is a little tedious, because it requires a little bit of digging
/// to understand what needs to hold in order to be able to prove that e.g. the
/// sequence remains unmodified from h0 to h2, but this seems more robust?
val modifies_footprint:
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
s:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State _ buf_ _ _ _ = B.deref h0 s in (
update_pre c i s data len h0 /\
B.(modifies (loc_buffer buf_) h0 h1))))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 s in
let State bs1 buf1 _ _ k1 = B.deref h1 s in (
footprint c i h0 s == footprint c i h1 s /\
preserves_freeable c i s h0 h1 /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1 /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_addr_of_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.state.footprint h1 bs1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_buffer s) (c.state.footprint h1 bs1)) /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer s) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer s) loc_none) /\
True)))))
let modifies_footprint c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf0 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_buffer buf0) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_buffer buf0) k0 h0 h1
val modifies_footprint':
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
p:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h0 p /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h0 bs0)) /\
B.(loc_disjoint (loc_addr_of_buffer p) (loc_addr_of_buffer buf0)) /\
c.state.invariant h0 bs0 /\
(if c.km = Runtime then
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h0 k0)) /\
c.key.invariant #i h0 k0
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none)) /\
B.(modifies (loc_buffer p) h0 h1)) /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h1 p /\
footprint c i h0 p == footprint c i h1 p /\
preserves_freeable c i p h0 h1 /\
B.(loc_disjoint (loc_addr_of_buffer p) (footprint_s c i h1 (B.deref h1 p))) /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h1 bs1)) /\
B.(loc_disjoint (loc_buffer p) (c.state.footprint #i h1 bs1)) /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer p) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none))))))
let modifies_footprint' c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let _ = c.state.frame_invariant #i in
let _ = c.key.frame_invariant #i in
let _ = allow_inversion key_management in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf1 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_addr_of_buffer p) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_addr_of_buffer p) k0 h0 h1
/// Small helper which we use to factor out functional correctness proof obligations.
/// It states that a state was correctly updated to process some data between two
/// memory snapshots (the key is the same, the seen data was updated, etc.).
///
/// Note that we don't specify anything about the buffer and the block_state: they
/// might have been updated differently depending on the case.
unfold val state_is_updated :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Type0)
#push-options "--z3cliopt smt.arith.nl=false"
let state_is_updated #index c i t t' p data len h0 h1 =
// Functional conditions about the memory updates
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
block_state1 == block_state0 /\
buf1 == buf0 /\
U64.v total_len1 == U64.v total_len0 + U32.v len /\
key1 == key0 /\
seen1 `S.equal` (seen0 `S.append` (B.as_seq h0 data)) /\
optional_reveal #index #i #c.km #c.key h1 key1 == optional_reveal #index #i #c.km #c.key h0 key0
#pop-options
/// The functional part of the invariant
unfold val invariant_s_funct :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Pure Type0 (requires
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
state_is_updated c i t t' s data len h0 h1)
(ensures (fun _ -> True)))
let invariant_s_funct #index c i t t' p data len h0 h1 =
let blocks, rest = split_at_last_all_seen c i h1 p in
let s = B.get h1 p 0 in
let State block_state buf_ total_len seen key = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 key in
let init_s = c.init_s i key_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
c.state.v i h1 block_state == c.update_multi_s i init_s 0 blocks /\
S.equal (S.slice (B.as_seq h1 buf_) 0 (Seq.length rest)) rest
/// We isolate the functional correctness proof obligations for [update_small]
val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#push-options "--z3cliopt smt.arith.nl=false"
let update_small_functional_correctness #index c i t t' p data len h0 h1 =
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state buf total_len0 seen0 key = s0 in
let seen0 = G.reveal seen0 in
let i = Ghost.reveal i in
let key_v0 = optional_reveal #_ #i #c.km #c.key h0 key in
let init_v0 = c.init_input_s i key_v0 in
let all_seen0 = S.append init_v0 seen0 in
let blocks0, rest0 = split_at_last c i all_seen0 in
let State block_state buf total_len1 seen1 key = s1 in
let seen1 = G.reveal seen1 in
let i = Ghost.reveal i in
let key_v1 = optional_reveal #_ #i #c.km #c.key h1 key in
assert(key_v1 == key_v0);
let init_v1 = c.init_input_s i key_v1 in
assert(init_v1 == init_v0);
let all_seen1 = S.append init_v1 seen1 in
let blocks1, rest1 = split_at_last c i all_seen1 in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
let data_v0 = B.as_seq h0 data in
split_at_last_small c i all_seen0 data_v0;
// The first problematic condition
assert(blocks1 `S.equal` blocks0);
assert(c.state.v i h1 block_state == c.update_multi_s i (c.init_s i key_v1) 0 blocks1);
// The second problematic condition
assert(S.equal (S.slice (B.as_seq h1 buf) 0 (Seq.length rest1)) rest1)
#pop-options
// The absence of loc_disjoint_includes makes reasoning a little more difficult.
// Notably, we lose all of the important disjointness properties between the
// outer point p and the buffer within B.deref h p. These need to be
// re-established by hand. Another thing that we lose without this pattern is
// knowing that loc_buffer b is included within loc_addr_of_buffer b. This is
// important for reasoning about the preservation of e.g. the contents of data.
#restart-solver
#push-options "--z3rlimit 300 --z3cliopt smt.arith.nl=false --z3refresh \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2,-FStar.Seq.Properties.slice_slice,-LowStar.Monotonic.Buffer.loc_disjoint_includes_r'"
let update_small #index c i t t' p data len =
let open LowStar.BufferOps in
let s = !*p in
let State block_state buf total_len seen_ k' = s in
[@inline_let]
let block_state: c.state.s i = block_state in
// Functional reasoning.
let sz = rest c i total_len in
add_len_small c i total_len len;
let h0 = ST.get () in
let buf1 = B.sub buf 0ul sz in
let buf2 = B.sub buf sz len in
// Memory reasoning.
c.state.invariant_loc_in_footprint h0 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h0 k';
// key_invariant_loc_in_footprint #index c i h0 p;
B.(loc_disjoint_includes_r (loc_buffer data) (footprint c i h0 p) (loc_buffer buf2));
// FIRST STATEFUL OPERATION
B.blit data 0ul buf2 0ul len;
// Memory reasoning.
let h1 = ST.get () in
modifies_footprint c i p data len h0 h1;
c.state.invariant_loc_in_footprint h1 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h1 k';
// Functional reasoning on data
begin
let buf1_v0 = B.as_seq h0 buf1 in
let buf1_v1 = B.as_seq h1 buf1 in
let buf2_v1 = B.as_seq h1 buf2 in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
let data_v0 = B.as_seq h0 data in
assert(buf1_v1 == buf1_v0);
assert(buf1_v0 == buf_beg_v0);
assert(buf2_v1 `S.equal` data_v0);
assert(buf_part_v1 `S.equal` S.append buf_beg_v0 data_v0)
end;
// SECOND STATEFUL OPERATION
let total_len = add_len c i total_len len in
[@inline_let]
let tmp: state_s c i t t' =
State #index #c #i block_state buf total_len
(G.hide (G.reveal seen_ `S.append` (B.as_seq h0 data))) k'
in
p *= tmp;
// Memory reasoning.
let h2 = ST.get () in
modifies_footprint' c i p data len h1 h2;
c.state.invariant_loc_in_footprint h2 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h2 k';
ST.lemma_equal_domains_trans h0 h1 h2;
// Prove the invariant
update_small_functional_correctness c i t t' p data len h0 h2
#pop-options
// Stupid name collisions
noextract let seen_h = seen
noextract let all_seen_h = all_seen
/// Case 2: we have no buffered data (ie: the buffer was just initialized), or the
/// internal buffer is full meaning that we can just hash it to go to the case where
/// there is no buffered data. Of course, the data we append has to be non-empty,
/// otherwise we might end-up with an empty internal buffer.
/// Auxiliary lemma which groups the functional correctness proof obligations
/// for [update_empty_or_full].
#push-options "--z3cliopt smt.arith.nl=false"
val update_empty_or_full_functional_correctness :
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// Same precondition as [update_empty_or_full_buf]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0 /\
// Generic additional preconditions
state_is_updated c i t t' s data len h0 h1 /\
// Additional preconditions
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let seen0 = G.reveal seen0 in
let seen1 = G.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.v n_blocks * U32.v (c.blocks_state_len i) <= U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let all_seen0 = all_seen c i h0 s in
let all_seen1 = all_seen c i h1 s in
let blocks0, res0 = split_at_last c i all_seen0 in
let blocks1, res1 = split_at_last c i all_seen1 in
let data1_v = B.as_seq h0 data1 in
let data2_v = B.as_seq h0 data2 in
let key = optional_reveal #index #i #c.km #c.key h0 key0 in
let init_s = c.init_s i key in
let all_seen_data1 = S.append all_seen0 data1_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
S.length all_seen0 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
S.length all_seen_data1 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
c.state.v i h1 block_state == c.update_multi_s i init_s 0 all_seen_data1 /\
S.slice (B.as_seq h1 buf) 0 (Seq.length data2_v) `S.equal` data2_v /\
True
end /\
True
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let update_empty_or_full_functional_correctness #index c i t t' p data len h0 h1 =
let s = B.get h0 p 0 in
let State block_state buf_ total_len seen0 key = s in
let init_s = c.init_s i (optional_reveal #index #i #c.km #c.key h0 key) in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let data_v = B.as_seq h0 data in
let init_input = init_input c i h0 p in
let seen1 = seen c i h1 p in
let all_seen0 = all_seen c i h0 p in
let all_seen1 = all_seen c i h1 p in
let blocks0, rest0 = split_at_last_all_seen c i h0 p in
let blocks1, rest1 = split_at_last_all_seen c i h1 p in
let data_blocks, data_rest = split_at_last c i data_v in
split_at_last_blocks c i all_seen0 data_v;
assert(Seq.equal all_seen1 (S.append all_seen0 data_v));
assert(S.equal blocks1 (S.append all_seen0 data_blocks));
assert(S.equal data_rest rest1)
#pop-options
inline_for_extraction noextract
val update_empty_or_full_buf:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0)
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
#push-options "--z3cliopt smt.arith.nl=false --z3rlimit 500"
let update_empty_or_full_buf #index c i t t' p data len =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.update_multi_associative i in
let open LowStar.BufferOps in
let s = !*p in
let State block_state buf total_len seen k' = s in
[@inline_let]
let block_state: c.state.s i = block_state in
let sz = rest c i total_len in
let h0 = ST.get () in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
assert(0 % U32.v (c.block_len i) = 0);
let init_key : Ghost.erased _ = optional_reveal h0 (k' <: optional_key i c.km c.key) in
let init_state : Ghost.erased _ = c.init_s i init_key in
assert(
let all_seen = all_seen c i h0 p in
let blocks, rest = split_at_last c i all_seen in
Seq.length rest = U32.v sz /\
c.state.v i h0 block_state ==
c.update_multi_s i init_state 0 blocks);
(* Start by "flushing" the buffer: hash it so that all the data seen so far
* has been processed and we can consider the buffer as empty *)
if U32.(sz =^ 0ul) then
begin
assert(
let all_seen = all_seen c i h0 p in
c.state.v i h0 block_state == c.update_multi_s i init_state 0 all_seen)
end
else begin
let prevlen = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 sz) in
c.update_multi (G.hide i) block_state prevlen buf (c.blocks_state_len i);
begin
let h1 = ST.get () in
let all_seen = all_seen c i h0 p in
let blocks, rest = split_at_last c i all_seen in
assert(Seq.length blocks = U64.v prevlen);
assert(c.state.v i h0 block_state == c.update_multi_s i init_state 0 blocks);
assert(c.state.v i h1 block_state ==
c.update_multi_s i (c.update_multi_s i init_state 0 blocks) (U64.v prevlen) rest);
assert(all_seen `Seq.equal` Seq.append blocks rest);
(* TODO: the pattern of ``update_multi_associative`` is not triggered *)
c.update_multi_associative i init_state 0 (U64.v prevlen) blocks rest;
assert(c.state.v i h1 block_state == c.update_multi_s i init_state 0 all_seen)
end
end;
let h1 = ST.get () in
assert(
let all_seen = all_seen c i h0 p in
c.state.v i h1 block_state ==
c.update_multi_s i init_state 0 all_seen);
split_at_last_blocks c i (all_seen c i h0 p) (B.as_seq h0 data); // TODO: remove?
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.sub data 0ul data1_len in
let data2 = B.sub data data1_len data2_len in
c.update_multi (G.hide i) block_state total_len data1 data1_len;
let h01 = ST.get () in
optional_frame #_ #i #c.km #c.key (c.state.footprint h0 block_state) k' h0 h01;
assert(preserves_freeable c i p h0 h01);
begin
let all_seen = all_seen c i h0 p in
let data1_v = B.as_seq h01 data1 in
c.update_multi_associative i init_state 0 (Seq.length all_seen) all_seen data1_v;
assert(c.state.v i h01 block_state == c.update_multi_s i init_state 0 (Seq.append all_seen data1_v))
end;
let dst = B.sub buf 0ul data2_len in
let h1 = ST.get () in
B.blit data2 0ul dst 0ul data2_len;
let h2 = ST.get () in
c.state.frame_invariant (B.loc_buffer buf) block_state h1 h2;
optional_frame #_ #i #c.km #c.key (B.loc_buffer buf) k' h1 h2;
stateful_frame_preserves_freeable #index #(Block?.state c) #i
(B.loc_buffer dst)
(State?.block_state s) h1 h2;
assert(preserves_freeable c i p h01 h2);
[@inline_let]
let total_len' = add_len c i total_len len in
[@inline_let]
let tmp: state_s c i t t' = State #index #c #i block_state buf total_len'
(seen `S.append` B.as_seq h0 data) k'
in
p *= tmp;
let h3 = ST.get () in
c.state.frame_invariant (B.loc_buffer p) block_state h2 h3;
optional_frame #_ #i #c.km #c.key (B.loc_buffer p) k' h2 h3;
stateful_frame_preserves_freeable #index #(Block?.state c) #i
(B.loc_buffer p)
(State?.block_state s) h2 h3;
assert(preserves_freeable c i p h2 h3);
assert(preserves_freeable c i p h0 h3);
update_empty_or_full_functional_correctness #index c i t t' p data len h0 h3;
(* The following proof obligation is the difficult one - keep it here for
* easy debugging when updating the definitions/proofs *)
assert(invariant_s c i h3 (B.get h3 p 0))
#pop-options
/// Case 3: we are given just enough data to end up on the boundary. It is just
/// a sub-case of [update_small], but with a little bit more precise pre and post
/// conditions.
inline_for_extraction noextract
val update_round:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\ (
let r = rest c i (total_len_h c i h0 s) in
U32.v len + U32.v r = U32.v (c.blocks_state_len i) /\
r <> 0ul))
(ensures fun h0 _ h1 ->
update_post c i s data len h0 h1 /\
begin
let blocks, rest = split_at_last_all_seen c i h0 s in
let blocks', rest' = split_at_last_all_seen c i h1 s in
blocks' `S.equal` blocks /\
rest' `S.equal` S.append rest (B.as_seq h0 data) /\
S.length rest' = U32.v (c.blocks_state_len i)
end)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Hacl.Streaming.Interface.block index ->
i: index ->
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)} ->
s: Hacl.Streaming.Functor.state c i t t' ->
data: LowStar.Buffer.buffer Hacl.Streaming.Spec.uint8 ->
len: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Streaming.Interface.block",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Spec.uint8",
"FStar.UInt32.t",
"Hacl.Streaming.Spec.bytes",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Functor.split_at_last_all_seen",
"Hacl.Streaming.Spec.split_at_last_small",
"Hacl.Streaming.Functor.all_seen",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Buffer.trivial_preorder",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Streaming.Functor.update_small",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"FStar.Integers.int_t",
"FStar.Integers.Signed",
"FStar.Integers.Winfinite",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Interface.uint8",
"Prims.l_and",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"FStar.UInt32.v",
"Hacl.Streaming.Interface.__proj__Block__item__block_len",
"FStar.Seq.Base.length",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Block__item__max_input_len",
"Prims.squash",
"FStar.Seq.Base.append",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_s",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_associative",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"LowStar.Monotonic.Buffer.loc_in",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant_loc_in_footprint"
] | [] | false | true | false | false | false | let update_round #index c i t t' p data len =
| [@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.update_multi_associative i in
let open LowStar.BufferOps in
let h0 = ST.get () in
update_small #index c i t t' p data len;
let h1 = ST.get () in
split_at_last_small c i (all_seen c i h0 p) (B.as_seq h0 data);
let blocks, rest = split_at_last_all_seen c i h0 p in
let blocks', rest' = split_at_last_all_seen c i h1 p in
() | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.qsqr | val qsqr: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res /\
as_nat h x < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res = (as_nat h0 x * as_nat h0 x * SM.qmont_R_inv) % S.order /\
qmont_as_nat h1 res = S.qmul (qmont_as_nat h0 x) (qmont_as_nat h0 x)) | val qsqr: res:felem -> x:felem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ eq_or_disjoint x res /\
as_nat h x < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res = (as_nat h0 x * as_nat h0 x * SM.qmont_R_inv) % S.order /\
qmont_as_nat h1 res = S.qmul (qmont_as_nat h0 x) (qmont_as_nat h0 x)) | let qsqr res x =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
bn_sqr4 tmp x;
let h1 = ST.get () in
Math.Lemmas.lemma_mult_lt_sqr (as_nat h0 x) (as_nat h0 x) S.order;
qmont_reduction res tmp;
SM.qmont_mul_lemma (as_nat h0 x) (as_nat h0 x);
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 180,
"start_col": 0,
"start_line": 171
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order
[@CInline]
let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame ()
[@CInline]
let qadd res x y =
let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame ()
val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order)
[@CInline]
let qmont_reduction res x =
push_frame ();
let n = create_felem () in
make_order n;
let h0 = ST.get () in
BM.bn_mont_reduction Hacl.Bignum256.bn_inst n (u64 0xccd1c8aaee00bc4f) x res;
SM.bn_qmont_reduction_lemma (as_seq h0 x) (as_seq h0 n);
pop_frame ()
[@CInline]
let from_qmont res x =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
update_sub tmp 0ul 4ul x;
BD.bn_eval_update_sub 4 (as_seq h0 x) 8;
let h1 = ST.get () in
assert (wide_as_nat h1 tmp = as_nat h0 x);
assert_norm (S.order < S.order * S.order);
qmont_reduction res tmp;
pop_frame ()
[@CInline]
let qmul res x y =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
bn_mul4 tmp x y;
let h1 = ST.get () in
Math.Lemmas.lemma_mult_lt_sqr (as_nat h0 x) (as_nat h0 y) S.order;
qmont_reduction res tmp;
SM.qmont_mul_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.qmont_mul_lemma",
"Hacl.Impl.P256.Bignum.as_nat",
"Hacl.Impl.P256.Scalar.qmont_reduction",
"FStar.Math.Lemmas.lemma_mult_lt_sqr",
"Spec.P256.PointOps.order",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Bignum.bn_sqr4",
"Hacl.Impl.P256.Bignum.widefelem",
"Hacl.Impl.P256.Bignum.create_widefelem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let qsqr res x =
| push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
bn_sqr4 tmp x;
let h1 = ST.get () in
Math.Lemmas.lemma_mult_lt_sqr (as_nat h0 x) (as_nat h0 x) S.order;
qmont_reduction res tmp;
SM.qmont_mul_lemma (as_nat h0 x) (as_nat h0 x);
pop_frame () | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.load_qelem_conditional | val load_qelem_conditional: res:felem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
let is_b_valid = 0 < b_nat && b_nat < S.order in
(v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\
as_nat h1 res == (if is_b_valid then b_nat else 1))) | val load_qelem_conditional: res:felem -> b:lbuffer uint8 32ul -> Stack uint64
(requires fun h ->
live h res /\ live h b /\ disjoint res b)
(ensures fun h0 m h1 -> modifies (loc res) h0 h1 /\
(let b_nat = BSeq.nat_from_bytes_be (as_seq h0 b) in
let is_b_valid = 0 < b_nat && b_nat < S.order in
(v m = ones_v U64 \/ v m = 0) /\ (v m = ones_v U64) = is_b_valid /\
as_nat h1 res == (if is_b_valid then b_nat else 1))) | let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 12,
"end_line": 80,
"start_col": 0,
"start_line": 68
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul
-> FStar.HyperStack.ST.Stack Lib.IntTypes.uint64 | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint64",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.op_Equality",
"Prims.int",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.bool",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.ByteBuffer.buf_mask_select",
"Hacl.Impl.P256.Bignum.bn_set_one4",
"Hacl.Impl.P256.Bignum.create_felem",
"Lib.IntTypes.int_t",
"Hacl.Impl.P256.Scalar.bn_is_lt_order_and_gt_zero_mask4",
"Hacl.Impl.P256.Bignum.bn_from_bytes_be4",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let load_qelem_conditional res b =
| push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.qmul | val qmul: res:felem -> x:felem -> y:felem -> Stack unit
(requires fun h ->
live h x /\ live h y /\ live h res /\
eq_or_disjoint x y /\ eq_or_disjoint x res /\ eq_or_disjoint y res /\
as_nat h x < S.order /\ as_nat h y < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res = (as_nat h0 x * as_nat h0 y * SM.qmont_R_inv) % S.order /\
qmont_as_nat h1 res = S.qmul (qmont_as_nat h0 x) (qmont_as_nat h0 y)) | val qmul: res:felem -> x:felem -> y:felem -> Stack unit
(requires fun h ->
live h x /\ live h y /\ live h res /\
eq_or_disjoint x y /\ eq_or_disjoint x res /\ eq_or_disjoint y res /\
as_nat h x < S.order /\ as_nat h y < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res = (as_nat h0 x * as_nat h0 y * SM.qmont_R_inv) % S.order /\
qmont_as_nat h1 res = S.qmul (qmont_as_nat h0 x) (qmont_as_nat h0 y)) | let qmul res x y =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
bn_mul4 tmp x y;
let h1 = ST.get () in
Math.Lemmas.lemma_mult_lt_sqr (as_nat h0 x) (as_nat h0 y) S.order;
qmont_reduction res tmp;
SM.qmont_mul_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 167,
"start_col": 0,
"start_line": 158
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order
[@CInline]
let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame ()
[@CInline]
let qadd res x y =
let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame ()
val qmont_reduction: res:felem -> x:widefelem -> Stack unit
(requires fun h ->
live h x /\ live h res /\ disjoint x res /\
wide_as_nat h x < S.order * S.order)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc x) h0 h1 /\
as_nat h1 res == wide_as_nat h0 x * SM.qmont_R_inv % S.order)
[@CInline]
let qmont_reduction res x =
push_frame ();
let n = create_felem () in
make_order n;
let h0 = ST.get () in
BM.bn_mont_reduction Hacl.Bignum256.bn_inst n (u64 0xccd1c8aaee00bc4f) x res;
SM.bn_qmont_reduction_lemma (as_seq h0 x) (as_seq h0 n);
pop_frame ()
[@CInline]
let from_qmont res x =
push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
update_sub tmp 0ul 4ul x;
BD.bn_eval_update_sub 4 (as_seq h0 x) 8;
let h1 = ST.get () in
assert (wide_as_nat h1 tmp = as_nat h0 x);
assert_norm (S.order < S.order * S.order);
qmont_reduction res tmp;
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem -> y: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.qmont_mul_lemma",
"Hacl.Impl.P256.Bignum.as_nat",
"Hacl.Impl.P256.Scalar.qmont_reduction",
"FStar.Math.Lemmas.lemma_mult_lt_sqr",
"Spec.P256.PointOps.order",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Bignum.bn_mul4",
"Hacl.Impl.P256.Bignum.widefelem",
"Hacl.Impl.P256.Bignum.create_widefelem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let qmul res x y =
| push_frame ();
let tmp = create_widefelem () in
let h0 = ST.get () in
bn_mul4 tmp x y;
let h1 = ST.get () in
Math.Lemmas.lemma_mult_lt_sqr (as_nat h0 x) (as_nat h0 y) S.order;
qmont_reduction res tmp;
SM.qmont_mul_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame () | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_cons' | val valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) | val valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) | let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 63,
"end_line": 129,
"start_col": 0,
"start_line": 109
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires n > 0 /\ LowParse.Low.Base.Spec.valid p h sl pos)
(ensures
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos <==>
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1) /\
(LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1 ==>
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos ==
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
pos1))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Classical.move_requires",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.unit",
"Prims.op_Addition",
"LowParse.Low.VCList.valid_nlist_cons",
"Prims.squash",
"Prims.l_iff",
"Prims.l_imp",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid p h sl pos))
(ensures
(let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==>
get_valid_pos (parse_nlist n p) h sl pos ==
get_valid_pos (parse_nlist (n - 1) p) h sl pos1))) =
| Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_valid_list | val valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) | val valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) | let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 293,
"start_col": 0,
"start_line": 263
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
Mkparser_kind'?.parser_kind_low k > 0 /\
Mkparser_kind'?.parser_kind_subkind k ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)
(ensures
(let pos' =
LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos
in
LowParse.Low.Base.Spec.valid_list p h sl pos pos' /\
LowParse.Low.Base.Spec.contents_list p h sl pos pos' ==
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist n p) h sl pos)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_Equality",
"Prims.int",
"LowParse.Low.Base.Spec.valid_list_nil",
"Prims.unit",
"LowParse.Low.VCList.valid_nlist_nil_recip",
"Prims.bool",
"LowParse.Low.Base.Spec.valid_list_cons",
"LowParse.Low.VCList.valid_nlist_valid_list",
"Prims.op_Subtraction",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_list",
"Prims.list",
"LowParse.Low.Base.Spec.contents_list",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(k.parser_kind_low > 0 /\ k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos))
(ensures
(let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos)) =
| if n = 0
then
(valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos)
else
(valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos') | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_list_valid_nlist | val valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) | val valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) | let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 322,
"start_col": 0,
"start_line": 295
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t ->
pos': FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires LowParse.Low.Base.Spec.valid_list p h sl pos pos')
(ensures
(let x = LowParse.Low.Base.Spec.contents_list p h sl pos pos' in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (FStar.List.Tot.Base.length
x)
p)
h
sl
pos
x
pos'))
(decreases FStar.UInt32.v pos' - FStar.UInt32.v pos) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_Equality",
"LowParse.Low.VCList.valid_nlist_nil",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_list_nil",
"Prims.bool",
"LowParse.Low.VCList.valid_nlist_cons",
"FStar.List.Tot.Base.length",
"LowParse.Low.Base.Spec.contents_list",
"LowParse.Low.VCList.valid_list_valid_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.valid_list_cons_recip",
"LowParse.Low.Base.Spec.valid_list",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.list",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos pos': U32.t)
: Lemma (requires (valid_list p h sl pos pos'))
(ensures
(let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'))
(decreases (U32.v pos' - U32.v pos)) =
| if pos = pos'
then
(valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos)
else
(valid_list_cons_recip p h sl pos pos';
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos';
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos) | false |
ArrayRealized.fst | ArrayRealized.index | val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a | val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a | let index (Seq c j k) i = __index__ c (i + j) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 45,
"end_line": 44,
"start_col": 0,
"start_line": 44
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: ArrayRealized.seq 'a -> i: Prims.nat{ArrayRealized.length s > i} -> 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"ArrayRealized.length",
"ArrayRealized.contents",
"Prims.op_GreaterThanOrEqual",
"ArrayRealized.__index__",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let index (Seq c j k) i =
| __index__ c (i + j) | false |
Hacl.Impl.P256.Scalar.fst | Hacl.Impl.P256.Scalar.qadd | val qadd: res:felem -> x:felem -> y:felem -> Stack unit
(requires fun h ->
live h x /\ live h y /\ live h res /\
eq_or_disjoint x y /\ eq_or_disjoint x res /\ eq_or_disjoint y res /\
as_nat h x < S.order /\ as_nat h y < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == S.qadd (as_nat h0 x) (as_nat h0 y) /\
qmont_as_nat h1 res == S.qadd (qmont_as_nat h0 x) (qmont_as_nat h0 y)) | val qadd: res:felem -> x:felem -> y:felem -> Stack unit
(requires fun h ->
live h x /\ live h y /\ live h res /\
eq_or_disjoint x y /\ eq_or_disjoint x res /\ eq_or_disjoint y res /\
as_nat h x < S.order /\ as_nat h y < S.order)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_nat h1 res == S.qadd (as_nat h0 x) (as_nat h0 y) /\
qmont_as_nat h1 res == S.qadd (qmont_as_nat h0 x) (qmont_as_nat h0 y)) | let qadd res x y =
let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame () | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.Scalar.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 121,
"start_col": 0,
"start_line": 112
} | module Hacl.Impl.P256.Scalar
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Constants
module S = Spec.P256
module SM = Hacl.Spec.P256.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
module BM = Hacl.Bignum.Montgomery
friend Hacl.Bignum256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
/// Create one
[@CInline]
let make_qone f =
[@inline_let] let f0 = u64 0xc46353d039cdaaf in
[@inline_let] let f1 = u64 0x4319055258e8617b in
[@inline_let] let f2 = u64 0x0 in
[@inline_let] let f3 = u64 0xffffffff in
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 < S.order);
assert_norm (v f0 + v f1 * pow2 64 + v f2 * pow2 128 + v f3 * pow2 192 == SM.to_qmont 1);
SM.lemma_to_from_qmont_id 1;
bn_make_u64_4 f f0 f1 f2 f3
/// Comparison
[@CInline]
let bn_is_lt_order_mask4 f =
let h0 = ST.get () in
push_frame ();
let tmp = create_felem () in
make_order tmp;
let c = bn_sub4 tmp f tmp in
assert (if v c = 0 then as_nat h0 f >= S.order else as_nat h0 f < S.order);
pop_frame ();
u64 0 -. c
[@CInline]
let bn_is_lt_order_and_gt_zero_mask4 f =
let h0 = ST.get () in
let is_lt_order = bn_is_lt_order_mask4 f in
assert (v is_lt_order = (if as_nat h0 f < S.order then ones_v U64 else 0));
let is_eq_zero = bn_is_zero_mask4 f in
assert (v is_eq_zero = (if as_nat h0 f = 0 then ones_v U64 else 0));
lognot_lemma is_eq_zero;
assert (v (lognot is_eq_zero) = (if 0 < as_nat h0 f then ones_v U64 else 0));
let res = logand is_lt_order (lognot is_eq_zero) in
logand_lemma is_lt_order (lognot is_eq_zero);
assert (v res == (if 0 < as_nat h0 f && as_nat h0 f < S.order then ones_v U64 else 0));
res
let load_qelem_conditional res b =
push_frame ();
bn_from_bytes_be4 res b;
let is_b_valid = bn_is_lt_order_and_gt_zero_mask4 res in
let oneq = create_felem () in
bn_set_one4 oneq;
let h0 = ST.get () in
Lib.ByteBuffer.buf_mask_select res oneq is_b_valid res;
let h1 = ST.get () in
assert (as_seq h1 res == (if (v is_b_valid = 0) then as_seq h0 oneq else as_seq h0 res));
pop_frame ();
is_b_valid
/// Field Arithmetic
val qmod_short_lemma: a:nat{a < pow2 256} ->
Lemma (let r = if a >= S.order then a - S.order else a in r = a % S.order)
let qmod_short_lemma a =
let r = if a >= S.order then a - S.order else a in
if a >= S.order then begin
Math.Lemmas.lemma_mod_sub a S.order 1;
assert_norm (pow2 256 - S.order < S.order);
Math.Lemmas.small_mod r S.order end
else
Math.Lemmas.small_mod r S.order
[@CInline]
let qmod_short res x =
push_frame ();
let tmp = create_felem () in
make_order tmp;
let h0 = ST.get () in
let c = bn_sub4 tmp x tmp in
bn_cmovznz4 res c tmp x;
BD.bn_eval_bound (as_seq h0 x) 4;
qmod_short_lemma (as_nat h0 x);
pop_frame () | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.P256.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Impl.P256.Constants.fst.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"Hacl.Bignum256.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.Scalar.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Constants",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.P256.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | res: Hacl.Impl.P256.Bignum.felem -> x: Hacl.Impl.P256.Bignum.felem -> y: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.P256.Montgomery.qmont_add_lemma",
"Hacl.Impl.P256.Bignum.as_nat",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Addition",
"Spec.P256.PointOps.order",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.P256.Bignum.bn_add_mod4",
"Hacl.Impl.P256.Constants.make_order",
"Hacl.Impl.P256.Bignum.create_felem",
"FStar.HyperStack.ST.push_frame"
] | [] | false | true | false | false | false | let qadd res x y =
| let h0 = ST.get () in
push_frame ();
let n = create_felem () in
make_order n;
bn_add_mod4 res n x y;
let h1 = ST.get () in
assert (as_nat h1 res == (as_nat h0 x + as_nat h0 y) % S.order);
SM.qmont_add_lemma (as_nat h0 x) (as_nat h0 y);
pop_frame () | false |
ArrayRealized.fst | ArrayRealized.update | val update: s:seq 'a -> i:nat{length s > i} -> v:'a -> Tot (seq 'a) | val update: s:seq 'a -> i:nat{length s > i} -> v:'a -> Tot (seq 'a) | let update (Seq c j k) i v = Seq (__update__ c (i + j) v) j k | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 61,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1)
val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a
let index (Seq c j k) i = __index__ c (i + j)
val __update__: contents 'a -> int -> 'a -> Tot (contents 'a)
let rec __update__ c i v = match c with
| Const _
| Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: ArrayRealized.seq 'a -> i: Prims.nat{ArrayRealized.length s > i} -> v: 'a -> ArrayRealized.seq 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_GreaterThan",
"ArrayRealized.length",
"ArrayRealized.contents",
"Prims.op_GreaterThanOrEqual",
"ArrayRealized.Seq",
"ArrayRealized.__update__",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let update (Seq c j k) i v =
| Seq (__update__ c (i + j) v) j k | false |
Vale.Lib.Seqs.fsti | Vale.Lib.Seqs.list_to_seq_post | val list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) | val list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) | let rec list_to_seq_post (#a:Type) (l:list a) (s:seq a) (n:nat) : Pure prop
(requires n + List.length l == Seq.length s)
(ensures fun _ -> True)
(decreases l)
=
match l with
| [] -> n == Seq.length s
| h::t -> Seq.index s n == h /\ list_to_seq_post t s (n + 1) | {
"file_name": "vale/code/lib/collections/Vale.Lib.Seqs.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 63,
"start_col": 0,
"start_line": 56
} | module Vale.Lib.Seqs
open FStar.Mul
open Vale.Lib.Seqs_s
open FStar.Seq
val lemma_slice_first_exactly_in_append (#a:Type) (x y:seq a) :
Lemma (slice (append x y) 0 (length x) == x)
val lemma_all_but_last_append (#t:Type) (a:seq t) (b:seq t{length b > 0}) :
Lemma (all_but_last (append a b) == append a (all_but_last b))
val reverse_seq_append (#a:eqtype) (s:seq a) (t:seq a) :
Lemma(ensures reverse_seq (append s t) == append (reverse_seq t) (reverse_seq s))
val reverse_reverse_seq (#a:Type) (s:seq a) :
Lemma(ensures reverse_seq (reverse_seq s) == s)
[SMTPat (reverse_seq (reverse_seq s))]
val seq_map_i_indexed (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) (i:int) :
Tot (s':seq b { length s' == length s /\
(forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f (i + j) (index s j))
})
val seq_map_i (#a:Type) (#b:Type) (f:int->a->b) (s:seq a) :
Tot (s':seq b { length s' == length s /\
(forall j . {:pattern index s' j} 0 <= j /\ j < length s ==> index s' j == f j (index s j))
})
val seq_map_internal_associative (#a:Type) (#b:eqtype) (f:int->a->b) (s:seq a) (pivot:int{0 <= pivot /\ pivot < length s}) :
Lemma (let left,right = split s pivot in
seq_map_i f s == seq_map_i_indexed f left 0 @| seq_map_i_indexed f right pivot )
val seq_map_inverses (#a #b:Type) (f:a -> b) (g:b -> a) (s:seq a) : Lemma
(requires forall x . g (f x) == x)
(ensures seq_map g (seq_map f s) == s)
val slice_append_adds (#a:Type) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) :
Lemma (slice s 0 i @| slice s i j == slice s 0 j)
val slice_seq_map_commute (#a #b:Type) (f:a -> b) (s:seq a) (i:nat) (j:nat{ i <= j /\ j <= length s }) :
Lemma (slice (seq_map f s) i j == seq_map f (slice s i j))
val append_distributes_seq_map (#a #b:Type) (f:a -> b) (s1 s2:seq a) :
Lemma (seq_map f (s1 @| s2) == seq_map f s1 @| seq_map f s2)
val seq_map_injective (#a #b:Type) (f:a -> b) (s s':seq a) : Lemma
(requires (forall (x x':a).{:pattern (f x); (f x')} f x == f x' ==> x == x') /\ seq_map f s == seq_map f s')
(ensures s == s')
val list_to_seq (#a:Type) (l:list a) : Pure (seq a)
(requires True)
(ensures fun s -> Seq.length s == List.length l) | {
"checked_file": "/",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Lib.Seqs.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib",
"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 | l: Prims.list a -> s: FStar.Seq.Base.seq a -> n: Prims.nat -> Prims.Pure Prims.prop | Prims.Pure | [
""
] | [] | [
"Prims.list",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.eq2",
"FStar.Seq.Base.length",
"Prims.l_and",
"FStar.Seq.Base.index",
"Vale.Lib.Seqs.list_to_seq_post",
"Prims.op_Addition",
"Prims.prop",
"Prims.int",
"FStar.List.Tot.Base.length",
"Prims.l_True"
] | [
"recursion"
] | false | false | false | false | true | let rec list_to_seq_post (#a: Type) (l: list a) (s: seq a) (n: nat)
: Pure prop (requires n + List.length l == Seq.length s) (ensures fun _ -> True) (decreases l) =
| match l with
| [] -> n == Seq.length s
| h :: t -> Seq.index s n == h /\ list_to_seq_post t s (n + 1) | false |
ArrayRealized.fst | ArrayRealized.create | val create: n:nat -> init:'a -> Tot (seq 'a) | val create: n:nat -> init:'a -> Tot (seq 'a) | let create n init = Seq (Const init) 0 n | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 32,
"start_col": 0,
"start_line": 32
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: Prims.nat -> init: 'a -> ArrayRealized.seq 'a | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"ArrayRealized.Seq",
"ArrayRealized.Const",
"ArrayRealized.seq"
] | [] | false | false | false | true | false | let create n init =
| Seq (Const init) 0 n | false |
ArrayRealized.fst | ArrayRealized.length | val length: s:seq 'a -> Tot nat | val length: s:seq 'a -> Tot nat | let length s = Seq?.end_i s - Seq?.start_i s | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 35,
"start_col": 0,
"start_line": 35
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: ArrayRealized.seq 'a -> Prims.nat | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"Prims.op_Subtraction",
"ArrayRealized.__proj__Seq__item__end_i",
"ArrayRealized.__proj__Seq__item__start_i",
"Prims.nat"
] | [] | false | false | false | true | false | let length s =
| Seq?.end_i s - Seq?.start_i s | false |
ArrayRealized.fst | ArrayRealized.append | val append: seq 'a -> seq 'a -> Tot (seq 'a) | val append: seq 'a -> seq 'a -> Tot (seq 'a) | let append s1 s2 = Seq (Append s1 s2) 0 (length s1 + length s2) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 63,
"end_line": 65,
"start_col": 0,
"start_line": 65
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1)
val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a
let index (Seq c j k) i = __index__ c (i + j)
val __update__: contents 'a -> int -> 'a -> Tot (contents 'a)
let rec __update__ c i v = match c with
| Const _
| Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2))
val update: s:seq 'a -> i:nat{length s > i} -> v:'a -> Tot (seq 'a)
let update (Seq c j k) i v = Seq (__update__ c (i + j) v) j k
val slice: s:seq 'a -> i:nat -> j:nat{(i <= j /\ j <= length s)} -> Tot (seq 'a)
let slice (Seq c start_i end_i) i j = Seq c (start_i + i) (start_i + j)
val split: s:seq 'a -> i:nat{(0 <= i /\ i < length s)} -> Tot (seq 'a * seq 'a)
let split s i = slice s 0 i, slice s i (length s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s1: ArrayRealized.seq 'a -> s2: ArrayRealized.seq 'a -> ArrayRealized.seq 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"ArrayRealized.Seq",
"ArrayRealized.Append",
"Prims.op_Addition",
"ArrayRealized.length"
] | [] | false | false | false | true | false | let append s1 s2 =
| Seq (Append s1 s2) 0 (length s1 + length s2) | false |
ArrayRealized.fst | ArrayRealized.__update__ | val __update__: contents 'a -> int -> 'a -> Tot (contents 'a) | val __update__: contents 'a -> int -> 'a -> Tot (contents 'a) | let rec __update__ c i v = match c with
| Const _
| Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2)) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 102,
"end_line": 53,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1)
val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a
let index (Seq c j k) i = __index__ c (i + j) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: ArrayRealized.contents 'a -> i: Prims.int -> v: 'a -> ArrayRealized.contents 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.contents",
"Prims.int",
"ArrayRealized.Upd",
"ArrayRealized.seq",
"Prims.op_LessThan",
"ArrayRealized.length",
"ArrayRealized.Append",
"ArrayRealized.Seq",
"ArrayRealized.__update__",
"ArrayRealized.__proj__Seq__item__c",
"ArrayRealized.__proj__Seq__item__start_i",
"ArrayRealized.__proj__Seq__item__end_i",
"Prims.bool",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec __update__ c i v =
| match c with
| Const _ | Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2)) | false |
ArrayRealized.fst | ArrayRealized.__index__ | val __index__: contents 'a -> int -> Tot 'a | val __index__: contents 'a -> int -> Tot 'a | let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 108,
"end_line": 41,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: ArrayRealized.contents 'a -> i: Prims.int -> 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.contents",
"Prims.int",
"Prims.op_Equality",
"Prims.bool",
"ArrayRealized.__index__",
"ArrayRealized.seq",
"Prims.op_LessThan",
"ArrayRealized.length",
"ArrayRealized.__proj__Seq__item__c",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | true | false | let rec __index__ c i =
| match c with
| Const v -> v
| Upd j v tl -> if i = j then v else __index__ tl i
| Append s1 s2 ->
if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1) | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.reset | val reset:
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
reset_st #index c i t t') | val reset:
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
reset_st #index c i t t') | let reset #index c i t t' state key =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
(**) let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i; // This is only used in types and proofs
[@inline_let]
let block_state: c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
(**) let h2 = ST.get () in
(**) optional_frame #_ #i #c.km #c.key (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) k' h1 h2;
(**) c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) key h1 h2;
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % UInt32.v (Block?.block_len c i) = 0);
(**) assert (reveal_key c i h1 state == reveal_key c i h2 state);
(**) c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
(**) c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
(**) stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased ->
G.hide (c.key.v i h1 key)
in
(**) let h2 = ST.get () in
(**) assert(preserves_freeable c i state h1 h2);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp: state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
(**) let h3 = ST.get () in
(**) c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
(**) c.key.frame_invariant B.(loc_buffer state) key h2 h3;
(**) optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
(**) stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
(**) assert(preserves_freeable c i state h2 h3);
// This seems to cause insurmountable difficulties. Puzzled.
ST.lemma_equal_domains_trans h1 h2 h3;
// AR: 07/22: same old `Seq.equal` and `==` story
(**) assert (Seq.equal (seen c i h3 state) Seq.empty);
(**) assert (footprint c i h1 state == footprint c i h3 state);
(**) assert (B.(modifies (footprint c i h1 state) h1 h3));
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h3 state in
(**) let all_seen_ = all_seen c i h3 state in
// SH (11/22): the proof fails if we don't introduce the call to [split_at_last]
(**) let blocks, rest = split_at_last c i all_seen_ in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert (invariant_s c i h3 (B.get h3 state 0))
(**) end;
(**) assert(preserves_freeable c i state h1 h3) | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 625,
"start_col": 0,
"start_line": 557
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options
#push-options "--z3rlimit 200"
let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Hacl.Streaming.Interface.block index -> i: FStar.Ghost.erased index
-> (let i = FStar.Ghost.reveal i in
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)}
-> Hacl.Streaming.Functor.reset_st c (FStar.Ghost.hide i) t t') | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"FStar.Ghost.erased",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"FStar.Ghost.reveal",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"FStar.Ghost.hide",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"FStar.UInt64.t",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.uint8",
"Prims._assert",
"Hacl.Streaming.Functor.preserves_freeable",
"Prims.unit",
"Hacl.Streaming.Spec.bytes",
"Hacl.Streaming.Functor.invariant_s",
"LowStar.Monotonic.Buffer.get",
"Hacl.Streaming.Functor.state_s",
"Hacl.Streaming.Spec.split_at_last_init",
"Hacl.Streaming.Interface.uint8",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.Seq.Base.length",
"FStar.UInt32.v",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_len",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_s",
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Spec.split_at_last",
"Hacl.Streaming.Functor.bytes",
"Hacl.Streaming.Functor.all_seen",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Functor.reveal_key",
"Prims.op_LessThanOrEqual",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Block__item__max_input_len",
"LowStar.Monotonic.Buffer.modifies",
"Hacl.Streaming.Functor.footprint",
"LowStar.Monotonic.Buffer.loc",
"FStar.Seq.Base.equal",
"Hacl.Streaming.Functor.seen",
"FStar.Seq.Base.empty",
"FStar.HyperStack.ST.lemma_equal_domains_trans",
"Hacl.Streaming.Functor.stateful_frame_preserves_freeable",
"LowStar.Monotonic.Buffer.loc_buffer",
"Hacl.Streaming.Functor.optional_frame",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_invariant",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.__uint_to_t",
"Hacl.Streaming.Functor.State",
"FStar.Int.Cast.uint32_to_uint64",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"Hacl.Streaming.Interface.__proj__Stateful__item__copy",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_zero",
"Prims.op_Modulus",
"Hacl.Streaming.Interface.__proj__Block__item__block_len",
"FStar.Math.Lemmas.modulo_lemma",
"LowStar.Monotonic.Buffer.loc_union",
"Hacl.Streaming.Interface.__proj__Block__item__init",
"LowStar.Ignore.ignore",
"Hacl.Streaming.Interface.__proj__Block__item__index_of_state",
"LowStar.BufferOps.op_Bang_Star",
"FStar.Pervasives.allow_inversion",
"Hacl.Streaming.Interface.key_management",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_in",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant_loc_in_footprint"
] | [] | false | false | false | false | false | let reset #index c i t t' state key =
| [@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i;
[@@ inline_let ]let block_state:c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
let h2 = ST.get () in
optional_frame #_
#i
#c.km
#c.key
(B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf))
k'
h1
h2;
c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf))
key
h1
h2;
Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
assert (0 % UInt32.v (Block?.block_len c i) = 0);
assert (reveal_key c i h1 state == reveal_key c i h2 state);
c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k':optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
let h4 = ST.get () in
assert (c.key.invariant #i h4 k');
c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased -> G.hide (c.key.v i h1 key)
in
let h2 = ST.get () in
assert (preserves_freeable c i state h1 h2);
[@@ inline_let ]let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp:state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
let h3 = ST.get () in
c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
c.key.frame_invariant B.(loc_buffer state) key h2 h3;
optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
assert (preserves_freeable c i state h2 h3);
ST.lemma_equal_domains_trans h1 h2 h3;
assert (Seq.equal (seen c i h3 state) Seq.empty);
assert (footprint c i h1 state == footprint c i h3 state);
assert (let open B in modifies (footprint c i h1 state) h1 h3);
assert (U64.v total_len <= U64.v (c.max_input_len i));
(let key_v = reveal_key c i h3 state in
let all_seen_ = all_seen c i h3 state in
let blocks, rest = split_at_last c i all_seen_ in
let init_input = c.init_input_s i key_v in
split_at_last_init c i init_input;
assert (invariant_s c i h3 (B.get h3 state 0)));
assert (preserves_freeable c i state h1 h3) | false |
ArrayRealized.fst | ArrayRealized.split | val split: s:seq 'a -> i:nat{(0 <= i /\ i < length s)} -> Tot (seq 'a * seq 'a) | val split: s:seq 'a -> i:nat{(0 <= i /\ i < length s)} -> Tot (seq 'a * seq 'a) | let split s i = slice s 0 i, slice s i (length s) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 49,
"end_line": 62,
"start_col": 0,
"start_line": 62
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1)
val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a
let index (Seq c j k) i = __index__ c (i + j)
val __update__: contents 'a -> int -> 'a -> Tot (contents 'a)
let rec __update__ c i v = match c with
| Const _
| Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2))
val update: s:seq 'a -> i:nat{length s > i} -> v:'a -> Tot (seq 'a)
let update (Seq c j k) i v = Seq (__update__ c (i + j) v) j k
val slice: s:seq 'a -> i:nat -> j:nat{(i <= j /\ j <= length s)} -> Tot (seq 'a)
let slice (Seq c start_i end_i) i j = Seq c (start_i + i) (start_i + j) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: ArrayRealized.seq 'a -> i: Prims.nat{0 <= i /\ i < ArrayRealized.length s}
-> ArrayRealized.seq 'a * ArrayRealized.seq 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"ArrayRealized.length",
"FStar.Pervasives.Native.Mktuple2",
"ArrayRealized.slice",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let split s i =
| slice s 0 i, slice s i (length s) | false |
ArrayRealized.fst | ArrayRealized.slice | val slice: s:seq 'a -> i:nat -> j:nat{(i <= j /\ j <= length s)} -> Tot (seq 'a) | val slice: s:seq 'a -> i:nat -> j:nat{(i <= j /\ j <= length s)} -> Tot (seq 'a) | let slice (Seq c start_i end_i) i j = Seq c (start_i + i) (start_i + j) | {
"file_name": "examples/data_structures/ArrayRealized.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 71,
"end_line": 59,
"start_col": 0,
"start_line": 59
} | (*
Copyright 2008-2014 Nikhil Swamy and Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
(* A logical theory of integer-indexed arrays, from [0, n) *)
module ArrayRealized
noeq type contents (a:Type u#a) : Type u#a =
| Const : v:a -> contents a
| Upd : ix:int -> v:a -> tl:contents a -> contents a
| Append : s1:seq a -> s2:seq a -> contents a
and seq (a:Type u#a) : Type u#a =
| Seq : c:contents a
-> start_i:nat
-> end_i:nat{end_i >= start_i}
-> seq a
val create: n:nat -> init:'a -> Tot (seq 'a)
let create n init = Seq (Const init) 0 n
val length: s:seq 'a -> Tot nat
let length s = Seq?.end_i s - Seq?.start_i s
val __index__: contents 'a -> int -> Tot 'a
let rec __index__ c i = match c with
| Const v -> v
| Upd j v tl -> if i=j then v else __index__ tl i
| Append s1 s2 -> if i < length s1 then __index__ (Seq?.c s1) i else __index__ (Seq?.c s2) (i - length s1)
val index: s:seq 'a -> i:nat{length s > i} -> Tot 'a
let index (Seq c j k) i = __index__ c (i + j)
val __update__: contents 'a -> int -> 'a -> Tot (contents 'a)
let rec __update__ c i v = match c with
| Const _
| Upd _ _ _ -> Upd i v c
| Append s1 s2 ->
if i < length s1
then Append (Seq (__update__ (Seq?.c s1) i v) (Seq?.start_i s1) (Seq?.end_i s1)) s2
else Append s1 (Seq (__update__ (Seq?.c s2) (i - length s1) v) (Seq?.start_i s2) (Seq?.end_i s2))
val update: s:seq 'a -> i:nat{length s > i} -> v:'a -> Tot (seq 'a)
let update (Seq c j k) i v = Seq (__update__ c (i + j) v) j k | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "ArrayRealized.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | s: ArrayRealized.seq 'a -> i: Prims.nat -> j: Prims.nat{i <= j /\ j <= ArrayRealized.length s}
-> ArrayRealized.seq 'a | Prims.Tot | [
"total"
] | [] | [
"ArrayRealized.seq",
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"ArrayRealized.length",
"ArrayRealized.contents",
"Prims.op_GreaterThanOrEqual",
"ArrayRealized.Seq",
"Prims.op_Addition"
] | [] | false | false | false | false | false | let slice (Seq c start_i end_i) i j =
| Seq c (start_i + i) (start_i + j) | false |
InsertionSort.fst | InsertionSort.insert_implicit | val insert_implicit : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m}) | val insert_implicit : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m}) | let rec insert_implicit i l = match l with
| [] -> [i]
| hd::tl ->
if i <= hd then i::l
else hd::(insert_implicit i tl) | {
"file_name": "examples/algorithms/InsertionSort.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 42,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2014 Nikhil Swamy, Chantal Keller, Catalin Hritcu
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 InsertionSort
open FStar.List.Tot
open IntSort
(* Explicitly calling sorted_smaller lemma
(otherwise verification takes a lot longer) *)
val insert : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m})
let rec insert i l = match l with
| [] -> [i]
| hd::tl ->
if i <= hd then i::l
else let i_tl = insert i tl in
let (z::_) = i_tl in
if mem z tl then sorted_smaller hd z tl;
hd::i_tl
(* Solver implicitly uses the lemma: sorted_smaller hd (Cons.hd i_tl) tl *)
val insert_implicit : i:int -> l:list int{sorted l} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"IntSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort.fst"
} | [
{
"abbrev": false,
"full_module": "IntSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.int -> l: Prims.list Prims.int {IntSort.sorted l}
-> m: Prims.list Prims.int {IntSort.sorted m /\ IntSort.permutation (i :: l) m} | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.list",
"Prims.b2t",
"IntSort.sorted",
"Prims.Cons",
"Prims.Nil",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"InsertionSort.insert_implicit",
"Prims.l_and",
"IntSort.permutation"
] | [
"recursion"
] | false | false | false | false | false | let rec insert_implicit i l =
| match l with
| [] -> [i]
| hd :: tl -> if i <= hd then i :: l else hd :: (insert_implicit i tl) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_cons_recip | val valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) | val valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) | let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1 | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 47,
"end_line": 105,
"start_col": 0,
"start_line": 75
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
n > 0 /\ LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p) h sl pos)
(ensures
LowParse.Low.Base.Spec.valid p h sl pos /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos) /\
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist n p)
h
sl
pos
(LowParse.Low.Base.Spec.contents p h sl pos ::
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist (n - 1) p) h sl pos1
)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (n - 1) p)
h
sl
pos1))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"Prims.op_Subtraction",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.unit",
"LowParse.Spec.VCList.parse_nlist_eq",
"LowParse.Slice.bytes_of_slice_from",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThan",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (n > 0 /\ valid (parse_nlist n p) h sl pos))
(ensures
(valid p h sl pos /\
(let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos (parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)))) =
| valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1 | false |
InsertionSort.fst | InsertionSort.insert | val insert : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m}) | val insert : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m}) | let rec insert i l = match l with
| [] -> [i]
| hd::tl ->
if i <= hd then i::l
else let i_tl = insert i tl in
let (z::_) = i_tl in
if mem z tl then sorted_smaller hd z tl;
hd::i_tl | {
"file_name": "examples/algorithms/InsertionSort.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 33,
"start_col": 0,
"start_line": 26
} | (*
Copyright 2008-2014 Nikhil Swamy, Chantal Keller, Catalin Hritcu
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 InsertionSort
open FStar.List.Tot
open IntSort
(* Explicitly calling sorted_smaller lemma
(otherwise verification takes a lot longer) *)
val insert : i:int -> l:list int{sorted l} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"IntSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort.fst"
} | [
{
"abbrev": false,
"full_module": "IntSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.int -> l: Prims.list Prims.int {IntSort.sorted l}
-> m: Prims.list Prims.int {IntSort.sorted m /\ IntSort.permutation (i :: l) m} | Prims.Tot | [
"total"
] | [] | [
"Prims.int",
"Prims.list",
"Prims.b2t",
"IntSort.sorted",
"Prims.Cons",
"Prims.Nil",
"Prims.op_LessThanOrEqual",
"Prims.bool",
"Prims.unit",
"FStar.List.Tot.Base.mem",
"IntSort.sorted_smaller",
"Prims.l_and",
"IntSort.permutation",
"InsertionSort.insert"
] | [
"recursion"
] | false | false | false | false | false | let rec insert i l =
| match l with
| [] -> [i]
| hd :: tl ->
if i <= hd
then i :: l
else
let i_tl = insert i tl in
let z :: _ = i_tl in
if mem z tl then sorted_smaller hd z tl;
hd :: i_tl | false |
InsertionSort.fst | InsertionSort.sort | val sort : l:list int -> Tot (m:list int{sorted m /\ permutation l m}) | val sort : l:list int -> Tot (m:list int{sorted m /\ permutation l m}) | let rec sort l = match l with
| [] -> []
| x::xs -> insert x (sort xs) | {
"file_name": "examples/algorithms/InsertionSort.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 48,
"start_col": 0,
"start_line": 46
} | (*
Copyright 2008-2014 Nikhil Swamy, Chantal Keller, Catalin Hritcu
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 InsertionSort
open FStar.List.Tot
open IntSort
(* Explicitly calling sorted_smaller lemma
(otherwise verification takes a lot longer) *)
val insert : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m})
let rec insert i l = match l with
| [] -> [i]
| hd::tl ->
if i <= hd then i::l
else let i_tl = insert i tl in
let (z::_) = i_tl in
if mem z tl then sorted_smaller hd z tl;
hd::i_tl
(* Solver implicitly uses the lemma: sorted_smaller hd (Cons.hd i_tl) tl *)
val insert_implicit : i:int -> l:list int{sorted l} ->
Tot (m:list int{sorted m /\ permutation (i::l) m})
let rec insert_implicit i l = match l with
| [] -> [i]
| hd::tl ->
if i <= hd then i::l
else hd::(insert_implicit i tl)
(* Insertion sort *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"IntSort.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "InsertionSort.fst"
} | [
{
"abbrev": false,
"full_module": "IntSort",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.list Prims.int -> m: Prims.list Prims.int {IntSort.sorted m /\ IntSort.permutation l m} | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.int",
"Prims.Nil",
"InsertionSort.insert",
"InsertionSort.sort",
"Prims.l_and",
"Prims.b2t",
"IntSort.sorted",
"IntSort.permutation"
] | [
"recursion"
] | false | false | false | false | false | let rec sort l =
| match l with
| [] -> []
| x :: xs -> insert x (sort xs) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_vclist_elim | val valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) | val valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) | let valid_vclist_elim
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_vclist min max lp p) h input pos))
(ensures (
valid lp h input pos /\ (
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p) h input pos1 x (get_valid_pos (parse_vclist min max lp p) h input pos)
)))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 54,
"end_line": 415,
"start_col": 0,
"start_line": 388
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1
inline_for_extraction
let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
lp:
LowParse.Spec.Base.parser lk FStar.UInt32.t
{ Mkparser_kind'?.parser_kind_subkind lk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_vclist min max lp p) h input pos)
(ensures
LowParse.Low.Base.Spec.valid lp h input pos /\
(let len = LowParse.Low.Base.Spec.contents lp h input pos in
let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let x =
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos
in
FStar.List.Tot.Base.length x == FStar.UInt32.v len /\
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v
len)
p)
h
input
pos1
x
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.contents",
"Prims.unit",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.List.Tot.Base.length",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let valid_vclist_elim
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid (parse_vclist min max lp p) h input pos))
(ensures
(valid lp h input pos /\
(let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p)
h
input
pos1
x
(get_valid_pos (parse_vclist min max lp p) h input pos)))) =
| valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.malloc | val malloc:
#index: Type0 ->
c:block index ->
i:index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
malloc_st c i t t' | val malloc:
#index: Type0 ->
c:block index ->
i:index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
malloc_st c i t t' | let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 367,
"start_col": 0,
"start_line": 268
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": 500,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Hacl.Streaming.Interface.block index ->
i: index ->
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)}
-> Hacl.Streaming.Functor.malloc_st c i t t' | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"FStar.Monotonic.HyperHeap.rid",
"Prims.unit",
"Prims._assert",
"FStar.HyperStack.ST.equal_stack_domains",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.loc_region_only",
"Hacl.Streaming.Functor.footprint",
"LowStar.Monotonic.Buffer.fresh_loc",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.uint8",
"Hacl.Streaming.Functor.seen",
"FStar.Seq.Base.empty",
"Hacl.Streaming.Functor.invariant",
"Hacl.Streaming.Functor.invariant_s",
"Hacl.Streaming.Spec.split_at_last_init",
"Hacl.Streaming.Interface.uint8",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.Seq.Base.length",
"FStar.UInt32.v",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_len",
"Hacl.Streaming.Interface.__proj__Block__item__init_input_s",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Functor.reveal_key",
"Hacl.Streaming.Functor.state_s",
"LowStar.Monotonic.Buffer.get",
"LowStar.Buffer.trivial_preorder",
"Prims.op_LessThanOrEqual",
"FStar.UInt64.v",
"Hacl.Streaming.Interface.__proj__Block__item__max_input_len",
"Hacl.Streaming.Functor.state",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"Hacl.Streaming.Interface.__proj__Block__item__init_s",
"Hacl.Streaming.Functor.optional_reveal",
"LowStar.Monotonic.Buffer.modifies_only_not_unused_in",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_zero",
"Hacl.Streaming.Functor.optional_frame",
"LowStar.Monotonic.Buffer.loc_union",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"LowStar.Monotonic.Buffer.loc_buffer",
"Lib.IntTypes.uint8",
"Hacl.Streaming.Interface.__proj__Block__item__init",
"FStar.Ghost.hide",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_freeable",
"Hacl.Streaming.Functor.footprint_s",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_invariant",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.Buffer.malloc",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.loc_unused_in_not_unused_in_disjoint",
"Hacl.Streaming.Functor.State",
"FStar.UInt64.t",
"FStar.Int.Cast.uint32_to_uint64",
"Hacl.Streaming.Functor.optional_footprint",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"Hacl.Streaming.Interface.__proj__Stateful__item__copy",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Hacl.Streaming.Interface.__proj__Stateful__item__create_in",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"Lib.IntTypes.u8",
"FStar.Pervasives.allow_inversion",
"Hacl.Streaming.Interface.key_management",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_in",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant_loc_in_footprint"
] | [] | false | false | false | false | false | let malloc #index c i t t' key r =
| [@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let h0 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
let h1 = ST.get () in
assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
B.loc_unused_in_not_unused_in_disjoint h1;
(let open B in modifies_only_not_unused_in loc_none h0 h1);
c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
let h2 = ST.get () in
assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
B.loc_unused_in_not_unused_in_disjoint h2;
(let open B in modifies_only_not_unused_in loc_none h1 h2);
c.key.frame_invariant B.loc_none key h1 h2;
let k':optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
let h3 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h3;
(let open B in modifies_only_not_unused_in loc_none h2 h3);
c.key.frame_invariant B.loc_none key h2 h3;
c.state.frame_invariant B.loc_none block_state h2 h3;
c.state.frame_freeable B.loc_none block_state h2 h3;
assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
assert (c.key.invariant #i h3 k');
assert (c.key.invariant #i h3 key);
assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
let h4 = ST.get () in
assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
B.loc_unused_in_not_unused_in_disjoint h4;
(let open B in modifies_only_not_unused_in loc_none h2 h4);
assert (c.key.invariant #i h4 k');
c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> G.hide (c.key.v i h0 key)
in
let h5 = ST.get () in
assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@@ inline_let ]let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
let h6 = ST.get () in
(let open B in modifies_only_not_unused_in loc_none h5 h6);
(let open B in modifies_only_not_unused_in loc_none h0 h6);
c.key.frame_invariant B.loc_none key h5 h6;
c.state.frame_invariant B.loc_none block_state h5 h6;
optional_frame B.loc_none k' h5 h6;
assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
c.state.frame_freeable B.loc_none block_state h5 h6;
assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
let h7 = ST.get () in
assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
c.update_multi_zero i (c.state.v i h7 block_state) 0;
B.modifies_only_not_unused_in B.loc_none h0 h7;
assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
let h8 = ST.get () in
assert (U64.v total_len <= U64.v (c.max_input_len i));
(let s = B.get h8 p 0 in
let key_v = reveal_key c i h8 p in
let init_input = c.init_input_s i key_v in
split_at_last_init c i init_input;
assert (invariant_s c i h8 s));
assert (invariant c i h8 p);
assert (seen c i h8 p == S.empty);
assert B.(modifies loc_none h0 h8);
assert (B.fresh_loc (footprint c i h8 p) h0 h8);
assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
assert (ST.equal_stack_domains h1 h8);
assert (ST.equal_stack_domains h0 h1);
p | false |
FStar.DM4F.IntStoreFixedReader.fst | FStar.DM4F.IntStoreFixedReader.return_isr | val return_isr (a: Type) (x: a) : int_store_reader a | val return_isr (a: Type) (x: a) : int_store_reader a | let return_isr (a:Type) (x:a) : int_store_reader a = fun store -> x | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixedReader.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 67,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixedReader
open FStar.DM4F.Heap.IntStoreFixed | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixedReader.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> x: a -> FStar.DM4F.IntStoreFixedReader.int_store_reader a | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.DM4F.IntStoreFixedReader.int_store_reader"
] | [] | false | false | false | true | false | let return_isr (a: Type) (x: a) : int_store_reader a =
| fun store -> x | false |
FStar.DM4F.IntStoreFixedReader.fst | FStar.DM4F.IntStoreFixedReader.bind_isr | val bind_isr (a b: Type) (x: int_store_reader a) (f: (a -> int_store_reader b)) : int_store_reader b | val bind_isr (a b: Type) (x: int_store_reader a) (f: (a -> int_store_reader b)) : int_store_reader b | let bind_isr (a b : Type) (x:int_store_reader a) (f: a -> int_store_reader b)
: int_store_reader b
= fun store ->
let z = x store in
f z store | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixedReader.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 26,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixedReader
open FStar.DM4F.Heap.IntStoreFixed
type int_store_reader (a:Type) = heap -> M a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixedReader.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Type ->
b: Type ->
x: FStar.DM4F.IntStoreFixedReader.int_store_reader a ->
f: (_: a -> FStar.DM4F.IntStoreFixedReader.int_store_reader b)
-> FStar.DM4F.IntStoreFixedReader.int_store_reader b | Prims.Tot | [
"total"
] | [] | [
"FStar.DM4F.IntStoreFixedReader.int_store_reader",
"FStar.DM4F.Heap.IntStoreFixed.heap"
] | [] | false | false | false | true | false | let bind_isr (a b: Type) (x: int_store_reader a) (f: (a -> int_store_reader b)) : int_store_reader b =
| fun store ->
let z = x store in
f z store | false |
FStar.DM4F.IntStoreFixedReader.fst | FStar.DM4F.IntStoreFixedReader.get | val get: Prims.unit -> int_store_reader heap | val get: Prims.unit -> int_store_reader heap | let get () : int_store_reader heap = fun store -> store | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixedReader.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 55,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixedReader
open FStar.DM4F.Heap.IntStoreFixed
type int_store_reader (a:Type) = heap -> M a
let return_isr (a:Type) (x:a) : int_store_reader a = fun store -> x
let bind_isr (a b : Type) (x:int_store_reader a) (f: a -> int_store_reader b)
: int_store_reader b
= fun store ->
let z = x store in
f z store | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixedReader.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: Prims.unit -> FStar.DM4F.IntStoreFixedReader.int_store_reader FStar.DM4F.Heap.IntStoreFixed.heap | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.DM4F.IntStoreFixedReader.int_store_reader"
] | [] | false | false | false | true | false | let get () : int_store_reader heap =
| fun store -> store | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.digest_process_begin_functional_correctness | val digest_process_begin_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
dst:B.buffer uint8 ->
l: c.output_length_t { B.length dst == c.output_length i l } ->
h0: HS.mem ->
h1: HS.mem ->
tmp_block_state: t ->
Lemma
(requires (
// The precondition of [digest]
invariant c i h0 s /\
c.state.invariant #i h1 tmp_block_state /\
begin
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let r = rest c i total_len in
(**) assert(U32.v r <= U64.v total_len);
let prev_len = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = rest_finish c i r in
(**) assert(U32.v r_last <= U32.v r);
let r_multi = U32.(r -^ r_last) in
let buf_multi = B.gsub buf_ 0ul r_multi in
let prev_length = U64.v prev_len in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
c.state.v i h1 tmp_block_state == c.update_multi_s i (c.state.v i h0 block_state) prev_length (B.as_seq h0 buf_multi)
end))
(ensures (
let all_seen = all_seen c i h0 s in
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let block_length = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length (S.length all_seen)) in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
let init_state = c.init_s i k in
(**) Math.Lemmas.modulo_lemma 0 block_length;
(**) Math.Lemmas.cancel_mul_mod n block_length;
(**) Math.Lemmas.nat_times_nat_is_nat n block_length;
(**) split_at_last_num_blocks_lem c i (S.length all_seen);
0 % block_length = 0 /\
0 <= n * block_length /\ (n * block_length) % block_length = 0 /\
c.state.v i h1 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (n * block_length)))
)) | val digest_process_begin_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
dst:B.buffer uint8 ->
l: c.output_length_t { B.length dst == c.output_length i l } ->
h0: HS.mem ->
h1: HS.mem ->
tmp_block_state: t ->
Lemma
(requires (
// The precondition of [digest]
invariant c i h0 s /\
c.state.invariant #i h1 tmp_block_state /\
begin
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let r = rest c i total_len in
(**) assert(U32.v r <= U64.v total_len);
let prev_len = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = rest_finish c i r in
(**) assert(U32.v r_last <= U32.v r);
let r_multi = U32.(r -^ r_last) in
let buf_multi = B.gsub buf_ 0ul r_multi in
let prev_length = U64.v prev_len in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
c.state.v i h1 tmp_block_state == c.update_multi_s i (c.state.v i h0 block_state) prev_length (B.as_seq h0 buf_multi)
end))
(ensures (
let all_seen = all_seen c i h0 s in
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let block_length = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length (S.length all_seen)) in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
let init_state = c.init_s i k in
(**) Math.Lemmas.modulo_lemma 0 block_length;
(**) Math.Lemmas.cancel_mul_mod n block_length;
(**) Math.Lemmas.nat_times_nat_is_nat n block_length;
(**) split_at_last_num_blocks_lem c i (S.length all_seen);
0 % block_length = 0 /\
0 <= n * block_length /\ (n * block_length) % block_length = 0 /\
c.state.v i h1 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (n * block_length)))
)) | let digest_process_begin_functional_correctness #index c i t t' p dst l h0 h1 tmp_block_state =
let h3 = h0 in
let h4 = h1 in
let s = B.get h0 p 0 in
let State block_state buf_ total_len seen k' = s in
let r = rest c i total_len in
let buf_ = B.gsub buf_ 0ul r in
let prev_len = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = rest_finish c i r in
let r_multi = U32.(r -^ r_last) in
let i = G.reveal i in
let all_seen = all_seen c i h0 p in
let block_length = U32.v (c.block_len i) in
let blocks_state_length = U32.v (c.blocks_state_len i) in
let k = optional_reveal #_ #i #c.km #c.key h0 k' in
let prev_length = U64.v prev_len in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length (S.length all_seen)) in
let init_state = c.init_s i k in
Math.Lemmas.modulo_lemma 0 block_length;
Math.Lemmas.cancel_mul_mod n block_length;
assert(prev_length + U32.v r = U64.v total_len);
assert(U32.v r_multi <= U32.v r);
assert(prev_length + U32.v r_multi <= U64.v total_len);
assert(n * block_length <= U64.v total_len);
let buf_multi = B.gsub buf_ 0ul r_multi in
assert(
c.state.v i h4 tmp_block_state ==
c.update_multi_s i (c.state.v i h0 block_state) prev_length (B.as_seq h3 buf_multi));
assert(
B.as_seq h3 buf_multi ==
S.slice all_seen prev_length (prev_length + U32.v r_multi));
assert(
c.state.v i h4 tmp_block_state ==
c.update_multi_s i
(c.update_multi_s i init_state 0 (S.slice all_seen 0 prev_length))
prev_length (S.slice all_seen prev_length (prev_length + U32.v r_multi)));
assert(0 % block_length = 0);
assert(S.length (S.slice all_seen 0 prev_length) % block_length = 0);
assert(prev_length + U32.v r_multi <= S.length all_seen);
c.update_multi_associative i init_state 0 prev_length
(S.slice all_seen 0 prev_length)
(S.slice all_seen prev_length (prev_length + U32.v r_multi));
assert(
S.equal (S.append (S.slice all_seen 0 prev_length)
(S.slice all_seen prev_length (prev_length + U32.v r_multi)))
(S.slice all_seen 0 (prev_length + U32.v r_multi)));
assert(
c.state.v i h4 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (prev_length + U32.v r_multi)));
split_at_last_finish c i all_seen;
Math.Lemmas.nat_times_nat_is_nat n block_length;
assert(0 <= n * block_length);
assert(n * block_length <= S.length all_seen);
assert(
c.state.v i h4 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (n * block_length))) | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 76,
"end_line": 1649,
"start_col": 0,
"start_line": 1591
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options
#push-options "--z3rlimit 200"
let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let reset #index c i t t' state key =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
(**) let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i; // This is only used in types and proofs
[@inline_let]
let block_state: c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
(**) let h2 = ST.get () in
(**) optional_frame #_ #i #c.km #c.key (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) k' h1 h2;
(**) c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) key h1 h2;
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % UInt32.v (Block?.block_len c i) = 0);
(**) assert (reveal_key c i h1 state == reveal_key c i h2 state);
(**) c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
(**) c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
(**) stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased ->
G.hide (c.key.v i h1 key)
in
(**) let h2 = ST.get () in
(**) assert(preserves_freeable c i state h1 h2);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp: state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
(**) let h3 = ST.get () in
(**) c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
(**) c.key.frame_invariant B.(loc_buffer state) key h2 h3;
(**) optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
(**) stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
(**) assert(preserves_freeable c i state h2 h3);
// This seems to cause insurmountable difficulties. Puzzled.
ST.lemma_equal_domains_trans h1 h2 h3;
// AR: 07/22: same old `Seq.equal` and `==` story
(**) assert (Seq.equal (seen c i h3 state) Seq.empty);
(**) assert (footprint c i h1 state == footprint c i h3 state);
(**) assert (B.(modifies (footprint c i h1 state) h1 h3));
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h3 state in
(**) let all_seen_ = all_seen c i h3 state in
// SH (11/22): the proof fails if we don't introduce the call to [split_at_last]
(**) let blocks, rest = split_at_last c i all_seen_ in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert (invariant_s c i h3 (B.get h3 state 0))
(**) end;
(**) assert(preserves_freeable c i state h1 h3)
#pop-options
/// Some helpers to minimize modulo-reasoning
/// =========================================
val split_at_last_num_blocks_lem (#index : Type0) (c: block index) (i: index) (b: nat):
Lemma (
let n_blocks = split_at_last_num_blocks c i b in
let blocks = n_blocks * U32.v (c.blocks_state_len i) in
0 <= blocks /\ blocks <= b)
let split_at_last_num_blocks_lem #index c i b = ()
/// The ``rest`` function below allows computing, based ``total_len`` stored in
/// the state, the length of useful data currently stored in ``buf``.
/// Unsurprisingly, there's a fair amount of modulo reasoning here because of
/// 64-bit-to-32-bit conversions, so we do them once and for all in a helper.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest #index (c: block index) (i: index)
(total_len: UInt64.t): (x:UInt32.t {
let n = split_at_last_num_blocks c i (U64.v total_len) in
let l = U32.v (c.blocks_state_len i) in
0 <= n * l /\ n * l <= U64.v total_len /\
U32.v x = U64.v total_len - (n * l)})
=
let open FStar.Int.Cast in
[@inline_let] let l = uint32_to_uint64 (c.blocks_state_len i) in
[@inline_let] let r = total_len `U64.rem` l in
(**) let total_len_v : Ghost.erased nat = U64.v total_len in
(**) let l_v : Ghost.erased nat = U64.v l in
(**) let r_v : Ghost.erased nat = U64.v r in
(**) assert(Ghost.reveal r_v = total_len_v - ((total_len_v / l_v) * l_v));
(**) Math.Lemmas.euclidean_division_definition total_len_v l_v;
(**) assert(Ghost.reveal r_v = total_len_v % l_v);
(**) assert(r_v < l_v);
if U64.(r =^ uint_to_t 0) && U64.(total_len >^ uint_to_t 0) then
begin
(**) split_at_last_num_blocks_lem c i (U64.v total_len);
c.blocks_state_len i
end
else
begin
[@inline_let] let r' = FStar.Int.Cast.uint64_to_uint32 r in
(**) FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32);
(**) calc (==) {
(**) U32.v r';
(**) (==) { }
(**) U64.v r % pow2 32;
(**) (==) { FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32) }
(**) U64.v r;
(**) (==) { FStar.Math.Lemmas.euclidean_division_definition (U64.v total_len) (U64.v (uint32_to_uint64 (c.blocks_state_len i))) }
(**) U64.v total_len % U64.v (uint32_to_uint64 (c.blocks_state_len i) );
(**) (==) { }
(**) U64.v total_len % U32.v (c.blocks_state_len i);
(**) };
(**) assert(
(**) let n = split_at_last_num_blocks c i (U64.v total_len) in
(**) let l = U32.v (c.blocks_state_len i) in
(**) U32.v r' = U64.v total_len - (n * l));
r'
end
#pop-options
/// The ``nblocks`` function below allows computing, given ``total_len`` stored in
/// the state, the number of blocks of data which have been processed (the remaining
/// unprocessed data being left in ``buf``).
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let nblocks #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.blocks_state_len i) in
U32.v x * l <= U32.v len /\
U32.v x = split_at_last_num_blocks c i (U32.v len) })
=
let open FStar.Int.Cast in
[@inline_let] let l = c.blocks_state_len i in
[@inline_let] let r = rest c i (uint32_to_uint64 len) in
(**) let len_v : Ghost.erased nat = U32.v len in
(**) let l_v : Ghost.erased nat = U32.v l in
(**) let r_v : Ghost.erased nat = U32.v r in
(**) let n_s : Ghost.erased nat = split_at_last_num_blocks c i len_v in
(**) assert(Ghost.reveal len_v = n_s * l_v + r_v);
(**) Math.Lemmas.nat_times_nat_is_nat n_s l_v;
(**) assert(U32.v r <= U32.v len);
[@inline_let] let blocks = len `U32.sub` r in
(**) let blocks_v : Ghost.erased nat = U32.v blocks in
(**) assert(blocks_v % l_v = 0);
[@inline_let] let n = blocks `U32.div` l in
(**) let n_v : Ghost.erased nat = U32.v n in
(**) assert(n_v * l_v = Ghost.reveal blocks_v);
(**) split_at_last_num_blocks_spec c i len_v n_v r_v;
n
#pop-options
/// The ``rest`` function to call on the unprocessed data length in the ``finish``
/// function.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest_finish #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
0 <= n * l /\ n * l <= U32.v len /\
U32.v x = U32.v len - (n * l)})
=
[@inline_let] let l = c.block_len i in
[@inline_let] let r = len `U32.rem` l in
(**) split_at_last_num_blocks_lem c i (U32.v len);
if U32.(r =^ uint_to_t 0) && U32.(len >^ uint_to_t 0) then
begin
(**) begin
(**) let l = U32.v (c.block_len i) in
(**) let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
(**) Math.Lemmas.nat_times_nat_is_nat n l
(**) end;
c.block_len i
end
else
r
#pop-options
/// We always add 32-bit lengths to 64-bit lengths. Having a helper for that allows
/// doing modulo reasoning once and for all.
inline_for_extraction noextract
let add_len #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t):
Pure UInt64.t
(requires U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures fun x -> U64.v x = U64.v total_len + U32.v len /\ U64.v x <= U64.v (c.max_input_len i))
=
total_len `U64.add` Int.Cast.uint32_to_uint64 len
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let add_len_small #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t): Lemma
(requires
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i total_len) /\
U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures (rest c i (add_len c i total_len len) = rest c i total_len `U32.add` len))
=
let total_len_v = U64.v total_len in
let l = U32.v (c.blocks_state_len i) in
let b = total_len_v + U32.v len in
let n = split_at_last_num_blocks c i total_len_v in
let r = U32.v (rest c i total_len) in
assert(total_len_v = n * l + r);
let r' = U32.v (rest c i total_len) + U32.v len in
assert(r' <= l);
assert(r' = 0 ==> b = 0);
Math.Lemmas.euclidean_division_definition b l;
assert(b = n * l + r');
split_at_last_num_blocks_spec c i b n r'
#pop-options
/// Beginning of the three sub-cases (see Hacl.Streaming.Spec)
/// ==========================================================
noextract
let total_len_h #index (c: block index) (i: index) h (p: state' c i) =
State?.total_len (B.deref h p)
noextract
let split_at_last_all_seen #index (c: block index) (i: index) h (p: state' c i) =
let all_seen = all_seen c i h p in
let blocks, rest = split_at_last c i all_seen in
blocks, rest
inline_for_extraction noextract
val update_small:
#index:Type0 ->
(c: block index) ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)))
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
/// SH: The proof obligations for update_small have problem succeeding in command
/// line mode: hence the restart-solver instruction, the crazy rlimit and the
/// intermediate lemma. Interestingly (and frustratingly), the proof succeeds
/// quite quickly locally on command-line with this rlimit, but fails with a lower
/// one. Besides, the lemma is needed only for the CI regression.
let split_at_last_rest_eq (#index : Type0) (c: block index)
(i: index)
(t:Type0 { t == c.state.s i })
(t':Type0 { t' == optional_key i c.km c.key })
(s: state c i t t') (h0: HS.mem) :
Lemma
(requires (
invariant c i h0 s))
(ensures (
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
Seq.length r == U32.v sz)) =
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
()
/// Particularly difficult proof. Z3 profiling indicates that a pattern goes off
/// the rails. So I disabled all of the known "bad" patterns, then did the proof
/// by hand. Fortunately, there were only two stateful operations. The idea was
/// to do all ofthe modifies-reasoning in the two lemmas above, then disable the
/// bad pattern for the main function.
///
/// This style is a little tedious, because it requires a little bit of digging
/// to understand what needs to hold in order to be able to prove that e.g. the
/// sequence remains unmodified from h0 to h2, but this seems more robust?
val modifies_footprint:
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
s:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State _ buf_ _ _ _ = B.deref h0 s in (
update_pre c i s data len h0 /\
B.(modifies (loc_buffer buf_) h0 h1))))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 s in
let State bs1 buf1 _ _ k1 = B.deref h1 s in (
footprint c i h0 s == footprint c i h1 s /\
preserves_freeable c i s h0 h1 /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1 /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_addr_of_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.state.footprint h1 bs1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_buffer s) (c.state.footprint h1 bs1)) /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer s) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer s) loc_none) /\
True)))))
let modifies_footprint c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf0 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_buffer buf0) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_buffer buf0) k0 h0 h1
val modifies_footprint':
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
p:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h0 p /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h0 bs0)) /\
B.(loc_disjoint (loc_addr_of_buffer p) (loc_addr_of_buffer buf0)) /\
c.state.invariant h0 bs0 /\
(if c.km = Runtime then
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h0 k0)) /\
c.key.invariant #i h0 k0
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none)) /\
B.(modifies (loc_buffer p) h0 h1)) /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h1 p /\
footprint c i h0 p == footprint c i h1 p /\
preserves_freeable c i p h0 h1 /\
B.(loc_disjoint (loc_addr_of_buffer p) (footprint_s c i h1 (B.deref h1 p))) /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h1 bs1)) /\
B.(loc_disjoint (loc_buffer p) (c.state.footprint #i h1 bs1)) /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer p) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none))))))
let modifies_footprint' c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let _ = c.state.frame_invariant #i in
let _ = c.key.frame_invariant #i in
let _ = allow_inversion key_management in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf1 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_addr_of_buffer p) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_addr_of_buffer p) k0 h0 h1
/// Small helper which we use to factor out functional correctness proof obligations.
/// It states that a state was correctly updated to process some data between two
/// memory snapshots (the key is the same, the seen data was updated, etc.).
///
/// Note that we don't specify anything about the buffer and the block_state: they
/// might have been updated differently depending on the case.
unfold val state_is_updated :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Type0)
#push-options "--z3cliopt smt.arith.nl=false"
let state_is_updated #index c i t t' p data len h0 h1 =
// Functional conditions about the memory updates
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
block_state1 == block_state0 /\
buf1 == buf0 /\
U64.v total_len1 == U64.v total_len0 + U32.v len /\
key1 == key0 /\
seen1 `S.equal` (seen0 `S.append` (B.as_seq h0 data)) /\
optional_reveal #index #i #c.km #c.key h1 key1 == optional_reveal #index #i #c.km #c.key h0 key0
#pop-options
/// The functional part of the invariant
unfold val invariant_s_funct :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Pure Type0 (requires
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
state_is_updated c i t t' s data len h0 h1)
(ensures (fun _ -> True)))
let invariant_s_funct #index c i t t' p data len h0 h1 =
let blocks, rest = split_at_last_all_seen c i h1 p in
let s = B.get h1 p 0 in
let State block_state buf_ total_len seen key = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 key in
let init_s = c.init_s i key_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
c.state.v i h1 block_state == c.update_multi_s i init_s 0 blocks /\
S.equal (S.slice (B.as_seq h1 buf_) 0 (Seq.length rest)) rest
/// We isolate the functional correctness proof obligations for [update_small]
val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#push-options "--z3cliopt smt.arith.nl=false"
let update_small_functional_correctness #index c i t t' p data len h0 h1 =
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state buf total_len0 seen0 key = s0 in
let seen0 = G.reveal seen0 in
let i = Ghost.reveal i in
let key_v0 = optional_reveal #_ #i #c.km #c.key h0 key in
let init_v0 = c.init_input_s i key_v0 in
let all_seen0 = S.append init_v0 seen0 in
let blocks0, rest0 = split_at_last c i all_seen0 in
let State block_state buf total_len1 seen1 key = s1 in
let seen1 = G.reveal seen1 in
let i = Ghost.reveal i in
let key_v1 = optional_reveal #_ #i #c.km #c.key h1 key in
assert(key_v1 == key_v0);
let init_v1 = c.init_input_s i key_v1 in
assert(init_v1 == init_v0);
let all_seen1 = S.append init_v1 seen1 in
let blocks1, rest1 = split_at_last c i all_seen1 in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
let data_v0 = B.as_seq h0 data in
split_at_last_small c i all_seen0 data_v0;
// The first problematic condition
assert(blocks1 `S.equal` blocks0);
assert(c.state.v i h1 block_state == c.update_multi_s i (c.init_s i key_v1) 0 blocks1);
// The second problematic condition
assert(S.equal (S.slice (B.as_seq h1 buf) 0 (Seq.length rest1)) rest1)
#pop-options
// The absence of loc_disjoint_includes makes reasoning a little more difficult.
// Notably, we lose all of the important disjointness properties between the
// outer point p and the buffer within B.deref h p. These need to be
// re-established by hand. Another thing that we lose without this pattern is
// knowing that loc_buffer b is included within loc_addr_of_buffer b. This is
// important for reasoning about the preservation of e.g. the contents of data.
#restart-solver
#push-options "--z3rlimit 300 --z3cliopt smt.arith.nl=false --z3refresh \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2,-FStar.Seq.Properties.slice_slice,-LowStar.Monotonic.Buffer.loc_disjoint_includes_r'"
let update_small #index c i t t' p data len =
let open LowStar.BufferOps in
let s = !*p in
let State block_state buf total_len seen_ k' = s in
[@inline_let]
let block_state: c.state.s i = block_state in
// Functional reasoning.
let sz = rest c i total_len in
add_len_small c i total_len len;
let h0 = ST.get () in
let buf1 = B.sub buf 0ul sz in
let buf2 = B.sub buf sz len in
// Memory reasoning.
c.state.invariant_loc_in_footprint h0 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h0 k';
// key_invariant_loc_in_footprint #index c i h0 p;
B.(loc_disjoint_includes_r (loc_buffer data) (footprint c i h0 p) (loc_buffer buf2));
// FIRST STATEFUL OPERATION
B.blit data 0ul buf2 0ul len;
// Memory reasoning.
let h1 = ST.get () in
modifies_footprint c i p data len h0 h1;
c.state.invariant_loc_in_footprint h1 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h1 k';
// Functional reasoning on data
begin
let buf1_v0 = B.as_seq h0 buf1 in
let buf1_v1 = B.as_seq h1 buf1 in
let buf2_v1 = B.as_seq h1 buf2 in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
let data_v0 = B.as_seq h0 data in
assert(buf1_v1 == buf1_v0);
assert(buf1_v0 == buf_beg_v0);
assert(buf2_v1 `S.equal` data_v0);
assert(buf_part_v1 `S.equal` S.append buf_beg_v0 data_v0)
end;
// SECOND STATEFUL OPERATION
let total_len = add_len c i total_len len in
[@inline_let]
let tmp: state_s c i t t' =
State #index #c #i block_state buf total_len
(G.hide (G.reveal seen_ `S.append` (B.as_seq h0 data))) k'
in
p *= tmp;
// Memory reasoning.
let h2 = ST.get () in
modifies_footprint' c i p data len h1 h2;
c.state.invariant_loc_in_footprint h2 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h2 k';
ST.lemma_equal_domains_trans h0 h1 h2;
// Prove the invariant
update_small_functional_correctness c i t t' p data len h0 h2
#pop-options
// Stupid name collisions
noextract let seen_h = seen
noextract let all_seen_h = all_seen
/// Case 2: we have no buffered data (ie: the buffer was just initialized), or the
/// internal buffer is full meaning that we can just hash it to go to the case where
/// there is no buffered data. Of course, the data we append has to be non-empty,
/// otherwise we might end-up with an empty internal buffer.
/// Auxiliary lemma which groups the functional correctness proof obligations
/// for [update_empty_or_full].
#push-options "--z3cliopt smt.arith.nl=false"
val update_empty_or_full_functional_correctness :
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// Same precondition as [update_empty_or_full_buf]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0 /\
// Generic additional preconditions
state_is_updated c i t t' s data len h0 h1 /\
// Additional preconditions
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let seen0 = G.reveal seen0 in
let seen1 = G.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.v n_blocks * U32.v (c.blocks_state_len i) <= U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let all_seen0 = all_seen c i h0 s in
let all_seen1 = all_seen c i h1 s in
let blocks0, res0 = split_at_last c i all_seen0 in
let blocks1, res1 = split_at_last c i all_seen1 in
let data1_v = B.as_seq h0 data1 in
let data2_v = B.as_seq h0 data2 in
let key = optional_reveal #index #i #c.km #c.key h0 key0 in
let init_s = c.init_s i key in
let all_seen_data1 = S.append all_seen0 data1_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
S.length all_seen0 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
S.length all_seen_data1 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
c.state.v i h1 block_state == c.update_multi_s i init_s 0 all_seen_data1 /\
S.slice (B.as_seq h1 buf) 0 (Seq.length data2_v) `S.equal` data2_v /\
True
end /\
True
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let update_empty_or_full_functional_correctness #index c i t t' p data len h0 h1 =
let s = B.get h0 p 0 in
let State block_state buf_ total_len seen0 key = s in
let init_s = c.init_s i (optional_reveal #index #i #c.km #c.key h0 key) in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let data_v = B.as_seq h0 data in
let init_input = init_input c i h0 p in
let seen1 = seen c i h1 p in
let all_seen0 = all_seen c i h0 p in
let all_seen1 = all_seen c i h1 p in
let blocks0, rest0 = split_at_last_all_seen c i h0 p in
let blocks1, rest1 = split_at_last_all_seen c i h1 p in
let data_blocks, data_rest = split_at_last c i data_v in
split_at_last_blocks c i all_seen0 data_v;
assert(Seq.equal all_seen1 (S.append all_seen0 data_v));
assert(S.equal blocks1 (S.append all_seen0 data_blocks));
assert(S.equal data_rest rest1)
#pop-options
inline_for_extraction noextract
val update_empty_or_full_buf:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0)
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
#push-options "--z3cliopt smt.arith.nl=false --z3rlimit 500"
let update_empty_or_full_buf #index c i t t' p data len =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.update_multi_associative i in
let open LowStar.BufferOps in
let s = !*p in
let State block_state buf total_len seen k' = s in
[@inline_let]
let block_state: c.state.s i = block_state in
let sz = rest c i total_len in
let h0 = ST.get () in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
assert(0 % U32.v (c.block_len i) = 0);
let init_key : Ghost.erased _ = optional_reveal h0 (k' <: optional_key i c.km c.key) in
let init_state : Ghost.erased _ = c.init_s i init_key in
assert(
let all_seen = all_seen c i h0 p in
let blocks, rest = split_at_last c i all_seen in
Seq.length rest = U32.v sz /\
c.state.v i h0 block_state ==
c.update_multi_s i init_state 0 blocks);
(* Start by "flushing" the buffer: hash it so that all the data seen so far
* has been processed and we can consider the buffer as empty *)
if U32.(sz =^ 0ul) then
begin
assert(
let all_seen = all_seen c i h0 p in
c.state.v i h0 block_state == c.update_multi_s i init_state 0 all_seen)
end
else begin
let prevlen = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 sz) in
c.update_multi (G.hide i) block_state prevlen buf (c.blocks_state_len i);
begin
let h1 = ST.get () in
let all_seen = all_seen c i h0 p in
let blocks, rest = split_at_last c i all_seen in
assert(Seq.length blocks = U64.v prevlen);
assert(c.state.v i h0 block_state == c.update_multi_s i init_state 0 blocks);
assert(c.state.v i h1 block_state ==
c.update_multi_s i (c.update_multi_s i init_state 0 blocks) (U64.v prevlen) rest);
assert(all_seen `Seq.equal` Seq.append blocks rest);
(* TODO: the pattern of ``update_multi_associative`` is not triggered *)
c.update_multi_associative i init_state 0 (U64.v prevlen) blocks rest;
assert(c.state.v i h1 block_state == c.update_multi_s i init_state 0 all_seen)
end
end;
let h1 = ST.get () in
assert(
let all_seen = all_seen c i h0 p in
c.state.v i h1 block_state ==
c.update_multi_s i init_state 0 all_seen);
split_at_last_blocks c i (all_seen c i h0 p) (B.as_seq h0 data); // TODO: remove?
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.sub data 0ul data1_len in
let data2 = B.sub data data1_len data2_len in
c.update_multi (G.hide i) block_state total_len data1 data1_len;
let h01 = ST.get () in
optional_frame #_ #i #c.km #c.key (c.state.footprint h0 block_state) k' h0 h01;
assert(preserves_freeable c i p h0 h01);
begin
let all_seen = all_seen c i h0 p in
let data1_v = B.as_seq h01 data1 in
c.update_multi_associative i init_state 0 (Seq.length all_seen) all_seen data1_v;
assert(c.state.v i h01 block_state == c.update_multi_s i init_state 0 (Seq.append all_seen data1_v))
end;
let dst = B.sub buf 0ul data2_len in
let h1 = ST.get () in
B.blit data2 0ul dst 0ul data2_len;
let h2 = ST.get () in
c.state.frame_invariant (B.loc_buffer buf) block_state h1 h2;
optional_frame #_ #i #c.km #c.key (B.loc_buffer buf) k' h1 h2;
stateful_frame_preserves_freeable #index #(Block?.state c) #i
(B.loc_buffer dst)
(State?.block_state s) h1 h2;
assert(preserves_freeable c i p h01 h2);
[@inline_let]
let total_len' = add_len c i total_len len in
[@inline_let]
let tmp: state_s c i t t' = State #index #c #i block_state buf total_len'
(seen `S.append` B.as_seq h0 data) k'
in
p *= tmp;
let h3 = ST.get () in
c.state.frame_invariant (B.loc_buffer p) block_state h2 h3;
optional_frame #_ #i #c.km #c.key (B.loc_buffer p) k' h2 h3;
stateful_frame_preserves_freeable #index #(Block?.state c) #i
(B.loc_buffer p)
(State?.block_state s) h2 h3;
assert(preserves_freeable c i p h2 h3);
assert(preserves_freeable c i p h0 h3);
update_empty_or_full_functional_correctness #index c i t t' p data len h0 h3;
(* The following proof obligation is the difficult one - keep it here for
* easy debugging when updating the definitions/proofs *)
assert(invariant_s c i h3 (B.get h3 p 0))
#pop-options
/// Case 3: we are given just enough data to end up on the boundary. It is just
/// a sub-case of [update_small], but with a little bit more precise pre and post
/// conditions.
inline_for_extraction noextract
val update_round:
#index:Type0 ->
c:block index ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\ (
let r = rest c i (total_len_h c i h0 s) in
U32.v len + U32.v r = U32.v (c.blocks_state_len i) /\
r <> 0ul))
(ensures fun h0 _ h1 ->
update_post c i s data len h0 h1 /\
begin
let blocks, rest = split_at_last_all_seen c i h0 s in
let blocks', rest' = split_at_last_all_seen c i h1 s in
blocks' `S.equal` blocks /\
rest' `S.equal` S.append rest (B.as_seq h0 data) /\
S.length rest' = U32.v (c.blocks_state_len i)
end))
#push-options "--z3rlimit 200 --z3cliopt smt.arith.nl=false"
let update_round #index c i t t' p data len =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.update_multi_associative i in
let open LowStar.BufferOps in
(**) let h0 = ST.get() in
update_small #index c i t t' p data len;
(**) let h1 = ST.get() in
(**) split_at_last_small c i (all_seen c i h0 p) (B.as_seq h0 data);
(**) begin // For some reason, the proof fails if we don't call those
(**) let blocks, rest = split_at_last_all_seen c i h0 p in
(**) let blocks', rest' = split_at_last_all_seen c i h1 p in
(**) ()
(**) end
#pop-options
/// General update function, as a decomposition of the three sub-cases
/// ==================================================================
#push-options "--z3rlimit 200"
let update #index c i t t' state chunk chunk_len =
let open LowStar.BufferOps in
let s = !*state in
let State block_state buf_ total_len seen k' = s in
let i = c.index_of_state i block_state in
if FStar.UInt64.(FStar.Int.Cast.uint32_to_uint64 chunk_len >^ c.max_input_len i -^ total_len) then
Hacl.Streaming.Types.MaximumLengthExceeded
else
let sz = rest c i total_len in
if chunk_len `U32.lte` (c.blocks_state_len i `U32.sub` sz) then
update_small c i t t' state chunk chunk_len
else if sz = 0ul then
update_empty_or_full_buf c i t t' state chunk chunk_len
else begin
let h0 = ST.get () in
let diff = c.blocks_state_len i `U32.sub` sz in
let chunk1 = B.sub chunk 0ul diff in
let chunk2 = B.sub chunk diff (chunk_len `U32.sub` diff) in
update_round c i t t' state chunk1 diff;
let h1 = ST.get () in
update_empty_or_full_buf c i t t' state chunk2 (chunk_len `U32.sub` diff);
let h2 = ST.get () in
(
let seen = G.reveal seen in
assert (seen_h c i h1 state `S.equal` (S.append seen (B.as_seq h0 chunk1)));
assert (seen_h c i h2 state `S.equal` (S.append (S.append seen (B.as_seq h0 chunk1)) (B.as_seq h0 chunk2)));
S.append_assoc seen (B.as_seq h0 chunk1) (B.as_seq h0 chunk2);
assert (S.equal (S.append (B.as_seq h0 chunk1) (B.as_seq h0 chunk2)) (B.as_seq h0 chunk));
assert (S.equal
(S.append (S.append seen (B.as_seq h0 chunk1)) (B.as_seq h0 chunk2))
(S.append seen (B.as_seq h0 chunk)));
assert (seen_h c i h2 state `S.equal` (S.append seen (B.as_seq h0 chunk)));
()
)
end;
Hacl.Streaming.Types.Success
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
val digest_process_begin_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
dst:B.buffer uint8 ->
l: c.output_length_t { B.length dst == c.output_length i l } ->
h0: HS.mem ->
h1: HS.mem ->
tmp_block_state: t ->
Lemma
(requires (
// The precondition of [digest]
invariant c i h0 s /\
c.state.invariant #i h1 tmp_block_state /\
begin
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let r = rest c i total_len in
(**) assert(U32.v r <= U64.v total_len);
let prev_len = U64.(total_len `sub` FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = rest_finish c i r in
(**) assert(U32.v r_last <= U32.v r);
let r_multi = U32.(r -^ r_last) in
let buf_multi = B.gsub buf_ 0ul r_multi in
let prev_length = U64.v prev_len in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
c.state.v i h1 tmp_block_state == c.update_multi_s i (c.state.v i h0 block_state) prev_length (B.as_seq h0 buf_multi)
end))
(ensures (
let all_seen = all_seen c i h0 s in
let s = B.get h0 s 0 in
let State block_state buf_ total_len seen key = s in
let block_length = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length (S.length all_seen)) in
let k = optional_reveal #_ #i #c.km #c.key h0 key in
let init_state = c.init_s i k in
(**) Math.Lemmas.modulo_lemma 0 block_length;
(**) Math.Lemmas.cancel_mul_mod n block_length;
(**) Math.Lemmas.nat_times_nat_is_nat n block_length;
(**) split_at_last_num_blocks_lem c i (S.length all_seen);
0 % block_length = 0 /\
0 <= n * block_length /\ (n * block_length) % block_length = 0 /\
c.state.v i h1 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (n * block_length)))
))
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Hacl.Streaming.Interface.block index -> i: FStar.Ghost.erased index
-> (let i = FStar.Ghost.reveal i in
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)} ->
s: Hacl.Streaming.Functor.state c i t t' ->
dst: LowStar.Buffer.buffer Hacl.Streaming.Spec.uint8 ->
l:
Block?.output_length_t c
{LowStar.Monotonic.Buffer.length dst == Block?.output_length c i l} ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem ->
tmp_block_state: t
-> FStar.Pervasives.Lemma
(requires
Hacl.Streaming.Functor.invariant c i h0 s /\
Stateful?.invariant (Block?.state c) h1 tmp_block_state /\
(let s = LowStar.Monotonic.Buffer.get h0 s 0 in
let _ = s in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ block_state buf_ total_len _ key =
_
in
let r = Hacl.Streaming.Functor.rest c i total_len in
assert (FStar.UInt32.v r <= FStar.UInt64.v total_len);
let prev_len = FStar.UInt64.sub total_len (FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = Hacl.Streaming.Functor.rest_finish c i r in
assert (FStar.UInt32.v r_last <= FStar.UInt32.v r);
let r_multi = r -^ r_last in
let buf_multi = LowStar.Buffer.gsub buf_ 0ul r_multi in
let prev_length = FStar.UInt64.v prev_len in
let k = Hacl.Streaming.Functor.optional_reveal h0 key in
Stateful?.v (Block?.state c) i h1 tmp_block_state ==
Block?.update_multi_s c
i
(Stateful?.v (Block?.state c) i h0 block_state)
prev_length
(LowStar.Monotonic.Buffer.as_seq h0 buf_multi))
<:
Prims.logical))
(ensures
(let all_seen = Hacl.Streaming.Functor.all_seen c i h0 s in
let s = LowStar.Monotonic.Buffer.get h0 s 0 in
let _ = s in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ _ _ _ _ key = _ in
let block_length = FStar.UInt32.v (Block?.block_len c i) in
let n =
FStar.Pervasives.Native.fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length
(FStar.Seq.Base.length all_seen))
in
let k = Hacl.Streaming.Functor.optional_reveal h0 key in
let init_state = Block?.init_s c i k in
FStar.Math.Lemmas.modulo_lemma 0 block_length;
FStar.Math.Lemmas.cancel_mul_mod n block_length;
FStar.Math.Lemmas.nat_times_nat_is_nat n block_length;
Hacl.Streaming.Functor.split_at_last_num_blocks_lem c
i
(FStar.Seq.Base.length all_seen);
0 % block_length = 0 /\ 0 <= n * block_length /\
n * block_length % block_length = 0 /\
Stateful?.v (Block?.state c) i h1 tmp_block_state ==
Block?.update_multi_s c
i
init_state
0
(FStar.Seq.Base.slice all_seen 0 (n * block_length)))
<:
Type0))) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"FStar.Ghost.erased",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"FStar.Ghost.reveal",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Spec.uint8",
"Hacl.Streaming.Interface.__proj__Block__item__output_length_t",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__output_length",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"FStar.UInt64.t",
"FStar.Seq.Base.seq",
"Prims._assert",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Interface.__proj__Stateful__item__v",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_s",
"FStar.Seq.Base.slice",
"FStar.Mul.op_Star",
"Prims.unit",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"FStar.Math.Lemmas.nat_times_nat_is_nat",
"Hacl.Streaming.Spec.split_at_last_finish",
"Prims.op_Addition",
"FStar.UInt32.v",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.append",
"Hacl.Streaming.Interface.__proj__Block__item__update_multi_associative",
"Prims.int",
"Prims.op_Modulus",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.mbuffer",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"LowStar.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.UInt64.v",
"FStar.Math.Lemmas.cancel_mul_mod",
"FStar.Math.Lemmas.modulo_lemma",
"Hacl.Streaming.Interface.__proj__Block__item__init_s",
"FStar.Pervasives.Native.fst",
"Lib.UpdateMulti.split_at_last_lazy_nb_rem",
"FStar.UInt.uint_t",
"Hacl.Streaming.Functor.optional_reveal",
"Hacl.Streaming.Interface.__proj__Block__item__block_len",
"Hacl.Streaming.Functor.bytes",
"Hacl.Streaming.Functor.all_seen",
"FStar.UInt32.op_Subtraction_Hat",
"Prims.l_and",
"Prims.op_Multiply",
"Prims.op_Subtraction",
"Hacl.Streaming.Functor.rest_finish",
"FStar.UInt64.sub",
"FStar.Int.Cast.uint32_to_uint64",
"Hacl.Streaming.Spec.split_at_last_num_blocks",
"Hacl.Streaming.Functor.rest",
"Hacl.Streaming.Functor.state_s",
"LowStar.Monotonic.Buffer.get"
] | [] | false | false | false | false | false | let digest_process_begin_functional_correctness #index c i t t' p dst l h0 h1 tmp_block_state =
| let h3 = h0 in
let h4 = h1 in
let s = B.get h0 p 0 in
let State block_state buf_ total_len seen k' = s in
let r = rest c i total_len in
let buf_ = B.gsub buf_ 0ul r in
let prev_len = let open U64 in total_len `sub` (FStar.Int.Cast.uint32_to_uint64 r) in
let r_last = rest_finish c i r in
let r_multi = let open U32 in r -^ r_last in
let i = G.reveal i in
let all_seen = all_seen c i h0 p in
let block_length = U32.v (c.block_len i) in
let blocks_state_length = U32.v (c.blocks_state_len i) in
let k = optional_reveal #_ #i #c.km #c.key h0 k' in
let prev_length = U64.v prev_len in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem block_length (S.length all_seen)) in
let init_state = c.init_s i k in
Math.Lemmas.modulo_lemma 0 block_length;
Math.Lemmas.cancel_mul_mod n block_length;
assert (prev_length + U32.v r = U64.v total_len);
assert (U32.v r_multi <= U32.v r);
assert (prev_length + U32.v r_multi <= U64.v total_len);
assert (n * block_length <= U64.v total_len);
let buf_multi = B.gsub buf_ 0ul r_multi in
assert (c.state.v i h4 tmp_block_state ==
c.update_multi_s i (c.state.v i h0 block_state) prev_length (B.as_seq h3 buf_multi));
assert (B.as_seq h3 buf_multi == S.slice all_seen prev_length (prev_length + U32.v r_multi));
assert (c.state.v i h4 tmp_block_state ==
c.update_multi_s i
(c.update_multi_s i init_state 0 (S.slice all_seen 0 prev_length))
prev_length
(S.slice all_seen prev_length (prev_length + U32.v r_multi)));
assert (0 % block_length = 0);
assert (S.length (S.slice all_seen 0 prev_length) % block_length = 0);
assert (prev_length + U32.v r_multi <= S.length all_seen);
c.update_multi_associative i
init_state
0
prev_length
(S.slice all_seen 0 prev_length)
(S.slice all_seen prev_length (prev_length + U32.v r_multi));
assert (S.equal (S.append (S.slice all_seen 0 prev_length)
(S.slice all_seen prev_length (prev_length + U32.v r_multi)))
(S.slice all_seen 0 (prev_length + U32.v r_multi)));
assert (c.state.v i h4 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (prev_length + U32.v r_multi)));
split_at_last_finish c i all_seen;
Math.Lemmas.nat_times_nat_is_nat n block_length;
assert (0 <= n * block_length);
assert (n * block_length <= S.length all_seen);
assert (c.state.v i h4 tmp_block_state ==
c.update_multi_s i init_state 0 (S.slice all_seen 0 (n * block_length))) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_code_KeyExpansionStdcall | val va_code_KeyExpansionStdcall : alg:algorithm -> Tot va_code | val va_code_KeyExpansionStdcall : alg:algorithm -> Tot va_code | let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ()))))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 27,
"start_col": 0,
"start_line": 23
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Vale.PPC64LE.InsMem.va_code_CreateHeaplets",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_code_KeyExpansion128Stdcall",
"Vale.PPC64LE.Decls.va_CNil",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_code_KeyExpansion256Stdcall",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsMem.va_code_DestroyHeaplets"
] | [] | false | false | false | true | false | let va_code_KeyExpansionStdcall alg =
| (va_Block (va_CCons (va_code_CreateHeaplets ())
(va_CCons (if (alg = AES_128)
then va_Block (va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ()))
else va_Block (va_CCons (va_code_KeyExpansion256Stdcall ()) (va_CNil ())))
(va_CCons (va_code_DestroyHeaplets ()) (va_CNil ()))))) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_vclist_intro | val valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) | val valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) | let valid_vclist_intro
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid lp h input pos /\ (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\
valid (parse_nlist (U32.v len) p) h input pos1
)))
(ensures (
let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p) h input pos (contents (parse_nlist (U32.v len) p) h input pos1) (get_valid_pos (parse_nlist (U32.v len) p) h input pos1)
))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 54,
"end_line": 448,
"start_col": 0,
"start_line": 418
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1
inline_for_extraction
let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1
#pop-options
let valid_vclist_elim
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#lk: parser_kind)
(lp: parser lk U32.t { lk.parser_kind_subkind == Some ParserStrong })
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_vclist min max lp p) h input pos))
(ensures (
valid lp h input pos /\ (
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
let x = contents (parse_vclist min max lp p) h input pos in
L.length x == U32.v len /\
valid_content_pos (parse_nlist (U32.v len) p) h input pos1 x (get_valid_pos (parse_vclist min max lp p) h input pos)
)))
= valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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 |
min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
lp:
LowParse.Spec.Base.parser lk FStar.UInt32.t
{ Mkparser_kind'?.parser_kind_subkind lk ==
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserStrong } ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid lp h input pos /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let len = LowParse.Low.Base.Spec.contents lp h input pos in
min <= FStar.UInt32.v len /\ FStar.UInt32.v len <= max /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len) p)
h
input
pos1))
(ensures
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos lp h input pos in
let len = LowParse.Low.Base.Spec.contents lp h input pos in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_vclist min max lp p)
h
input
pos
(LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len)
p)
h
input
pos1)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v len
)
p)
h
input
pos1))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserStrong",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"LowParse.Low.Base.Spec.contents",
"Prims.unit",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let valid_vclist_intro
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#lk: parser_kind)
(lp: parser lk U32.t {lk.parser_kind_subkind == Some ParserStrong})
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos: U32.t)
: Lemma
(requires
(valid lp h input pos /\
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
min <= U32.v len /\ U32.v len <= max /\ valid (parse_nlist (U32.v len) p) h input pos1))
)
(ensures
(let pos1 = get_valid_pos lp h input pos in
let len = contents lp h input pos in
valid_content_pos (parse_vclist min max lp p)
h
input
pos
(contents (parse_nlist (U32.v len) p) h input pos1)
(get_valid_pos (parse_nlist (U32.v len) p) h input pos1))) =
| valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos;
let len = contents lp h input pos in
let pos1 = get_valid_pos lp h input pos in
valid_facts (parse_nlist (U32.v len) p) h input pos1 | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_codegen_success_AESEncryptBlock | val va_codegen_success_AESEncryptBlock : alg:algorithm -> Tot va_pbool | val va_codegen_success_AESEncryptBlock : alg:algorithm -> Tot va_pbool | let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ())) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 120,
"start_col": 0,
"start_line": 117
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
()))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_codegen_success_AES128EncryptBlock",
"Vale.PPC64LE.Decls.va_ttrue",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_codegen_success_AES256EncryptBlock",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_AESEncryptBlock alg =
| (va_pbool_and (if (alg = AES_128)
then va_pbool_and (va_codegen_success_AES128EncryptBlock ()) (va_ttrue ())
else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ())) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.validate_vclist | val validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) | val validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) | let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1 | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 35,
"end_line": 358,
"start_col": 0,
"start_line": 329
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: FStar.UInt32.t ->
max: FStar.UInt32.t{FStar.UInt32.v min <= FStar.UInt32.v max} ->
lv: LowParse.Low.Base.validator lp ->
lr: LowParse.Low.Base.leaf_reader lp ->
v: LowParse.Low.Base.validator p
-> LowParse.Low.Base.validator (LowParse.Spec.VCList.parse_vclist (FStar.UInt32.v min)
(FStar.UInt32.v max)
lp
p) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.validator",
"LowParse.Low.Base.leaf_reader",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"LowParse.Low.ErrorCode.is_error",
"Prims.bool",
"Prims.op_BarBar",
"FStar.UInt32.lt",
"LowParse.Low.ErrorCode.validator_error_generic",
"LowParse.Low.VCList.validate_nlist",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | false | false | false | false | let validate_vclist
(min: U32.t)
(max: U32.t{U32.v min <= U32.v max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p)) =
| fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min)
(U32.v max)
lp
p
(bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@@ inline_let ]let _ =
valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1)
in
validate_nlist n v input pos1 | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_codegen_success_KeyExpansionStdcall | val va_codegen_success_KeyExpansionStdcall : alg:algorithm -> Tot va_pbool | val va_codegen_success_KeyExpansionStdcall : alg:algorithm -> Tot va_pbool | let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 34,
"start_col": 0,
"start_line": 30
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ()))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Vale.PPC64LE.InsMem.va_codegen_success_CreateHeaplets",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_codegen_success_KeyExpansion128Stdcall",
"Vale.PPC64LE.Decls.va_ttrue",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_codegen_success_KeyExpansion256Stdcall",
"Vale.PPC64LE.Decls.va_pbool",
"Vale.PPC64LE.InsMem.va_codegen_success_DestroyHeaplets"
] | [] | false | false | false | true | false | let va_codegen_success_KeyExpansionStdcall alg =
| (va_pbool_and (va_codegen_success_CreateHeaplets ())
(va_pbool_and (if (alg = AES_128)
then va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ())
else va_pbool_and (va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ()))
(va_pbool_and (va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_qcode_KeyExpansionStdcall | val va_qcode_KeyExpansionStdcall
(va_mods: va_mods_t)
(alg: algorithm)
(input_key_b output_key_expansion_b: buffer128)
: (va_quickCode unit (va_code_KeyExpansionStdcall alg)) | val va_qcode_KeyExpansionStdcall
(va_mods: va_mods_t)
(alg: algorithm)
(input_key_b output_key_expansion_b: buffer128)
: (va_quickCode unit (va_code_KeyExpansionStdcall alg)) | let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 59,
"start_col": 0,
"start_line": 37
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ())))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
input_key_b: Vale.PPC64LE.Memory.buffer128 ->
output_key_expansion_b: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.AES.va_code_KeyExpansionStdcall alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.InsMem.va_code_CreateHeaplets",
"Vale.PPC64LE.QuickCodes.if_code",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.PPC64LE.QuickCodes.block",
"Vale.AES.PPC64LE.AES128.va_code_KeyExpansion128Stdcall",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.AES.PPC64LE.AES256.va_code_KeyExpansion256Stdcall",
"Vale.PPC64LE.InsMem.va_code_DestroyHeaplets",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.InsMem.va_quick_CreateHeaplets",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.PPC64LE.InsMem.declare_buffer128",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.Arch.HeapImpl.Immutable",
"Vale.Arch.HeapImpl.Mutable",
"Vale.PPC64LE.QuickCodes.va_qInlineIf",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.AES.PPC64LE.AES128.va_quick_KeyExpansion128Stdcall",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.AES.PPC64LE.AES256.va_quick_KeyExpansion256Stdcall",
"Vale.PPC64LE.InsMem.va_quick_DestroyHeaplets",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.PPC64LE.Decls.va_if",
"Vale.Def.Types_s.nat32",
"Prims.b2t",
"Vale.AES.AES256_helpers_BE.be_quad32_to_seq",
"Prims.l_not",
"Vale.AES.AES256_helpers_BE.make_AES256_key",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.PPC64LE.Decls.buffer128_read",
"Vale.PPC64LE.Decls.va_get_mem",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.AES.va_code_KeyExpansionStdcall"
] | [] | false | false | false | false | false | let va_qcode_KeyExpansionStdcall
(va_mods: va_mods_t)
(alg: algorithm)
(input_key_b output_key_expansion_b: buffer128)
: (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
let in_key1:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b
0
(va_get_mem va_s))
in
let in_key2:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b
1
(va_get_mem va_s))
in
let key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32) =
va_if (alg = AES_128)
(fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1)
(fun _ -> Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2)
in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([
declare_buffer128 input_key_b 0 Secret Immutable;
declare_buffer128 output_key_expansion_b 1 Secret Mutable
]))
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods
(alg = AES_128)
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b)
(va_QEmpty (()))))
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b)
(va_QEmpty (())))))
(fun (va_s: va_state) va_g ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ())
(va_QEmpty (())))))) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock | val va_code_AESEncryptBlock : alg:algorithm -> Tot va_code | val va_code_AESEncryptBlock : alg:algorithm -> Tot va_code | let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
()))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 9,
"end_line": 114,
"start_col": 0,
"start_line": 111
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock",
"Vale.PPC64LE.Decls.va_CNil",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_code_AES256EncryptBlock",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_AESEncryptBlock alg =
| (va_Block (va_CCons (if (alg = AES_128)
then va_Block (va_CCons (va_code_AES128EncryptBlock ()) (va_CNil ()))
else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ())))
(va_CNil ()))) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_qcode_AESEncryptBlock | val va_qcode_AESEncryptBlock
(va_mods: va_mods_t)
(alg: algorithm)
(input: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock alg)) | val va_qcode_AESEncryptBlock
(va_mods: va_mods_t)
(alg: algorithm)
(input: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock alg)) | let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (())))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 134,
"start_col": 0,
"start_line": 123
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ())) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.QuickCodes.if_code",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.PPC64LE.QuickCodes.block",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.AES.PPC64LE.AES256.va_code_AES256EncryptBlock",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.QuickCodes.va_qInlineIf",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.AES.PPC64LE.AES128.va_quick_AES128EncryptBlock",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.AES.PPC64LE.AES256.va_quick_AES256EncryptBlock",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock"
] | [] | false | false | false | false | false | let va_qcode_AESEncryptBlock
(va_mods: va_mods_t)
(alg: algorithm)
(input: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods
(alg = AES_128)
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer)
(va_QEmpty (()))))
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer)
(va_QEmpty (())))))
(fun (va_s: va_state) va_g -> va_QEmpty (())))) | false |
LList.fst | LList.new_llist | val new_llist (#a:Type) (init:a)
: Steel (t a & list (cell a))
emp
(fun pc -> llist (fst pc) (snd pc))
(requires fun _ -> True)
(ensures fun _ pc _ -> datas (snd pc) == [init]) | val new_llist (#a:Type) (init:a)
: Steel (t a & list (cell a))
emp
(fun pc -> llist (fst pc) (snd pc))
(requires fun _ -> True)
(ensures fun _ pc _ -> datas (snd pc) == [init]) | let new_llist #a init =
let cell = mk_cell null_llist init in
let p = alloc_pt cell in
intro_llist_nil a;
rewrite_slprop (llist null_llist []) (llist (next cell) []) (fun _ -> ());
intro_llist_cons p cell [];
let pc = p, [cell] in
pc | {
"file_name": "share/steel/examples/steel/LList.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 4,
"end_line": 31,
"start_col": 0,
"start_line": 24
} | module LList
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.FractionalPermission
open Steel.Reference
include LList.Invariant
module L = FStar.List.Tot.Base
#set-options "--ide_id_info_off"
let rec datas (#a:Type) (l:list (cell a)) : list a =
match l with
| [] -> []
| hd::tl -> data hd :: datas tl
val new_llist (#a:Type) (init:a)
: Steel (t a & list (cell a))
emp
(fun pc -> llist (fst pc) (snd pc))
(requires fun _ -> True)
(ensures fun _ pc _ -> datas (snd pc) == [init]) | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"LList.Invariant.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked"
],
"interface_file": false,
"source_file": "LList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.List.Tot.Base",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LList.Invariant",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | init: a -> Steel.Effect.Steel (LList.Invariant.t a * Prims.list (LList.Invariant.cell a)) | Steel.Effect.Steel | [] | [] | [
"FStar.Pervasives.Native.tuple2",
"LList.Invariant.t",
"Prims.list",
"LList.Invariant.cell",
"FStar.Pervasives.Native.Mktuple2",
"Prims.Cons",
"Prims.Nil",
"Prims.unit",
"LList.Invariant.intro_llist_cons",
"Steel.Effect.Atomic.rewrite_slprop",
"FStar.Ghost.hide",
"FStar.Set.set",
"Steel.Memory.iname",
"FStar.Set.empty",
"LList.Invariant.llist",
"LList.Invariant.null_llist",
"LList.Invariant.next",
"Steel.Memory.mem",
"LList.Invariant.intro_llist_nil",
"Steel.Reference.ref",
"Steel.Reference.alloc_pt",
"LList.Invariant.mk_cell"
] | [] | false | true | false | false | false | let new_llist #a init =
| let cell = mk_cell null_llist init in
let p = alloc_pt cell in
intro_llist_nil a;
rewrite_slprop (llist null_llist []) (llist (next cell) []) (fun _ -> ());
intro_llist_cons p cell [];
let pc = p, [cell] in
pc | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_codegen_success_AESEncryptBlock_6way | val va_codegen_success_AESEncryptBlock_6way : alg:algorithm -> Tot va_pbool | val va_codegen_success_AESEncryptBlock_6way : alg:algorithm -> Tot va_pbool | let va_codegen_success_AESEncryptBlock_6way alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock_6way
()) (va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock_6way ()) (va_ttrue
())) (va_ttrue ())) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 175,
"start_col": 0,
"start_line": 172
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock_6way alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock_6way
()) (va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ()))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_pbool_and",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_codegen_success_AES128EncryptBlock_6way",
"Vale.PPC64LE.Decls.va_ttrue",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_codegen_success_AES256EncryptBlock_6way",
"Vale.PPC64LE.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_AESEncryptBlock_6way alg =
| (va_pbool_and (if (alg = AES_128)
then va_pbool_and (va_codegen_success_AES128EncryptBlock_6way ()) (va_ttrue ())
else va_pbool_and (va_codegen_success_AES256EncryptBlock_6way ()) (va_ttrue ()))
(va_ttrue ())) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.valid_nlist_cons | val valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) | val valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) | let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos) | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 57,
"end_line": 73,
"start_col": 0,
"start_line": 43
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
n: Prims.nat ->
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
sl: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.Spec.valid p h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos))
(ensures
LowParse.Low.Base.Spec.valid p h sl pos /\
LowParse.Low.Base.Spec.valid (LowParse.Spec.VCList.parse_nlist n p)
h
sl
(LowParse.Low.Base.Spec.get_valid_pos p h sl pos) /\
(let pos1 = LowParse.Low.Base.Spec.get_valid_pos p h sl pos in
LowParse.Low.Base.Spec.valid_content_pos (LowParse.Spec.VCList.parse_nlist (n + 1) p)
h
sl
pos
(LowParse.Low.Base.Spec.contents p h sl pos ::
LowParse.Low.Base.Spec.contents (LowParse.Spec.VCList.parse_nlist n p) h sl pos1)
(LowParse.Low.Base.Spec.get_valid_pos (LowParse.Spec.VCList.parse_nlist n p) h sl pos1))
) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"LowParse.Spec.VCList.parse_nlist_eq",
"Prims.op_Addition",
"LowParse.Slice.bytes_of_slice_from",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.l_and",
"LowParse.Low.Base.Spec.valid",
"Prims.squash",
"LowParse.Low.Base.Spec.valid_content_pos",
"Prims.Cons",
"LowParse.Low.Base.Spec.contents",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | true | false | true | false | false | let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma (requires (valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)))
(ensures
(valid p h sl pos /\ valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\
(let pos1 = get_valid_pos p h sl pos in
valid_content_pos (parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)))) =
| let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way | val va_code_AESEncryptBlock_6way : alg:algorithm -> Tot va_code | val va_code_AESEncryptBlock_6way : alg:algorithm -> Tot va_code | let va_code_AESEncryptBlock_6way alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock_6way
()) (va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ()))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 169,
"start_col": 0,
"start_line": 166
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock_6way | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | alg: Vale.AES.AES_common_s.algorithm -> Vale.PPC64LE.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Decls.va_Block",
"Vale.PPC64LE.Decls.va_CCons",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock_6way",
"Vale.PPC64LE.Decls.va_CNil",
"Prims.bool",
"Vale.AES.PPC64LE.AES256.va_code_AES256EncryptBlock_6way",
"Vale.PPC64LE.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_AESEncryptBlock_6way alg =
| (va_Block (va_CCons (if (alg = AES_128)
then va_Block (va_CCons (va_code_AES128EncryptBlock_6way ()) (va_CNil ()))
else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ()))) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_qcode_AESEncryptBlock_6way | val va_qcode_AESEncryptBlock_6way
(va_mods: va_mods_t)
(alg: algorithm)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) | val va_qcode_AESEncryptBlock_6way
(va_mods: va_mods_t)
(alg: algorithm)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) | let va_qcode_AESEncryptBlock_6way (va_mods:va_mods_t) (alg:algorithm) (in1:quad32) (in2:quad32)
(in3:quad32) (in4:quad32) (in5:quad32) (in6:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (())))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 70,
"end_line": 189,
"start_col": 0,
"start_line": 178
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock_6way alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock_6way
()) (va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock_6way alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock_6way
()) (va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock_6way ()) (va_ttrue
())) (va_ttrue ())) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
in1: Vale.PPC64LE.Memory.quad32 ->
in2: Vale.PPC64LE.Memory.quad32 ->
in3: Vale.PPC64LE.Memory.quad32 ->
in4: Vale.PPC64LE.Memory.quad32 ->
in5: Vale.PPC64LE.Memory.quad32 ->
in6: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.QuickCodes.if_code",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.PPC64LE.QuickCodes.block",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock_6way",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Vale.AES.PPC64LE.AES256.va_code_AES256EncryptBlock_6way",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.PPC64LE.QuickCodes.va_qInlineIf",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.AES.PPC64LE.AES128.va_quick_AES128EncryptBlock_6way",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.AES.PPC64LE.AES256.va_quick_AES256EncryptBlock_6way",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way"
] | [] | false | false | false | false | false | let va_qcode_AESEncryptBlock_6way
(va_mods: va_mods_t)
(alg: algorithm)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods
(alg = AES_128)
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock_6way in1
in2
in3
in4
in5
in6
key
round_keys
keys_buffer)
(va_QEmpty (()))))
(qblock va_mods
(fun (va_s: va_state) ->
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock_6way in1
in2
in3
in4
in5
in6
key
round_keys
keys_buffer)
(va_QEmpty (())))))
(fun (va_s: va_state) va_g -> va_QEmpty (())))) | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.copy | val copy:
#index: Type0 ->
c:block index ->
i:G.erased index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key (G.reveal i) c.km c.key } ->
copy_st c i t t' | val copy:
#index: Type0 ->
c:block index ->
i:G.erased index ->
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key (G.reveal i) c.km c.key } ->
copy_st c i t t' | let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 458,
"start_col": 0,
"start_line": 371
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
c: Hacl.Streaming.Interface.block index ->
i: FStar.Ghost.erased index ->
t: Type0{t == Stateful?.s (Block?.state c) (FStar.Ghost.reveal i)} ->
t':
Type0
{ t' ==
Hacl.Streaming.Interface.optional_key (FStar.Ghost.reveal i) (Block?.km c) (Block?.key c)
}
-> Hacl.Streaming.Functor.copy_st c (FStar.Ghost.reveal i) t t' | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"FStar.Ghost.erased",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"FStar.Ghost.reveal",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"FStar.Monotonic.HyperHeap.rid",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Prims.b2t",
"Prims.op_Equality",
"FStar.UInt32.t",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"FStar.UInt64.t",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.uint8",
"Prims.unit",
"Prims._assert",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Functor.optional_reveal",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_freeable",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.fresh_loc",
"Hacl.Streaming.Functor.footprint_s",
"LowStar.Monotonic.Buffer.loc_addr_of_buffer",
"Hacl.Streaming.Functor.state_s",
"Hacl.Streaming.Functor.optional_frame",
"Hacl.Streaming.Interface.__proj__Stateful__item__frame_invariant",
"Hacl.Streaming.Interface.key_management",
"Hacl.Streaming.Interface.Runtime",
"Prims.bool",
"LowStar.Monotonic.Buffer.modifies_only_not_unused_in",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.l_and",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Monotonic.Buffer.frameOf",
"LowStar.Monotonic.Buffer.freeable",
"LowStar.Buffer.malloc",
"FStar.UInt32.__uint_to_t",
"LowStar.Monotonic.Buffer.loc_unused_in_not_unused_in_disjoint",
"Hacl.Streaming.Functor.State",
"Hacl.Streaming.Interface.__proj__Stateful__item__footprint",
"Hacl.Streaming.Functor.optional_footprint",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant",
"Hacl.Streaming.Interface.__proj__Stateful__item__copy",
"FStar.Ghost.hide",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Hacl.Streaming.Interface.__proj__Stateful__item__create_in",
"Hacl.Streaming.Functor.invariant",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowStar.Monotonic.Buffer.blit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.u8",
"Hacl.Streaming.Interface.__proj__Block__item__index_of_state",
"LowStar.BufferOps.op_Bang_Star",
"FStar.Pervasives.allow_inversion",
"Prims.squash",
"LowStar.Monotonic.Buffer.loc_in",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil",
"Hacl.Streaming.Interface.__proj__Stateful__item__invariant_loc_in_footprint"
] | [] | false | false | false | false | false | let copy #index c i t t' state r =
| [@@ inline_let ]let _ = c.state.invariant_loc_in_footprint #i in
[@@ inline_let ]let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
let h0 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
let h1 = ST.get () in
assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
B.loc_unused_in_not_unused_in_disjoint h1;
(let open B in modifies_only_not_unused_in loc_none h0 h1);
if c.km = Runtime then c.key.frame_invariant #i B.loc_none k0 h0 h1;
c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
let h2 = ST.get () in
assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
B.loc_unused_in_not_unused_in_disjoint h2;
(let open B in modifies_only_not_unused_in loc_none h1 h2);
if c.km = Runtime then c.key.frame_invariant #i B.loc_none k0 h1 h2;
c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
let h2 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h2;
(let open B in modifies_only_not_unused_in loc_none h1 h2);
if c.km = Runtime then c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k':optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
let h3 = ST.get () in
B.loc_unused_in_not_unused_in_disjoint h3;
(let open B in modifies_only_not_unused_in loc_none h2 h3);
c.key.frame_invariant #i B.loc_none k0 h2 h3;
c.state.frame_invariant #i B.loc_none block_state h2 h3;
c.state.frame_freeable #i B.loc_none block_state h2 h3;
assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
assert (c.key.invariant #i h3 k');
assert (c.key.invariant #i h3 k0);
assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
let h4 = ST.get () in
assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
B.loc_unused_in_not_unused_in_disjoint h4;
(let open B in modifies_only_not_unused_in loc_none h2 h4);
assert (c.key.invariant #i h4 k');
c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
let h5 = ST.get () in
assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
let h6 = ST.get () in
(let open B in modifies_only_not_unused_in loc_none h5 h6);
(let open B in modifies_only_not_unused_in loc_none h0 h6);
if c.km = Runtime then c.key.frame_invariant #i B.loc_none k0 h5 h6;
c.state.frame_invariant #i B.loc_none block_state h5 h6;
optional_frame B.loc_none k' h5 h6;
assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
c.state.frame_freeable B.loc_none block_state h5 h6;
assert (optional_reveal h5 k' == optional_reveal h6 k');
p | false |
Hacl.Streaming.Functor.fst | Hacl.Streaming.Functor.update_empty_or_full_functional_correctness | val update_empty_or_full_functional_correctness :
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// Same precondition as [update_empty_or_full_buf]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0 /\
// Generic additional preconditions
state_is_updated c i t t' s data len h0 h1 /\
// Additional preconditions
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let seen0 = G.reveal seen0 in
let seen1 = G.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.v n_blocks * U32.v (c.blocks_state_len i) <= U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let all_seen0 = all_seen c i h0 s in
let all_seen1 = all_seen c i h1 s in
let blocks0, res0 = split_at_last c i all_seen0 in
let blocks1, res1 = split_at_last c i all_seen1 in
let data1_v = B.as_seq h0 data1 in
let data2_v = B.as_seq h0 data2 in
let key = optional_reveal #index #i #c.km #c.key h0 key0 in
let init_s = c.init_s i key in
let all_seen_data1 = S.append all_seen0 data1_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
S.length all_seen0 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
S.length all_seen_data1 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
c.state.v i h1 block_state == c.update_multi_s i init_s 0 all_seen_data1 /\
S.slice (B.as_seq h1 buf) 0 (Seq.length data2_v) `S.equal` data2_v /\
True
end /\
True
))
(ensures (invariant_s_funct c i t t' s data len h0 h1))) | val update_empty_or_full_functional_correctness :
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// Same precondition as [update_empty_or_full_buf]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0 /\
// Generic additional preconditions
state_is_updated c i t t' s data len h0 h1 /\
// Additional preconditions
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let seen0 = G.reveal seen0 in
let seen1 = G.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.v n_blocks * U32.v (c.blocks_state_len i) <= U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let all_seen0 = all_seen c i h0 s in
let all_seen1 = all_seen c i h1 s in
let blocks0, res0 = split_at_last c i all_seen0 in
let blocks1, res1 = split_at_last c i all_seen1 in
let data1_v = B.as_seq h0 data1 in
let data2_v = B.as_seq h0 data2 in
let key = optional_reveal #index #i #c.km #c.key h0 key0 in
let init_s = c.init_s i key in
let all_seen_data1 = S.append all_seen0 data1_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
S.length all_seen0 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
S.length all_seen_data1 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
c.state.v i h1 block_state == c.update_multi_s i init_s 0 all_seen_data1 /\
S.slice (B.as_seq h1 buf) 0 (Seq.length data2_v) `S.equal` data2_v /\
True
end /\
True
))
(ensures (invariant_s_funct c i t t' s data len h0 h1))) | let update_empty_or_full_functional_correctness #index c i t t' p data len h0 h1 =
let s = B.get h0 p 0 in
let State block_state buf_ total_len seen0 key = s in
let init_s = c.init_s i (optional_reveal #index #i #c.km #c.key h0 key) in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let data_v = B.as_seq h0 data in
let init_input = init_input c i h0 p in
let seen1 = seen c i h1 p in
let all_seen0 = all_seen c i h0 p in
let all_seen1 = all_seen c i h1 p in
let blocks0, rest0 = split_at_last_all_seen c i h0 p in
let blocks1, rest1 = split_at_last_all_seen c i h1 p in
let data_blocks, data_rest = split_at_last c i data_v in
split_at_last_blocks c i all_seen0 data_v;
assert(Seq.equal all_seen1 (S.append all_seen0 data_v));
assert(S.equal blocks1 (S.append all_seen0 data_blocks));
assert(S.equal data_rest rest1) | {
"file_name": "code/streaming/Hacl.Streaming.Functor.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 1302,
"start_col": 0,
"start_line": 1274
} | module Hacl.Streaming.Functor
/// Provided an instance of the type class, this creates a streaming API on top.
/// This means that every function in this module takes two extra arguments
/// compared to the previous streaming module specialized for hashes: the type
/// of the index, and a type class for that index. Then, as usual, a given value
/// for the index as a parameter.
#set-options "--max_fuel 0 --max_ifuel 0 \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2' --z3rlimit 50"
module ST = FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
open Hacl.Streaming.Interface
open FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
open Hacl.Streaming.Spec
/// State machinery
/// ===============
/// Little bit of trickery here to make sure state_s is parameterized over
/// something at Type0, not Type0 -> Type0 -- otherwise it wouldn't monomorphize
/// in KaRaMeL.
noeq
type state_s #index (c: block index) (i: index)
(t: Type0 { t == c.state.s i })
(t': Type0 { t' == optional_key i c.km c.key })
=
| State:
block_state: t ->
buf: B.buffer Lib.IntTypes.uint8 { B.len buf = c.blocks_state_len i } ->
total_len: UInt64.t ->
seen: G.erased (S.seq uint8) ->
// Stupid name conflict on overloaded projectors leads to inscrutable
// interleaving errors. Need a field name that does not conflict with the
// one in Hacl.Streaming.Interface. Sigh!!
p_key: t' ->
state_s #index c i t t'
/// Defining a series of helpers to deal with the indexed type of the key. This
/// makes proofs easier.
let optional_freeable #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.freeable #i h k
let optional_invariant #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> True
| Runtime -> key.invariant #i h k
let optional_footprint #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> B.loc_none
| Runtime -> key.footprint #i h k
let optional_reveal #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: optional_key i km key)
=
allow_inversion key_management;
match km with
| Erased -> G.reveal k
| Runtime -> key.v i h k
let optional_hide #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(h: HS.mem)
(k: key.s i):
optional_key i km key
=
allow_inversion key_management;
match km with
| Erased -> G.hide (key.v i h k)
| Runtime -> k
/// This lemma is used to convert the Hacl.Streaming.Interface.stateful.frame_freeable
/// lemma, written with freeable in its precondition, into a lemma of the form:
/// [> freeable h0 s => freeable h1 s
val stateful_frame_preserves_freeable:
#index:Type0 -> #sc:stateful index -> #i:index -> l:B.loc -> s:sc.s i -> h0:HS.mem -> h1:HS.mem ->
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
sc.freeable h0 s ==> sc.freeable h1 s))
let stateful_frame_preserves_freeable #index #sc #i l s h0 h1 =
let lem h0 h1 :
Lemma
(requires (
sc.invariant h0 s /\
B.loc_disjoint l (sc.footprint h0 s) /\
B.modifies l h0 h1 /\
sc.freeable h0 s))
(ensures (
sc.freeable h1 s))
[SMTPat (sc.freeable h0 s);
SMTPat (sc.freeable h1 s)] =
sc.frame_freeable l s h0 h1
in
()
let optional_frame #index
(#i: index)
(#km: key_management)
(#key: stateful index)
(l: B.loc)
(s: optional_key i km key)
(h0 h1: HS.mem):
Lemma
(requires (
optional_invariant h0 s /\
B.loc_disjoint l (optional_footprint h0 s) /\
B.modifies l h0 h1))
(ensures (
optional_invariant h1 s /\
optional_reveal h0 s == optional_reveal h1 s /\
optional_footprint h1 s == optional_footprint h0 s /\
(optional_freeable h0 s ==> optional_freeable h1 s)))
=
allow_inversion key_management;
match km with
| Erased -> ()
| Runtime ->
key.frame_invariant #i l s h0 h1;
stateful_frame_preserves_freeable #index #key #i l s h0 h1
let footprint_s #index (c: block index) (i: index) (h: HS.mem) s =
let State block_state buf_ _ _ p_key = s in
B.(loc_addr_of_buffer buf_ `loc_union` c.state.footprint h block_state `loc_union` optional_footprint h p_key)
/// Invariants
/// ==========
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let invariant_s #index (c: block index) (i: index) h s =
let State block_state buf_ total_len seen key = s in
let seen = G.reveal seen in
let key_v = optional_reveal h key in
let all_seen = S.append (c.init_input_s i key_v) seen in
let blocks, rest = split_at_last c i all_seen in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
// Liveness and disjointness (administrative)
B.live h buf_ /\ c.state.invariant #i h block_state /\ optional_invariant h key /\
B.(loc_disjoint (loc_buffer buf_) (c.state.footprint h block_state)) /\
B.(loc_disjoint (loc_buffer buf_) (optional_footprint h key)) /\
B.(loc_disjoint (optional_footprint h key) (c.state.footprint h block_state)) /\
// Formerly, the "hashes" predicate
S.length blocks + S.length rest = U64.v total_len /\
U32.v (c.init_input_len i) + S.length seen = U64.v total_len /\
U64.v total_len <= U64.v (c.max_input_len i) /\
// Note the double equals here, we now no longer know that this is a sequence.
c.state.v i h block_state == c.update_multi_s i (c.init_s i key_v) 0 blocks /\
S.equal (S.slice (B.as_seq h buf_) 0 (Seq.length rest)) rest
#pop-options
inline_for_extraction noextract
let freeable_s (#index: Type0) (c: block index) (i: index) (h: HS.mem) (s: state_s' c i): Type0 =
let State block_state buf_ total_len seen key = s in
B.freeable buf_ /\ c.state.freeable h block_state /\ optional_freeable h key
let freeable (#index : Type0) (c: block index) (i: index) (h: HS.mem) (s: state' c i) =
freeable_s c i h (B.get h s 0) /\
B.freeable s
#push-options "--max_ifuel 1"
let invariant_loc_in_footprint #index c i s m =
[@inline_let]
let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let]
let _ = c.key.invariant_loc_in_footprint #i in
()
#pop-options
let seen #index c i h s =
G.reveal (State?.seen (B.deref h s))
let seen_bounded #index c i h s =
()
let reveal_key #index c i h s =
optional_reveal h (State?.p_key (B.deref h s))
let init_input (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
c.init_input_s i (reveal_key c i h s)
let all_seen (#index:Type0) (c:block index) (i:index) (h:HS.mem) (s:state' c i) : GTot bytes =
S.append (init_input c i h s) (seen c i h s)
let frame_invariant #index c i l s h0 h1 =
let state_t = B.deref h0 s in
let State block_state _ _ _ p_key = state_t in
c.state.frame_invariant #i l block_state h0 h1;
stateful_frame_preserves_freeable #index #c.state #i l block_state h0 h1;
allow_inversion key_management;
match c.km with
| Erased -> ()
| Runtime ->
stateful_frame_preserves_freeable #index #c.key #i l p_key h0 h1;
c.key.frame_invariant #i l p_key h0 h1
let frame_seen #_ _ _ _ _ _ _ =
()
/// Stateful API
/// ============
let index_of_state #index c i t t' s =
let open LowStar.BufferOps in
let State block_state _ _ _ _ = !*s in
c.index_of_state i block_state
let seen_length #index c i t t' s =
let open LowStar.BufferOps in
let State _ _ total_len _ _ = !*s in
total_len
(* TODO: malloc and alloca have big portions of proofs in common, so it may
* be possible to factorize them, but it is not clear how *)
#restart-solver
#push-options "--z3rlimit 500"
let malloc #index c i t t' key r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none key h0 h1;
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none key h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none key h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) c.state.frame_freeable B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 key);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 key) (c.key.footprint #i h3 k'));
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') key h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 key)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none key h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) key buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let s = B.get h8 p 0 in
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true r) (footprint c i h8 p));
(**) assert (ST.equal_stack_domains h1 h8);
(**) assert (ST.equal_stack_domains h0 h1);
p
#pop-options
#push-options "--z3rlimit 100"
let copy #index c i t t' state r =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
// All source state is suffixed by 0.
let State block_state0 buf0 total_len0 seen0 k0 = !*state in
let i = c.index_of_state i block_state0 in
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.malloc r (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
B.blit buf0 0ul buf 0ul (c.blocks_state_len i);
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h0 h1;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h1 state);
let block_state = c.state.create_in i r in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h1 h2;
(**) c.state.frame_invariant #i B.loc_none block_state0 h0 h1;
(**) assert (invariant c i h2 state);
c.state.copy (G.hide i) block_state0 block_state;
(**) let h2 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i (c.state.footprint #i h2 block_state) k0 h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.create_in i r in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant #i B.loc_none k0 h2 h3;
(**) c.state.frame_invariant #i B.loc_none block_state h2 h3;
(**) c.state.frame_freeable #i B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k0);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k0) (c.key.footprint #i h3 k'));
c.key.copy i k0 k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant #i (c.key.footprint #i h3 k') k0 h3 h4;
(**) c.state.frame_invariant #i (c.key.footprint #i h3 k') block_state h3 h4;
(**) c.state.frame_freeable #i (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased -> k0
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
let s = State block_state buf total_len0 seen0 k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.malloc r s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) if c.km = Runtime then
(**) c.key.frame_invariant #i B.loc_none k0 h5 h6;
(**) c.state.frame_invariant #i B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) c.state.frame_freeable B.loc_none block_state h5 h6;
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
p
#pop-options
#push-options "--z3rlimit 200"
let alloca #index c i t t' k =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
(**) let h0 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h0;
let buf = B.alloca (Lib.IntTypes.u8 0) (c.blocks_state_len i) in
(**) let h1 = ST.get () in
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h1);
(**) B.loc_unused_in_not_unused_in_disjoint h1;
(**) B.(modifies_only_not_unused_in loc_none h0 h1);
(**) c.key.frame_invariant B.loc_none k h0 h1;
let block_state = c.state.alloca i in
(**) let h2 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h2 block_state) h0 h2);
(**) B.loc_unused_in_not_unused_in_disjoint h2;
(**) B.(modifies_only_not_unused_in loc_none h1 h2);
(**) c.key.frame_invariant B.loc_none k h1 h2;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
let k' = c.key.alloca i in
(**) let h3 = ST.get () in
(**) B.loc_unused_in_not_unused_in_disjoint h3;
(**) B.(modifies_only_not_unused_in loc_none h2 h3);
(**) c.key.frame_invariant B.loc_none k h2 h3;
(**) c.state.frame_invariant B.loc_none block_state h2 h3;
(**) assert (B.fresh_loc (c.key.footprint #i h3 k') h0 h3);
(**) assert (c.key.invariant #i h3 k');
(**) assert (c.key.invariant #i h3 k);
(**) assert B.(loc_disjoint (c.key.footprint #i h3 k) (c.key.footprint #i h3 k'));
c.key.copy i k k';
(**) let h4 = ST.get () in
(**) assert (B.fresh_loc (c.key.footprint #i h4 k') h0 h4);
(**) B.loc_unused_in_not_unused_in_disjoint h4;
(**) B.(modifies_only_not_unused_in loc_none h2 h4);
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h3 k') k h3 h4;
(**) c.state.frame_invariant (c.key.footprint #i h3 k') block_state h3 h4;
k'
| Erased ->
G.hide (c.key.v i h0 k)
in
(**) let h5 = ST.get () in
(**) assert (B.fresh_loc (optional_footprint h5 k') h0 h5);
(**) assert (B.fresh_loc (c.state.footprint #i h5 block_state) h0 h5);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let s = State block_state buf total_len (G.hide S.empty) k' in
(**) assert (B.fresh_loc (footprint_s c i h5 s) h0 h5);
(**) B.loc_unused_in_not_unused_in_disjoint h5;
let p = B.alloca s 1ul in
(**) let h6 = ST.get () in
(**) B.(modifies_only_not_unused_in loc_none h5 h6);
(**) B.(modifies_only_not_unused_in loc_none h0 h6);
(**) c.key.frame_invariant B.loc_none k h5 h6;
(**) c.state.frame_invariant B.loc_none block_state h5 h6;
(**) optional_frame B.loc_none k' h5 h6;
(**) assert (B.fresh_loc (B.loc_addr_of_buffer p) h0 h6);
(**) assert (B.fresh_loc (footprint_s c i h6 s) h0 h6);
(**) assert (optional_reveal h5 k' == optional_reveal h6 k');
c.init (G.hide i) k buf block_state;
(**) let h7 = ST.get () in
(**) assert (B.fresh_loc (c.state.footprint #i h7 block_state) h0 h7);
(**) assert (B.fresh_loc (B.loc_buffer buf) h0 h7);
(**) optional_frame (B.loc_union (c.state.footprint #i h7 block_state) (B.loc_buffer buf)) k' h6 h7;
(**) c.update_multi_zero i (c.state.v i h7 block_state) 0;
(**) B.modifies_only_not_unused_in B.loc_none h0 h7;
(**) assert (c.state.v i h7 block_state == c.init_s i (optional_reveal h6 k'));
(**) let h8 = ST.get () in
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h8 p in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert(invariant_s c i h8 s)
(**) end;
(**) assert (invariant c i h8 p);
(**) assert (seen c i h8 p == S.empty);
(**) assert B.(modifies loc_none h0 h8);
(**) assert (B.fresh_loc (footprint c i h8 p) h0 h8);
(**) assert B.(loc_includes (loc_region_only true (HS.get_tip h8)) (footprint c i h8 p));
(**) assert(ST.same_refs_in_non_tip_regions h0 h8);
p
#pop-options
#push-options "--z3cliopt smt.arith.nl=false"
let reset #index c i t t' state key =
[@inline_let] let _ = c.state.invariant_loc_in_footprint #i in
[@inline_let] let _ = c.key.invariant_loc_in_footprint #i in
allow_inversion key_management;
let open LowStar.BufferOps in
(**) let h1 = ST.get () in
let State block_state buf _ _ k' = !*state in
let i = c.index_of_state i block_state in
LowStar.Ignore.ignore i; // This is only used in types and proofs
[@inline_let]
let block_state: c.state.s i = block_state in
c.init (G.hide i) key buf block_state;
(**) let h2 = ST.get () in
(**) optional_frame #_ #i #c.km #c.key (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) k' h1 h2;
(**) c.key.frame_invariant (B.loc_union (c.state.footprint #i h1 block_state) (B.loc_buffer buf)) key h1 h2;
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % UInt32.v (Block?.block_len c i) = 0);
(**) assert (reveal_key c i h1 state == reveal_key c i h2 state);
(**) c.update_multi_zero i (c.state.v i h2 block_state) 0;
let k': optional_key i c.km c.key =
match c.km with
| Runtime ->
c.key.copy i key k';
(**) let h4 = ST.get () in
(**) assert (c.key.invariant #i h4 k');
(**) c.key.frame_invariant (c.key.footprint #i h2 k') key h2 h4;
(**) c.state.frame_invariant (c.key.footprint #i h2 k') block_state h2 h4;
(**) stateful_frame_preserves_freeable (c.key.footprint #i h2 k') block_state h2 h4;
k'
| Erased ->
G.hide (c.key.v i h1 key)
in
(**) let h2 = ST.get () in
(**) assert(preserves_freeable c i state h1 h2);
[@inline_let] let total_len = Int.Cast.uint32_to_uint64 (c.init_input_len i) in
let tmp: state_s c i t t' = State block_state buf total_len (G.hide S.empty) k' in
B.upd state 0ul tmp;
(**) let h3 = ST.get () in
(**) c.state.frame_invariant B.(loc_buffer state) block_state h2 h3;
(**) c.key.frame_invariant B.(loc_buffer state) key h2 h3;
(**) optional_frame #_ #i #c.km #c.key B.(loc_buffer state) k' h2 h3;
(**) stateful_frame_preserves_freeable B.(loc_buffer state) block_state h2 h3;
(**) assert(preserves_freeable c i state h2 h3);
// This seems to cause insurmountable difficulties. Puzzled.
ST.lemma_equal_domains_trans h1 h2 h3;
// AR: 07/22: same old `Seq.equal` and `==` story
(**) assert (Seq.equal (seen c i h3 state) Seq.empty);
(**) assert (footprint c i h1 state == footprint c i h3 state);
(**) assert (B.(modifies (footprint c i h1 state) h1 h3));
(**) assert (U64.v total_len <= U64.v (c.max_input_len i));
(**) begin
(**) let key_v = reveal_key c i h3 state in
(**) let all_seen_ = all_seen c i h3 state in
// SH (11/22): the proof fails if we don't introduce the call to [split_at_last]
(**) let blocks, rest = split_at_last c i all_seen_ in
(**) let init_input = c.init_input_s i key_v in
(**) split_at_last_init c i init_input;
(**) assert (invariant_s c i h3 (B.get h3 state 0))
(**) end;
(**) assert(preserves_freeable c i state h1 h3)
#pop-options
/// Some helpers to minimize modulo-reasoning
/// =========================================
val split_at_last_num_blocks_lem (#index : Type0) (c: block index) (i: index) (b: nat):
Lemma (
let n_blocks = split_at_last_num_blocks c i b in
let blocks = n_blocks * U32.v (c.blocks_state_len i) in
0 <= blocks /\ blocks <= b)
let split_at_last_num_blocks_lem #index c i b = ()
/// The ``rest`` function below allows computing, based ``total_len`` stored in
/// the state, the length of useful data currently stored in ``buf``.
/// Unsurprisingly, there's a fair amount of modulo reasoning here because of
/// 64-bit-to-32-bit conversions, so we do them once and for all in a helper.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest #index (c: block index) (i: index)
(total_len: UInt64.t): (x:UInt32.t {
let n = split_at_last_num_blocks c i (U64.v total_len) in
let l = U32.v (c.blocks_state_len i) in
0 <= n * l /\ n * l <= U64.v total_len /\
U32.v x = U64.v total_len - (n * l)})
=
let open FStar.Int.Cast in
[@inline_let] let l = uint32_to_uint64 (c.blocks_state_len i) in
[@inline_let] let r = total_len `U64.rem` l in
(**) let total_len_v : Ghost.erased nat = U64.v total_len in
(**) let l_v : Ghost.erased nat = U64.v l in
(**) let r_v : Ghost.erased nat = U64.v r in
(**) assert(Ghost.reveal r_v = total_len_v - ((total_len_v / l_v) * l_v));
(**) Math.Lemmas.euclidean_division_definition total_len_v l_v;
(**) assert(Ghost.reveal r_v = total_len_v % l_v);
(**) assert(r_v < l_v);
if U64.(r =^ uint_to_t 0) && U64.(total_len >^ uint_to_t 0) then
begin
(**) split_at_last_num_blocks_lem c i (U64.v total_len);
c.blocks_state_len i
end
else
begin
[@inline_let] let r' = FStar.Int.Cast.uint64_to_uint32 r in
(**) FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32);
(**) calc (==) {
(**) U32.v r';
(**) (==) { }
(**) U64.v r % pow2 32;
(**) (==) { FStar.Math.Lemmas.small_modulo_lemma_1 (U64.v r) (pow2 32) }
(**) U64.v r;
(**) (==) { FStar.Math.Lemmas.euclidean_division_definition (U64.v total_len) (U64.v (uint32_to_uint64 (c.blocks_state_len i))) }
(**) U64.v total_len % U64.v (uint32_to_uint64 (c.blocks_state_len i) );
(**) (==) { }
(**) U64.v total_len % U32.v (c.blocks_state_len i);
(**) };
(**) assert(
(**) let n = split_at_last_num_blocks c i (U64.v total_len) in
(**) let l = U32.v (c.blocks_state_len i) in
(**) U32.v r' = U64.v total_len - (n * l));
r'
end
#pop-options
/// The ``nblocks`` function below allows computing, given ``total_len`` stored in
/// the state, the number of blocks of data which have been processed (the remaining
/// unprocessed data being left in ``buf``).
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let nblocks #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.blocks_state_len i) in
U32.v x * l <= U32.v len /\
U32.v x = split_at_last_num_blocks c i (U32.v len) })
=
let open FStar.Int.Cast in
[@inline_let] let l = c.blocks_state_len i in
[@inline_let] let r = rest c i (uint32_to_uint64 len) in
(**) let len_v : Ghost.erased nat = U32.v len in
(**) let l_v : Ghost.erased nat = U32.v l in
(**) let r_v : Ghost.erased nat = U32.v r in
(**) let n_s : Ghost.erased nat = split_at_last_num_blocks c i len_v in
(**) assert(Ghost.reveal len_v = n_s * l_v + r_v);
(**) Math.Lemmas.nat_times_nat_is_nat n_s l_v;
(**) assert(U32.v r <= U32.v len);
[@inline_let] let blocks = len `U32.sub` r in
(**) let blocks_v : Ghost.erased nat = U32.v blocks in
(**) assert(blocks_v % l_v = 0);
[@inline_let] let n = blocks `U32.div` l in
(**) let n_v : Ghost.erased nat = U32.v n in
(**) assert(n_v * l_v = Ghost.reveal blocks_v);
(**) split_at_last_num_blocks_spec c i len_v n_v r_v;
n
#pop-options
/// The ``rest`` function to call on the unprocessed data length in the ``finish``
/// function.
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let rest_finish #index (c: block index) (i: index)
(len: UInt32.t): (x:UInt32.t {
let l = U32.v (c.block_len i) in
let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
0 <= n * l /\ n * l <= U32.v len /\
U32.v x = U32.v len - (n * l)})
=
[@inline_let] let l = c.block_len i in
[@inline_let] let r = len `U32.rem` l in
(**) split_at_last_num_blocks_lem c i (U32.v len);
if U32.(r =^ uint_to_t 0) && U32.(len >^ uint_to_t 0) then
begin
(**) begin
(**) let l = U32.v (c.block_len i) in
(**) let n = fst (Lib.UpdateMulti.split_at_last_lazy_nb_rem l (U32.v len)) in
(**) Math.Lemmas.nat_times_nat_is_nat n l
(**) end;
c.block_len i
end
else
r
#pop-options
/// We always add 32-bit lengths to 64-bit lengths. Having a helper for that allows
/// doing modulo reasoning once and for all.
inline_for_extraction noextract
let add_len #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t):
Pure UInt64.t
(requires U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures fun x -> U64.v x = U64.v total_len + U32.v len /\ U64.v x <= U64.v (c.max_input_len i))
=
total_len `U64.add` Int.Cast.uint32_to_uint64 len
#push-options "--z3cliopt smt.arith.nl=false"
inline_for_extraction noextract
let add_len_small #index (c: block index) (i: index) (total_len: UInt64.t) (len: UInt32.t): Lemma
(requires
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i total_len) /\
U64.v total_len + U32.v len <= U64.v (c.max_input_len i))
(ensures (rest c i (add_len c i total_len len) = rest c i total_len `U32.add` len))
=
let total_len_v = U64.v total_len in
let l = U32.v (c.blocks_state_len i) in
let b = total_len_v + U32.v len in
let n = split_at_last_num_blocks c i total_len_v in
let r = U32.v (rest c i total_len) in
assert(total_len_v = n * l + r);
let r' = U32.v (rest c i total_len) + U32.v len in
assert(r' <= l);
assert(r' = 0 ==> b = 0);
Math.Lemmas.euclidean_division_definition b l;
assert(b = n * l + r');
split_at_last_num_blocks_spec c i b n r'
#pop-options
/// Beginning of the three sub-cases (see Hacl.Streaming.Spec)
/// ==========================================================
noextract
let total_len_h #index (c: block index) (i: index) h (p: state' c i) =
State?.total_len (B.deref h p)
noextract
let split_at_last_all_seen #index (c: block index) (i: index) h (p: state' c i) =
let all_seen = all_seen c i h p in
let blocks, rest = split_at_last c i all_seen in
blocks, rest
inline_for_extraction noextract
val update_small:
#index:Type0 ->
(c: block index) ->
i:index -> (
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
Stack unit
(requires fun h0 ->
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)))
(ensures fun h0 s' h1 ->
update_post c i s data len h0 h1))
/// SH: The proof obligations for update_small have problem succeeding in command
/// line mode: hence the restart-solver instruction, the crazy rlimit and the
/// intermediate lemma. Interestingly (and frustratingly), the proof succeeds
/// quite quickly locally on command-line with this rlimit, but fails with a lower
/// one. Besides, the lemma is needed only for the CI regression.
let split_at_last_rest_eq (#index : Type0) (c: block index)
(i: index)
(t:Type0 { t == c.state.s i })
(t':Type0 { t' == optional_key i c.km c.key })
(s: state c i t t') (h0: HS.mem) :
Lemma
(requires (
invariant c i h0 s))
(ensures (
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
Seq.length r == U32.v sz)) =
let s = B.get h0 s 0 in
let State block_state buf total_len seen_ k' = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 k' in
let all_seen = S.append (c.init_input_s i key_v) seen_ in
let _, r = split_at_last c i all_seen in
let sz = rest c i total_len in
()
/// Particularly difficult proof. Z3 profiling indicates that a pattern goes off
/// the rails. So I disabled all of the known "bad" patterns, then did the proof
/// by hand. Fortunately, there were only two stateful operations. The idea was
/// to do all ofthe modifies-reasoning in the two lemmas above, then disable the
/// bad pattern for the main function.
///
/// This style is a little tedious, because it requires a little bit of digging
/// to understand what needs to hold in order to be able to prove that e.g. the
/// sequence remains unmodified from h0 to h2, but this seems more robust?
val modifies_footprint:
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
s:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State _ buf_ _ _ _ = B.deref h0 s in (
update_pre c i s data len h0 /\
B.(modifies (loc_buffer buf_) h0 h1))))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 s in
let State bs1 buf1 _ _ k1 = B.deref h1 s in (
footprint c i h0 s == footprint c i h1 s /\
preserves_freeable c i s h0 h1 /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1 /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (loc_addr_of_buffer buf1)) /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.state.footprint h1 bs1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer buf1)) /\
B.(loc_disjoint (loc_buffer s) (loc_buffer data)) /\
B.(loc_disjoint (loc_buffer s) (c.state.footprint h1 bs1)) /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer s) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer s) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer s) loc_none) /\
True)))))
let modifies_footprint c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf0 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_buffer buf0) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_buffer buf0) k0 h0 h1
val modifies_footprint':
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
p:state' c i ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h0 p /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h0 bs0)) /\
B.(loc_disjoint (loc_addr_of_buffer p) (loc_addr_of_buffer buf0)) /\
c.state.invariant h0 bs0 /\
(if c.km = Runtime then
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h0 k0)) /\
c.key.invariant #i h0 k0
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none)) /\
B.(modifies (loc_buffer p) h0 h1)) /\
bs0 == bs1 /\ buf0 == buf1 /\ k0 == k1))
(ensures (
let State bs0 buf0 _ _ k0 = B.deref h0 p in
let State bs1 buf1 _ _ k1 = B.deref h1 p in (
B.live h1 p /\
footprint c i h0 p == footprint c i h1 p /\
preserves_freeable c i p h0 h1 /\
B.(loc_disjoint (loc_addr_of_buffer p) (footprint_s c i h1 (B.deref h1 p))) /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.state.footprint #i h1 bs1)) /\
B.(loc_disjoint (loc_buffer p) (c.state.footprint #i h1 bs1)) /\
c.state.invariant h1 bs1 /\
c.state.v i h1 bs1 == c.state.v i h0 bs0 /\
c.state.footprint h1 bs1 == c.state.footprint h0 bs0 /\
(if c.km = Runtime then
c.key.invariant #i h1 k1 /\
c.key.v i h1 k1 == c.key.v i h0 k0 /\
c.key.footprint #i h1 k1 == c.key.footprint #i h0 k0 /\
B.(loc_disjoint (loc_addr_of_buffer p) (c.key.footprint #i h1 k1)) /\
B.(loc_disjoint (loc_buffer p) (c.key.footprint #i h1 k1))
else
B.(loc_disjoint (loc_addr_of_buffer p) loc_none))))))
let modifies_footprint' c i p data len h0 h1 =
let _ = c.state.frame_freeable #i in
let _ = c.key.frame_freeable #i in
let _ = c.state.frame_invariant #i in
let _ = c.key.frame_invariant #i in
let _ = allow_inversion key_management in
let s0 = B.deref h0 p in
let s1 = B.deref h0 p in
let State bs0 buf0 _ _ k0 = s0 in
let State bs1 buf1 _ _ k1 = s1 in
c.state.frame_invariant (B.loc_addr_of_buffer p) bs0 h0 h1;
if c.km = Runtime then
c.key.frame_invariant #i (B.loc_addr_of_buffer p) k0 h0 h1
/// Small helper which we use to factor out functional correctness proof obligations.
/// It states that a state was correctly updated to process some data between two
/// memory snapshots (the key is the same, the seen data was updated, etc.).
///
/// Note that we don't specify anything about the buffer and the block_state: they
/// might have been updated differently depending on the case.
unfold val state_is_updated :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Type0)
#push-options "--z3cliopt smt.arith.nl=false"
let state_is_updated #index c i t t' p data len h0 h1 =
// Functional conditions about the memory updates
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
block_state1 == block_state0 /\
buf1 == buf0 /\
U64.v total_len1 == U64.v total_len0 + U32.v len /\
key1 == key0 /\
seen1 `S.equal` (seen0 `S.append` (B.as_seq h0 data)) /\
optional_reveal #index #i #c.km #c.key h1 key1 == optional_reveal #index #i #c.km #c.key h0 key0
#pop-options
/// The functional part of the invariant
unfold val invariant_s_funct :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Pure Type0 (requires
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
state_is_updated c i t t' s data len h0 h1)
(ensures (fun _ -> True)))
let invariant_s_funct #index c i t t' p data len h0 h1 =
let blocks, rest = split_at_last_all_seen c i h1 p in
let s = B.get h1 p 0 in
let State block_state buf_ total_len seen key = s in
let key_v = optional_reveal #index #i #c.km #c.key h0 key in
let init_s = c.init_s i key_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
c.state.v i h1 block_state == c.update_multi_s i init_s 0 blocks /\
S.equal (S.slice (B.as_seq h1 buf_) 0 (Seq.length rest)) rest
/// We isolate the functional correctness proof obligations for [update_small]
val update_small_functional_correctness :
#index:Type0 ->
(c: block index) ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// The precondition of [small_update]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
U32.v len <= U32.v (c.blocks_state_len i) - U32.v (rest c i (total_len_h c i h0 s)) /\
// Generic conditions
state_is_updated c i t t' s data len h0 h1 /\
// Functional conditions about the memory updates
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let sz = rest c i total_len0 in
let buf = buf0 in
let data_v0 = B.as_seq h0 data in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
buf_part_v1 == S.append buf_beg_v0 data_v0 /\
c.state.v i h1 block_state1 == c.state.v i h0 block_state0
end
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#push-options "--z3cliopt smt.arith.nl=false"
let update_small_functional_correctness #index c i t t' p data len h0 h1 =
let s0 = B.get h0 p 0 in
let s1 = B.get h1 p 0 in
let State block_state buf total_len0 seen0 key = s0 in
let seen0 = G.reveal seen0 in
let i = Ghost.reveal i in
let key_v0 = optional_reveal #_ #i #c.km #c.key h0 key in
let init_v0 = c.init_input_s i key_v0 in
let all_seen0 = S.append init_v0 seen0 in
let blocks0, rest0 = split_at_last c i all_seen0 in
let State block_state buf total_len1 seen1 key = s1 in
let seen1 = G.reveal seen1 in
let i = Ghost.reveal i in
let key_v1 = optional_reveal #_ #i #c.km #c.key h1 key in
assert(key_v1 == key_v0);
let init_v1 = c.init_input_s i key_v1 in
assert(init_v1 == init_v0);
let all_seen1 = S.append init_v1 seen1 in
let blocks1, rest1 = split_at_last c i all_seen1 in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.block_len c i));
(**) assert(0 % U32.v (Block?.block_len c i) = 0);
(**) Math.Lemmas.modulo_lemma 0 (U32.v (Block?.blocks_state_len c i));
(**) assert(0 % U32.v (Block?.blocks_state_len c i) = 0);
let data_v0 = B.as_seq h0 data in
split_at_last_small c i all_seen0 data_v0;
// The first problematic condition
assert(blocks1 `S.equal` blocks0);
assert(c.state.v i h1 block_state == c.update_multi_s i (c.init_s i key_v1) 0 blocks1);
// The second problematic condition
assert(S.equal (S.slice (B.as_seq h1 buf) 0 (Seq.length rest1)) rest1)
#pop-options
// The absence of loc_disjoint_includes makes reasoning a little more difficult.
// Notably, we lose all of the important disjointness properties between the
// outer point p and the buffer within B.deref h p. These need to be
// re-established by hand. Another thing that we lose without this pattern is
// knowing that loc_buffer b is included within loc_addr_of_buffer b. This is
// important for reasoning about the preservation of e.g. the contents of data.
#restart-solver
#push-options "--z3rlimit 300 --z3cliopt smt.arith.nl=false --z3refresh \
--using_facts_from '*,-LowStar.Monotonic.Buffer.unused_in_not_unused_in_disjoint_2,-FStar.Seq.Properties.slice_slice,-LowStar.Monotonic.Buffer.loc_disjoint_includes_r'"
let update_small #index c i t t' p data len =
let open LowStar.BufferOps in
let s = !*p in
let State block_state buf total_len seen_ k' = s in
[@inline_let]
let block_state: c.state.s i = block_state in
// Functional reasoning.
let sz = rest c i total_len in
add_len_small c i total_len len;
let h0 = ST.get () in
let buf1 = B.sub buf 0ul sz in
let buf2 = B.sub buf sz len in
// Memory reasoning.
c.state.invariant_loc_in_footprint h0 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h0 k';
// key_invariant_loc_in_footprint #index c i h0 p;
B.(loc_disjoint_includes_r (loc_buffer data) (footprint c i h0 p) (loc_buffer buf2));
// FIRST STATEFUL OPERATION
B.blit data 0ul buf2 0ul len;
// Memory reasoning.
let h1 = ST.get () in
modifies_footprint c i p data len h0 h1;
c.state.invariant_loc_in_footprint h1 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h1 k';
// Functional reasoning on data
begin
let buf1_v0 = B.as_seq h0 buf1 in
let buf1_v1 = B.as_seq h1 buf1 in
let buf2_v1 = B.as_seq h1 buf2 in
let buf_beg_v0 = S.slice (B.as_seq h0 buf) 0 (U32.v sz) in
let buf_part_v1 = S.slice (B.as_seq h1 buf) 0 (U32.v sz + U32.v len) in
let data_v0 = B.as_seq h0 data in
assert(buf1_v1 == buf1_v0);
assert(buf1_v0 == buf_beg_v0);
assert(buf2_v1 `S.equal` data_v0);
assert(buf_part_v1 `S.equal` S.append buf_beg_v0 data_v0)
end;
// SECOND STATEFUL OPERATION
let total_len = add_len c i total_len len in
[@inline_let]
let tmp: state_s c i t t' =
State #index #c #i block_state buf total_len
(G.hide (G.reveal seen_ `S.append` (B.as_seq h0 data))) k'
in
p *= tmp;
// Memory reasoning.
let h2 = ST.get () in
modifies_footprint' c i p data len h1 h2;
c.state.invariant_loc_in_footprint h2 block_state;
if c.km = Runtime then
c.key.invariant_loc_in_footprint #i h2 k';
ST.lemma_equal_domains_trans h0 h1 h2;
// Prove the invariant
update_small_functional_correctness c i t t' p data len h0 h2
#pop-options
// Stupid name collisions
noextract let seen_h = seen
noextract let all_seen_h = all_seen
/// Case 2: we have no buffered data (ie: the buffer was just initialized), or the
/// internal buffer is full meaning that we can just hash it to go to the case where
/// there is no buffered data. Of course, the data we append has to be non-empty,
/// otherwise we might end-up with an empty internal buffer.
/// Auxiliary lemma which groups the functional correctness proof obligations
/// for [update_empty_or_full].
#push-options "--z3cliopt smt.arith.nl=false"
val update_empty_or_full_functional_correctness :
#index:Type0 ->
c:block index ->
i:G.erased index -> (
let i = G.reveal i in
t:Type0 { t == c.state.s i } ->
t':Type0 { t' == optional_key i c.km c.key } ->
s:state c i t t' ->
data: B.buffer Lib.IntTypes.uint8 ->
len: UInt32.t ->
h0: HS.mem ->
h1: HS.mem ->
Lemma
(requires (
// Same precondition as [update_empty_or_full_buf]
update_pre c i s data len h0 /\
U32.v (c.init_input_len i) + S.length (seen c i h0 s) + U32.v len <= U64.v (c.max_input_len i) /\
(rest c i (total_len_h c i h0 s) = 0ul \/
rest c i (total_len_h c i h0 s) = c.blocks_state_len i) /\
U32.v len > 0 /\
// Generic additional preconditions
state_is_updated c i t t' s data len h0 h1 /\
// Additional preconditions
begin
let s0 = B.get h0 s 0 in
let s1 = B.get h1 s 0 in
let State block_state0 buf0 total_len0 seen0 key0 = s0 in
let State block_state1 buf1 total_len1 seen1 key1 = s1 in
let seen0 = G.reveal seen0 in
let seen1 = G.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = nblocks c i len in
(**) split_at_last_num_blocks_lem c i (U32.v len);
(**) assert(U32.v n_blocks * U32.v (c.blocks_state_len i) <= U32.v len);
(**) assert(U32.(FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n));
let data1_len = n_blocks `U32.mul` c.blocks_state_len i in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let all_seen0 = all_seen c i h0 s in
let all_seen1 = all_seen c i h1 s in
let blocks0, res0 = split_at_last c i all_seen0 in
let blocks1, res1 = split_at_last c i all_seen1 in
let data1_v = B.as_seq h0 data1 in
let data2_v = B.as_seq h0 data2 in
let key = optional_reveal #index #i #c.km #c.key h0 key0 in
let init_s = c.init_s i key in
let all_seen_data1 = S.append all_seen0 data1_v in
(**) Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
S.length all_seen0 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
S.length all_seen_data1 % U32.v (c.block_len i) = 0 /\ // TODO: should be proved automatically
c.state.v i h1 block_state == c.update_multi_s i init_s 0 all_seen_data1 /\
S.slice (B.as_seq h1 buf) 0 (Seq.length data2_v) `S.equal` data2_v /\
True
end /\
True
))
(ensures (invariant_s_funct c i t t' s data len h0 h1)))
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.UpdateMulti.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Types.fst.checked",
"Hacl.Streaming.Spec.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Streaming.Functor.fst"
} | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Interface",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"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": [
"smt.arith.nl=false"
],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | c: Hacl.Streaming.Interface.block index -> i: FStar.Ghost.erased index
-> (let i = FStar.Ghost.reveal i in
t: Type0{t == Stateful?.s (Block?.state c) i} ->
t': Type0{t' == Hacl.Streaming.Interface.optional_key i (Block?.km c) (Block?.key c)} ->
s: Hacl.Streaming.Functor.state c i t t' ->
data: LowStar.Buffer.buffer Lib.IntTypes.uint8 ->
len: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
Hacl.Streaming.Functor.update_pre c i s data len h0 /\
FStar.UInt32.v (Block?.init_input_len c i) +
FStar.Seq.Base.length (Hacl.Streaming.Functor.seen c i h0 s) +
FStar.UInt32.v len <=
FStar.UInt64.v (Block?.max_input_len c i) /\
(Hacl.Streaming.Functor.rest c i (Hacl.Streaming.Functor.total_len_h c i h0 s) = 0ul \/
Hacl.Streaming.Functor.rest c i (Hacl.Streaming.Functor.total_len_h c i h0 s) =
Block?.blocks_state_len c i) /\ FStar.UInt32.v len > 0 /\
Hacl.Streaming.Functor.state_is_updated c (FStar.Ghost.hide i) t t' s data len h0 h1 /\
(let s0 = LowStar.Monotonic.Buffer.get h0 s 0 in
let s1 = LowStar.Monotonic.Buffer.get h1 s 0 in
let _ = s0 in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ block_state0 buf0 _ seen0 key0 =
_
in
let _ = s1 in
(let Hacl.Streaming.Functor.State #_ #_ #_ #_ #_ _ _ _ seen1 _ = _ in
let seen0 = FStar.Ghost.reveal seen0 in
let seen1 = FStar.Ghost.reveal seen1 in
let block_state = block_state0 in
let buf = buf0 in
let n_blocks = Hacl.Streaming.Functor.nblocks c i len in
Hacl.Streaming.Functor.split_at_last_num_blocks_lem c i (FStar.UInt32.v len);
assert (FStar.UInt32.v n_blocks * FStar.UInt32.v (Block?.blocks_state_len c i) <=
FStar.UInt32.v len);
assert (FStar.UInt.size (FStar.UInt32.v n_blocks *
FStar.UInt32.v (Block?.blocks_state_len c i))
FStar.UInt32.n);
let data1_len = FStar.UInt32.mul n_blocks (Block?.blocks_state_len c i) in
let data2_len = FStar.UInt32.sub len data1_len in
let data1 = LowStar.Buffer.gsub data 0ul data1_len in
let data2 = LowStar.Buffer.gsub data data1_len data2_len in
let all_seen0 = Hacl.Streaming.Functor.all_seen c i h0 s in
let all_seen1 = Hacl.Streaming.Functor.all_seen c i h1 s in
let _ = Hacl.Streaming.Spec.split_at_last c i all_seen0 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ _ _ = _ in
let _ = Hacl.Streaming.Spec.split_at_last c i all_seen1 in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ _ _ = _ in
let data1_v = LowStar.Monotonic.Buffer.as_seq h0 data1 in
let data2_v = LowStar.Monotonic.Buffer.as_seq h0 data2 in
let key = Hacl.Streaming.Functor.optional_reveal h0 key0 in
let init_s = Block?.init_s c i key in
let all_seen_data1 = FStar.Seq.Base.append all_seen0 data1_v in
FStar.Math.Lemmas.modulo_lemma 0 (FStar.UInt32.v (Block?.block_len c i));
FStar.Seq.Base.length all_seen0 % FStar.UInt32.v (Block?.block_len c i) = 0 /\
FStar.Seq.Base.length all_seen_data1 % FStar.UInt32.v (Block?.block_len c i) =
0 /\
Stateful?.v (Block?.state c) i h1 block_state ==
Block?.update_multi_s c i init_s 0 all_seen_data1 /\
FStar.Seq.Base.equal (FStar.Seq.Base.slice (LowStar.Monotonic.Buffer.as_seq h1
buf)
0
(FStar.Seq.Base.length data2_v))
data2_v /\ Prims.l_True)
<:
Prims.logical)
<:
Prims.logical)
<:
Prims.logical)
<:
Prims.logical) /\ Prims.l_True)
(ensures
Hacl.Streaming.Functor.invariant_s_funct c (FStar.Ghost.hide i) t t' s data len h0 h1)
) | Prims.Tot | [
"total"
] | [] | [
"Hacl.Streaming.Interface.block",
"FStar.Ghost.erased",
"Prims.eq2",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.Interface.__proj__Block__item__state",
"FStar.Ghost.reveal",
"Hacl.Streaming.Interface.optional_key",
"Hacl.Streaming.Interface.__proj__Block__item__km",
"Hacl.Streaming.Interface.__proj__Block__item__key",
"Hacl.Streaming.Functor.state",
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"Prims.b2t",
"Prims.op_Equality",
"LowStar.Monotonic.Buffer.len",
"LowStar.Buffer.trivial_preorder",
"Hacl.Streaming.Interface.__proj__Block__item__blocks_state_len",
"FStar.UInt64.t",
"FStar.Seq.Base.seq",
"Hacl.Streaming.Spec.uint8",
"Hacl.Streaming.Spec.bytes",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.unit",
"FStar.Seq.Base.append",
"Hacl.Streaming.Spec.split_at_last_blocks",
"FStar.Pervasives.Native.tuple2",
"Hacl.Streaming.Spec.split_at_last",
"Hacl.Streaming.Functor.split_at_last_all_seen",
"Hacl.Streaming.Functor.bytes",
"Hacl.Streaming.Functor.all_seen",
"Hacl.Streaming.Functor.seen",
"Hacl.Streaming.Functor.init_input",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"LowStar.Monotonic.Buffer.as_seq",
"LowStar.Monotonic.Buffer.mbuffer",
"LowStar.Buffer.gsub",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.sub",
"FStar.UInt32.mul",
"FStar.UInt.size",
"FStar.Mul.op_Star",
"FStar.UInt32.v",
"FStar.UInt32.n",
"Hacl.Streaming.Functor.split_at_last_num_blocks_lem",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_Multiply",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Hacl.Streaming.Spec.split_at_last_num_blocks",
"Hacl.Streaming.Functor.nblocks",
"FStar.Math.Lemmas.modulo_lemma",
"Hacl.Streaming.Interface.__proj__Block__item__block_len",
"Hacl.Streaming.Interface.__proj__Stateful__item__t",
"Hacl.Streaming.Interface.__proj__Block__item__init_s",
"Hacl.Streaming.Functor.optional_reveal",
"Hacl.Streaming.Functor.state_s",
"LowStar.Monotonic.Buffer.get"
] | [] | false | false | false | false | false | let update_empty_or_full_functional_correctness #index c i t t' p data len h0 h1 =
| let s = B.get h0 p 0 in
let State block_state buf_ total_len seen0 key = s in
let init_s = c.init_s i (optional_reveal #index #i #c.km #c.key h0 key) in
Math.Lemmas.modulo_lemma 0 (U32.v (c.block_len i));
let n_blocks = nblocks c i len in
split_at_last_num_blocks_lem c i (U32.v len);
assert (let open U32 in FStar.UInt.size (v n_blocks * v (c.blocks_state_len i)) n);
let data1_len = n_blocks `U32.mul` (c.blocks_state_len i) in
let data2_len = len `U32.sub` data1_len in
let data1 = B.gsub data 0ul data1_len in
let data2 = B.gsub data data1_len data2_len in
let data_v = B.as_seq h0 data in
let init_input = init_input c i h0 p in
let seen1 = seen c i h1 p in
let all_seen0 = all_seen c i h0 p in
let all_seen1 = all_seen c i h1 p in
let blocks0, rest0 = split_at_last_all_seen c i h0 p in
let blocks1, rest1 = split_at_last_all_seen c i h1 p in
let data_blocks, data_rest = split_at_last c i data_v in
split_at_last_blocks c i all_seen0 data_v;
assert (Seq.equal all_seen1 (S.append all_seen0 data_v));
assert (S.equal blocks1 (S.append all_seen0 data_blocks));
assert (S.equal data_rest rest1) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.jump_vclist | val jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) | val jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) | let jump_vclist
(min: nat)
(max: nat { min <= max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1 | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 27,
"end_line": 384,
"start_col": 0,
"start_line": 361
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res
inline_for_extraction
let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res
#pop-options
let rec valid_nlist_valid_list
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
k.parser_kind_low > 0 /\
k.parser_kind_subkind == Some ParserStrong /\
valid (parse_nlist n p) h sl pos
))
(ensures (
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_list p h sl pos pos' /\
contents_list p h sl pos pos' == contents (parse_nlist n p) h sl pos
))
= if n = 0
then begin
valid_nlist_nil_recip p h sl pos;
valid_list_nil p h sl pos
end else begin
valid_nlist_cons_recip n p h sl pos;
let pos1 = get_valid_pos p h sl pos in
let pos' = get_valid_pos (parse_nlist n p) h sl pos in
valid_nlist_valid_list (n - 1) p h sl pos1;
valid_list_cons p h sl pos pos'
end
let rec valid_list_valid_nlist
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
(pos' : U32.t)
: Lemma
(requires (
valid_list p h sl pos pos'
))
(ensures (
let x = contents_list p h sl pos pos' in
valid_content_pos (parse_nlist (L.length x) p) h sl pos x pos'
))
(decreases (U32.v pos' - U32.v pos))
= if pos = pos'
then begin
valid_list_nil p h sl pos;
valid_nlist_nil p h sl pos
end else begin
valid_list_cons_recip p h sl pos pos' ;
let pos1 = get_valid_pos p h sl pos in
valid_list_valid_nlist p h sl pos1 pos' ;
valid_nlist_cons (L.length (contents_list p h sl pos1 pos')) p h sl pos
end
(* vclist *)
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_vclist
(min: U32.t)
(max: U32.t { U32.v min <= U32.v max } )
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: validator lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_vclist (U32.v min) (U32.v max) lp p))
= fun #rrel #rel input pos ->
let h = HST.get () in
[@inline_let] let _ =
valid_facts (parse_vclist (U32.v min) (U32.v max) lp p) h input (uint64_to_uint32 pos);
parse_vclist_eq (U32.v min) (U32.v max) lp p (bytes_of_slice_from h input (uint64_to_uint32 pos));
valid_facts lp h input (uint64_to_uint32 pos)
in
let pos1 = lv input pos in
if is_error pos1
then pos1 // error
else
let n = lr input (uint64_to_uint32 pos) in
if n `U32.lt` min || max `U32.lt` n
then validator_error_generic
else
[@inline_let]
let _ = valid_facts (parse_nlist (U32.v n) p) h input (uint64_to_uint32 pos1) in
validate_nlist n v input pos1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
max: Prims.nat{min <= max} ->
lv: LowParse.Low.Base.jumper lp ->
lr: LowParse.Low.Base.leaf_reader lp ->
v: LowParse.Low.Base.jumper p
-> LowParse.Low.Base.jumper (LowParse.Spec.VCList.parse_vclist min max lp p) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.UInt32.t",
"LowParse.Low.Base.jumper",
"LowParse.Low.Base.leaf_reader",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"LowParse.Low.VCList.jump_nlist",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.VCList.parse_nlist_kind",
"FStar.UInt32.v",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"LowParse.Spec.VCList.parse_vclist_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowParse.Spec.VCList.parse_vclist_kind",
"LowParse.Spec.Array.vlarray",
"LowParse.Spec.VCList.parse_vclist",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | false | false | false | false | false | let jump_vclist
(min: nat)
(max: nat{min <= max})
(#lk: parser_kind)
(#lp: parser lk U32.t)
(lv: jumper lp)
(lr: leaf_reader lp)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_vclist min max lp p)) =
| fun #rrel #rel input pos ->
let h = HST.get () in
[@@ inline_let ]let _ =
valid_facts (parse_vclist min max lp p) h input pos;
parse_vclist_eq min max lp p (bytes_of_slice_from h input pos);
valid_facts lp h input pos
in
let pos1 = lv input pos in
let n = lr input pos in
[@@ inline_let ]let _ = valid_facts (parse_nlist (U32.v n) p) h input pos1 in
jump_nlist n v input pos1 | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_wpProof_KeyExpansionStdcall | val va_wpProof_KeyExpansionStdcall : alg:algorithm -> input_key_b:buffer128 ->
output_key_expansion_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_KeyExpansionStdcall alg input_key_b output_key_expansion_b
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionStdcall alg) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_KeyExpansionStdcall : alg:algorithm -> input_key_b:buffer128 ->
output_key_expansion_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_KeyExpansionStdcall alg input_key_b output_key_expansion_b
va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionStdcall alg) ([va_Mod_vec
5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 105,
"start_col": 0,
"start_line": 94
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
input_key_b: Vale.PPC64LE.Memory.buffer128 ->
output_key_expansion_b: Vale.PPC64LE.Memory.buffer128 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_layout",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_mem_layout",
"Vale.PPC64LE.Decls.va_update_mem_heaplet",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_update_mem",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.AES.va_lemma_KeyExpansionStdcall",
"Vale.AES.PPC64LE.AES.va_code_KeyExpansionStdcall"
] | [] | false | false | false | false | false | let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg)
va_s0
alg
input_key_b
output_key_expansion_b
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1
va_sM
(va_update_vec 0
va_sM
(va_update_reg 10
va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))));
va_lemma_norm_mods ([
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_wpProof_AESEncryptBlock | val va_wpProof_AESEncryptBlock : alg:algorithm -> input:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_buffer: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_AESEncryptBlock alg input key round_keys keys_buffer va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESEncryptBlock alg) ([va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_AESEncryptBlock : alg:algorithm -> input:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_buffer: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_AESEncryptBlock alg input key round_keys keys_buffer va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESEncryptBlock alg) ([va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 160,
"start_col": 0,
"start_line": 152
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.AES.va_lemma_AESEncryptBlock",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock"
] | [] | false | false | false | false | false | let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
| let va_sM, va_f0 =
va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key round_keys keys_buffer
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 2
va_sM
(va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
FStar.Class.Eq.fst | FStar.Class.Eq.decides_eq | val decides_eq (#a: Type) (f: (a -> a -> bool)) : prop | val decides_eq (#a: Type) (f: (a -> a -> bool)) : prop | let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 22,
"start_col": 0,
"start_line": 21
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: (_: a -> _: a -> Prims.bool) -> Prims.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.bool",
"Prims.l_Forall",
"Prims.l_iff",
"Prims.b2t",
"Prims.eq2",
"Prims.prop"
] | [] | false | false | false | true | true | let decides_eq (#a: Type) (f: (a -> a -> bool)) : prop =
| forall x y. f x y <==> x == y | false |
FStar.Class.Eq.fst | FStar.Class.Eq.deq_raw_deq | [@@ FStar.Tactics.Typeclasses.tcinstance]
val deq_raw_deq (a: Type) (d: deq a) : Raw.deq a | [@@ FStar.Tactics.Typeclasses.tcinstance]
val deq_raw_deq (a: Type) (d: deq a) : Raw.deq a | instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 30,
"start_col": 0,
"start_line": 30
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> d: FStar.Class.Eq.deq a -> FStar.Class.Eq.Raw.deq a | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.deq",
"FStar.Class.Eq.__proj__Mkdeq__item__raw",
"FStar.Class.Eq.Raw.deq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let deq_raw_deq (a: Type) (d: deq a) : Raw.deq a =
| d.raw | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eq | val eq (#a: Type) {| d: deq a |} (x y: a) : bool | val eq (#a: Type) {| d: deq a |} (x y: a) : bool | let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 33,
"start_col": 0,
"start_line": 32
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | {| d: FStar.Class.Eq.deq a |} -> x: a -> y: a -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.deq",
"FStar.Class.Eq.Raw.__proj__Mkdeq__item__eq",
"FStar.Class.Eq.__proj__Mkdeq__item__raw",
"Prims.bool"
] | [] | false | false | false | true | false | let eq (#a: Type) {| d: deq a |} (x y: a) : bool =
| d.raw.eq x y | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_lemma_AESEncryptBlock | val va_lemma_AESEncryptBlock : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> input:quad32 ->
key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESEncryptBlock alg) va_s0 /\ va_get_ok va_s0 /\ (alg
= AES_128 \/ alg = AES_256) /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
FStar.Seq.Base.length #quad32 round_keys == Vale.AES.AES_common_s.nr alg + 1 /\ round_keys ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ va_get_vec 0 va_s0 == input /\ va_get_reg 4
va_s0 == Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer
(va_get_mem_heaplet 0 va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0
va_s0) (va_get_reg 4 va_s0) keys_buffer (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout
va_s0) Secret /\ (forall (i:nat) . i < Vale.AES.AES_common_s.nr alg + 1 ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer i
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input /\ va_state_eq va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))) | val va_lemma_AESEncryptBlock : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> input:quad32 ->
key:(seq nat32) -> round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESEncryptBlock alg) va_s0 /\ va_get_ok va_s0 /\ (alg
= AES_128 \/ alg = AES_256) /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
FStar.Seq.Base.length #quad32 round_keys == Vale.AES.AES_common_s.nr alg + 1 /\ round_keys ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ va_get_vec 0 va_s0 == input /\ va_get_reg 4
va_s0 == Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer
(va_get_mem_heaplet 0 va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0
va_s0) (va_get_reg 4 va_s0) keys_buffer (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout
va_s0) Secret /\ (forall (i:nat) . i < Vale.AES.AES_common_s.nr alg + 1 ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer i
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input /\ va_state_eq va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))) | let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 148,
"start_col": 0,
"start_line": 137
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (())))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.AES.va_qcode_AESEncryptBlock"
] | [] | false | false | false | false | false | let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
| let va_mods:va_mods_t = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_AESEncryptBlock alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_wpProof_AESEncryptBlock_6way | val va_wpProof_AESEncryptBlock_6way : alg:algorithm -> in1:quad32 -> in2:quad32 -> in3:quad32 ->
in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_buffer: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_AESEncryptBlock_6way alg in1 in2 in3 in4 in5 in6 key
round_keys keys_buffer va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESEncryptBlock_6way alg) ([va_Mod_vec
6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) | val va_wpProof_AESEncryptBlock_6way : alg:algorithm -> in1:quad32 -> in2:quad32 -> in3:quad32 ->
in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_buffer: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_AESEncryptBlock_6way alg in1 in2 in3 in4 in5 in6 key
round_keys keys_buffer va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AESEncryptBlock_6way alg) ([va_Mod_vec
6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g)))) | let va_wpProof_AESEncryptBlock_6way alg in1 in2 in3 in4 in5 in6 key round_keys keys_buffer va_s0
va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock_6way (va_code_AESEncryptBlock_6way alg) va_s0 alg
in1 in2 in3 in4 in5 in6 key round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 232,
"start_col": 0,
"start_line": 221
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock_6way alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock_6way
()) (va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock_6way alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock_6way
()) (va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock_6way ()) (va_ttrue
())) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock_6way (va_mods:va_mods_t) (alg:algorithm) (in1:quad32) (in2:quad32)
(in3:quad32) (in4:quad32) (in5:quad32) (in6:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock_6way va_b0 va_s0 alg in1 in2 in3 in4 in5 in6 key round_keys
keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock_6way va_mods alg in1 in2 in3 in4 in5 in6 key round_keys
keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock_6way alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 120 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 152 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 153 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 154 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in3) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 155 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in4) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in5) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 157 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in6)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
in1: Vale.PPC64LE.Memory.quad32 ->
in2: Vale.PPC64LE.Memory.quad32 ->
in3: Vale.PPC64LE.Memory.quad32 ->
in4: Vale.PPC64LE.Memory.quad32 ->
in5: Vale.PPC64LE.Memory.quad32 ->
in6: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128 ->
va_s0: Vale.PPC64LE.Decls.va_state ->
va_k: (_: Vale.PPC64LE.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Decls.va_state",
"Prims.unit",
"Vale.PPC64LE.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Prims.Nil",
"Prims._assert",
"Vale.PPC64LE.Decls.va_state_eq",
"Vale.PPC64LE.Decls.va_update_vec",
"Vale.PPC64LE.Decls.va_update_reg",
"Vale.PPC64LE.Decls.va_update_ok",
"Vale.PPC64LE.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.PPC64LE.Machine_s.state",
"Vale.AES.PPC64LE.AES.va_lemma_AESEncryptBlock_6way",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way"
] | [] | false | false | false | false | false | let va_wpProof_AESEncryptBlock_6way
alg
in1
in2
in3
in4
in5
in6
key
round_keys
keys_buffer
va_s0
va_k
=
| let va_sM, va_f0 =
va_lemma_AESEncryptBlock_6way (va_code_AESEncryptBlock_6way alg) va_s0 alg in1 in2 in3 in4 in5 in6
key round_keys keys_buffer
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_vec 6
va_sM
(va_update_vec 5
va_sM
(va_update_vec 4
va_sM
(va_update_vec 3
va_sM
(va_update_vec 2
va_sM
(va_update_vec 1
va_sM
(va_update_vec 0
va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([
va_Mod_vec 6;
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_vec 0;
va_Mod_reg 10
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
FStar.Class.Eq.fst | FStar.Class.Eq.unit_has_eq | [@@ FStar.Tactics.Typeclasses.tcinstance]
val unit_has_eq:deq unit | [@@ FStar.Tactics.Typeclasses.tcinstance]
val unit_has_eq:deq unit | instance unit_has_eq : deq unit = eq_instance_of_eqtype | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 55,
"end_line": 41,
"start_col": 0,
"start_line": 41
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Class.Eq.deq Prims.unit | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.eq_instance_of_eqtype",
"Prims.unit",
"FStar.Class.Eq.Raw.unit_has_eq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let unit_has_eq:deq unit =
| eq_instance_of_eqtype | false |
FStar.Class.Eq.fst | FStar.Class.Eq.bool_has_eq | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bool_has_eq:deq bool | [@@ FStar.Tactics.Typeclasses.tcinstance]
val bool_has_eq:deq bool | instance bool_has_eq : deq bool = eq_instance_of_eqtype | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 55,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Class.Eq.deq Prims.bool | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.eq_instance_of_eqtype",
"Prims.bool",
"FStar.Class.Eq.Raw.bool_has_eq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let bool_has_eq:deq bool =
| eq_instance_of_eqtype | false |
FStar.Class.Eq.fst | FStar.Class.Eq.int_has_eq | [@@ FStar.Tactics.Typeclasses.tcinstance]
val int_has_eq:deq int | [@@ FStar.Tactics.Typeclasses.tcinstance]
val int_has_eq:deq int | instance int_has_eq : deq int = eq_instance_of_eqtype | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 53,
"end_line": 40,
"start_col": 0,
"start_line": 40
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Class.Eq.deq Prims.int | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.eq_instance_of_eqtype",
"Prims.int",
"FStar.Class.Eq.Raw.int_has_eq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let int_has_eq:deq int =
| eq_instance_of_eqtype | false |
FStar.Class.Eq.fst | FStar.Class.Eq.string_has_eq | [@@ FStar.Tactics.Typeclasses.tcinstance]
val string_has_eq:deq string | [@@ FStar.Tactics.Typeclasses.tcinstance]
val string_has_eq:deq string | instance string_has_eq : deq string = eq_instance_of_eqtype | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 43,
"start_col": 0,
"start_line": 43
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype
instance unit_has_eq : deq unit = eq_instance_of_eqtype | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | FStar.Class.Eq.deq Prims.string | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.eq_instance_of_eqtype",
"Prims.string",
"FStar.Class.Eq.Raw.string_has_eq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let string_has_eq:deq string =
| eq_instance_of_eqtype | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eq_instance_of_eqtype | val eq_instance_of_eqtype (#a: eqtype) {| _: Raw.deq a |} : deq a | val eq_instance_of_eqtype (#a: eqtype) {| _: Raw.deq a |} : deq a | let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
} | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 38,
"start_col": 0,
"start_line": 35
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | {| _: FStar.Class.Eq.Raw.deq a |} -> FStar.Class.Eq.deq a | Prims.Tot | [
"total"
] | [] | [
"Prims.eqtype",
"FStar.Class.Eq.Raw.deq",
"FStar.Class.Eq.Mkdeq",
"FStar.Class.Eq.Raw.eq_instance_of_eqtype",
"FStar.Class.Eq.deq"
] | [] | false | false | false | false | false | let eq_instance_of_eqtype (#a: eqtype) {| _: Raw.deq a |} : deq a =
| { raw = Raw.eq_instance_of_eqtype #a; eq_dec = () } | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eqList_ok | val eqList_ok (#a: Type) (d: deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) | val eqList_ok (#a: Type) (d: deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) | let eqList_ok (#a:Type) (d : deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) =
let rec aux (xs ys : list a) : Lemma (Raw.eqList d.raw.eq xs ys <==> xs == ys) =
match xs, ys with
| x::xs, y::ys ->
aux xs ys
| [], [] -> ()
| _ -> ()
in
Classical.forall_intro_2 aux;
() | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 54,
"start_col": 0,
"start_line": 45
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype
instance unit_has_eq : deq unit = eq_instance_of_eqtype
instance bool_has_eq : deq bool = eq_instance_of_eqtype
instance string_has_eq : deq string = eq_instance_of_eqtype | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: FStar.Class.Eq.deq a
-> FStar.Pervasives.Lemma
(ensures FStar.Class.Eq.decides_eq (FStar.Class.Eq.Raw.eqList (Mkdeq?.eq (Mkdeq?.raw d)))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"FStar.Class.Eq.deq",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Prims.list",
"Prims.l_iff",
"Prims.b2t",
"FStar.Class.Eq.Raw.eqList",
"FStar.Class.Eq.Raw.__proj__Mkdeq__item__eq",
"FStar.Class.Eq.__proj__Mkdeq__item__raw",
"Prims.eq2",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.Class.Eq.decides_eq"
] | [] | false | false | true | false | false | let eqList_ok (#a: Type) (d: deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) =
| let rec aux (xs ys: list a) : Lemma (Raw.eqList d.raw.eq xs ys <==> xs == ys) =
match xs, ys with
| x :: xs, y :: ys -> aux xs ys
| [], [] -> ()
| _ -> ()
in
Classical.forall_intro_2 aux;
() | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eq_list | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_list (d: deq 'a) : deq (list 'a) | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_list (d: deq 'a) : deq (list 'a) | instance eq_list (d : deq 'a) : deq (list 'a) = {
raw = Raw.eq_list d.raw;
eq_dec = eqList_ok d;
} | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 59,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype
instance unit_has_eq : deq unit = eq_instance_of_eqtype
instance bool_has_eq : deq bool = eq_instance_of_eqtype
instance string_has_eq : deq string = eq_instance_of_eqtype
let eqList_ok (#a:Type) (d : deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) =
let rec aux (xs ys : list a) : Lemma (Raw.eqList d.raw.eq xs ys <==> xs == ys) =
match xs, ys with
| x::xs, y::ys ->
aux xs ys
| [], [] -> ()
| _ -> ()
in
Classical.forall_intro_2 aux;
() | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | d: FStar.Class.Eq.deq 'a -> FStar.Class.Eq.deq (Prims.list 'a) | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.deq",
"FStar.Class.Eq.Mkdeq",
"Prims.list",
"FStar.Class.Eq.Raw.eq_list",
"FStar.Class.Eq.__proj__Mkdeq__item__raw",
"FStar.Class.Eq.eqList_ok"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_list (d: deq 'a) : deq (list 'a) =
| { raw = Raw.eq_list d.raw; eq_dec = eqList_ok d } | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eq_option | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_option: deq 'a -> deq (option 'a) | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_option: deq 'a -> deq (option 'a) | instance eq_option (_ : deq 'a) : deq (option 'a) = {
raw = solve;
eq_dec = ();
} | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 69,
"start_col": 0,
"start_line": 66
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype
instance unit_has_eq : deq unit = eq_instance_of_eqtype
instance bool_has_eq : deq bool = eq_instance_of_eqtype
instance string_has_eq : deq string = eq_instance_of_eqtype
let eqList_ok (#a:Type) (d : deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) =
let rec aux (xs ys : list a) : Lemma (Raw.eqList d.raw.eq xs ys <==> xs == ys) =
match xs, ys with
| x::xs, y::ys ->
aux xs ys
| [], [] -> ()
| _ -> ()
in
Classical.forall_intro_2 aux;
()
instance eq_list (d : deq 'a) : deq (list 'a) = {
raw = Raw.eq_list d.raw;
eq_dec = eqList_ok d;
}
instance eq_pair (_ : deq 'a) (_ : deq 'b) : deq ('a * 'b) = {
raw = solve;
eq_dec = ();
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: FStar.Class.Eq.deq 'a -> FStar.Class.Eq.deq (FStar.Pervasives.Native.option 'a) | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.deq",
"FStar.Class.Eq.Mkdeq",
"FStar.Pervasives.Native.option",
"FStar.Class.Eq.Raw.eq_option",
"FStar.Class.Eq.deq_raw_deq",
"FStar.Class.Eq.Raw.deq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_option (_: deq 'a) : deq (option 'a) =
| { raw = solve; eq_dec = () } | false |
FStar.Class.Eq.fst | FStar.Class.Eq.eq_pair | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b) | [@@ FStar.Tactics.Typeclasses.tcinstance]
val eq_pair: deq 'a -> deq 'b -> deq ('a * 'b) | instance eq_pair (_ : deq 'a) (_ : deq 'b) : deq ('a * 'b) = {
raw = solve;
eq_dec = ();
} | {
"file_name": "ulib/FStar.Class.Eq.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 64,
"start_col": 0,
"start_line": 61
} | (*
Copyright 2008-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 FStar.Class.Eq
open FStar.Tactics.Typeclasses
module Raw = FStar.Class.Eq.Raw
let decides_eq (#a:Type) (f : a -> a -> bool) : prop =
forall x y. f x y <==> x == y
class deq a = {
raw : Raw.deq a;
eq_dec : squash (decides_eq raw.eq);
}
(* Superclass *)
instance deq_raw_deq (a:Type) (d:deq a) : Raw.deq a = d.raw
let eq (#a:Type) {| d : deq a |} (x y : a) : bool =
d.raw.eq x y
let eq_instance_of_eqtype (#a:eqtype) {| Raw.deq a |} : deq a = {
raw = Raw.eq_instance_of_eqtype #a;
eq_dec = ();
}
instance int_has_eq : deq int = eq_instance_of_eqtype
instance unit_has_eq : deq unit = eq_instance_of_eqtype
instance bool_has_eq : deq bool = eq_instance_of_eqtype
instance string_has_eq : deq string = eq_instance_of_eqtype
let eqList_ok (#a:Type) (d : deq a) : Lemma (decides_eq #(list a) (Raw.eqList d.raw.eq)) =
let rec aux (xs ys : list a) : Lemma (Raw.eqList d.raw.eq xs ys <==> xs == ys) =
match xs, ys with
| x::xs, y::ys ->
aux xs ys
| [], [] -> ()
| _ -> ()
in
Classical.forall_intro_2 aux;
()
instance eq_list (d : deq 'a) : deq (list 'a) = {
raw = Raw.eq_list d.raw;
eq_dec = eqList_ok d;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Class.Eq.Raw.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Class.Eq.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Class.Eq.Raw",
"short_module": "Raw"
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Typeclasses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Class",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | _: FStar.Class.Eq.deq 'a -> _: FStar.Class.Eq.deq 'b -> FStar.Class.Eq.deq ('a * 'b) | Prims.Tot | [
"total"
] | [] | [
"FStar.Class.Eq.deq",
"FStar.Class.Eq.Mkdeq",
"FStar.Pervasives.Native.tuple2",
"FStar.Class.Eq.Raw.eq_pair",
"FStar.Class.Eq.deq_raw_deq",
"FStar.Class.Eq.Raw.deq"
] | [] | false | false | false | true | false | [@@ FStar.Tactics.Typeclasses.tcinstance]
let eq_pair (_: deq 'a) (_: deq 'b) : deq ('a * 'b) =
| { raw = solve; eq_dec = () } | false |
Hacl.Bignum.fsti | Hacl.Bignum.meta_len | val meta_len : t: Hacl.Bignum.Definitions.limb_t -> Type0 | let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t} | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 83,
"end_line": 373,
"start_col": 0,
"start_line": 373
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Lib.IntTypes.max_size_t"
] | [] | false | false | false | true | true | let meta_len (t: limb_t) =
| len: size_t{0 < v len /\ (2 * bits t) * v len <= max_size_t} | false |
|
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_lemma_AESEncryptBlock_6way | val va_lemma_AESEncryptBlock_6way : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in1:quad32
-> in2:quad32 -> in3:quad32 -> in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESEncryptBlock_6way alg) va_s0 /\ va_get_ok va_s0 /\
(alg = AES_128 \/ alg = AES_256) /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
FStar.Seq.Base.length #quad32 round_keys == Vale.AES.AES_common_s.nr alg + 1 /\ round_keys ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ va_get_vec 0 va_s0 == in1 /\ va_get_vec 1
va_s0 == in2 /\ va_get_vec 2 va_s0 == in3 /\ va_get_vec 3 va_s0 == in4 /\ va_get_vec 4 va_s0 ==
in5 /\ va_get_vec 5 va_s0 == in6 /\ va_get_reg 4 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ (forall
(i:nat) . i < Vale.AES.AES_common_s.nr alg + 1 ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in1 /\ va_get_vec 1 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in2 /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in3 /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in4 /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in5 /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in6 /\ va_state_eq va_sM (va_update_vec 6 va_sM
(va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))) | val va_lemma_AESEncryptBlock_6way : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in1:quad32
-> in2:quad32 -> in3:quad32 -> in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AESEncryptBlock_6way alg) va_s0 /\ va_get_ok va_s0 /\
(alg = AES_128 \/ alg = AES_256) /\ Vale.AES.AES_BE_s.is_aes_key_word alg key /\
FStar.Seq.Base.length #quad32 round_keys == Vale.AES.AES_common_s.nr alg + 1 /\ round_keys ==
Vale.AES.AES_BE_s.key_to_round_keys_word alg key /\ va_get_vec 0 va_s0 == in1 /\ va_get_vec 1
va_s0 == in2 /\ va_get_vec 2 va_s0 == in3 /\ va_get_vec 3 va_s0 == in4 /\ va_get_vec 4 va_s0 ==
in5 /\ va_get_vec 5 va_s0 == in6 /\ va_get_reg 4 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0 va_s0) /\
Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret /\ (forall
(i:nat) . i < Vale.AES.AES_common_s.nr alg + 1 ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer i (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in1 /\ va_get_vec 1 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in2 /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in3 /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in4 /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in5 /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word alg key in6 /\ va_state_eq va_sM (va_update_vec 6 va_sM
(va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))) | let va_lemma_AESEncryptBlock_6way va_b0 va_s0 alg in1 in2 in3 in4 in5 in6 key round_keys
keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock_6way va_mods alg in1 in2 in3 in4 in5 in6 key round_keys
keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock_6way alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 120 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 152 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 153 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 154 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in3) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 155 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in4) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in5) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 157 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in6)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 217,
"start_col": 0,
"start_line": 192
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (()))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionStdcall alg input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionStdcall (va_code_KeyExpansionStdcall alg) va_s0 alg
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM
(va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_mem_layout va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))));
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock ())
(va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock ()) (va_CNil ()))) (va_CNil
())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock ())
(va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock ()) (va_ttrue ()))
(va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock (va_mods:va_mods_t) (alg:algorithm) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock
alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 113 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 114 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock input key round_keys keys_buffer) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 116 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock input key round_keys keys_buffer) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QEmpty (()))))
[@"opaque_to_smt"]
let va_lemma_AESEncryptBlock va_b0 va_s0 alg input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AESEncryptBlock va_mods alg input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AESEncryptBlock alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 89 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 111 column 48 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AESEncryptBlock alg input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AESEncryptBlock (va_code_AESEncryptBlock alg) va_s0 alg input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AESEncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AESEncryptBlock_6way alg =
(va_Block (va_CCons (if (alg = AES_128) then va_Block (va_CCons (va_code_AES128EncryptBlock_6way
()) (va_CNil ())) else va_Block (va_CCons (va_code_AES256EncryptBlock_6way ()) (va_CNil ())))
(va_CNil ())))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AESEncryptBlock_6way alg =
(va_pbool_and (if (alg = AES_128) then va_pbool_and (va_codegen_success_AES128EncryptBlock_6way
()) (va_ttrue ()) else va_pbool_and (va_codegen_success_AES256EncryptBlock_6way ()) (va_ttrue
())) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AESEncryptBlock_6way (va_mods:va_mods_t) (alg:algorithm) (in1:quad32) (in2:quad32)
(in3:quad32) (in4:quad32) (in5:quad32) (in6:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AESEncryptBlock_6way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 160 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES128EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (())))) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 162 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_AES256EncryptBlock_6way in1 in2 in3 in4 in5 in6 key round_keys keys_buffer)
(va_QEmpty (()))))) (fun (va_s:va_state) va_g -> va_QEmpty (())))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
in1: Vale.PPC64LE.Memory.quad32 ->
in2: Vale.PPC64LE.Memory.quad32 ->
in3: Vale.PPC64LE.Memory.quad32 ->
in4: Vale.PPC64LE.Memory.quad32 ->
in5: Vale.PPC64LE.Memory.quad32 ->
in6: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.AES.va_qcode_AESEncryptBlock_6way"
] | [] | false | false | false | false | false | let va_lemma_AESEncryptBlock_6way va_b0 va_s0 alg in1 in2 in3 in4 in5 in6 key round_keys keys_buffer =
| let va_mods:va_mods_t =
[
va_Mod_vec 6;
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_vec 0;
va_Mod_reg 10;
va_Mod_ok
]
in
let va_qc =
va_qcode_AESEncryptBlock_6way va_mods alg in1 in2 in3 in4 in5 in6 key round_keys keys_buffer
in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_AESEncryptBlock_6way alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 120 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 152 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in1) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 153 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in2) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 154 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in3) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 155 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in4) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 156 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in5) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 157 column 46 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word alg key in6))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 6;
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_vec 0;
va_Mod_reg 10;
va_Mod_ok
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Vale.AES.PPC64LE.AES.fst | Vale.AES.PPC64LE.AES.va_lemma_KeyExpansionStdcall | val va_lemma_KeyExpansionStdcall : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
input_key_b:buffer128 -> output_key_expansion_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_KeyExpansionStdcall alg) va_s0 /\ va_get_ok va_s0 /\
(let (in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s0)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s0)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = (if (alg = AES_128) then
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1 else
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 input_key_b
output_key_expansion_b /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4
va_s0) input_key_b (if (alg = AES_128) then 1 else 2) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0)
output_key_expansion_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s0)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s0)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = (if (alg = AES_128) then
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1 else
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in
Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM) /\ (forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j)) /\ va_state_eq va_sM (va_update_vec 5
va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1
va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | val va_lemma_KeyExpansionStdcall : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
input_key_b:buffer128 -> output_key_expansion_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_KeyExpansionStdcall alg) va_s0 /\ va_get_ok va_s0 /\
(let (in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s0)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s0)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = (if (alg = AES_128) then
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1 else
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in
Vale.PPC64LE.Memory.is_initial_heap (va_get_mem_layout va_s0) (va_get_mem va_s0) /\ (alg =
AES_128 \/ alg = AES_256) /\ Vale.PPC64LE.Decls.buffers_disjoint128 input_key_b
output_key_expansion_b /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem va_s0) (va_get_reg 4
va_s0) input_key_b (if (alg = AES_128) then 1 else 2) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem va_s0) (va_get_reg 3 va_s0)
output_key_expansion_b (Vale.AES.AES_common_s.nr alg + 1) (va_get_mem_layout va_s0) Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s0)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s0)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = (if (alg = AES_128) then
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1 else
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in
Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM) /\ (forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j)) /\ va_state_eq va_sM (va_update_vec 5
va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1
va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_layout va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))) | let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\ (let (in_key1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem va_s0)) in let (in_key2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 1
(va_get_mem va_s0)) in let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg =
AES_128) (fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem va_s0) (va_get_mem
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j . 0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j (va_get_mem va_sM)) == FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.AES.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 90,
"start_col": 0,
"start_line": 64
} | module Vale.AES.PPC64LE.AES
open Vale.Def.Types_s
open FStar.Seq
open Vale.Arch.HeapImpl
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.Def.Opaque_s
open Vale.AES.PPC64LE.AES128
open Vale.AES.PPC64LE.AES256
#reset-options "--z3rlimit 20"
//-- KeyExpansionStdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionStdcall alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (if (alg = AES_128) then va_Block
(va_CCons (va_code_KeyExpansion128Stdcall ()) (va_CNil ())) else va_Block (va_CCons
(va_code_KeyExpansion256Stdcall ()) (va_CNil ()))) (va_CCons (va_code_DestroyHeaplets ())
(va_CNil ())))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionStdcall alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and (if (alg = AES_128) then
va_pbool_and (va_codegen_success_KeyExpansion128Stdcall ()) (va_ttrue ()) else va_pbool_and
(va_codegen_success_KeyExpansion256Stdcall ()) (va_ttrue ())) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionStdcall (va_mods:va_mods_t) (alg:algorithm) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansionStdcall alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(in_key1:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem va_s)) in let
(in_key2:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 1 (va_get_mem va_s)) in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = va_if (alg = AES_128) (fun _ ->
Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1) (fun _ ->
Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 72 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 input_key_b 0 Secret Immutable; declare_buffer128
output_key_expansion_b 1 Secret Mutable])) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 76 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_qInlineIf va_mods (alg = AES_128) (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 77 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion128Stdcall input_key_b output_key_expansion_b) (va_QEmpty (())))) (qblock
va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 79 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_KeyExpansion256Stdcall input_key_b output_key_expansion_b) (va_QEmpty (()))))) (fun
(va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 82 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.PPC64LE.AES256.fsti.checked",
"Vale.AES.PPC64LE.AES128.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"Vale.AES.AES256_helpers_BE.fsti.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.PPC64LE.AES.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE.AES256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"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.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
input_key_b: Vale.PPC64LE.Memory.buffer128 ->
output_key_expansion_b: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_mem_layout",
"Vale.PPC64LE.QuickCode.va_Mod_mem_heaplet",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Vale.PPC64LE.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.AES.va_code_KeyExpansionStdcall",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.PPC64LE.Decls.modifies_buffer128",
"Vale.PPC64LE.Decls.va_get_mem",
"Prims.l_Forall",
"Prims.int",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_BE_s.key_to_round_keys_word",
"Prims.l_imp",
"Prims.op_LessThanOrEqual",
"Vale.AES.AES_common_s.nr",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.PPC64LE.Decls.buffer128_read",
"FStar.Seq.Base.index",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.PPC64LE.Decls.va_if",
"Vale.Def.Types_s.nat32",
"Prims.op_Equality",
"Vale.AES.AES_common_s.AES_128",
"Vale.AES.AES256_helpers_BE.be_quad32_to_seq",
"Prims.l_not",
"Vale.AES.AES256_helpers_BE.make_AES256_key",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.AES.va_qcode_KeyExpansionStdcall"
] | [] | false | false | false | false | false | let va_lemma_KeyExpansionStdcall va_b0 va_s0 alg input_key_b output_key_expansion_b =
| let va_mods:va_mods_t =
[
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
]
in
let va_qc = va_qcode_KeyExpansionStdcall va_mods alg input_key_b output_key_expansion_b in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_KeyExpansionStdcall alg)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 44 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(va_get_ok va_sM) /\
(let in_key1:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b
0
(va_get_mem va_s0))
in
let in_key2:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b
1
(va_get_mem va_s0))
in
let key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32) =
va_if (alg = AES_128)
(fun _ -> Vale.AES.AES256_helpers_BE.be_quad32_to_seq in_key1)
(fun _ -> Vale.AES.AES256_helpers_BE.make_AES256_key in_key1 in_key2)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 68 column 66 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b
(va_get_mem va_s0)
(va_get_mem va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 70 column 127 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES.vaf *****"
(forall j.
0 <= j /\ j <= Vale.AES.AES_common_s.nr alg ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b
j
(va_get_mem va_sM)) ==
FStar.Seq.Base.index #Vale.Def.Types_s.quad32
(Vale.AES.AES_BE_s.key_to_round_keys_word alg key)
j)))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_layout; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
Hacl.Bignum.fsti | Hacl.Bignum.bn_add_mod_n_st | val bn_add_mod_n_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 147,
"start_col": 0,
"start_line": 136
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add_mod_n"
] | [] | false | false | false | false | true | let bn_add_mod_n_st (t: limb_t) (len: size_t{v len > 0}) =
| n: lbignum t len -> a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h b /\ live h res /\ disjoint n a /\ disjoint n b /\
disjoint n res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | false |
|
LowParse.Low.VCList.fst | LowParse.Low.VCList.jump_nlist | val jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) | val jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) | let jump_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U32.v pos <= U32.v pos1 /\
U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\ valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\
(stop == true ==> r == 0ul)
))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@inline_let]
let _ =
valid_nlist_cons_recip (U32.v r) p h0 input pos1
in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
valid_nlist_nil p h0 input res
in
HST.pop_frame ();
res | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 259,
"start_col": 0,
"start_line": 213
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32"
inline_for_extraction
let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: FStar.UInt32.t -> v: LowParse.Low.Base.jumper p
-> LowParse.Low.Base.jumper (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v n) p) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.jumper",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowParse.Low.VCList.valid_nlist_nil",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"FStar.Monotonic.HyperStack.mem",
"Prims.bool",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.l_imp",
"LowStar.Monotonic.Buffer.get",
"Prims.op_Equality",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.sub",
"LowParse.Low.VCList.valid_nlist_cons_recip",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let jump_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: jumper p)
: Tot (jumper (parse_nlist (U32.v n) p)) =
| fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while (fun h stop ->
B.modifies ((B.loc_buffer bpos1) `B.loc_union` (B.loc_buffer br)) h1 h /\
(let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\ U32.v pos <= U32.v pos1 /\ U32.v pos1 <= U32.v input.len /\
valid (parse_nlist (U32.v n) p) h0 input pos /\
valid (parse_nlist (U32.v r) p) h0 input pos1 /\
get_valid_pos (parse_nlist (U32.v n) p) h0 input pos ==
get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1 /\ (stop == true ==> r == 0ul)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
[@@ inline_let ]let _ = valid_nlist_cons_recip (U32.v r) p h0 input pos1 in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
false);
let res = B.index bpos1 0ul in
[@@ inline_let ]let _ = valid_nlist_nil p h0 input res in
HST.pop_frame ();
res | false |
Hacl.Bignum.fsti | Hacl.Bignum.bn_sub_mod_n_st | val bn_sub_mod_n_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 166,
"start_col": 0,
"start_line": 155
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_GreaterThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub_mod_n"
] | [] | false | false | false | false | true | let bn_sub_mod_n_st (t: limb_t) (len: size_t{v len > 0}) =
| n: lbignum t len -> a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h b /\ live h res /\ disjoint n a /\ disjoint n b /\
disjoint n res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b)) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_sub_eq_len_st | val bn_sub_eq_len_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 77,
"start_col": 0,
"start_line": 68
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub"
] | [] | false | false | false | true | true | let bn_sub_eq_len_st (t: limb_t) (len: size_t) =
| a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\
eq_or_disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)
) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_add_st | val bn_add_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 96,
"start_col": 0,
"start_line": 85
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add"
] | [] | false | false | false | true | true | let bn_add_st (t: limb_t) =
|
aLen: size_t ->
a: lbignum t aLen ->
bLen: size_t{v bLen <= v aLen} ->
b: lbignum t bLen ->
res: lbignum t aLen
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint a b /\ eq_or_disjoint a res /\
disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)
) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_add_eq_len_st | val bn_add_eq_len_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 67,
"end_line": 60,
"start_col": 0,
"start_line": 51
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_add"
] | [] | false | false | false | true | true | let bn_add_eq_len_st (t: limb_t) (len: size_t) =
| a: lbignum t len -> b: lbignum t len -> res: lbignum t len
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ eq_or_disjoint a b /\ eq_or_disjoint a res /\
eq_or_disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b)
) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_sub_st | val bn_sub_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 115,
"start_col": 0,
"start_line": 104
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Bignum.Base.carry",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Hacl.Spec.Bignum.Definitions.lbignum",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_sub"
] | [] | false | false | false | true | true | let bn_sub_st (t: limb_t) =
|
aLen: size_t ->
a: lbignum t aLen ->
bLen: size_t{v bLen <= v aLen} ->
b: lbignum t bLen ->
res: lbignum t aLen
-> Stack (carry t)
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint a b /\ eq_or_disjoint a res /\
disjoint b res)
(ensures
fun h0 c_out h1 ->
modifies (loc res) h0 h1 /\ (c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b)
) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_karatsuba_mul_st | val bn_karatsuba_mul_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 196,
"start_col": 0,
"start_line": 188
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | false | false | false | false | true | let bn_karatsuba_mul_st
(t: limb_t)
(len: size_t{0 < v len /\ 4 * v len <= max_size_t})
(a: lbignum t len)
=
| b: lbignum t len -> res: lbignum t (len +! len)
-> Stack unit
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\
eq_or_disjoint a b)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_sqr_st | val bn_sqr_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 251,
"start_col": 0,
"start_line": 246
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{ 0 < Lib.IntTypes.v len /\
Lib.IntTypes.v len + Lib.IntTypes.v len <= Lib.IntTypes.max_size_t } ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | false | false | false | false | true | let bn_sqr_st (t: limb_t) (len: size_t{0 < v len /\ v len + v len <= max_size_t}) (a: lbignum t len) =
| res: lbignum t (len +! len)
-> Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_mul_st | val bn_mul_st : t: Hacl.Bignum.Definitions.limb_t ->
aLen: Lib.IntTypes.size_t ->
bLen: Lib.IntTypes.size_t{Lib.IntTypes.v aLen + Lib.IntTypes.v bLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen
-> Type0 | let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 216,
"start_col": 0,
"start_line": 208
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
aLen: Lib.IntTypes.size_t ->
bLen: Lib.IntTypes.size_t{Lib.IntTypes.v aLen + Lib.IntTypes.v bLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | false | false | false | false | true | let bn_mul_st
(t: limb_t)
(aLen: size_t)
(bLen: size_t{v aLen + v bLen <= max_size_t})
(a: lbignum t aLen)
=
| b: lbignum t bLen -> res: lbignum t (aLen +! bLen)
-> Stack unit
(requires
fun h ->
live h a /\ live h b /\ live h res /\ disjoint res a /\ disjoint res b /\
eq_or_disjoint a b)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b)) | false |
|
Pulse.Lib.Array.fst | Pulse.Lib.Array.compare | val compare
(#t:eqtype)
(l:SZ.t)
(a1 a2:larray t (SZ.v l))
(#p1 #p2:perm)
(#s1 #s2:Ghost.erased (Seq.seq t))
: stt bool
(requires
pts_to a1 #p1 s1 **
pts_to a2 #p2 s2)
(ensures fun res ->
pts_to a1 #p1 s1 **
pts_to a2 #p2 s2 **
pure (res <==> Seq.equal s1 s2)) | val compare
(#t:eqtype)
(l:SZ.t)
(a1 a2:larray t (SZ.v l))
(#p1 #p2:perm)
(#s1 #s2:Ghost.erased (Seq.seq t))
: stt bool
(requires
pts_to a1 #p1 s1 **
pts_to a2 #p2 s2)
(ensures fun res ->
pts_to a1 #p1 s1 **
pts_to a2 #p2 s2 **
pure (res <==> Seq.equal s1 s2)) | let compare = compare' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Array.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 22,
"end_line": 63,
"start_col": 0,
"start_line": 63
} | (*
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.Lib.Array
module PM = Pulse.Main
open Pulse.Lib.Core
open Pulse.Lib.Reference
open Pulse.Lib.Array.Core
open FStar.Ghost
module US = FStar.SizeT
module U8 = FStar.UInt8
open Pulse.Lib.BoundedIntegers
module A = Pulse.Lib.Array.Core
module R = Pulse.Lib.Reference
```pulse
fn compare' (#t:eqtype) (l:US.t) (a1 a2:larray t (US.v l))
requires pts_to a1 #p1 's1
** pts_to a2 #p2 's2
returns res:bool
ensures pts_to a1 #p1 's1
** pts_to a2 #p2 's2
** (pure (res <==> Seq.equal 's1 's2))
{
pts_to_len a1 #p1 #'s1;
pts_to_len a2 #p2 #'s2;
let mut i = 0sz;
while (let vi = !i;
if (vi < l) {
let v1 = a1.(vi);
let v2 = a2.(vi);
(v1 = v2) }
else { false } )
invariant b. exists* (vi:US.t). (
R.pts_to i vi **
A.pts_to a1 #p1 's1 **
A.pts_to a2 #p2 's2 **
pure (vi <= l
/\ (b == (vi < l && Seq.index 's1 (US.v vi) = Seq.index 's2 (US.v vi)))
/\ (forall (i:nat). i < US.v vi ==> Seq.index 's1 i == Seq.index 's2 i)))
{
let vi = !i;
i := vi + 1sz;
};
let vi = !i;
let res = vi = l;
res
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.Reference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"Pulse.Lib.BoundedIntegers.fst.checked",
"Pulse.Lib.Array.Core.fsti.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Array.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Lib.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.Array.Core",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.BoundedIntegers",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Reference",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Main",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.SizeT.t ->
a1: Pulse.Lib.Array.Core.larray t (FStar.SizeT.v l) ->
a2: Pulse.Lib.Array.Core.larray t (FStar.SizeT.v l)
-> Pulse.Lib.Core.stt Prims.bool
(Pulse.Lib.Array.Core.pts_to a1 (FStar.Ghost.reveal s1) **
Pulse.Lib.Array.Core.pts_to a2 (FStar.Ghost.reveal s2))
(fun res ->
(Pulse.Lib.Array.Core.pts_to a1 (FStar.Ghost.reveal s1) **
Pulse.Lib.Array.Core.pts_to a2 (FStar.Ghost.reveal s2)) **
Pulse.Lib.Core.pure (res <==>
FStar.Seq.Base.equal (FStar.Ghost.reveal s1) (FStar.Ghost.reveal s2))) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Array.compare'"
] | [] | false | false | false | false | false | let compare =
| compare' | false |
Hacl.Bignum.fsti | Hacl.Bignum.bn_karatsuba_sqr_st | val bn_karatsuba_sqr_st : t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 234,
"start_col": 0,
"start_line": 229
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t: Hacl.Bignum.Definitions.limb_t ->
len:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v len /\ 4 * Lib.IntTypes.v len <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t len
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.bn_mul"
] | [] | false | false | false | false | true | let bn_karatsuba_sqr_st
(t: limb_t)
(len: size_t{0 < v len /\ 4 * v len <= max_size_t})
(a: lbignum t len)
=
| res: lbignum t (len +! len)
-> Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures
fun h0 _ h1 ->
modifies (loc res) h0 h1 /\ as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a)) | false |
|
Spec.Agile.Cipher.fst | Spec.Agile.Cipher.expand | val expand (a: cipher_alg) (k: key a) : xkey a | val expand (a: cipher_alg) (k: key a) : xkey a | let expand (a: cipher_alg) (k: key a): xkey a =
match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 27,
"start_col": 0,
"start_line": 24
} | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n'
let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key
/// As specified by the NIST. Other implementations (e.g. Vale) may perform | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.Cipher.cipher_alg -> k: Spec.Agile.Cipher.key a -> Spec.Agile.Cipher.xkey a | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.Agile.Cipher.key",
"Spec.AES.aes_key_expansion",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Spec.Agile.Cipher.xkey"
] | [] | false | false | false | false | false | let expand (a: cipher_alg) (k: key a) : xkey a =
| match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | false |
Pulse.Lib.Array.fst | Pulse.Lib.Array.memcpy | val memcpy
(#t:eqtype)
(l:SZ.t)
(src dst:larray t (SZ.v l))
(#p:perm)
(#src0 #dst0:Ghost.erased (Seq.seq t))
: stt unit
(requires
pts_to src #p src0 **
pts_to dst dst0)
(ensures (fun _ ->
pts_to src #p src0 **
pts_to dst src0)) | val memcpy
(#t:eqtype)
(l:SZ.t)
(src dst:larray t (SZ.v l))
(#p:perm)
(#src0 #dst0:Ghost.erased (Seq.seq t))
: stt unit
(requires
pts_to src #p src0 **
pts_to dst dst0)
(ensures (fun _ ->
pts_to src #p src0 **
pts_to dst src0)) | let memcpy = memcpy' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Array.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 20,
"end_line": 97,
"start_col": 0,
"start_line": 97
} | (*
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.Lib.Array
module PM = Pulse.Main
open Pulse.Lib.Core
open Pulse.Lib.Reference
open Pulse.Lib.Array.Core
open FStar.Ghost
module US = FStar.SizeT
module U8 = FStar.UInt8
open Pulse.Lib.BoundedIntegers
module A = Pulse.Lib.Array.Core
module R = Pulse.Lib.Reference
```pulse
fn compare' (#t:eqtype) (l:US.t) (a1 a2:larray t (US.v l))
requires pts_to a1 #p1 's1
** pts_to a2 #p2 's2
returns res:bool
ensures pts_to a1 #p1 's1
** pts_to a2 #p2 's2
** (pure (res <==> Seq.equal 's1 's2))
{
pts_to_len a1 #p1 #'s1;
pts_to_len a2 #p2 #'s2;
let mut i = 0sz;
while (let vi = !i;
if (vi < l) {
let v1 = a1.(vi);
let v2 = a2.(vi);
(v1 = v2) }
else { false } )
invariant b. exists* (vi:US.t). (
R.pts_to i vi **
A.pts_to a1 #p1 's1 **
A.pts_to a2 #p2 's2 **
pure (vi <= l
/\ (b == (vi < l && Seq.index 's1 (US.v vi) = Seq.index 's2 (US.v vi)))
/\ (forall (i:nat). i < US.v vi ==> Seq.index 's1 i == Seq.index 's2 i)))
{
let vi = !i;
i := vi + 1sz;
};
let vi = !i;
let res = vi = l;
res
}
```
let compare = compare'
```pulse
fn memcpy' (#t:eqtype) (l:US.t) (src dst:larray t (US.v l))
(#p:perm) (#src0 #dst0:Ghost.erased (Seq.seq t))
requires A.pts_to src #p src0
** A.pts_to dst dst0
ensures A.pts_to src #p src0
** A.pts_to dst src0
{
pts_to_len src #p #src0;
pts_to_len dst #full_perm #dst0;
let mut i = 0sz;
while (let vi = !i; (vi < l) )
invariant b. exists* (vi:US.t) (s:Seq.seq t). (
R.pts_to i vi **
A.pts_to src #p src0 **
A.pts_to dst s **
pure (vi <= l
/\ Seq.length s == US.v l
/\ (b == (vi < l))
/\ (forall (i:nat). i < US.v vi ==> Seq.index src0 i == Seq.index s i)))
{
let vi = !i;
let x = src.(vi);
with s. assert (A.pts_to dst s);
(dst.(vi) <- x);
i := vi + 1sz;
};
with s. assert (A.pts_to dst s);
Seq.lemma_eq_elim src0 s;
()
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.Reference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"Pulse.Lib.BoundedIntegers.fst.checked",
"Pulse.Lib.Array.Core.fsti.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Array.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Lib.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.Array.Core",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.BoundedIntegers",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Reference",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Main",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
l: FStar.SizeT.t ->
src: Pulse.Lib.Array.Core.larray t (FStar.SizeT.v l) ->
dst: Pulse.Lib.Array.Core.larray t (FStar.SizeT.v l)
-> Pulse.Lib.Core.stt Prims.unit
(Pulse.Lib.Array.Core.pts_to src (FStar.Ghost.reveal src0) **
Pulse.Lib.Array.Core.pts_to dst (FStar.Ghost.reveal dst0))
(fun _ ->
Pulse.Lib.Array.Core.pts_to src (FStar.Ghost.reveal src0) **
Pulse.Lib.Array.Core.pts_to dst (FStar.Ghost.reveal src0)) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Array.memcpy'"
] | [] | false | false | false | false | false | let memcpy =
| memcpy' | false |
Pulse.Lib.Array.fst | Pulse.Lib.Array.fill | val fill
(#t:Type0)
(l:SZ.t)
(a:larray t (SZ.v l))
(v:t)
(#s:Ghost.erased (Seq.seq t))
: stt unit
(requires
pts_to a s)
(ensures fun _ ->
exists* (s:Seq.seq t).
pts_to a s **
pure (s `Seq.equal` Seq.create (SZ.v l) v)) | val fill
(#t:Type0)
(l:SZ.t)
(a:larray t (SZ.v l))
(v:t)
(#s:Ghost.erased (Seq.seq t))
: stt unit
(requires
pts_to a s)
(ensures fun _ ->
exists* (s:Seq.seq t).
pts_to a s **
pure (s `Seq.equal` Seq.create (SZ.v l) v)) | let fill = fill' | {
"file_name": "share/steel/examples/pulse/lib/Pulse.Lib.Array.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 16,
"end_line": 123,
"start_col": 0,
"start_line": 123
} | (*
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.Lib.Array
module PM = Pulse.Main
open Pulse.Lib.Core
open Pulse.Lib.Reference
open Pulse.Lib.Array.Core
open FStar.Ghost
module US = FStar.SizeT
module U8 = FStar.UInt8
open Pulse.Lib.BoundedIntegers
module A = Pulse.Lib.Array.Core
module R = Pulse.Lib.Reference
```pulse
fn compare' (#t:eqtype) (l:US.t) (a1 a2:larray t (US.v l))
requires pts_to a1 #p1 's1
** pts_to a2 #p2 's2
returns res:bool
ensures pts_to a1 #p1 's1
** pts_to a2 #p2 's2
** (pure (res <==> Seq.equal 's1 's2))
{
pts_to_len a1 #p1 #'s1;
pts_to_len a2 #p2 #'s2;
let mut i = 0sz;
while (let vi = !i;
if (vi < l) {
let v1 = a1.(vi);
let v2 = a2.(vi);
(v1 = v2) }
else { false } )
invariant b. exists* (vi:US.t). (
R.pts_to i vi **
A.pts_to a1 #p1 's1 **
A.pts_to a2 #p2 's2 **
pure (vi <= l
/\ (b == (vi < l && Seq.index 's1 (US.v vi) = Seq.index 's2 (US.v vi)))
/\ (forall (i:nat). i < US.v vi ==> Seq.index 's1 i == Seq.index 's2 i)))
{
let vi = !i;
i := vi + 1sz;
};
let vi = !i;
let res = vi = l;
res
}
```
let compare = compare'
```pulse
fn memcpy' (#t:eqtype) (l:US.t) (src dst:larray t (US.v l))
(#p:perm) (#src0 #dst0:Ghost.erased (Seq.seq t))
requires A.pts_to src #p src0
** A.pts_to dst dst0
ensures A.pts_to src #p src0
** A.pts_to dst src0
{
pts_to_len src #p #src0;
pts_to_len dst #full_perm #dst0;
let mut i = 0sz;
while (let vi = !i; (vi < l) )
invariant b. exists* (vi:US.t) (s:Seq.seq t). (
R.pts_to i vi **
A.pts_to src #p src0 **
A.pts_to dst s **
pure (vi <= l
/\ Seq.length s == US.v l
/\ (b == (vi < l))
/\ (forall (i:nat). i < US.v vi ==> Seq.index src0 i == Seq.index s i)))
{
let vi = !i;
let x = src.(vi);
with s. assert (A.pts_to dst s);
(dst.(vi) <- x);
i := vi + 1sz;
};
with s. assert (A.pts_to dst s);
Seq.lemma_eq_elim src0 s;
()
}
```
let memcpy = memcpy'
```pulse
fn fill' (#t:Type0) (l:US.t) (a:larray t (US.v l)) (v:t)
requires A.pts_to a 's
ensures exists* (s:Seq.seq t).
A.pts_to a s **
pure (s `Seq.equal` Seq.create (US.v l) v)
{
pts_to_len a #full_perm #'s;
let mut i = 0sz;
while (let vi = !i; (vi < l))
invariant b. exists* (vi:US.t) (s:Seq.seq t). (
R.pts_to i vi **
A.pts_to a s **
pure (vi <= l
/\ Seq.length s == US.v l
/\ (b == (vi < l))
/\ (forall (i:nat). i < US.v vi ==> Seq.index s i == v)))
{
let vi = !i;
(a.(vi) <- v);
i := vi + 1sz;
}
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Main.fsti.checked",
"Pulse.Lib.Reference.fsti.checked",
"Pulse.Lib.Core.fsti.checked",
"Pulse.Lib.BoundedIntegers.fst.checked",
"Pulse.Lib.Array.Core.fsti.checked",
"prims.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.SizeT.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Lib.Array.fst"
} | [
{
"abbrev": true,
"full_module": "Pulse.Lib.Reference",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "Pulse.Lib.Array.Core",
"short_module": "A"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.BoundedIntegers",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "US"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Reference",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Main",
"short_module": "PM"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.SizeT",
"short_module": "SZ"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "PulseCore.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Array.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: FStar.SizeT.t -> a: Pulse.Lib.Array.Core.larray t (FStar.SizeT.v l) -> v: t
-> Pulse.Lib.Core.stt Prims.unit
(Pulse.Lib.Array.Core.pts_to a (FStar.Ghost.reveal s))
(fun _ ->
exists* (s: FStar.Seq.Base.seq t).
Pulse.Lib.Array.Core.pts_to a s **
Pulse.Lib.Core.pure (FStar.Seq.Base.equal s (FStar.Seq.Base.create (FStar.SizeT.v l) v))
) | Prims.Tot | [
"total"
] | [] | [
"Pulse.Lib.Array.fill'"
] | [] | false | false | false | false | false | let fill =
| fill' | false |
Spec.Agile.Cipher.fst | Spec.Agile.Cipher.xkey | val xkey : a: Spec.Agile.Cipher.cipher_alg -> Type0 | let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 33,
"end_line": 20,
"start_col": 0,
"start_line": 17
} | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Agile.Cipher.cipher_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.AES.aes_xkey",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Spec.Chacha20.key"
] | [] | false | false | false | true | true | let xkey (a: cipher_alg) =
| match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key | false |
|
Hacl.Bignum.fsti | Hacl.Bignum.bn_eq_mask_st | val bn_eq_mask_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | let bn_eq_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 419,
"start_col": 0,
"start_line": 413
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd.
inline_for_extraction noextract
let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t}
/// This type class is entirely meta-level and will not appear after partial
/// evaluation in the resulting C code. Clients can take this type class as a
/// parameter if they want the benefits of a function set specialized for a
/// given bignum length.
inline_for_extraction noextract
class bn (t:limb_t) = {
len: meta_len t;
add: bn_add_eq_len_st t len;
sub: bn_sub_eq_len_st t len;
add_mod_n: bn_add_mod_n_st t len;
sub_mod_n: bn_sub_mod_n_st t len;
mul: a:lbignum t len -> bn_karatsuba_mul_st t len a;
sqr: a:lbignum t len -> bn_karatsuba_sqr_st t len a;
}
inline_for_extraction noextract
val mk_runtime_bn: t:limb_t -> len:meta_len t -> bn t
val mk_runtime_bn_len_lemma: t:limb_t -> len:meta_len t ->
Lemma ((mk_runtime_bn t len).len == len) [SMTPat (mk_runtime_bn t len)]
///
/// Bignum comparison and test functions
///
inline_for_extraction noextract
val bn_is_odd:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_odd (as_seq h0 a)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.bn_eq_mask",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq"
] | [] | false | false | false | true | true | let bn_eq_mask_st (t: limb_t) (len: size_t) =
| a: lbignum t len -> b: lbignum t len
-> Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b)) | false |
|
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_codegen_success_Cmovc64 | val va_codegen_success_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | val va_codegen_success_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | let va_codegen_success_Cmovc64 dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 51,
"start_col": 0,
"start_line": 50
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Cmovc64 dst src =
| (va_ttrue ()) | false |
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_codegen_success_Mov64 | val va_codegen_success_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | val va_codegen_success_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | let va_codegen_success_Mov64 dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 21,
"start_col": 0,
"start_line": 20
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Mov64 dst src =
| (va_ttrue ()) | false |
Hacl.HPKE.Curve64_CP128_SHA256.fsti | Hacl.HPKE.Curve64_CP128_SHA256.vale_p | val vale_p : Prims.logical | let vale_p = Vale.X64.CPU_Features_s.(adx_enabled /\ bmi2_enabled) | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA256.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 66,
"end_line": 13,
"start_col": 0,
"start_line": 13
} | module Hacl.HPKE.Curve64_CP128_SHA256
open Hacl.Impl.HPKE
module S = Spec.Agile.HPKE
module DH = Spec.Agile.DH
module AEAD = Spec.Agile.AEAD
module Hash = Spec.Agile.Hash
noextract unfold
let cs:S.ciphersuite = (DH.DH_Curve25519, Hash.SHA2_256, S.Seal AEAD.CHACHA20_POLY1305, Hash.SHA2_256) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Spec.Agile.HPKE.fsti.checked",
"Spec.Agile.Hash.fsti.checked",
"Spec.Agile.DH.fst.checked",
"Spec.Agile.AEAD.fsti.checked",
"prims.fst.checked",
"Hacl.Impl.HPKE.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA256.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"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": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.l_and",
"Prims.b2t",
"Vale.X64.CPU_Features_s.adx_enabled",
"Vale.X64.CPU_Features_s.bmi2_enabled"
] | [] | false | false | false | true | true | let vale_p =
| let open Vale.X64.CPU_Features_s in adx_enabled /\ bmi2_enabled | false |
|
Spec.Agile.Cipher.fst | Spec.Agile.Cipher.ctr_block | val ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a | val ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a | let ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr): block a =
let k = expand a k in
match a with
| AES128 | AES256 ->
let open Spec.AES in
let open Lib.LoopCombinators in
let block = create 16 (u8 0) in
let block = repeati #(lbytes 16) (length iv) (fun i b -> b.[i] <- Seq.index iv i) block in
let block = aes_ctr_block_add_counter block c in
aes_encrypt_block (aes_alg_of_alg a) k block
| CHACHA20 ->
let open Spec.Chacha20 in
let block = chacha20_init k iv c in
let block' = rounds block in
uints_to_bytes_le (sum_state block block') | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 45,
"start_col": 0,
"start_line": 30
} | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = ()
let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n'
let xkey (a: cipher_alg) =
match a with
| AES128 | AES256 -> Spec.AES.aes_xkey (aes_alg_of_alg a)
| CHACHA20 -> Spec.Chacha20.key
/// As specified by the NIST. Other implementations (e.g. Vale) may perform
/// other steps beyond key expansion but this is an implementation detail.
let expand (a: cipher_alg) (k: key a): xkey a =
match a with
| AES128 | AES256 -> Spec.AES.aes_key_expansion (aes_alg_of_alg a) k
| CHACHA20 -> k | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Agile.Cipher.cipher_alg ->
k: Spec.Agile.Cipher.key a ->
iv: Spec.Agile.Cipher.nonce a ->
c: Spec.Agile.Cipher.ctr
-> Spec.Agile.Cipher.block a | Prims.Tot | [
"total"
] | [] | [
"Spec.Agile.Cipher.cipher_alg",
"Spec.Agile.Cipher.key",
"Spec.Agile.Cipher.nonce",
"Spec.Agile.Cipher.ctr",
"Spec.AES.aes_encrypt_block",
"Spec.Agile.Cipher.aes_alg_of_alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Agile.Cipher.aes_ctr_block_add_counter",
"Lib.LoopCombinators.repeati",
"Lib.ByteSequence.lbytes",
"Lib.Sequence.length",
"Lib.IntTypes.uint_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Assignment",
"FStar.Seq.Base.index",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.create",
"Lib.IntTypes.mk_int",
"Prims.l_Forall",
"Prims.l_imp",
"Lib.Sequence.index",
"Lib.Sequence.create",
"Lib.IntTypes.u8",
"Lib.ByteSequence.uints_to_bytes_le",
"Lib.IntTypes.U32",
"Spec.Chacha20.sum_state",
"Spec.Chacha20.state",
"Spec.Chacha20.rounds",
"Spec.Chacha20.chacha20_init",
"Spec.Agile.Cipher.block",
"Spec.Agile.Cipher.xkey",
"Spec.Agile.Cipher.expand"
] | [] | false | false | false | false | false | let ctr_block (a: cipher_alg) (k: key a) (iv: nonce a) (c: ctr) : block a =
| let k = expand a k in
match a with
| AES128
| AES256 ->
let open Spec.AES in
let open Lib.LoopCombinators in
let block = create 16 (u8 0) in
let block = repeati #(lbytes 16) (length iv) (fun i b -> b.[ i ] <- Seq.index iv i) block in
let block = aes_ctr_block_add_counter block c in
aes_encrypt_block (aes_alg_of_alg a) k block
| CHACHA20 ->
let open Spec.Chacha20 in
let block = chacha20_init k iv c in
let block' = rounds block in
uints_to_bytes_le (sum_state block block') | false |
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_code_Mov64 | val va_code_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | val va_code_Mov64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 75,
"end_line": 17,
"start_col": 0,
"start_line": 16
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr_annotate",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Mov64",
"Vale.X64.Machine_Semantics_s.AnnotateMov64",
"Vale.X64.Instruction_s.InstrTypeRecord",
"Vale.X64.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Mov64 dst src =
| (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) | false |
Spec.Agile.Cipher.fst | Spec.Agile.Cipher.aes_ctr_block_add_counter | val aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) | val aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) | let aes_ctr_block_add_counter (block: lbytes 16) (incr:size_nat): Tot (lbytes 16) =
let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | {
"file_name": "specs/Spec.Agile.Cipher.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 15,
"start_col": 0,
"start_line": 12
} | module Spec.Agile.Cipher
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Lib.ByteSequence
#reset-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 1"
let force_flush_interleaving = () | {
"checked_file": "/",
"dependencies": [
"Spec.Chacha20.fst.checked",
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.Agile.Cipher.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Agile",
"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": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | block: Lib.ByteSequence.lbytes 16 -> incr: Lib.IntTypes.size_nat -> Lib.ByteSequence.lbytes 16 | Prims.Tot | [
"total"
] | [] | [
"Lib.ByteSequence.lbytes",
"Lib.IntTypes.size_nat",
"Lib.ByteSequence.nat_to_bytes_be",
"Lib.IntTypes.SEC",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Addition",
"Prims.pow2",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Lib.Sequence.length",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.ByteSequence.nat_from_bytes_be"
] | [] | false | false | false | false | false | let aes_ctr_block_add_counter (block: lbytes 16) (incr: size_nat) : Tot (lbytes 16) =
| let n = nat_from_bytes_be block in
let n' = (n + incr) % pow2 128 in
nat_to_bytes_be 16 n' | false |
Hacl.Bignum.fsti | Hacl.Bignum.bn_lt_mask_st | val bn_lt_mask_st : t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | let bn_lt_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) | {
"file_name": "code/bignum/Hacl.Bignum.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 50,
"end_line": 444,
"start_col": 0,
"start_line": 438
} | module Hacl.Bignum
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Base
open Hacl.Bignum.Definitions
module S = Hacl.Spec.Bignum
module ST = FStar.HyperStack.ST
module Loops = Lib.LoopCombinators
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val bn_add1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_add1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
val bn_sub1:
#t:limb_t
-> aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint a res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(let c, r = S.bn_sub1 (as_seq h0 a) b1 in
c_out == c /\ as_seq h1 res == r))
inline_for_extraction noextract
let bn_add_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_eq_len: #t:limb_t -> len:size_t -> bn_add_eq_len_st t len
inline_for_extraction noextract
let bn_sub_eq_len_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_eq_len: #t:limb_t -> len:size_t -> bn_sub_eq_len_st t len
inline_for_extraction noextract
let bn_add_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_add (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add: #t:limb_t -> bn_add_st t
inline_for_extraction noextract
let bn_sub_st (t:limb_t) =
aLen:size_t
-> a:lbignum t aLen
-> bLen:size_t{v bLen <= v aLen}
-> b:lbignum t bLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint a b /\ eq_or_disjoint a res /\ disjoint b res)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_sub (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub: #t:limb_t -> bn_sub_st t
inline_for_extraction noextract
val bn_reduce_once:
#t:limb_t
-> aLen:size_t{v aLen > 0}
-> n:lbignum t aLen
-> c:carry t
-> a:lbignum t aLen ->
Stack unit
(requires fun h -> live h a /\ live h n /\ disjoint a n)
(ensures fun h0 c_out h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_reduce_once (as_seq h0 n) c (as_seq h0 a))
inline_for_extraction noextract
let bn_add_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_add_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_add_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_add_mod_n_st t len
inline_for_extraction noextract
let bn_sub_mod_n_st (t:limb_t) (len:size_t{v len > 0}) =
n:lbignum t len
-> a:lbignum t len
-> b:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h b /\ live h res /\
disjoint n a /\ disjoint n b /\ disjoint n res /\
eq_or_disjoint a b /\ eq_or_disjoint a res /\ eq_or_disjoint b res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_sub_mod_n (as_seq h0 n) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_sub_mod_n: #t:limb_t -> len:size_t{v len > 0} -> bn_sub_mod_n_st t len
inline_for_extraction noextract
val bn_mul1:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> l:limb t
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h a /\ live h res /\ eq_or_disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1 (as_seq h0 a) l)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
b:lbignum t len
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_mul_st t len a
inline_for_extraction noextract
let bn_mul_st (t:limb_t) (aLen:size_t) (bLen:size_t{v aLen + v bLen <= max_size_t}) (a:lbignum t aLen) =
b:lbignum t bLen
-> res:lbignum t (aLen +! bLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_mul:
#t:limb_t
-> aLen:size_t
-> bLen:size_t{v aLen + v bLen <= max_size_t}
-> a:lbignum t aLen ->
bn_mul_st t aLen bLen a
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) (len:size_t{0 < v len /\ 4 * v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ 4 * v len <= max_size_t}
-> a:lbignum t len ->
bn_karatsuba_sqr_st t len a
inline_for_extraction noextract
let bn_sqr_st (t:limb_t) (len:size_t{0 < v len /\ v len + v len <= max_size_t}) (a:lbignum t len) =
res:lbignum t (len +! len) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mul (as_seq h0 a) (as_seq h0 a))
inline_for_extraction noextract
val bn_sqr:
#t:limb_t
-> len:size_t{0 < v len /\ v len + v len <= max_size_t}
-> a:lbignum t len ->
bn_sqr_st t len a
inline_for_extraction noextract
val bn_mul1_lshift_add_in_place:
#t:limb_t
-> aLen:size_t
-> a:lbignum t aLen
-> b:limb t
-> resLen:size_t
-> j:size_t{v j + v aLen <= v resLen}
-> res:lbignum t resLen ->
Stack (limb t)
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 c_out h1 -> modifies (loc res) h0 h1 /\
(c_out, as_seq h1 res) == S.bn_mul1_lshift_add (as_seq h0 a) b (v j) (as_seq h0 res))
inline_for_extraction noextract
val bn_rshift:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i < v len}
-> res:lbignum t (len -! i) ->
Stack unit
(requires fun h -> live h b /\ live h res /\ disjoint res b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_rshift (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_sub_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> n:lbignum t len
-> a:lbignum t len ->
Stack unit
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\
as_seq h1 a == S.bn_sub_mask (as_seq h0 n) (as_seq h0 a))
///
/// Get and set i-th bit of a bignum
///
inline_for_extraction noextract
val bn_get_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val bn_get_bits:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t
-> l:size_t{v l < bits t /\ v i / bits t < v len} ->
Stack (limb t)
(requires fun h -> live h b)
(ensures fun h0 r h1 -> h0 == h1 /\
r == S.bn_get_bits (as_seq h0 b) (v i) (v l))
inline_for_extraction noextract
val bn_set_ith_bit:
#t:limb_t
-> len:size_t
-> b:lbignum t len
-> i:size_t{v i / bits t < v len} ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
as_seq h1 b == S.bn_set_ith_bit (as_seq h0 b) (v i))
inline_for_extraction noextract
val cswap2:
#t:limb_t
-> len:size_t
-> bit:limb t
-> b1:lbignum t len
-> b2:lbignum t len ->
Stack unit
(requires fun h -> live h b1 /\ live h b2 /\ disjoint b1 b2)
(ensures fun h0 _ h1 -> modifies (loc b1 |+| loc b2) h0 h1 /\
(as_seq h1 b1, as_seq h1 b2) == S.cswap2 bit (as_seq h0 b1) (as_seq h0 b2))
/// Start of the len-based specialization infrastructure.
///
/// Essentially, we wish to describe a type class of basic bignum operations
/// needed to implement Montgomery reduction. This will allow us to generate
/// specialized versions of modular exponentiation for a given bignum size.
///
/// This is done "by hand" because the specialization pattern is more
/// complicated than other pieces of code (chacha, poly, curve), meaning I don't
/// (yet) know how to automate it with a tactic. So, a type class seems like the
/// most efficient way to go about it.
///
/// The operations of the type class were found by essentially reading the code,
/// writing down which operations from Hacl.Bignum are (transitively) needed to
/// implement modular exponentiation, and figuring out for each call-site
/// whether they can be specialized for the bignum size, or whether they have to
/// been inline-for-extraction'd.
inline_for_extraction noextract
let meta_len (t:limb_t) = len:size_t{0 < v len /\ 2 * bits t * v len <= max_size_t}
/// This type class is entirely meta-level and will not appear after partial
/// evaluation in the resulting C code. Clients can take this type class as a
/// parameter if they want the benefits of a function set specialized for a
/// given bignum length.
inline_for_extraction noextract
class bn (t:limb_t) = {
len: meta_len t;
add: bn_add_eq_len_st t len;
sub: bn_sub_eq_len_st t len;
add_mod_n: bn_add_mod_n_st t len;
sub_mod_n: bn_sub_mod_n_st t len;
mul: a:lbignum t len -> bn_karatsuba_mul_st t len a;
sqr: a:lbignum t len -> bn_karatsuba_sqr_st t len a;
}
inline_for_extraction noextract
val mk_runtime_bn: t:limb_t -> len:meta_len t -> bn t
val mk_runtime_bn_len_lemma: t:limb_t -> len:meta_len t ->
Lemma ((mk_runtime_bn t len).len == len) [SMTPat (mk_runtime_bn t len)]
///
/// Bignum comparison and test functions
///
inline_for_extraction noextract
val bn_is_odd:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_odd (as_seq h0 a))
inline_for_extraction noextract
let bn_eq_mask_st (t:limb_t) (len:size_t) =
a:lbignum t len
-> b:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_eq_mask (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_eq_mask: #t:limb_t -> len:size_t -> bn_eq_mask_st t len
inline_for_extraction noextract
val bn_is_zero_mask:
#t:limb_t
-> len:size_t{v len > 0}
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_is_zero_mask (as_seq h0 a)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"FStar.Tactics.Typeclasses.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.fsti"
} | [
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | t: Hacl.Bignum.Definitions.limb_t -> len: Lib.IntTypes.size_t -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.modifies0",
"Prims.eq2",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.bn_lt_mask",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq"
] | [] | false | false | false | true | true | let bn_lt_mask_st (t: limb_t) (len: size_t) =
| a: lbignum t len -> b: lbignum t len
-> Stack (limb t)
(requires fun h -> live h a /\ live h b)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\ r == S.bn_lt_mask (as_seq h0 a) (as_seq h0 b)) | false |
|
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_code_Add64 | val va_code_Add64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | val va_code_Add64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src)) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 76,
"start_col": 0,
"start_line": 75
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.out",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.HavocFlags",
"Vale.X64.Instructions_s.ins_Add64",
"Vale.X64.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Add64 dst src =
| (mk_ins (make_instr (I.ins_Add64) dst src)) | false |
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_code_Cmovc64 | val va_code_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | val va_code_Cmovc64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_code | let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src)) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 47,
"end_line": 47,
"start_col": 0,
"start_line": 46
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_code | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Taint_Semantics.mk_ins",
"Vale.X64.InsLemmas.make_instr",
"Prims.Cons",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.inOut",
"Vale.X64.Instruction_s.op64",
"Prims.Nil",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.opFlagsCf",
"Vale.X64.Instruction_s.PreserveFlags",
"Vale.X64.Instructions_s.ins_Cmovc64",
"Vale.X64.Decls.va_code"
] | [] | false | false | false | true | false | let va_code_Cmovc64 dst src =
| (mk_ins (make_instr (I.ins_Cmovc64) dst src)) | false |
Vale.X64.InsBasic.fst | Vale.X64.InsBasic.va_codegen_success_Add64 | val va_codegen_success_Add64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | val va_codegen_success_Add64 : dst:va_operand_dst_opr64 -> src:va_operand_opr64 -> Tot va_pbool | let va_codegen_success_Add64 dst src =
(va_ttrue ()) | {
"file_name": "obj/Vale.X64.InsBasic.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 80,
"start_col": 0,
"start_line": 79
} | module Vale.X64.InsBasic
open Vale.X64
open Vale.X64.StateLemmas
open Vale.X64.InsLemmas
open Vale.X64.Taint_Semantics
open Vale.X64.CPU_Features_s
open Vale.X64.Memory
open Vale.X64.Stack_i
module I = Vale.X64.Instructions_s
module S = Vale.X64.Machine_Semantics_s
friend Vale.X64.Decls
#reset-options "--initial_fuel 5 --max_fuel 5 --max_ifuel 2 --z3rlimit 20"
//-- Mov64
[@ "opaque_to_smt"]
let va_code_Mov64 dst src =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Mov64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Mov64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Mov64) (va_code_Mov64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ())
dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Mov64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mov64 (va_code_Mov64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Cmovc64
[@ "opaque_to_smt"]
let va_code_Cmovc64 dst src =
(mk_ins (make_instr (I.ins_Cmovc64) dst src))
[@ "opaque_to_smt"]
let va_codegen_success_Cmovc64 dst src =
(va_ttrue ())
[@"opaque_to_smt"]
let va_lemma_Cmovc64 va_b0 va_s0 dst src =
va_reveal_opaque (`%va_code_Cmovc64) (va_code_Cmovc64 dst src);
let (va_old_s:va_state) = va_s0 in
va_ins_lemma (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0;
let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr (I.ins_Cmovc64) dst src)) va_s0 in
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Cmovc64 dst src va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Cmovc64 (va_code_Cmovc64 dst src) va_s0 dst src in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0)));
va_lemma_norm_mods ([va_mod_dst_opr64 dst]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Add64
[@ "opaque_to_smt"]
let va_code_Add64 dst src =
(mk_ins (make_instr (I.ins_Add64) dst src)) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.Taint_Semantics.fst.checked",
"Vale.X64.StateLemmas.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.InsLemmas.fsti.checked",
"Vale.X64.Decls.fst.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": true,
"source_file": "Vale.X64.InsBasic.fst"
} | [
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Vale.X64.Instructions_s",
"short_module": "I"
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Taint_Semantics",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.StateLemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"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.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_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": 5,
"initial_ifuel": 0,
"max_fuel": 5,
"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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | dst: Vale.X64.Decls.va_operand_dst_opr64 -> src: Vale.X64.Decls.va_operand_opr64
-> Vale.X64.Decls.va_pbool | Prims.Tot | [
"total"
] | [] | [
"Vale.X64.Decls.va_operand_dst_opr64",
"Vale.X64.Decls.va_operand_opr64",
"Vale.X64.Decls.va_ttrue",
"Vale.X64.Decls.va_pbool"
] | [] | false | false | false | true | false | let va_codegen_success_Add64 dst src =
| (va_ttrue ()) | false |
LowParse.Low.VCList.fst | LowParse.Low.VCList.validate_nlist | val validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) | val validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) | let validate_nlist
(n: U32.t)
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(v: validator p)
: Tot (validator (parse_nlist (U32.v n) p))
= fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1 : B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while
(fun h stop ->
B.modifies (B.loc_buffer bpos1 `B.loc_union` B.loc_buffer br) h1 h /\ (
let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\
U64.v pos <= U64.v pos1 /\ (
if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==> valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\ valid (parse_nlist (U32.v r) p) h0 input pos1) ==> get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) == get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~ (valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@inline_let]
let stop = is_error pos2 in
[@inline_let]
let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop
)
;
let res = B.index bpos1 0ul in
[@inline_let] let _ =
if is_success res
then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res | {
"file_name": "src/lowparse/LowParse.Low.VCList.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 210,
"start_col": 0,
"start_line": 154
} | module LowParse.Low.VCList
include LowParse.Spec.VCList
include LowParse.Low.List
module L = FStar.List.Tot
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module U32 = FStar.UInt32
module B = LowStar.Buffer
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_nlist_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (live_slice h sl /\ U32.v pos <= U32.v sl.len))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
let valid_nlist_nil_recip
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (valid (parse_nlist 0 p) h sl pos))
(ensures (valid_content_pos (parse_nlist 0 p) h sl pos [] pos))
= valid_facts (parse_nlist 0 p) h sl pos;
parse_nlist_eq 0 p (bytes_of_slice_from h sl pos)
#push-options "--z3rlimit 16"
let valid_nlist_cons
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos)
))
(ensures (
valid p h sl pos /\
valid (parse_nlist n p) h sl (get_valid_pos p h sl pos) /\ (
let pos1 = get_valid_pos p h sl pos in
valid_content_pos
(parse_nlist (n + 1) p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist n p) h sl pos1)
(get_valid_pos (parse_nlist n p) h sl pos1)
)))
= let pos1 = get_valid_pos p h sl pos in
valid_facts p h sl pos;
valid_facts (parse_nlist n p) h sl pos1;
valid_facts (parse_nlist (n + 1) p) h sl pos;
parse_nlist_eq (n + 1) p (bytes_of_slice_from h sl pos)
let valid_nlist_cons_recip
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid (parse_nlist n p) h sl pos
))
(ensures (
valid p h sl pos /\ (
let pos1 = get_valid_pos p h sl pos in
valid (parse_nlist (n - 1) p) h sl (get_valid_pos p h sl pos) /\
valid_content_pos
(parse_nlist n p)
h
sl
pos
(contents p h sl pos :: contents (parse_nlist (n - 1) p) h sl pos1)
(get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
)))
= valid_facts (parse_nlist n p) h sl pos;
parse_nlist_eq n p (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = get_valid_pos p h sl pos in
valid_facts (parse_nlist (n - 1) p) h sl pos1
#pop-options
let valid_nlist_cons'
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
valid p h sl pos
))
(ensures (
let pos1 = get_valid_pos p h sl pos in
(valid (parse_nlist n p) h sl pos <==> valid (parse_nlist (n - 1) p) h sl pos1) /\
((valid (parse_nlist n p) h sl pos /\ valid (parse_nlist (n - 1) p) h sl pos1) ==> get_valid_pos (parse_nlist n p) h sl pos == get_valid_pos (parse_nlist (n - 1) p) h sl pos1)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
let valid_nlist_cons_not
(n: nat)
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(sl: slice rrel rel)
(pos: U32.t)
: Lemma
(requires (
n > 0 /\
(~ (valid p h sl pos))
))
(ensures (
~ (valid (parse_nlist n p) h sl pos)
))
= Classical.move_requires (valid_nlist_cons (n - 1) p h sl) pos;
Classical.move_requires (valid_nlist_cons_recip n p h sl) pos
#push-options "--z3rlimit 32" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.VCList.fsti.checked",
"LowParse.Low.List.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.VCList.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "LowParse.Low.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.VCList",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"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": 32,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | n: FStar.UInt32.t -> v: LowParse.Low.Base.validator p
-> LowParse.Low.Base.validator (LowParse.Spec.VCList.parse_nlist (FStar.UInt32.v n) p) | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Low.Base.validator",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt64.t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowParse.Low.ErrorCode.is_success",
"LowParse.Low.VCList.valid_nlist_nil",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"Prims.bool",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_union",
"LowStar.Monotonic.Buffer.loc_buffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.UInt64.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"Prims.l_iff",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.VCList.parse_nlist_kind",
"LowParse.Spec.VCList.nlist",
"LowParse.Spec.VCList.parse_nlist",
"Prims.l_imp",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"Prims.l_not",
"Prims.logical",
"LowStar.Monotonic.Buffer.get",
"Prims.op_Equality",
"LowParse.Low.VCList.valid_nlist_cons_not",
"LowParse.Low.VCList.valid_nlist_cons'",
"LowParse.Low.ErrorCode.is_error",
"LowStar.Monotonic.Buffer.upd",
"FStar.UInt32.sub",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"LowStar.Buffer.buffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let validate_nlist (n: U32.t) (#k: parser_kind) (#t: Type) (#p: parser k t) (v: validator p)
: Tot (validator (parse_nlist (U32.v n) p)) =
| fun #rrel #rel input pos ->
let h0 = HST.get () in
HST.push_frame ();
let bpos1:B.buffer U64.t = B.alloca pos 1ul in
let br = B.alloca n 1ul in
let h1 = HST.get () in
C.Loops.do_while (fun h stop ->
B.modifies ((B.loc_buffer bpos1) `B.loc_union` (B.loc_buffer br)) h1 h /\
(let pos1 = B.get h bpos1 0 in
let r = B.get h br 0 in
U32.v r <= U32.v n /\ U64.v pos <= U64.v pos1 /\
(if is_success pos1
then
let pos1 = uint64_to_uint32 pos1 in
U32.v pos1 <= U32.v input.len /\
(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) <==>
valid (parse_nlist (U32.v r) p) h0 input pos1) /\
((valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) /\
valid (parse_nlist (U32.v r) p) h0 input pos1) ==>
get_valid_pos (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos) ==
get_valid_pos (parse_nlist (U32.v r) p) h0 input pos1) /\
(stop == true ==> r == 0ul)
else
(stop == true /\ (~(valid (parse_nlist (U32.v n) p) h0 input (uint64_to_uint32 pos))))
)))
(fun _ ->
let r = B.index br 0ul in
if r = 0ul
then true
else
let pos1 = B.index bpos1 0ul in
let pos2 = v input pos1 in
let _ = B.upd br 0ul (r `U32.sub` 1ul) in
let _ = B.upd bpos1 0ul pos2 in
[@@ inline_let ]let stop = is_error pos2 in
[@@ inline_let ]let _ =
if stop
then valid_nlist_cons_not (U32.v r) p h0 input (uint64_to_uint32 pos1)
else valid_nlist_cons' (U32.v r) p h0 input (uint64_to_uint32 pos1)
in
stop);
let res = B.index bpos1 0ul in
[@@ inline_let ]let _ =
if is_success res then valid_nlist_nil p h0 input (uint64_to_uint32 res)
in
HST.pop_frame ();
res | false |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.