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
Spec.Ed25519.PointOps.fst
Spec.Ed25519.PointOps.recover_x
val recover_x (y: nat) (sign: bool) : Tot (option elem)
val recover_x (y: nat) (sign: bool) : Tot (option elem)
let recover_x (y:nat) (sign:bool) : Tot (option elem) = if y >= prime then None else ( let y2 = y *% y in let x2 = (y2 -% one) *% (finv ((d *% y2) +% one)) in if x2 = zero then ( if sign then None else Some zero) else ( let x = x2 **% ((prime + 3) / 8) in let x = if ((x *% x) -% x2) <> zero then x *% modp_sqrt_m1 else x in if ((x *% x) -% x2) <> zero then None else ( let x = if (x % 2 = 1) <> sign then (prime - x) % prime else x in Some x)))
{ "file_name": "specs/Spec.Ed25519.PointOps.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 136, "start_col": 0, "start_line": 122 }
module Spec.Ed25519.PointOps open FStar.Mul open Spec.Curve25519 module BSeq = Lib.ByteSequence #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" type aff_point = elem & elem // Affine point type ext_point = elem & elem & elem & elem // Homogeneous extended coordinates (* 2 **% ((prime - 1) / 4) *) let modp_sqrt_m1 : elem = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0 let d : elem = let x = 37095705934669439343138083508754565189542113879843219016388785533085940283555 in assert_norm(x < prime); x let g_x : elem = 15112221349535400772501151409588531511454012693041857206046113283949847762202 let g_y : elem = 46316835694926478169428394003475163141307993866256225615783033603165251855960 let aff_g : aff_point = (g_x, g_y) let g: ext_point = (g_x, g_y, 1, g_x *% g_y) let is_on_curve (p:aff_point) = let (x, y) = p in y *% y -% x *% x == 1 +% d *% (x *% x) *% (y *% y) let to_aff_point (p:ext_point) : aff_point = let _X, _Y, _Z, _T = p in _X /% _Z, _Y /% _Z let is_ext (p:ext_point) = let _X, _Y, _Z, _T = p in _T == _X *% _Y /% _Z /\ _Z <> zero let point_inv (p:ext_point) = is_ext p /\ is_on_curve (to_aff_point p) // let is_on_curve_ext (p:ext_point) = // let _X, _Y, _Z, _T = p in // _Y *% _Y -% X *% X == _Z *% _Z +% d *% _T *% _T // let to_ext_point (p:aff_point) : ext_point = // let x, y = p in // (x, y, one, x *% y) /// Point addition and doubling in affine coordinates let aff_point_add (p:aff_point) (q:aff_point) : aff_point = let x1, y1 = p in let x2, y2 = q in let x3 = (x1 *% y2 +% y1 *% x2) /% (1 +% d *% (x1 *% x2) *% (y1 *% y2)) in let y3 = (y1 *% y2 +% x1 *% x2) /% (1 -% d *% (x1 *% x2) *% (y1 *% y2)) in x3, y3 let aff_point_double (p:aff_point) : aff_point = let x, y = p in let x3 = (2 *% x *% y) /% (y *% y -% x *% x) in let y3 = (y *% y +% x *% x) /% (2 -% y *% y +% x *% x) in x3, y3 let aff_point_at_infinity : aff_point = (zero, one) let aff_point_negate (p:aff_point) : aff_point = let x, y = p in ((-x) % prime, y) /// Point addition and doubling in Extended Twisted Edwards Coordinates let point_add (p:ext_point) (q:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let _X2, _Y2, _Z2, _T2 = q in let a = (_Y1 -% _X1) *% (_Y2 -% _X2) in let b = (_Y1 +% _X1) *% (_Y2 +% _X2) in let c = (2 *% d *% _T1) *% _T2 in let d = (2 *% _Z1) *% _Z2 in let e = b -% a in let f = d -% c in let g = d +% c in let h = b +% a in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_double (p:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let a = _X1 *% _X1 in let b = _Y1 *% _Y1 in let c = 2 *% (_Z1 *% _Z1) in let h = a +% b in let e = h -% ((_X1 +% _Y1) *% (_X1 +% _Y1)) in let g = a -% b in let f = c +% g in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_at_infinity: ext_point = (zero, one, one, zero) let point_negate (p:ext_point) : ext_point = let _X, _Y, _Z, _T = p in ((-_X) % prime, _Y, _Z, (-_T) % prime) let point_compress (p:ext_point) : Tot (BSeq.lbytes 32) = let px, py, pz, pt = p in let zinv = finv pz in let x = px *% zinv in let y = py *% zinv in BSeq.nat_to_bytes_le 32 (pow2 255 * (x % 2) + y)
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.PointOps.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
y: Prims.nat -> sign: Prims.bool -> FStar.Pervasives.Native.option Spec.Curve25519.elem
Prims.Tot
[ "total" ]
[]
[ "Prims.nat", "Prims.bool", "Prims.op_GreaterThanOrEqual", "Spec.Curve25519.prime", "FStar.Pervasives.Native.None", "Spec.Curve25519.elem", "Prims.op_Equality", "Spec.Curve25519.zero", "FStar.Pervasives.Native.Some", "FStar.Pervasives.Native.option", "Prims.op_disEquality", "Spec.Curve25519.op_Subtraction_Percent", "Spec.Curve25519.op_Star_Percent", "Prims.int", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "Spec.Ed25519.PointOps.modp_sqrt_m1", "Spec.Curve25519.op_Star_Star_Percent", "Prims.op_Division", "Prims.op_Addition", "Spec.Curve25519.one", "Spec.Curve25519.finv", "Spec.Curve25519.op_Plus_Percent", "Spec.Ed25519.PointOps.d" ]
[]
false
false
false
true
false
let recover_x (y: nat) (sign: bool) : Tot (option elem) =
if y >= prime then None else (let y2 = y *% y in let x2 = (y2 -% one) *% (finv ((d *% y2) +% one)) in if x2 = zero then (if sign then None else Some zero) else (let x = x2 **% ((prime + 3) / 8) in let x = if ((x *% x) -% x2) <> zero then x *% modp_sqrt_m1 else x in if ((x *% x) -% x2) <> zero then None else (let x = if (x % 2 = 1) <> sign then (prime - x) % prime else x in Some x)))
false
LowStar.UninitializedBuffer.fst
LowStar.UninitializedBuffer.ugcmalloc
val ugcmalloc (#a: Type0) (r: HS.rid) (len: U32.t) : HST.ST (b: lubuffer a (U32.v len) {frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None)))
val ugcmalloc (#a: Type0) (r: HS.rid) (len: U32.t) : HST.ST (b: lubuffer a (U32.v len) {frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None)))
let ugcmalloc (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer a (U32.v len){frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mgcmalloc r None len
{ "file_name": "ulib/LowStar.UninitializedBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 24, "end_line": 100, "start_col": 0, "start_line": 96 }
(* 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 LowStar.UninitializedBuffer include LowStar.Monotonic.Buffer module P = FStar.Preorder module G = FStar.Ghost module U32 = FStar.UInt32 module Seq = FStar.Seq module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* * Uninitialized buffers * * Modeled as: seq (option a) with a preorder that an index once set remains set *) private let initialization_preorder (a:Type0) :srel (option a) = fun s1 s2 -> Seq.length s1 == Seq.length s2 /\ (forall (i:nat).{:pattern (Seq.index s2 i)} i < Seq.length s1 ==> Some? (Seq.index s1 i) ==> Some? (Seq.index s2 i)) type ubuffer (a:Type0) = mbuffer (option a) (initialization_preorder a) (initialization_preorder a) unfold let unull (#a:Type0) :ubuffer a = mnull #(option a) #(initialization_preorder a) #(initialization_preorder a) unfold let gsub (#a:Type0) = mgsub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) unfold let gsub_inj (#a:Type0) = mgsub_inj #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (initialization_preorder a) inline_for_extraction type pointer (a:Type0) = b:ubuffer a{length b == 1} inline_for_extraction type pointer_or_null (a:Type0) = b:ubuffer a{if g_is_null b then True else length b == 1} inline_for_extraction let usub (#a:Type0) = msub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) inline_for_extraction let uoffset (#a:Type0) = moffset #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (****** main stateful API *****) (* * b `initialized_at` i: is a stable predicate that witnesses the initialization of an index i in ubuffer b *) private let ipred (#a:Type0) (i:nat) :spred (option a) = fun s -> i < Seq.length s ==> Some? (Seq.index s i) let initialized_at (#a:Type0) (b:ubuffer a) (i:nat) :Type0 = witnessed b (ipred i) (* * Clients need to prove that b is initialized_at i *) let uindex (#a:Type0) (b:ubuffer a) (i:U32.t) :HST.Stack a (requires (fun h0 -> live h0 b /\ U32.v i < length b /\ b `initialized_at` (U32.v i))) (ensures (fun h0 y h1 -> let y_opt = Seq.index (as_seq h0 b) (U32.v i) in Some? y_opt /\ y == Some?.v y_opt /\ h0 == h1)) = let y_opt = index b i in recall_p b (ipred (U32.v i)); Some?.v y_opt (* * b `initialized_at` i is a postcondition *) let uupd (#a:Type0) (b:ubuffer a) (i:U32.t) (v:a) :HST.Stack unit (requires (fun h0 -> live h0 b /\ U32.v i < length b)) (ensures (fun h0 _ h1 -> modifies (loc_buffer b) h0 h1 /\ live h1 b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (U32.v i) (Some v) /\ b `initialized_at` (U32.v i))) = upd b i (Some v); witness_p b (ipred (U32.v i)) unfold let lubuffer (a:Type0) (len:nat) = b:ubuffer a{length b == len} unfold let lubuffer_or_null (a:Type0) (len:nat) (r:HS.rid) = b:ubuffer a{(not (g_is_null b)) ==> (length b == len /\ frameOf b == r)} (* * No initializer
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.UninitializedBuffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: FStar.Monotonic.HyperHeap.rid -> len: FStar.UInt32.t -> FStar.HyperStack.ST.ST (b: LowStar.UninitializedBuffer.lubuffer a (FStar.UInt32.v len) {LowStar.Monotonic.Buffer.frameOf b == r /\ LowStar.Monotonic.Buffer.recallable b})
FStar.HyperStack.ST.ST
[]
[]
[ "FStar.Monotonic.HyperHeap.rid", "FStar.UInt32.t", "LowStar.Monotonic.Buffer.mgcmalloc", "FStar.Pervasives.Native.option", "LowStar.UninitializedBuffer.initialization_preorder", "FStar.Pervasives.Native.None", "LowStar.Monotonic.Buffer.lmbuffer", "FStar.UInt32.v", "Prims.l_and", "Prims.eq2", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.recallable", "LowStar.UninitializedBuffer.lubuffer", "FStar.Monotonic.HyperStack.mem", "LowStar.Monotonic.Buffer.malloc_pre", "LowStar.Monotonic.Buffer.alloc_post_mem_common", "FStar.Seq.Base.create" ]
[]
false
true
false
false
false
let ugcmalloc (#a: Type0) (r: HS.rid) (len: U32.t) : HST.ST (b: lubuffer a (U32.v len) {frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) =
mgcmalloc r None len
false
LowStar.UninitializedBuffer.fst
LowStar.UninitializedBuffer.witness_initialized
val witness_initialized (#a: Type0) (b: ubuffer a) (i: nat) : HST.ST unit (fun h0 -> i < length b /\ Some? (Seq.index (as_seq h0 b) i)) (fun h0 _ h1 -> h0 == h1 /\ b `initialized_at` i)
val witness_initialized (#a: Type0) (b: ubuffer a) (i: nat) : HST.ST unit (fun h0 -> i < length b /\ Some? (Seq.index (as_seq h0 b) i)) (fun h0 _ h1 -> h0 == h1 /\ b `initialized_at` i)
let witness_initialized (#a:Type0) (b:ubuffer a) (i:nat) :HST.ST unit (fun h0 -> i < length b /\ Some? (Seq.index (as_seq h0 b) i)) (fun h0 _ h1 -> h0 == h1 /\ b `initialized_at` i) = witness_p b (ipred i)
{ "file_name": "ulib/LowStar.UninitializedBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 25, "end_line": 179, "start_col": 0, "start_line": 176 }
(* 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 LowStar.UninitializedBuffer include LowStar.Monotonic.Buffer module P = FStar.Preorder module G = FStar.Ghost module U32 = FStar.UInt32 module Seq = FStar.Seq module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* * Uninitialized buffers * * Modeled as: seq (option a) with a preorder that an index once set remains set *) private let initialization_preorder (a:Type0) :srel (option a) = fun s1 s2 -> Seq.length s1 == Seq.length s2 /\ (forall (i:nat).{:pattern (Seq.index s2 i)} i < Seq.length s1 ==> Some? (Seq.index s1 i) ==> Some? (Seq.index s2 i)) type ubuffer (a:Type0) = mbuffer (option a) (initialization_preorder a) (initialization_preorder a) unfold let unull (#a:Type0) :ubuffer a = mnull #(option a) #(initialization_preorder a) #(initialization_preorder a) unfold let gsub (#a:Type0) = mgsub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) unfold let gsub_inj (#a:Type0) = mgsub_inj #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (initialization_preorder a) inline_for_extraction type pointer (a:Type0) = b:ubuffer a{length b == 1} inline_for_extraction type pointer_or_null (a:Type0) = b:ubuffer a{if g_is_null b then True else length b == 1} inline_for_extraction let usub (#a:Type0) = msub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) inline_for_extraction let uoffset (#a:Type0) = moffset #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (****** main stateful API *****) (* * b `initialized_at` i: is a stable predicate that witnesses the initialization of an index i in ubuffer b *) private let ipred (#a:Type0) (i:nat) :spred (option a) = fun s -> i < Seq.length s ==> Some? (Seq.index s i) let initialized_at (#a:Type0) (b:ubuffer a) (i:nat) :Type0 = witnessed b (ipred i) (* * Clients need to prove that b is initialized_at i *) let uindex (#a:Type0) (b:ubuffer a) (i:U32.t) :HST.Stack a (requires (fun h0 -> live h0 b /\ U32.v i < length b /\ b `initialized_at` (U32.v i))) (ensures (fun h0 y h1 -> let y_opt = Seq.index (as_seq h0 b) (U32.v i) in Some? y_opt /\ y == Some?.v y_opt /\ h0 == h1)) = let y_opt = index b i in recall_p b (ipred (U32.v i)); Some?.v y_opt (* * b `initialized_at` i is a postcondition *) let uupd (#a:Type0) (b:ubuffer a) (i:U32.t) (v:a) :HST.Stack unit (requires (fun h0 -> live h0 b /\ U32.v i < length b)) (ensures (fun h0 _ h1 -> modifies (loc_buffer b) h0 h1 /\ live h1 b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (U32.v i) (Some v) /\ b `initialized_at` (U32.v i))) = upd b i (Some v); witness_p b (ipred (U32.v i)) unfold let lubuffer (a:Type0) (len:nat) = b:ubuffer a{length b == len} unfold let lubuffer_or_null (a:Type0) (len:nat) (r:HS.rid) = b:ubuffer a{(not (g_is_null b)) ==> (length b == len /\ frameOf b == r)} (* * No initializer *) let ugcmalloc (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer a (U32.v len){frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mgcmalloc r None len inline_for_extraction let ugcmalloc_partial (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer_or_null a (U32.v len) r{recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_partial_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mgcmalloc r None len let umalloc (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer a (U32.v len){frameOf b == r /\ freeable b}) (requires (fun _ -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mmalloc r None len inline_for_extraction let umalloc_partial (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer_or_null a (U32.v len) r{(not (g_is_null b)) ==> freeable b}) (requires (fun _ -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_partial_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mmalloc r None len let ualloca (#a:Type0) (len:U32.t) :HST.StackInline (lubuffer a (U32.v len)) (requires (fun _ -> alloca_pre len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None) /\ frameOf b == HS.get_tip h0)) = malloca None len (* * blit functionality, where src is a regular buffer *) [@@"opaque_to_smt"] unfold let valid_j_for_blit (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a) (idx_dst:U32.t) (j:U32.t) = U32.v idx_src + U32.v j <= length src /\ U32.v idx_dst + U32.v j <= length dst (* * postcondition of blit *) [@@"opaque_to_smt"] unfold private let ublit_post_j (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a) (idx_dst:U32.t) (j:U32.t{valid_j_for_blit src idx_src dst idx_dst j}) (h0 h1:HS.mem) = modifies (loc_buffer dst) h0 h1 /\ live h1 dst /\ (forall (i:nat).{:pattern (Seq.index (as_seq h1 dst) i)} (i >= U32.v idx_dst /\ i < U32.v idx_dst + U32.v j ==> Seq.index (as_seq h1 dst) i == Some (Seq.index (as_seq h0 src) (U32.v idx_src + i - U32.v idx_dst))) ) /\ Seq.slice (as_seq h1 dst) 0 (U32.v idx_dst) == Seq.slice (as_seq h0 dst) 0 (U32.v idx_dst) /\ Seq.slice (as_seq h1 dst) (U32.v idx_dst + U32.v j) (length dst) == Seq.slice (as_seq h0 dst) (U32.v idx_dst + U32.v j) (length dst) /\ (forall (i:nat).{:pattern (dst `initialized_at` i)} (i >= U32.v idx_dst /\ i < U32.v idx_dst + U32.v j) ==> dst `initialized_at` i) let ublit (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a{disjoint src dst}) (idx_dst:U32.t) (len:U32.t{valid_j_for_blit src idx_src dst idx_dst len}) :HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) = let rec aux (j:U32.t{valid_j_for_blit src idx_src dst idx_dst j}) :HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst /\ ublit_post_j src idx_src dst idx_dst j h0 h0)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) = let open FStar.UInt32 in if j = len then () else if j <^ len then begin uupd dst (idx_dst +^ j) (index src (idx_src +^ j)); aux (j +^ 1ul) end in aux 0ul
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.UninitializedBuffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: LowStar.UninitializedBuffer.ubuffer a -> i: Prims.nat -> FStar.HyperStack.ST.ST Prims.unit
FStar.HyperStack.ST.ST
[]
[]
[ "LowStar.UninitializedBuffer.ubuffer", "Prims.nat", "LowStar.Monotonic.Buffer.witness_p", "FStar.Pervasives.Native.option", "LowStar.UninitializedBuffer.initialization_preorder", "LowStar.UninitializedBuffer.ipred", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "LowStar.Monotonic.Buffer.length", "FStar.Pervasives.Native.uu___is_Some", "FStar.Seq.Base.index", "LowStar.Monotonic.Buffer.as_seq", "Prims.eq2", "LowStar.UninitializedBuffer.initialized_at" ]
[]
false
true
false
false
false
let witness_initialized (#a: Type0) (b: ubuffer a) (i: nat) : HST.ST unit (fun h0 -> i < length b /\ Some? (Seq.index (as_seq h0 b) i)) (fun h0 _ h1 -> h0 == h1 /\ b `initialized_at` i) =
witness_p b (ipred i)
false
Spec.Ed25519.PointOps.fst
Spec.Ed25519.PointOps.point_decompress
val point_decompress (s: BSeq.lbytes 32) : Tot (option ext_point)
val point_decompress (s: BSeq.lbytes 32) : Tot (option ext_point)
let point_decompress (s:BSeq.lbytes 32) : Tot (option ext_point) = let y = BSeq.nat_from_bytes_le s in let sign = (y / pow2 255) % 2 = 1 in let y = y % pow2 255 in let x = recover_x y sign in match x with | Some x -> Some (x, y, one, x *% y) | _ -> None
{ "file_name": "specs/Spec.Ed25519.PointOps.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 145, "start_col": 0, "start_line": 138 }
module Spec.Ed25519.PointOps open FStar.Mul open Spec.Curve25519 module BSeq = Lib.ByteSequence #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" type aff_point = elem & elem // Affine point type ext_point = elem & elem & elem & elem // Homogeneous extended coordinates (* 2 **% ((prime - 1) / 4) *) let modp_sqrt_m1 : elem = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0 let d : elem = let x = 37095705934669439343138083508754565189542113879843219016388785533085940283555 in assert_norm(x < prime); x let g_x : elem = 15112221349535400772501151409588531511454012693041857206046113283949847762202 let g_y : elem = 46316835694926478169428394003475163141307993866256225615783033603165251855960 let aff_g : aff_point = (g_x, g_y) let g: ext_point = (g_x, g_y, 1, g_x *% g_y) let is_on_curve (p:aff_point) = let (x, y) = p in y *% y -% x *% x == 1 +% d *% (x *% x) *% (y *% y) let to_aff_point (p:ext_point) : aff_point = let _X, _Y, _Z, _T = p in _X /% _Z, _Y /% _Z let is_ext (p:ext_point) = let _X, _Y, _Z, _T = p in _T == _X *% _Y /% _Z /\ _Z <> zero let point_inv (p:ext_point) = is_ext p /\ is_on_curve (to_aff_point p) // let is_on_curve_ext (p:ext_point) = // let _X, _Y, _Z, _T = p in // _Y *% _Y -% X *% X == _Z *% _Z +% d *% _T *% _T // let to_ext_point (p:aff_point) : ext_point = // let x, y = p in // (x, y, one, x *% y) /// Point addition and doubling in affine coordinates let aff_point_add (p:aff_point) (q:aff_point) : aff_point = let x1, y1 = p in let x2, y2 = q in let x3 = (x1 *% y2 +% y1 *% x2) /% (1 +% d *% (x1 *% x2) *% (y1 *% y2)) in let y3 = (y1 *% y2 +% x1 *% x2) /% (1 -% d *% (x1 *% x2) *% (y1 *% y2)) in x3, y3 let aff_point_double (p:aff_point) : aff_point = let x, y = p in let x3 = (2 *% x *% y) /% (y *% y -% x *% x) in let y3 = (y *% y +% x *% x) /% (2 -% y *% y +% x *% x) in x3, y3 let aff_point_at_infinity : aff_point = (zero, one) let aff_point_negate (p:aff_point) : aff_point = let x, y = p in ((-x) % prime, y) /// Point addition and doubling in Extended Twisted Edwards Coordinates let point_add (p:ext_point) (q:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let _X2, _Y2, _Z2, _T2 = q in let a = (_Y1 -% _X1) *% (_Y2 -% _X2) in let b = (_Y1 +% _X1) *% (_Y2 +% _X2) in let c = (2 *% d *% _T1) *% _T2 in let d = (2 *% _Z1) *% _Z2 in let e = b -% a in let f = d -% c in let g = d +% c in let h = b +% a in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_double (p:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let a = _X1 *% _X1 in let b = _Y1 *% _Y1 in let c = 2 *% (_Z1 *% _Z1) in let h = a +% b in let e = h -% ((_X1 +% _Y1) *% (_X1 +% _Y1)) in let g = a -% b in let f = c +% g in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_at_infinity: ext_point = (zero, one, one, zero) let point_negate (p:ext_point) : ext_point = let _X, _Y, _Z, _T = p in ((-_X) % prime, _Y, _Z, (-_T) % prime) let point_compress (p:ext_point) : Tot (BSeq.lbytes 32) = let px, py, pz, pt = p in let zinv = finv pz in let x = px *% zinv in let y = py *% zinv in BSeq.nat_to_bytes_le 32 (pow2 255 * (x % 2) + y) let recover_x (y:nat) (sign:bool) : Tot (option elem) = if y >= prime then None else ( let y2 = y *% y in let x2 = (y2 -% one) *% (finv ((d *% y2) +% one)) in if x2 = zero then ( if sign then None else Some zero) else ( let x = x2 **% ((prime + 3) / 8) in let x = if ((x *% x) -% x2) <> zero then x *% modp_sqrt_m1 else x in if ((x *% x) -% x2) <> zero then None else ( let x = if (x % 2 = 1) <> sign then (prime - x) % prime else x in Some x)))
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.PointOps.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
s: Lib.ByteSequence.lbytes 32 -> FStar.Pervasives.Native.option Spec.Ed25519.PointOps.ext_point
Prims.Tot
[ "total" ]
[]
[ "Lib.ByteSequence.lbytes", "Spec.Curve25519.elem", "FStar.Pervasives.Native.Some", "Spec.Ed25519.PointOps.ext_point", "FStar.Pervasives.Native.Mktuple4", "Spec.Curve25519.one", "Spec.Curve25519.op_Star_Percent", "FStar.Pervasives.Native.option", "FStar.Pervasives.Native.None", "Spec.Ed25519.PointOps.recover_x", "Prims.int", "Prims.op_Modulus", "Prims.pow2", "Prims.bool", "Prims.op_Equality", "Prims.op_Division", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Multiply", "Lib.Sequence.length", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.ByteSequence.nat_from_bytes_le" ]
[]
false
false
false
false
false
let point_decompress (s: BSeq.lbytes 32) : Tot (option ext_point) =
let y = BSeq.nat_from_bytes_le s in let sign = (y / pow2 255) % 2 = 1 in let y = y % pow2 255 in let x = recover_x y sign in match x with | Some x -> Some (x, y, one, x *% y) | _ -> None
false
FStar.Algebra.CommMonoid.fst
FStar.Algebra.CommMonoid.right_identity
val right_identity (#a: Type) (m: cm a) (x: a) : Lemma (CM?.mult m x (CM?.unit m) == x)
val right_identity (#a: Type) (m: cm a) (x: a) : Lemma (CM?.mult m x (CM?.unit m) == x)
let right_identity (#a:Type) (m:cm a) (x:a) : Lemma (CM?.mult m x (CM?.unit m) == x) = CM?.commutativity m x (CM?.unit m); CM?.identity m x
{ "file_name": "ulib/FStar.Algebra.CommMonoid.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 54, "end_line": 33, "start_col": 0, "start_line": 31 }
(* 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.Algebra.CommMonoid open FStar.Mul unopteq type cm (a:Type) = | CM : unit:a -> mult:(a -> a -> a) -> identity : (x:a -> Lemma (unit `mult` x == x)) -> associativity : (x:a -> y:a -> z:a -> Lemma (x `mult` y `mult` z == x `mult` (y `mult` z))) -> commutativity:(x:a -> y:a -> Lemma (x `mult` y == y `mult` x)) -> cm a
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Algebra.CommMonoid.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
m: FStar.Algebra.CommMonoid.cm a -> x: a -> FStar.Pervasives.Lemma (ensures CM?.mult m x (CM?.unit m) == x)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Algebra.CommMonoid.cm", "FStar.Algebra.CommMonoid.__proj__CM__item__identity", "Prims.unit", "FStar.Algebra.CommMonoid.__proj__CM__item__commutativity", "FStar.Algebra.CommMonoid.__proj__CM__item__unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Algebra.CommMonoid.__proj__CM__item__mult", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let right_identity (#a: Type) (m: cm a) (x: a) : Lemma (CM?.mult m x (CM?.unit m) == x) =
CM?.commutativity m x (CM?.unit m); CM?.identity m x
false
FStar.Algebra.CommMonoid.fst
FStar.Algebra.CommMonoid.int_plus_cm
val int_plus_cm:cm int
val int_plus_cm:cm int
let int_plus_cm : cm int = CM 0 (+) (fun x -> ()) (fun x y z -> ()) (fun x y -> ())
{ "file_name": "ulib/FStar.Algebra.CommMonoid.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 58, "end_line": 36, "start_col": 0, "start_line": 35 }
(* 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.Algebra.CommMonoid open FStar.Mul unopteq type cm (a:Type) = | CM : unit:a -> mult:(a -> a -> a) -> identity : (x:a -> Lemma (unit `mult` x == x)) -> associativity : (x:a -> y:a -> z:a -> Lemma (x `mult` y `mult` z == x `mult` (y `mult` z))) -> commutativity:(x:a -> y:a -> Lemma (x `mult` y == y `mult` x)) -> cm a let right_identity (#a:Type) (m:cm a) (x:a) : Lemma (CM?.mult m x (CM?.unit m) == x) = CM?.commutativity m x (CM?.unit m); CM?.identity m x
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Algebra.CommMonoid.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Algebra.CommMonoid.cm Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.CM", "Prims.int", "Prims.op_Addition", "Prims.unit" ]
[]
false
false
false
true
false
let int_plus_cm:cm int =
CM 0 ( + ) (fun x -> ()) (fun x y z -> ()) (fun x y -> ())
false
FStar.Algebra.CommMonoid.fst
FStar.Algebra.CommMonoid.int_multiply_cm
val int_multiply_cm:cm int
val int_multiply_cm:cm int
let int_multiply_cm : cm int = CM 1 ( * ) (fun x -> ()) (fun x y z -> ()) (fun x y -> ())
{ "file_name": "ulib/FStar.Algebra.CommMonoid.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 60, "end_line": 39, "start_col": 0, "start_line": 38 }
(* 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.Algebra.CommMonoid open FStar.Mul unopteq type cm (a:Type) = | CM : unit:a -> mult:(a -> a -> a) -> identity : (x:a -> Lemma (unit `mult` x == x)) -> associativity : (x:a -> y:a -> z:a -> Lemma (x `mult` y `mult` z == x `mult` (y `mult` z))) -> commutativity:(x:a -> y:a -> Lemma (x `mult` y == y `mult` x)) -> cm a let right_identity (#a:Type) (m:cm a) (x:a) : Lemma (CM?.mult m x (CM?.unit m) == x) = CM?.commutativity m x (CM?.unit m); CM?.identity m x let int_plus_cm : cm int = CM 0 (+) (fun x -> ()) (fun x y z -> ()) (fun x y -> ())
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "FStar.Algebra.CommMonoid.fst" }
[ { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Algebra", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Algebra.CommMonoid.cm Prims.int
Prims.Tot
[ "total" ]
[]
[ "FStar.Algebra.CommMonoid.CM", "Prims.int", "FStar.Mul.op_Star", "Prims.unit" ]
[]
false
false
false
true
false
let int_multiply_cm:cm int =
CM 1 ( * ) (fun x -> ()) (fun x y z -> ()) (fun x y -> ())
false
LowStar.UninitializedBuffer.fst
LowStar.UninitializedBuffer.ublit
val ublit (#a: Type0) (#rrel #rel: srel a) (src: mbuffer a rrel rel) (idx_src: U32.t) (dst: ubuffer a {disjoint src dst}) (idx_dst: U32.t) (len: U32.t{valid_j_for_blit src idx_src dst idx_dst len}) : HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1))
val ublit (#a: Type0) (#rrel #rel: srel a) (src: mbuffer a rrel rel) (idx_src: U32.t) (dst: ubuffer a {disjoint src dst}) (idx_dst: U32.t) (len: U32.t{valid_j_for_blit src idx_src dst idx_dst len}) : HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1))
let ublit (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a{disjoint src dst}) (idx_dst:U32.t) (len:U32.t{valid_j_for_blit src idx_src dst idx_dst len}) :HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) = let rec aux (j:U32.t{valid_j_for_blit src idx_src dst idx_dst j}) :HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst /\ ublit_post_j src idx_src dst idx_dst j h0 h0)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) = let open FStar.UInt32 in if j = len then () else if j <^ len then begin uupd dst (idx_dst +^ j) (index src (idx_src +^ j)); aux (j +^ 1ul) end in aux 0ul
{ "file_name": "ulib/LowStar.UninitializedBuffer.fst", "git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
{ "end_col": 11, "end_line": 174, "start_col": 0, "start_line": 157 }
(* 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 LowStar.UninitializedBuffer include LowStar.Monotonic.Buffer module P = FStar.Preorder module G = FStar.Ghost module U32 = FStar.UInt32 module Seq = FStar.Seq module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* * Uninitialized buffers * * Modeled as: seq (option a) with a preorder that an index once set remains set *) private let initialization_preorder (a:Type0) :srel (option a) = fun s1 s2 -> Seq.length s1 == Seq.length s2 /\ (forall (i:nat).{:pattern (Seq.index s2 i)} i < Seq.length s1 ==> Some? (Seq.index s1 i) ==> Some? (Seq.index s2 i)) type ubuffer (a:Type0) = mbuffer (option a) (initialization_preorder a) (initialization_preorder a) unfold let unull (#a:Type0) :ubuffer a = mnull #(option a) #(initialization_preorder a) #(initialization_preorder a) unfold let gsub (#a:Type0) = mgsub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) unfold let gsub_inj (#a:Type0) = mgsub_inj #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (initialization_preorder a) inline_for_extraction type pointer (a:Type0) = b:ubuffer a{length b == 1} inline_for_extraction type pointer_or_null (a:Type0) = b:ubuffer a{if g_is_null b then True else length b == 1} inline_for_extraction let usub (#a:Type0) = msub #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) inline_for_extraction let uoffset (#a:Type0) = moffset #(option a) #(initialization_preorder a) #(initialization_preorder a) (initialization_preorder a) (****** main stateful API *****) (* * b `initialized_at` i: is a stable predicate that witnesses the initialization of an index i in ubuffer b *) private let ipred (#a:Type0) (i:nat) :spred (option a) = fun s -> i < Seq.length s ==> Some? (Seq.index s i) let initialized_at (#a:Type0) (b:ubuffer a) (i:nat) :Type0 = witnessed b (ipred i) (* * Clients need to prove that b is initialized_at i *) let uindex (#a:Type0) (b:ubuffer a) (i:U32.t) :HST.Stack a (requires (fun h0 -> live h0 b /\ U32.v i < length b /\ b `initialized_at` (U32.v i))) (ensures (fun h0 y h1 -> let y_opt = Seq.index (as_seq h0 b) (U32.v i) in Some? y_opt /\ y == Some?.v y_opt /\ h0 == h1)) = let y_opt = index b i in recall_p b (ipred (U32.v i)); Some?.v y_opt (* * b `initialized_at` i is a postcondition *) let uupd (#a:Type0) (b:ubuffer a) (i:U32.t) (v:a) :HST.Stack unit (requires (fun h0 -> live h0 b /\ U32.v i < length b)) (ensures (fun h0 _ h1 -> modifies (loc_buffer b) h0 h1 /\ live h1 b /\ as_seq h1 b == Seq.upd (as_seq h0 b) (U32.v i) (Some v) /\ b `initialized_at` (U32.v i))) = upd b i (Some v); witness_p b (ipred (U32.v i)) unfold let lubuffer (a:Type0) (len:nat) = b:ubuffer a{length b == len} unfold let lubuffer_or_null (a:Type0) (len:nat) (r:HS.rid) = b:ubuffer a{(not (g_is_null b)) ==> (length b == len /\ frameOf b == r)} (* * No initializer *) let ugcmalloc (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer a (U32.v len){frameOf b == r /\ recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mgcmalloc r None len inline_for_extraction let ugcmalloc_partial (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer_or_null a (U32.v len) r{recallable b}) (requires (fun h0 -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_partial_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mgcmalloc r None len let umalloc (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer a (U32.v len){frameOf b == r /\ freeable b}) (requires (fun _ -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mmalloc r None len inline_for_extraction let umalloc_partial (#a:Type0) (r:HS.rid) (len:U32.t) :HST.ST (b:lubuffer_or_null a (U32.v len) r{(not (g_is_null b)) ==> freeable b}) (requires (fun _ -> malloc_pre r len)) (ensures (fun h0 b h1 -> alloc_partial_post_mem_common b h0 h1 (Seq.create (U32.v len) None))) = mmalloc r None len let ualloca (#a:Type0) (len:U32.t) :HST.StackInline (lubuffer a (U32.v len)) (requires (fun _ -> alloca_pre len)) (ensures (fun h0 b h1 -> alloc_post_mem_common b h0 h1 (Seq.create (U32.v len) None) /\ frameOf b == HS.get_tip h0)) = malloca None len (* * blit functionality, where src is a regular buffer *) [@@"opaque_to_smt"] unfold let valid_j_for_blit (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a) (idx_dst:U32.t) (j:U32.t) = U32.v idx_src + U32.v j <= length src /\ U32.v idx_dst + U32.v j <= length dst (* * postcondition of blit *) [@@"opaque_to_smt"] unfold private let ublit_post_j (#a:Type0) (#rrel #rel:srel a) (src:mbuffer a rrel rel) (idx_src:U32.t) (dst:ubuffer a) (idx_dst:U32.t) (j:U32.t{valid_j_for_blit src idx_src dst idx_dst j}) (h0 h1:HS.mem) = modifies (loc_buffer dst) h0 h1 /\ live h1 dst /\ (forall (i:nat).{:pattern (Seq.index (as_seq h1 dst) i)} (i >= U32.v idx_dst /\ i < U32.v idx_dst + U32.v j ==> Seq.index (as_seq h1 dst) i == Some (Seq.index (as_seq h0 src) (U32.v idx_src + i - U32.v idx_dst))) ) /\ Seq.slice (as_seq h1 dst) 0 (U32.v idx_dst) == Seq.slice (as_seq h0 dst) 0 (U32.v idx_dst) /\ Seq.slice (as_seq h1 dst) (U32.v idx_dst + U32.v j) (length dst) == Seq.slice (as_seq h0 dst) (U32.v idx_dst + U32.v j) (length dst) /\ (forall (i:nat).{:pattern (dst `initialized_at` i)} (i >= U32.v idx_dst /\ i < U32.v idx_dst + U32.v j) ==> dst `initialized_at` i)
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "LowStar.Monotonic.Buffer.fsti.checked", "LowStar.ImmutableBuffer.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Seq.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.IndefiniteDescription.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "LowStar.UninitializedBuffer.fst" }
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "LowStar.Monotonic.Buffer", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "LowStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
src: LowStar.Monotonic.Buffer.mbuffer a rrel rel -> idx_src: FStar.UInt32.t -> dst: LowStar.UninitializedBuffer.ubuffer a {LowStar.Monotonic.Buffer.disjoint src dst} -> idx_dst: FStar.UInt32.t -> len: FStar.UInt32.t{LowStar.UninitializedBuffer.valid_j_for_blit src idx_src dst idx_dst len} -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "LowStar.Monotonic.Buffer.srel", "LowStar.Monotonic.Buffer.mbuffer", "FStar.UInt32.t", "LowStar.UninitializedBuffer.ubuffer", "LowStar.Monotonic.Buffer.disjoint", "FStar.Pervasives.Native.option", "LowStar.UninitializedBuffer.initialization_preorder", "LowStar.UninitializedBuffer.valid_j_for_blit", "FStar.UInt32.__uint_to_t", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "LowStar.Monotonic.Buffer.live", "LowStar.UninitializedBuffer.ublit_post_j", "Prims.op_Equality", "Prims.l_or", "Prims.bool", "FStar.UInt32.op_Less_Hat", "FStar.UInt32.op_Plus_Hat", "LowStar.UninitializedBuffer.uupd", "LowStar.Monotonic.Buffer.index" ]
[]
false
true
false
false
false
let ublit (#a: Type0) (#rrel #rel: srel a) (src: mbuffer a rrel rel) (idx_src: U32.t) (dst: ubuffer a {disjoint src dst}) (idx_dst: U32.t) (len: U32.t{valid_j_for_blit src idx_src dst idx_dst len}) : HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) =
let rec aux (j: U32.t{valid_j_for_blit src idx_src dst idx_dst j}) : HST.Stack unit (requires (fun h0 -> live h0 src /\ live h0 dst /\ ublit_post_j src idx_src dst idx_dst j h0 h0)) (ensures (fun h0 _ h1 -> ublit_post_j src idx_src dst idx_dst len h0 h1)) = let open FStar.UInt32 in if j = len then () else if j <^ len then (uupd dst (idx_dst +^ j) (index src (idx_src +^ j)); aux (j +^ 1ul)) in aux 0ul
false
Spec.Ed25519.PointOps.fst
Spec.Ed25519.PointOps.point_compress
val point_compress (p: ext_point) : Tot (BSeq.lbytes 32)
val point_compress (p: ext_point) : Tot (BSeq.lbytes 32)
let point_compress (p:ext_point) : Tot (BSeq.lbytes 32) = let px, py, pz, pt = p in let zinv = finv pz in let x = px *% zinv in let y = py *% zinv in BSeq.nat_to_bytes_le 32 (pow2 255 * (x % 2) + y)
{ "file_name": "specs/Spec.Ed25519.PointOps.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 120, "start_col": 0, "start_line": 115 }
module Spec.Ed25519.PointOps open FStar.Mul open Spec.Curve25519 module BSeq = Lib.ByteSequence #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" type aff_point = elem & elem // Affine point type ext_point = elem & elem & elem & elem // Homogeneous extended coordinates (* 2 **% ((prime - 1) / 4) *) let modp_sqrt_m1 : elem = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0 let d : elem = let x = 37095705934669439343138083508754565189542113879843219016388785533085940283555 in assert_norm(x < prime); x let g_x : elem = 15112221349535400772501151409588531511454012693041857206046113283949847762202 let g_y : elem = 46316835694926478169428394003475163141307993866256225615783033603165251855960 let aff_g : aff_point = (g_x, g_y) let g: ext_point = (g_x, g_y, 1, g_x *% g_y) let is_on_curve (p:aff_point) = let (x, y) = p in y *% y -% x *% x == 1 +% d *% (x *% x) *% (y *% y) let to_aff_point (p:ext_point) : aff_point = let _X, _Y, _Z, _T = p in _X /% _Z, _Y /% _Z let is_ext (p:ext_point) = let _X, _Y, _Z, _T = p in _T == _X *% _Y /% _Z /\ _Z <> zero let point_inv (p:ext_point) = is_ext p /\ is_on_curve (to_aff_point p) // let is_on_curve_ext (p:ext_point) = // let _X, _Y, _Z, _T = p in // _Y *% _Y -% X *% X == _Z *% _Z +% d *% _T *% _T // let to_ext_point (p:aff_point) : ext_point = // let x, y = p in // (x, y, one, x *% y) /// Point addition and doubling in affine coordinates let aff_point_add (p:aff_point) (q:aff_point) : aff_point = let x1, y1 = p in let x2, y2 = q in let x3 = (x1 *% y2 +% y1 *% x2) /% (1 +% d *% (x1 *% x2) *% (y1 *% y2)) in let y3 = (y1 *% y2 +% x1 *% x2) /% (1 -% d *% (x1 *% x2) *% (y1 *% y2)) in x3, y3 let aff_point_double (p:aff_point) : aff_point = let x, y = p in let x3 = (2 *% x *% y) /% (y *% y -% x *% x) in let y3 = (y *% y +% x *% x) /% (2 -% y *% y +% x *% x) in x3, y3 let aff_point_at_infinity : aff_point = (zero, one) let aff_point_negate (p:aff_point) : aff_point = let x, y = p in ((-x) % prime, y) /// Point addition and doubling in Extended Twisted Edwards Coordinates let point_add (p:ext_point) (q:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let _X2, _Y2, _Z2, _T2 = q in let a = (_Y1 -% _X1) *% (_Y2 -% _X2) in let b = (_Y1 +% _X1) *% (_Y2 +% _X2) in let c = (2 *% d *% _T1) *% _T2 in let d = (2 *% _Z1) *% _Z2 in let e = b -% a in let f = d -% c in let g = d +% c in let h = b +% a in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_double (p:ext_point) : Tot ext_point = let _X1, _Y1, _Z1, _T1 = p in let a = _X1 *% _X1 in let b = _Y1 *% _Y1 in let c = 2 *% (_Z1 *% _Z1) in let h = a +% b in let e = h -% ((_X1 +% _Y1) *% (_X1 +% _Y1)) in let g = a -% b in let f = c +% g in let _X3 = e *% f in let _Y3 = g *% h in let _T3 = e *% h in let _Z3 = f *% g in (_X3, _Y3, _Z3, _T3) let point_at_infinity: ext_point = (zero, one, one, zero) let point_negate (p:ext_point) : ext_point = let _X, _Y, _Z, _T = p in ((-_X) % prime, _Y, _Z, (-_T) % prime)
{ "checked_file": "/", "dependencies": [ "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.ByteSequence.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Ed25519.PointOps.fst" }
[ { "abbrev": true, "full_module": "Lib.ByteSequence", "short_module": "BSeq" }, { "abbrev": false, "full_module": "Spec.Curve25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Spec.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
p: Spec.Ed25519.PointOps.ext_point -> Lib.ByteSequence.lbytes 32
Prims.Tot
[ "total" ]
[]
[ "Spec.Ed25519.PointOps.ext_point", "Spec.Curve25519.elem", "Lib.ByteSequence.nat_to_bytes_le", "Lib.IntTypes.SEC", "Prims.op_Addition", "FStar.Mul.op_Star", "Prims.pow2", "Prims.op_Modulus", "Spec.Curve25519.op_Star_Percent", "Spec.Curve25519.finv", "Lib.ByteSequence.lbytes" ]
[]
false
false
false
false
false
let point_compress (p: ext_point) : Tot (BSeq.lbytes 32) =
let px, py, pz, pt = p in let zinv = finv pz in let x = px *% zinv in let y = py *% zinv in BSeq.nat_to_bytes_le 32 (pow2 255 * (x % 2) + y)
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_completed
val gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial_def alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
val gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial_def alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 124, "start_col": 0, "start_line": 122 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ Vale.AES.GCTR_BE.gctr_partial_def alg (FStar.Seq.Base.length cipher) plain cipher key icb) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR_BE.gctr_indexed" ]
[]
true
false
true
false
false
let gctr_partial_completed (alg: algorithm) (plain cipher: seq quad32) (key: seq nat32) (icb: quad32) =
gctr_indexed icb plain alg key cipher; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_opaque_init
val gctr_partial_opaque_init (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_partial alg 0 plain cipher key icb)
val gctr_partial_opaque_init (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_partial alg 0 plain cipher key icb)
let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 23, "start_col": 0, "start_line": 21 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key) (ensures Vale.AES.GCTR_BE.gctr_partial alg 0 plain cipher key icb)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR_BE.gctr_partial_reveal" ]
[]
true
false
true
false
false
let gctr_partial_opaque_init alg plain cipher key icb =
gctr_partial_reveal (); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_to_full_basic
val gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) : Lemma (requires is_aes_key_word alg key /\ cipher == gctr_encrypt_recursive icb plain alg key 0 /\ length plain * 16 < pow2_32 ) (ensures seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher) == gctr_encrypt icb (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) alg key)
val gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) : Lemma (requires is_aes_key_word alg key /\ cipher == gctr_encrypt_recursive icb plain alg key 0 /\ length plain * 16 < pow2_32 ) (ensures seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher) == gctr_encrypt icb (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) alg key)
let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 146, "start_col": 0, "start_line": 138 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
icb: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0 /\ FStar.Seq.Base.length plain * 16 < Vale.Def.Words_s.pow2_32) (ensures Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE cipher ) == Vale.AES.GCTR_BE_s.gctr_encrypt icb (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE plain )) alg key)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes", "Vale.Def.Words_s.nat8", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims._assert", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "FStar.Seq.Base.length", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
true
false
true
false
false
let gctr_partial_to_full_basic (icb: quad32) (plain: seq quad32) (alg: algorithm) (key: seq nat32) (cipher: seq quad32) =
gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_opaque_completed
val gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
val gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 49, "end_line": 136, "start_col": 0, "start_line": 126 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ FStar.Seq.Base.length plain < Vale.Def.Words_s.pow2_32 /\ Vale.AES.GCTR_BE.gctr_partial alg (FStar.Seq.Base.length cipher) plain cipher key icb) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Vale.AES.GCTR_BE.gctr_partial_completed", "Prims.unit", "Vale.AES.GCTR_BE.gctr_partial_reveal", "Prims.l_and", "Vale.AES.AES_BE_s.is_aes_key_word", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Prims.b2t", "Prims.op_LessThan", "Vale.Def.Words_s.pow2_32", "Vale.AES.GCTR_BE.gctr_partial", "Prims.squash", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gctr_partial_opaque_completed (alg: algorithm) (plain cipher: seq quad32) (key: seq nat32) (icb: quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) =
gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_encrypt_recursive_length
val gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))]
val gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))]
let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1)
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 69, "end_line": 47, "start_col": 0, "start_line": 39 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain_internal -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key i) == FStar.Seq.Base.length plain) (decreases FStar.Seq.Base.length plain) [ SMTPat (FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key i )) ]
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain_internal", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.int", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.bool", "Vale.AES.GCTR_BE.gctr_encrypt_recursive_length", "FStar.Seq.Properties.tail", "Prims.op_Addition", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "Prims.nat", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[ "recursion" ]
false
false
true
false
false
let rec gctr_encrypt_recursive_length (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] =
if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1)
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_opaque_ignores_postfix
val gctr_partial_opaque_ignores_postfix (alg:algorithm) (bound:nat32) (plain plain' cipher cipher':seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain >= bound /\ length cipher >= bound /\ length plain' >= bound /\ length cipher' >= bound /\ slice plain 0 bound == slice plain' 0 bound /\ slice cipher 0 bound == slice cipher' 0 bound) (ensures gctr_partial alg bound plain cipher key icb <==> gctr_partial alg bound plain' cipher' key icb)
val gctr_partial_opaque_ignores_postfix (alg:algorithm) (bound:nat32) (plain plain' cipher cipher':seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain >= bound /\ length cipher >= bound /\ length plain' >= bound /\ length cipher' >= bound /\ slice plain 0 bound == slice plain' 0 bound /\ slice cipher 0 bound == slice cipher' 0 bound) (ensures gctr_partial alg bound plain cipher key icb <==> gctr_partial alg bound plain' cipher' key icb)
let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 37, "start_col": 0, "start_line": 30 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> bound: Vale.Def.Types_s.nat32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> plain': FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher': FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ FStar.Seq.Base.length plain >= bound /\ FStar.Seq.Base.length cipher >= bound /\ FStar.Seq.Base.length plain' >= bound /\ FStar.Seq.Base.length cipher' >= bound /\ FStar.Seq.Base.slice plain 0 bound == FStar.Seq.Base.slice plain' 0 bound /\ FStar.Seq.Base.slice cipher 0 bound == FStar.Seq.Base.slice cipher' 0 bound) (ensures Vale.AES.GCTR_BE.gctr_partial alg bound plain cipher key icb <==> Vale.AES.GCTR_BE.gctr_partial alg bound plain' cipher' key icb)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.unit", "Prims._assert", "Prims.l_Forall", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.l_imp", "Prims.op_LessThanOrEqual", "Prims.eq2", "FStar.Seq.Base.index", "Vale.AES.GCTR_BE.gctr_partial_reveal" ]
[]
false
false
true
false
false
let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb =
gctr_partial_reveal (); assert (forall i. 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i. 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper3
val nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000)
val nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000)
let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 300, "start_col": 0, "start_line": 288 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s') (ensures k / 0x10000 == k' / 0x10000)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_2_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) =
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.lemma_slice_orig_index
val lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i))
val lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i))
let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 31, "end_line": 178, "start_col": 0, "start_line": 171 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq a -> s': FStar.Seq.Base.seq a -> m: Prims.nat -> n: Prims.nat -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length s == FStar.Seq.Base.length s' /\ m <= n /\ n <= FStar.Seq.Base.length s /\ FStar.Seq.Base.slice s m n == FStar.Seq.Base.slice s' m n) (ensures forall (i: Prims.int). {:pattern FStar.Seq.Base.index s i\/FStar.Seq.Base.index s' i} m <= i /\ i < n ==> FStar.Seq.Base.index s i == FStar.Seq.Base.index s' i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Prims.nat", "FStar.Classical.forall_intro", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "FStar.Seq.Base.lemma_index_slice", "Prims.op_Subtraction", "FStar.Seq.Base.length", "FStar.Seq.Base.slice", "Prims.l_Forall", "Prims.int", "Prims.l_imp" ]
[]
false
false
true
false
false
let lemma_slice_orig_index (#a: Type) (s s': seq a) (m n: nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i: int). {:pattern (index s i)\/(index s' i)} m <= i /\ i < n ==> index s i == index s' i)) =
let aux (i: nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.lemma_ishr_ixor_32
val lemma_ishr_ixor_32 (x y: nat32) (k: nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k))
val lemma_ishr_ixor_32 (x y: nat32) (k: nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k))
let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 189, "start_col": 0, "start_line": 180 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Def.Types_s.nat32 -> y: Vale.Def.Types_s.nat32 -> k: Prims.nat -> FStar.Pervasives.Lemma (ensures Vale.Def.Types_s.ishr (Vale.Def.Types_s.ixor x y) k == Vale.Def.Types_s.ixor (Vale.Def.Types_s.ishr x k) (Vale.Def.Types_s.ishr y k))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Prims.nat", "Prims.unit", "FStar.UInt.shift_right_logxor_lemma", "Vale.Def.TypesNative_s.reveal_ixor", "Vale.Def.Types_s.ishr", "Vale.Def.Words_s.pow2_32", "Vale.Def.TypesNative_s.reveal_ishr", "Vale.Def.Types_s.ixor", "Prims.l_True", "Prims.squash", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let lemma_ishr_ixor_32 (x y: nat32) (k: nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) =
Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_indexed
val gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
val gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0)
let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c)
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 120, "start_col": 0, "start_line": 111 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain_internal -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires FStar.Seq.Base.length cipher == FStar.Seq.Base.length plain /\ (forall (i: Prims.int { i >= 0 /\ i < FStar.Seq.Base.length plain /\ (i >= 0) /\ (i < FStar.Seq.Base.length cipher) }). {:pattern FStar.Seq.Base.index cipher i} 0 <= i /\ i < FStar.Seq.Base.length cipher ==> FStar.Seq.Base.index cipher i == Vale.Def.Types_s.quad32_xor (FStar.Seq.Base.index plain i) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 icb i)))) (ensures cipher == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key 0)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain_internal", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "FStar.Seq.Base.seq", "Prims._assert", "FStar.Seq.Base.equal", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Prims.unit", "Vale.AES.GCTR_BE.gctr_indexed_helper", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Prims.l_Forall", "Prims.int", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.l_imp", "Prims.op_LessThanOrEqual", "FStar.Seq.Base.index", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE_s.inc32", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let gctr_indexed (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (cipher: seq quad32) : Lemma (requires length cipher == length plain /\ (forall i. {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i)))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) =
gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert (equal cipher c)
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_indexed_helper
val gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain])
val gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain])
let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 41, "end_line": 109, "start_col": 0, "start_line": 86 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain_internal -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures (let cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb plain alg key i in FStar.Seq.Base.length cipher == FStar.Seq.Base.length plain /\ (forall (j: i: Prims.int { i >= 0 /\ i < FStar.Seq.Base.length plain /\ (i >= 0) /\ (i < FStar.Seq.Base.length cipher) }). {:pattern FStar.Seq.Base.index cipher j} 0 <= j /\ j < FStar.Seq.Base.length plain ==> FStar.Seq.Base.index cipher j == Vale.Def.Types_s.quad32_xor (FStar.Seq.Base.index plain j) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 icb (i + j)))) )) (decreases FStar.Seq.Base.length plain)
FStar.Pervasives.Lemma
[ "lemma", "" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain_internal", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.int", "Prims.op_Equality", "FStar.Seq.Base.length", "Prims.bool", "FStar.Classical.forall_intro", "Prims.l_imp", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "FStar.Seq.Base.index", "Vale.Def.Types_s.quad32_xor", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE_s.inc32", "Prims.op_Addition", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern", "Prims.op_AmpAmp", "Prims._assert", "Prims.op_Subtraction", "Vale.AES.GCTR_BE.gctr_indexed_helper", "Vale.AES.AES_BE_s.aes_encrypt_word_reveal", "FStar.Seq.Base.seq", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "FStar.Seq.Properties.tail", "Prims.nat", "Prims.l_Forall", "Prims.op_GreaterThanOrEqual" ]
[ "recursion" ]
false
false
true
false
false
let rec gctr_indexed_helper (icb: quad32) (plain: gctr_plain_internal) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j. {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)))))) (decreases %[length plain]) =
if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i + 1) in let helper (j: int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j))) )) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then (gctr_indexed_helper icb tl alg key (i + 1); assert (index r_cipher (j - 1) == quad32_xor (index tl (j - 1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1))))) in FStar.Classical.forall_intro helper
false
Selectors.LList2.fsti
Selectors.LList2.v_llist
val v_llist (#a: Type0) (#p: vprop) (r: t a) (h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist r) /\ True)}) : GTot (list a)
val v_llist (#a: Type0) (#p: vprop) (r: t a) (h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist r) /\ True)}) : GTot (list a)
let v_llist (#a:Type0) (#p:vprop) (r:t a) (h:rmem p{FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist r) /\ True)}) : GTot (list a) = h (llist r)
{ "file_name": "share/steel/examples/steel/Selectors.LList2.fsti", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 15, "end_line": 66, "start_col": 0, "start_line": 64 }
module Selectors.LList2 open Steel.Memory open Steel.Effect.Atomic open Steel.Effect open Steel.Reference module L = FStar.List.Tot /// This module provides the same interface as Selectors.LList. /// The difference is in the implementation, it uses a newer, promising style to handle vprop. /// Instead of going down all the way to the underlying slprop representation, it uses different /// combinators to define the core list vprop /// Abstract type of a list cell containing a value of type [a] val cell (a:Type0) : Type0 /// The type of a list: A reference to a cell inline_for_extraction let t (a:Type0) = ref (cell a) (* Helpers to manipulate cells while keeping its definition abstract *) inline_for_extraction val next (#a:Type0) (c:cell a) : t a inline_for_extraction val data (#a:Type0) (c:cell a) : a inline_for_extraction val mk_cell (#a:Type0) (n: t a) (d:a) : Pure (cell a) (requires True) (ensures fun c -> next c == n /\ data c == d) /// The null list pointer inline_for_extraction val null_llist (#a:Type) : t a /// Lifting the null pointer check to empty lists inline_for_extraction val is_null (#a:Type) (ptr:t a) : (b:bool{b <==> ptr == null_llist}) /// Separation logic predicate stating that reference [r] points to a valid list in memory val llist_sl (#a:Type0) (r:t a) : slprop u#1 /// Selector of a list. Returns an F* list of elements of type [a] val llist_sel (#a:Type0) (r:t a) : selector (list a) (llist_sl r) /// Combining the two above into a linked list vprop [@@__steel_reduce__] let llist' #a r : vprop' = {hp = llist_sl r; t = list a; sel = llist_sel r} unfold let llist (#a:Type0) (r:t a) = VUnit (llist' r) /// A wrapper to access a list selector more easily. /// Ensuring that the corresponding llist vprop is in the context is done by /// calling a variant of the framing tactic, as defined in Steel.Effect.Common
{ "checked_file": "/", "dependencies": [ "Steel.Reference.fsti.checked", "Steel.Memory.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "Steel.Effect.fsti.checked", "prims.fst.checked", "FStar.Tactics.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Selectors.LList2.fsti" }
[ { "abbrev": true, "full_module": "Steel.Memory", "short_module": "Mem" }, { "abbrev": false, "full_module": "Steel.FractionalPermission", "short_module": null }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "Steel.Reference", "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": "Selectors", "short_module": null }, { "abbrev": false, "full_module": "Selectors", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
r: Selectors.LList2.t a -> h: Steel.Effect.Common.rmem p { FStar.Tactics.Effect.with_tactic Steel.Effect.Common.selector_tactic (Steel.Effect.Common.can_be_split p (Selectors.LList2.llist r) /\ Prims.l_True) } -> Prims.GTot (Prims.list a)
Prims.GTot
[ "sometrivial" ]
[]
[ "Steel.Effect.Common.vprop", "Selectors.LList2.t", "Steel.Effect.Common.rmem", "FStar.Tactics.Effect.with_tactic", "Steel.Effect.Common.selector_tactic", "Prims.l_and", "Steel.Effect.Common.can_be_split", "Selectors.LList2.llist", "Prims.l_True", "Prims.list" ]
[]
false
false
false
false
false
let v_llist (#a: Type0) (#p: vprop) (r: t a) (h: rmem p {FStar.Tactics.with_tactic selector_tactic (can_be_split p (llist r) /\ True)}) : GTot (list a) =
h (llist r)
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.lemma_gctr_partial_append
val lemma_gctr_partial_append (alg:algorithm) (b1 b2:nat) (p1 c1 p2 c2:seq quad32) (key:seq nat32) (icb1 icb2:quad32) : Lemma (requires gctr_partial alg b1 p1 c1 key icb1 /\ gctr_partial alg b2 p2 c2 key icb2 /\ b1 == length p1 /\ b1 == length c1 /\ b2 == length p2 /\ b2 == length c2 /\ icb2 == inc32 icb1 b1) (ensures gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
val lemma_gctr_partial_append (alg:algorithm) (b1 b2:nat) (p1 c1 p2 c2:seq quad32) (key:seq nat32) (icb1 icb2:quad32) : Lemma (requires gctr_partial alg b1 p1 c1 key icb1 /\ gctr_partial alg b2 p2 c2 key icb2 /\ b1 == length p1 /\ b1 == length c1 /\ b2 == length p2 /\ b2 == length c2 /\ icb2 == inc32 icb1 b1) (ensures gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 28, "start_col": 0, "start_line": 26 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
alg: Vale.AES.AES_common_s.algorithm -> b1: Prims.nat -> b2: Prims.nat -> p1: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c1: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> p2: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> c2: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> icb1: Vale.Def.Types_s.quad32 -> icb2: Vale.Def.Types_s.quad32 -> FStar.Pervasives.Lemma (requires Vale.AES.GCTR_BE.gctr_partial alg b1 p1 c1 key icb1 /\ Vale.AES.GCTR_BE.gctr_partial alg b2 p2 c2 key icb2 /\ b1 == FStar.Seq.Base.length p1 /\ b1 == FStar.Seq.Base.length c1 /\ b2 == FStar.Seq.Base.length p2 /\ b2 == FStar.Seq.Base.length c2 /\ icb2 == Vale.AES.GCTR_BE_s.inc32 icb1 b1) (ensures Vale.AES.GCTR_BE.gctr_partial alg (b1 + b2) (p1 @| p2) (c1 @| c2) key icb1)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.AES.AES_common_s.algorithm", "Prims.nat", "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Vale.Def.Types_s.nat32", "Prims.unit", "Vale.AES.GCTR_BE.gctr_partial_reveal" ]
[]
true
false
true
false
false
let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 =
gctr_partial_reveal (); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper2
val nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3)
val nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3)
let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 236, "start_col": 0, "start_line": 221 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_1_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000) (ensures t.hi3 == t'.hi3) =
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper2
val nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
val nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 272, "start_col": 0, "start_line": 257 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t' /\ Mkfour?.lo1 t == Mkfour?.lo1 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_3_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) =
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper3
val nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100)
val nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100)
let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 314, "start_col": 0, "start_line": 302 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s' /\ Mkfour?.lo1 s == Mkfour?.lo1 s') (ensures k / 0x100 == k' / 0x100)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_3_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures k / 0x100 == k' / 0x100) =
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_1
val nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3)
val nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3)
let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 341, "start_col": 0, "start_line": 316 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ Mkfour?.hi3 s == Mkfour?.hi3 s') (ensures Mkfour?.hi3 t == Mkfour?.hi3 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper2", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.pow2", "Vale.AES.Types_helpers.pow2_24", "Vale.AES.GCTR_BE.lemma_ishr_ixor_32", "Vale.AES.Types_helpers.lemma_ishr_32", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper3", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_1 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3) (ensures t.hi3 == t'.hi3) =
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper2
val nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
val nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 255, "start_col": 0, "start_line": 238 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper1", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Prims.int", "Prims.op_Addition", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Prims.op_Division", "Prims.squash", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_2_helper2 (x x': nat32) (t t': four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) =
let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_encrypt_length
val gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))]
val gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))]
let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () )
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 83, "start_col": 0, "start_line": 51 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 40, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
icb: Vale.Def.Types_s.quad32 -> plain: Vale.AES.GCTR_BE_s.gctr_plain -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt icb plain alg key) == FStar.Seq.Base.length plain) [SMTPat (FStar.Seq.Base.length (Vale.AES.GCTR_BE_s.gctr_encrypt icb plain alg key))]
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.AES.GCTR_BE_s.gctr_plain", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.op_Equality", "Prims.int", "Vale.AES.GCTR_BE.gctr_encrypt_recursive_length", "FStar.Seq.Base.seq", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims.bool", "Vale.Def.Types_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "FStar.Mul.op_Star", "Prims.op_Addition", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Prims.op_Division", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Subtraction", "Vale.AES.GCTR_BE_s.gctr_encrypt", "Prims.op_Modulus", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal", "FStar.Pervasives.reveal_opaque", "Prims.l_True", "Prims.squash", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.Nil" ]
[]
false
false
true
false
false
let gctr_encrypt_length (icb: quad32) (plain: gctr_plain) (alg: algorithm) (key: aes_key_word alg) : Lemma (length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] =
reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then (let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0) else (let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); ())
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.step1
val step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE)
val step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE)
let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 168, "start_col": 0, "start_line": 148 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
p: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> num_bytes: Prims.nat{num_bytes < 16 * FStar.Seq.Base.length p} -> FStar.Pervasives.Lemma (ensures (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let _ = FStar.Seq.Properties.split (FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in (let FStar.Pervasives.Native.Mktuple2 #_ #_ full_blocks _ = _ in let full_quads_BE = Vale.Def.Types_s.be_bytes_to_seq_quad32 full_blocks in let p_prefix = FStar.Seq.Base.slice p 0 num_blocks in p_prefix == full_quads_BE) <: Type0))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "Vale.Def.Types_s.nat32", "Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes0", "Prims.int", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Division", "Prims.op_Modulus", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let step1 (p: seq quad32) (num_bytes: nat{num_bytes < 16 * length p}) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) =
let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_3
val nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
val nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1)
let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 393, "start_col": 0, "start_line": 369 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s' /\ Mkfour?.lo1 s == Mkfour?.lo1 s') (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t' /\ Mkfour?.lo1 t == Mkfour?.lo1 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper2", "Vale.AES.GCTR_BE.lemma_ishr_ixor_32", "Vale.AES.Types_helpers.lemma_ishr_32", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3_helper3", "Vale.Def.Words_s.nat8", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_3 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) =
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_1_helper3
val nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000)
val nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000)
let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 286, "start_col": 0, "start_line": 274 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ Mkfour?.hi3 s == Mkfour?.hi3 s') (ensures k / 0x1000000 == k' / 0x1000000)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Vale.Def.Words_s.natN", "Prims.pow2", "FStar.Mul.op_Star", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Words.Four_s.four_to_nat_unfold", "Vale.Def.Words_s.nat8", "Prims.l_and", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Prims.squash", "Prims.int", "Prims.op_Division", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_1_helper3 (k k': nat32) (s s': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3) (ensures k / 0x1000000 == k' / 0x1000000) =
let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); ()
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_constants
val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants}
val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants}
let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 18, "end_line": 79, "start_col": 0, "start_line": 75 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants:
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
b: Lib.Buffer.glbuffer Lib.IntTypes.size_t 4ul {Lib.Buffer.recallable b /\ Lib.Buffer.witnessed b Spec.Chacha20.chacha20_constants}
Prims.Tot
[ "total" ]
[]
[ "Lib.Buffer.createL_global", "Lib.IntTypes.size_t", "Lib.Buffer.glbuffer", "Lib.IntTypes.size", "FStar.Pervasives.normalize_term", "Lib.IntTypes.size_nat", "FStar.List.Tot.Base.length", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.UInt32.__uint_to_t", "Prims.l_and", "Lib.Buffer.recallable", "Lib.Buffer.CONST", "Lib.Buffer.witnessed", "Spec.Chacha20.chacha20_constants", "Prims.list", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.Cons", "Spec.Chacha20.c0", "Spec.Chacha20.c1", "Spec.Chacha20.c2", "Spec.Chacha20.c3", "Prims.Nil" ]
[]
false
false
false
false
false
let chacha20_constants =
[@@ inline_let ]let l = [Spec.c0; Spec.c1; Spec.c2; Spec.c3] in assert_norm (List.Tot.length l == 4); createL_global l
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.slice_pad_to_128_bits
val slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s)
val slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s)
let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 487, "start_col": 0, "start_line": 482 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 {0 < FStar.Seq.Base.length s /\ FStar.Seq.Base.length s < 16} -> FStar.Pervasives.Lemma (ensures FStar.Seq.Base.slice (Vale.AES.GCTR_BE_s.pad_to_128_bits s) 0 (FStar.Seq.Base.length s) == s)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Prims.eq2", "Prims.int", "Prims.op_Modulus", "Prims.l_True", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
true
false
true
false
false
let slice_pad_to_128_bits (s: seq nat8 {0 < length s /\ length s < 16}) : Lemma (slice (pad_to_128_bits s) 0 (length s) == s) =
assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.step2
val step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes)
val step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes)
let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 516, "start_col": 0, "start_line": 489 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
s: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 {0 < FStar.Seq.Base.length s /\ FStar.Seq.Base.length s < 16} -> q: Vale.Def.Types_s.quad32 -> icb_BE: Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_BE_s.aes_key_word alg -> i: Prims.int -> FStar.Pervasives.Lemma (ensures (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q_bytes_prefix = FStar.Seq.Base.slice q_bytes 0 (FStar.Seq.Base.length s) in let q_cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = FStar.Seq.Base.slice (Vale.Arch.Types.be_quad32_to_bytes q_cipher) 0 (FStar.Seq.Base.length s) in let s_quad = Vale.Def.Types_s.be_bytes_to_quad32 (Vale.AES.GCTR_BE_s.pad_to_128_bits s) in let s_cipher = Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = FStar.Seq.Base.slice (Vale.Arch.Types.be_quad32_to_bytes s_cipher) 0 (FStar.Seq.Base.length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat8", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length", "Vale.Def.Types_s.quad32", "Vale.AES.AES_common_s.algorithm", "Vale.AES.AES_BE_s.aes_key_word", "Prims.int", "Prims.unit", "Prims.op_Equality", "Vale.AES.GCTR_BE.quad32_xor_bytewise", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.GCTR_BE.slice_pad_to_128_bits", "Vale.Arch.Types.be_quad32_to_bytes_to_quad32", "Prims.bool", "Vale.AES.GCTR_BE_s.inc32", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Vale.Def.Words.Seq_s.seq16", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.eq2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let step2 (s: seq nat8 {0 < length s /\ length s < 16}) (q icb_BE: quad32) (alg: algorithm) (key: aes_key_word alg) (i: int) : Lemma (let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) =
let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then (be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); ()); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_encrypt_one_block
val gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_encrypt icb (be_quad32_to_bytes plain) alg key == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 (quad32_xor plain (aes_encrypt_word alg key icb)))) )
val gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) : Lemma (requires is_aes_key_word alg key) (ensures gctr_encrypt icb (be_quad32_to_bytes plain) alg key == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (create 1 (quad32_xor plain (aes_encrypt_word alg key icb)))) )
let gctr_encrypt_one_block (icb plain:quad32) (alg:algorithm) (key:seq nat32) = gctr_encrypt_reveal (); assert(inc32 icb 0 == icb); let encrypted_icb = aes_encrypt_word alg key icb in let p = be_quad32_to_bytes plain in let plain_quads = be_bytes_to_seq_quad32 p in let p_seq = create 1 plain in assert (length p == 16); be_bytes_to_seq_quad32_to_bytes_one_quad plain; assert (p_seq == plain_quads); let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in assert (cipher_quads == cons (gctr_encrypt_block icb (head plain_quads) alg key 0) (gctr_encrypt_recursive icb (tail plain_quads) alg key (1))); assert (head plain_quads == plain); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == (quad32_xor (head plain_quads) (aes_encrypt_word alg key icb))); assert (quad32_xor plain (aes_encrypt_word alg key icb) == (quad32_xor (head plain_quads) (aes_encrypt_word alg key (inc32 icb 0)))); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); aes_encrypt_word_reveal (); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain encrypted_icb); assert(gctr_encrypt_recursive icb (tail p_seq) alg key 1 == empty); // OBSERVE let x = quad32_xor plain encrypted_icb in append_empty_r (create 1 x); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 596, "start_col": 0, "start_line": 570 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); () let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); () #reset-options "--z3rlimit 30" open FStar.Seq.Properties let gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) = gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); // LHS quads let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); // LHS bytes assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert(final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); // RHS bytes be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
icb: Vale.Def.Types_s.quad32 -> plain: Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key) (ensures Vale.AES.GCTR_BE_s.gctr_encrypt icb (Vale.Arch.Types.be_quad32_to_bytes plain) alg key == Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE (FStar.Seq.Base.create 1 (Vale.Def.Types_s.quad32_xor plain (Vale.AES.AES_BE_s.aes_encrypt_word alg key icb)))))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Vale.AES.AES_common_s.algorithm", "FStar.Seq.Base.seq", "Vale.Def.Types_s.nat32", "Prims.unit", "FStar.Seq.Base.append_empty_r", "FStar.Seq.Base.create", "Vale.Def.Types_s.quad32_xor", "Prims._assert", "Prims.eq2", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "FStar.Seq.Properties.tail", "FStar.Seq.Base.empty", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "FStar.Seq.Properties.head", "Vale.AES.AES_BE_s.aes_encrypt_word", "Vale.AES.AES_BE_s.aes_encrypt_word_reveal", "Vale.AES.GCTR_BE_s.inc32", "FStar.Seq.Base.cons", "Vale.Arch.Types.be_bytes_to_seq_quad32_to_bytes_one_quad", "Prims.int", "FStar.Seq.Base.length", "Vale.Def.Words_s.nat8", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Vale.Def.Words.Seq_s.seq16", "Vale.Arch.Types.be_quad32_to_bytes", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
true
false
true
false
false
let gctr_encrypt_one_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) =
gctr_encrypt_reveal (); assert (inc32 icb 0 == icb); let encrypted_icb = aes_encrypt_word alg key icb in let p = be_quad32_to_bytes plain in let plain_quads = be_bytes_to_seq_quad32 p in let p_seq = create 1 plain in assert (length p == 16); be_bytes_to_seq_quad32_to_bytes_one_quad plain; assert (p_seq == plain_quads); let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in assert (cipher_quads == cons (gctr_encrypt_block icb (head plain_quads) alg key 0) (gctr_encrypt_recursive icb (tail plain_quads) alg key (1))); assert (head plain_quads == plain); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == (quad32_xor (head plain_quads) (aes_encrypt_word alg key icb))); assert (quad32_xor plain (aes_encrypt_word alg key icb) == (quad32_xor (head plain_quads) (aes_encrypt_word alg key (inc32 icb 0)))); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); aes_encrypt_word_reveal (); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain (aes_encrypt_word alg key icb)); assert (gctr_encrypt_block icb (head plain_quads) alg key 0 == quad32_xor plain encrypted_icb); assert (gctr_encrypt_recursive icb (tail p_seq) alg key 1 == empty); let x = quad32_xor plain encrypted_icb in append_empty_r (create 1 x); ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise_2
val nat32_xor_bytewise_2 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
val nat32_xor_bytewise_2 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2)
let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 367, "start_col": 0, "start_line": 343 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> x: Vale.Def.Types_s.nat32 -> x': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> s': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t: Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> t': Vale.Def.Words_s.four Vale.Def.Types_s.nat8 -> FStar.Pervasives.Lemma (requires k == Vale.Def.Words.Four_s.four_to_nat 8 s /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 s' /\ x == Vale.Def.Words.Four_s.four_to_nat 8 t /\ x' == Vale.Def.Words.Four_s.four_to_nat 8 t' /\ Vale.Def.Types_s.ixor k m == x /\ Vale.Def.Types_s.ixor k' m == x' /\ Mkfour?.hi3 s == Mkfour?.hi3 s' /\ Mkfour?.hi2 s == Mkfour?.hi2 s') (ensures Mkfour?.hi3 t == Mkfour?.hi3 t' /\ Mkfour?.hi2 t == Mkfour?.hi2 t')
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat8", "Prims.unit", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper2", "Vale.AES.GCTR_BE.lemma_ishr_ixor_32", "Vale.AES.Types_helpers.lemma_ishr_32", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2_helper3", "Vale.Def.Words_s.nat8", "Prims.l_and", "Prims.eq2", "Vale.Def.Words_s.natN", "Vale.Def.Words_s.pow2_32", "Vale.Def.Words.Four_s.four_to_nat", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise_2 (k k' x x' m: nat32) (s s' t t': four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) =
let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.nat32_xor_bytewise
val nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i))
val nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i))
let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 440, "start_col": 0, "start_line": 417 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
k: Vale.Def.Types_s.nat32 -> k': Vale.Def.Types_s.nat32 -> m: Vale.Def.Types_s.nat32 -> s: Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> s': Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> t: Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> t': Vale.Def.Words.Seq_s.seq4 Vale.Def.Types_s.nat8 -> n: Prims.nat -> FStar.Pervasives.Lemma (requires n <= 4 /\ k == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE s) /\ k' == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE s') /\ Vale.Def.Types_s.ixor k m == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE t) /\ Vale.Def.Types_s.ixor k' m == Vale.Def.Words.Four_s.four_to_nat 8 (Vale.Def.Words.Seq_s.seq_to_four_BE t') /\ FStar.Seq.Base.equal (FStar.Seq.Base.slice s 0 n) (FStar.Seq.Base.slice s' 0 n)) (ensures forall (i: Prims.nat). {:pattern FStar.Seq.Base.index t i\/FStar.Seq.Base.index t' i} i < n ==> FStar.Seq.Base.index t i == FStar.Seq.Base.index t' i)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.nat32", "Vale.Def.Words.Seq_s.seq4", "Vale.Def.Types_s.nat8", "Prims.nat", "Prims.unit", "Vale.AES.GCTR_BE.lemma_slice_orig_index", "Prims._assert", "FStar.Seq.Base.equal", "FStar.Seq.Base.slice", "Prims.op_Equality", "Prims.int", "Vale.AES.GCTR_BE.nat32_xor_bytewise_4", "Vale.Def.Words.Seq_s.seq_to_four_BE", "Prims.bool", "Vale.AES.GCTR_BE.nat32_xor_bytewise_3", "Vale.AES.GCTR_BE.nat32_xor_bytewise_2", "Vale.AES.GCTR_BE.nat32_xor_bytewise_1", "Vale.Def.Words_s.natN", "Vale.Def.Types_s.ixor", "Vale.Def.Words_s.pow2_32", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThan", "Prims.eq2", "FStar.Seq.Base.index", "Prims.l_and", "Prims.op_LessThanOrEqual", "Vale.Def.Words.Four_s.four_to_nat", "Prims.pow2", "FStar.Mul.op_Star", "Prims.squash", "Prims.l_Forall", "Prims.op_LessThan", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let nat32_xor_bytewise (k k' m: nat32) (s s' t t': seq4 nat8) (n: nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n)) (ensures (forall (i: nat). {:pattern (index t i)\/(index t' i)} i < n ==> index t i == index t' i)) =
assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; ()
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.gctr_partial_to_full_advanced
val gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) : Lemma (requires is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * length plain /\ 16 * (length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < pow2_32 /\ length plain == length cipher /\ ( let num_blocks = num_bytes / 16 in slice cipher 0 num_blocks == gctr_encrypt_recursive icb_BE (slice plain 0 num_blocks) alg key 0 /\ index cipher num_blocks == gctr_encrypt_block icb_BE (index plain num_blocks) alg key num_blocks) ) (ensures ( let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == gctr_encrypt icb_BE plain_bytes alg key ))
val gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) : Lemma (requires is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * length plain /\ 16 * (length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < pow2_32 /\ length plain == length cipher /\ ( let num_blocks = num_bytes / 16 in slice cipher 0 num_blocks == gctr_encrypt_recursive icb_BE (slice plain 0 num_blocks) alg key 0 /\ index cipher num_blocks == gctr_encrypt_block icb_BE (index plain num_blocks) alg key num_blocks) ) (ensures ( let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == gctr_encrypt icb_BE plain_bytes alg key ))
let gctr_partial_to_full_advanced (icb_BE:quad32) (plain:seq quad32) (cipher:seq quad32) (alg:algorithm) (key:seq nat32) (num_bytes:nat) = gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); // LHS quads let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); // LHS bytes assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert(final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); // RHS bytes be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 568, "start_col": 0, "start_line": 521 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; () let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); () let slice_pad_to_128_bits (s:seq nat8 { 0 < length s /\ length s < 16 }) : Lemma(slice (pad_to_128_bits s) 0 (length s) == s) = assert (length s % 16 == length s); assert (equal s (slice (pad_to_128_bits s) 0 (length s))); () let step2 (s:seq nat8 { 0 < length s /\ length s < 16 }) (q:quad32) (icb_BE:quad32) (alg:algorithm) (key:aes_key_word alg) (i:int): Lemma(let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in s == q_bytes_prefix ==> s_cipher_bytes == q_cipher_bytes) = let q_bytes = be_quad32_to_bytes q in let q_bytes_prefix = slice q_bytes 0 (length s) in let q_cipher = gctr_encrypt_block icb_BE q alg key i in let q_cipher_bytes = slice (be_quad32_to_bytes q_cipher) 0 (length s) in let s_quad = be_bytes_to_quad32 (pad_to_128_bits s) in let s_cipher = gctr_encrypt_block icb_BE s_quad alg key i in let s_cipher_bytes = slice (be_quad32_to_bytes s_cipher) 0 (length s) in let enc_ctr = aes_encrypt_word alg key (inc32 icb_BE i) in let icb = inc32 icb_BE i in if s = q_bytes_prefix then ( be_quad32_to_bytes_to_quad32 (pad_to_128_bits s); slice_pad_to_128_bits s; quad32_xor_bytewise q (be_bytes_to_quad32 (pad_to_128_bits s)) (aes_encrypt_word alg key icb) (length s); () ) else (); () #reset-options "--z3rlimit 30" open FStar.Seq.Properties
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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": 30, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
icb_BE: Vale.Def.Types_s.quad32 -> plain: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> cipher: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 -> alg: Vale.AES.AES_common_s.algorithm -> key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> num_bytes: Prims.nat -> FStar.Pervasives.Lemma (requires Vale.AES.AES_BE_s.is_aes_key_word alg key /\ 1 <= num_bytes /\ num_bytes < 16 * FStar.Seq.Base.length plain /\ 16 * (FStar.Seq.Base.length plain - 1) < num_bytes /\ num_bytes % 16 <> 0 /\ num_bytes < Vale.Def.Words_s.pow2_32 /\ FStar.Seq.Base.length plain == FStar.Seq.Base.length cipher /\ (let num_blocks = num_bytes / 16 in FStar.Seq.Base.slice cipher 0 num_blocks == Vale.AES.GCTR_BE_s.gctr_encrypt_recursive icb_BE (FStar.Seq.Base.slice plain 0 num_blocks) alg key 0 /\ FStar.Seq.Base.index cipher num_blocks == Vale.AES.GCTR_BE_s.gctr_encrypt_block icb_BE (FStar.Seq.Base.index plain num_blocks) alg key num_blocks)) (ensures (let plain_bytes = FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = FStar.Seq.Base.slice (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE cipher)) 0 num_bytes in cipher_bytes == Vale.AES.GCTR_BE_s.gctr_encrypt icb_BE plain_bytes alg key))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "FStar.Seq.Base.seq", "Vale.AES.AES_common_s.algorithm", "Vale.Def.Types_s.nat32", "Prims.nat", "Vale.Def.Words_s.nat8", "Prims.unit", "Prims._assert", "Prims.eq2", "FStar.Seq.Base.op_At_Bar", "Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE", "Vale.Def.Words.Seq_s.seq_four_to_seq_BE", "FStar.Seq.Base.slice", "Vale.Arch.Types.be_quad32_to_bytes", "FStar.Seq.Base.index", "FStar.Mul.op_Star", "Vale.Lib.Seqs.slice_append_adds", "FStar.Seq.Base.length", "Vale.Arch.Types.slice_commutes_be_seq_quad32_to_bytes0", "Vale.AES.GCM_helpers_BE.be_seq_quad32_to_bytes_tail_prefix", "Prims.int", "Vale.AES.GCTR_BE_s.gctr_encrypt_block", "Prims.op_Division", "Vale.AES.GCTR_BE_s.gctr_encrypt_recursive", "Vale.Def.Types_s.be_bytes_to_quad32", "Vale.AES.GCTR_BE_s.pad_to_128_bits", "Vale.Def.Types_s.be_bytes_to_seq_quad32", "Prims.op_Modulus", "FStar.Pervasives.Native.tuple2", "FStar.Seq.Properties.split", "Prims.op_Subtraction", "Vale.AES.GCTR_BE.step2", "Vale.AES.GCTR_BE.step1", "Vale.AES.GCTR_BE_s.gctr_encrypt_reveal" ]
[]
false
false
true
false
false
let gctr_partial_to_full_advanced (icb_BE: quad32) (plain cipher: seq quad32) (alg: algorithm) (key: seq nat32) (num_bytes: nat) =
gctr_encrypt_reveal (); let num_blocks = num_bytes / 16 in let plain_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) 0 num_bytes in let cipher_bytes = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes in step1 plain num_bytes; let s = slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain)) (num_blocks * 16) num_bytes in let final_p = index plain num_blocks in step2 s final_p icb_BE alg key num_blocks; let num_extra = num_bytes % 16 in let full_bytes_len = num_bytes - num_extra in let full_blocks, final_block = split plain_bytes full_bytes_len in assert (full_bytes_len % 16 == 0); assert (length full_blocks == full_bytes_len); let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let final_quad_BE = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads_BE = gctr_encrypt_recursive icb_BE full_quads_BE alg key 0 in let final_cipher_quad_BE = gctr_encrypt_block icb_BE final_quad_BE alg key (full_bytes_len / 16) in assert (cipher_quads_BE == slice cipher 0 num_blocks); let cipher_bytes_full_BE = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) in let final_cipher_bytes_BE = slice (be_quad32_to_bytes final_cipher_quad_BE) 0 num_extra in assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads_BE) == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))); assert (length s == num_extra); let q_prefix = slice (be_quad32_to_bytes final_p) 0 num_extra in be_seq_quad32_to_bytes_tail_prefix plain num_bytes; assert (q_prefix == s); assert (final_cipher_bytes_BE == slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); be_seq_quad32_to_bytes_tail_prefix cipher num_bytes; assert (slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_commutes_be_seq_quad32_to_bytes0 cipher num_blocks; assert (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks)) == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16)); assert (slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) (length cipher * 16)) 0 num_extra == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes); slice_append_adds (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes; assert (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 (num_blocks * 16) @| slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) (num_blocks * 16) num_bytes == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher)) 0 num_bytes); assert (cipher_bytes == (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice cipher 0 num_blocks))) @| slice (be_quad32_to_bytes (index cipher num_blocks)) 0 num_extra); ()
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_update
val chacha20_update: ctx:state -> len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ eq_or_disjoint text out /\ disjoint text ctx /\ disjoint out ctx) (ensures fun h0 _ h1 -> modifies (loc ctx |+| loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_update (as_seq h0 ctx) (as_seq h0 text))
val chacha20_update: ctx:state -> len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ eq_or_disjoint text out /\ disjoint text ctx /\ disjoint out ctx) (ensures fun h0 _ h1 -> modifies (loc ctx |+| loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_update (as_seq h0 ctx) (as_seq h0 text))
let chacha20_update ctx len out text = push_frame(); let blocks = len /. size 64 in let rem = len %. size 64 in let h0 = ST.get() in map_blocks h0 len 64ul text out (fun h -> Spec.chacha20_encrypt_block (as_seq h0 ctx)) (fun h -> Spec.chacha20_encrypt_last (as_seq h0 ctx)) (fun i -> chacha20_encrypt_block ctx (sub out (i *! 64ul) 64ul) i (sub text (i *! 64ul) 64ul)) (fun i -> chacha20_encrypt_last ctx rem (sub out (i *! 64ul) rem) i (sub text (i *! 64ul) rem)); pop_frame()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 181, "start_col": 0, "start_line": 171 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0)) let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); () val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text)) let chacha20_encrypt_block ctx out incr text = push_frame(); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame() val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text)) [@CInline] let chacha20_encrypt_last ctx len out incr text = push_frame(); let plain = create (size 64) (u8 0) in update_sub plain 0ul len text; chacha20_encrypt_block ctx plain incr plain; copy out (sub plain 0ul len); pop_frame() val chacha20_update: ctx:state -> len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ eq_or_disjoint text out /\ disjoint text ctx /\ disjoint out ctx) (ensures fun h0 _ h1 -> modifies (loc ctx |+| loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_update (as_seq h0 ctx) (as_seq h0 text))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctx: Hacl.Impl.Chacha20.Core32.state -> len: Lib.IntTypes.size_t -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.map_blocks", "Lib.Buffer.MUT", "FStar.UInt32.__uint_to_t", "FStar.Monotonic.HyperStack.mem", "Spec.Chacha20.chacha20_encrypt_block", "Lib.Buffer.as_seq", "Lib.IntTypes.uint32", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.op_Division", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Sequence.lseq", "Spec.Chacha20.chacha20_encrypt_last", "Prims.eq2", "Prims.int", "Lib.IntTypes.size_nat", "Hacl.Impl.Chacha20.chacha20_encrypt_block", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Lib.IntTypes.op_Star_Bang", "Hacl.Impl.Chacha20.chacha20_encrypt_last", "FStar.HyperStack.ST.get", "Lib.IntTypes.op_Percent_Dot", "Lib.IntTypes.size", "Lib.IntTypes.op_Slash_Dot", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let chacha20_update ctx len out text =
push_frame (); let blocks = len /. size 64 in let rem = len %. size 64 in let h0 = ST.get () in map_blocks h0 len 64ul text out (fun h -> Spec.chacha20_encrypt_block (as_seq h0 ctx)) (fun h -> Spec.chacha20_encrypt_last (as_seq h0 ctx)) (fun i -> chacha20_encrypt_block ctx (sub out (i *! 64ul) 64ul) i (sub text (i *! 64ul) 64ul)) (fun i -> chacha20_encrypt_last ctx rem (sub out (i *! 64ul) rem) i (sub text (i *! 64ul) rem)); pop_frame ()
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_core
val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0))
val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0))
let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 33, "end_line": 70, "start_col": 0, "start_line": 64 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
k: Hacl.Impl.Chacha20.Core32.state -> ctx0: Hacl.Impl.Chacha20.Core32.state -> ctr: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Lib.IntTypes.size_t", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.uint32", "FStar.UInt32.__uint_to_t", "Prims.unit", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Plus_Dot", "Lib.Buffer.op_Array_Access", "Lib.Buffer.MUT", "Hacl.Impl.Chacha20.Core32.sum_state", "Hacl.Impl.Chacha20.rounds", "Prims.eq2", "Lib.IntTypes.mk_int", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "Lib.IntTypes.size_to_uint32", "Hacl.Impl.Chacha20.Core32.copy_state" ]
[]
false
true
false
false
false
let chacha20_core k ctx ctr =
copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32
false
Hacl.Impl.MultiExponentiation.fsti
Hacl.Impl.MultiExponentiation.lexp_four_fw_tables_st
val lexp_four_fw_tables_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv1: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv2: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv3: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv4: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
let lexp_four_fw_tables_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv1:table_inv_t a_t len table_len) (table_inv2:table_inv_t a_t len table_len) (table_inv3:table_inv_t a_t len table_len) (table_inv4:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a1:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b1:lbuffer (uint_t a_t SEC) bLen -> a2:lbuffer (uint_t a_t SEC) len -> b2:lbuffer (uint_t a_t SEC) bLen -> a3:lbuffer (uint_t a_t SEC) len -> b3:lbuffer (uint_t a_t SEC) bLen -> a4:lbuffer (uint_t a_t SEC) len -> b4:lbuffer (uint_t a_t SEC) bLen -> table1:clbuffer (uint_t a_t SEC) (table_len *! len) -> table2:clbuffer (uint_t a_t SEC) (table_len *! len) -> table3:clbuffer (uint_t a_t SEC) (table_len *! len) -> table4:clbuffer (uint_t a_t SEC) (table_len *! len) -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a1 /\ live h b1 /\ live h a2 /\ live h b2 /\ live h a3 /\ live h b3 /\ live h a4 /\ live h b4 /\ live h res /\ live h ctx /\ live h table1 /\ live h table2 /\ live h table3 /\ live h table4 /\ eq_or_disjoint a1 a2 /\ eq_or_disjoint a1 a3 /\ eq_or_disjoint a1 a4 /\ eq_or_disjoint a2 a3 /\ eq_or_disjoint a2 a4 /\ eq_or_disjoint a3 a4 /\ disjoint a1 res /\ disjoint a1 ctx /\ disjoint a2 res /\ disjoint a2 ctx /\ disjoint a3 res /\ disjoint a3 ctx /\ disjoint a4 res /\ disjoint a4 ctx /\ disjoint b1 res /\ disjoint b2 res /\ disjoint b3 res /\ disjoint b4 res /\ disjoint res ctx /\ disjoint res table1 /\ disjoint res table2 /\ disjoint res table3 /\ disjoint res table4 /\ BD.bn_v h b1 < pow2 (v bBits) /\ BD.bn_v h b2 < pow2 (v bBits) /\ BD.bn_v h b3 < pow2 (v bBits) /\ BD.bn_v h b4 < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a1) /\ k.to.linv (as_seq h a2) /\ k.to.linv (as_seq h a3) /\ k.to.linv (as_seq h a4) /\ table_inv1 (as_seq h a1) (as_seq h table1) /\ table_inv2 (as_seq h a2) (as_seq h table2) /\ table_inv3 (as_seq h a3) (as_seq h table3) /\ table_inv4 (as_seq h a4) (as_seq h table4)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_four_fw k.to.comm_monoid (k.to.refl (as_seq h0 a1)) (v bBits) (BD.bn_v h0 b1) (k.to.refl (as_seq h0 a2)) (BD.bn_v h0 b2) (k.to.refl (as_seq h0 a3)) (BD.bn_v h0 b3) (k.to.refl (as_seq h0 a4)) (BD.bn_v h0 b4) (v l))
{ "file_name": "code/bignum/Hacl.Impl.MultiExponentiation.fsti", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 55, "end_line": 205, "start_col": 0, "start_line": 144 }
module Hacl.Impl.MultiExponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module S = Lib.Exponentiation module BD = Hacl.Bignum.Definitions open Hacl.Impl.Exponentiation #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // Double Fixed-window method using two precomputed tables //--------------------------------------------------------- inline_for_extraction noextract let lexp_double_fw_tables_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv1:table_inv_t a_t len table_len) (table_inv2:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a1:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b1:lbuffer (uint_t a_t SEC) bLen -> a2:lbuffer (uint_t a_t SEC) len -> b2:lbuffer (uint_t a_t SEC) bLen -> table1:clbuffer (uint_t a_t SEC) (table_len *! len) -> table2:clbuffer (uint_t a_t SEC) (table_len *! len) -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a1 /\ live h b1 /\ live h a2 /\ live h b2 /\ live h res /\ live h ctx /\ live h table1 /\ live h table2 /\ eq_or_disjoint a1 a2 /\ disjoint a1 res /\ disjoint a1 ctx /\ disjoint b1 res /\ disjoint a2 res /\ disjoint a2 ctx /\ disjoint b2 res /\ disjoint res ctx /\ disjoint res table1 /\ disjoint res table2 /\ BD.bn_v h b1 < pow2 (v bBits) /\ BD.bn_v h b2 < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a1) /\ k.to.linv (as_seq h a2) /\ table_inv1 (as_seq h a1) (as_seq h table1) /\ table_inv2 (as_seq h a2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_double_fw k.to.comm_monoid (k.to.refl (as_seq h0 a1)) (v bBits) (BD.bn_v h0 b1) (k.to.refl (as_seq h0 a2)) (BD.bn_v h0 b2) (v l)) inline_for_extraction noextract val mk_lexp_double_fw_tables: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> table_len:table_len_t len -> table_inv1:table_inv_t a_t len table_len -> table_inv2:table_inv_t a_t len table_len -> pow_a_to_small_b1:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv1 -> pow_a_to_small_b2:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv2 -> lexp_double_fw_tables_st a_t len ctx_len k l table_len table_inv1 table_inv2 // Double Fixed-window method with two precomputed tables // table1 = [a1^0 = one; a1^1; a1^2; ..; a1^(table_len - 1)] // table2 = [a2^0 = one; a2^1; a2^2; ..; a2^(table_len - 1)] //----------------------------------------------------------- inline_for_extraction noextract let lexp_double_fw_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a1:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b1:lbuffer (uint_t a_t SEC) bLen -> a2:lbuffer (uint_t a_t SEC) len -> b2:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a1 /\ live h b1 /\ live h a2 /\ live h b2 /\ live h res /\ live h ctx /\ eq_or_disjoint a1 a2 /\ disjoint a1 res /\ disjoint a1 ctx /\ disjoint a2 res /\ disjoint a2 ctx /\ disjoint res b1 /\ disjoint res b2 /\ disjoint res ctx /\ BD.bn_v h b1 < pow2 (v bBits) /\ BD.bn_v h b2 < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a1) /\ k.to.linv (as_seq h a2)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_double_fw #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a1)) (v bBits) (BD.bn_v h0 b1) (k.to.refl (as_seq h0 a2)) (BD.bn_v h0 b2) (v l)) // This function computes `a1^b1 `mul` a2^b2` using a fixed-window method // It takes variable time to compute the result inline_for_extraction noextract val lexp_double_fw_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> lexp_double_fw_st a_t len ctx_len k l // This function computes `a1^b1 `mul` a2^b2` using a fixed-window method // It takes constant time to compute the result inline_for_extraction noextract val lexp_double_fw_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> lexp_double_fw_st a_t len ctx_len k l //--------------------------------------------------
{ "checked_file": "/", "dependencies": [ "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.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.Impl.MultiExponentiation.fsti" }
[ { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv1: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv2: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv3: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> table_inv4: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
Prims.Tot
[ "total" ]
[]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.Exponentiation.size_window_t", "Hacl.Impl.Exponentiation.table_len_t", "Hacl.Impl.Exponentiation.table_inv_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.op_LessThan", "Prims.op_Division", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Lib.Buffer.clbuffer", "Lib.IntTypes.op_Star_Bang", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.CONST", "Lib.Buffer.eq_or_disjoint", "Lib.Buffer.disjoint", "Hacl.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.exp_four_fw", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
false
false
false
false
true
let lexp_four_fw_tables_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) (table_inv1 table_inv2 table_inv3 table_inv4: table_inv_t a_t len table_len) =
ctx: lbuffer (uint_t a_t SEC) ctx_len -> a1: lbuffer (uint_t a_t SEC) len -> bLen: size_t -> bBits: size_t{(v bBits - 1) / bits a_t < v bLen} -> b1: lbuffer (uint_t a_t SEC) bLen -> a2: lbuffer (uint_t a_t SEC) len -> b2: lbuffer (uint_t a_t SEC) bLen -> a3: lbuffer (uint_t a_t SEC) len -> b3: lbuffer (uint_t a_t SEC) bLen -> a4: lbuffer (uint_t a_t SEC) len -> b4: lbuffer (uint_t a_t SEC) bLen -> table1: clbuffer (uint_t a_t SEC) (table_len *! len) -> table2: clbuffer (uint_t a_t SEC) (table_len *! len) -> table3: clbuffer (uint_t a_t SEC) (table_len *! len) -> table4: clbuffer (uint_t a_t SEC) (table_len *! len) -> res: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a1 /\ live h b1 /\ live h a2 /\ live h b2 /\ live h a3 /\ live h b3 /\ live h a4 /\ live h b4 /\ live h res /\ live h ctx /\ live h table1 /\ live h table2 /\ live h table3 /\ live h table4 /\ eq_or_disjoint a1 a2 /\ eq_or_disjoint a1 a3 /\ eq_or_disjoint a1 a4 /\ eq_or_disjoint a2 a3 /\ eq_or_disjoint a2 a4 /\ eq_or_disjoint a3 a4 /\ disjoint a1 res /\ disjoint a1 ctx /\ disjoint a2 res /\ disjoint a2 ctx /\ disjoint a3 res /\ disjoint a3 ctx /\ disjoint a4 res /\ disjoint a4 ctx /\ disjoint b1 res /\ disjoint b2 res /\ disjoint b3 res /\ disjoint b4 res /\ disjoint res ctx /\ disjoint res table1 /\ disjoint res table2 /\ disjoint res table3 /\ disjoint res table4 /\ BD.bn_v h b1 < pow2 (v bBits) /\ BD.bn_v h b2 < pow2 (v bBits) /\ BD.bn_v h b3 < pow2 (v bBits) /\ BD.bn_v h b4 < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a1) /\ k.to.linv (as_seq h a2) /\ k.to.linv (as_seq h a3) /\ k.to.linv (as_seq h a4) /\ table_inv1 (as_seq h a1) (as_seq h table1) /\ table_inv2 (as_seq h a2) (as_seq h table2) /\ table_inv3 (as_seq h a3) (as_seq h table3) /\ table_inv4 (as_seq h a4) (as_seq h table4)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_four_fw k.to.comm_monoid (k.to.refl (as_seq h0 a1)) (v bBits) (BD.bn_v h0 b1) (k.to.refl (as_seq h0 a2)) (BD.bn_v h0 b2) (k.to.refl (as_seq h0 a3)) (BD.bn_v h0 b3) (k.to.refl (as_seq h0 a4)) (BD.bn_v h0 b4) (v l))
false
Vale.AES.GCTR_BE.fst
Vale.AES.GCTR_BE.quad32_xor_bytewise
val quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n))
val quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n))
let quad32_xor_bytewise (q q' r:quad32) (n:nat{ n <= 16 }) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) = let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else ( nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else ( nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else ( nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); () ) ) ); assert (equal (slice t 0 n) (slice t' 0 n)); ()
{ "file_name": "vale/code/crypto/aes/Vale.AES.GCTR_BE.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 480, "start_col": 0, "start_line": 442 }
module Vale.AES.GCTR_BE open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Words.Seq_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.Arch.Types open FStar.Mul open FStar.Seq open Vale.AES.AES_BE_s open Vale.AES.GCTR_BE_s open Vale.AES.GCM_helpers_BE open FStar.Math.Lemmas open Vale.Lib.Seqs open Vale.AES.Types_helpers let gctr_encrypt_block_offset (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) = () let gctr_partial_opaque_init alg plain cipher key icb = gctr_partial_reveal (); () #restart-solver let lemma_gctr_partial_append alg b1 b2 p1 c1 p2 c2 key icb1 icb2 = gctr_partial_reveal (); () let gctr_partial_opaque_ignores_postfix alg bound plain plain' cipher cipher' key icb = gctr_partial_reveal (); // OBSERVE: assert (forall i . 0 <= i /\ i < bound ==> index plain i == index (slice plain 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index plain' i == index (slice plain' 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher i == index (slice cipher 0 bound) i); assert (forall i . 0 <= i /\ i < bound ==> index cipher' i == index (slice cipher' 0 bound) i); () let rec gctr_encrypt_recursive_length (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures length (gctr_encrypt_recursive icb plain alg key i) == length plain) (decreases %[length plain]) [SMTPat (length (gctr_encrypt_recursive icb plain alg key i))] = if length plain = 0 then () else gctr_encrypt_recursive_length icb (tail plain) alg key (i + 1) //TODO: Check if ever being used #reset-options "--z3rlimit 40" let gctr_encrypt_length (icb:quad32) (plain:gctr_plain) (alg:algorithm) (key:aes_key_word alg) : Lemma(length (gctr_encrypt icb plain alg key) == length plain) [SMTPat (length (gctr_encrypt icb plain alg key))] = reveal_opaque (`%be_bytes_to_seq_quad32) be_bytes_to_seq_quad32; gctr_encrypt_reveal (); let num_extra = (length plain) % 16 in let result = gctr_encrypt icb plain alg key in if num_extra = 0 then ( let plain_quads = be_bytes_to_seq_quad32 plain in gctr_encrypt_recursive_length icb plain_quads alg key 0 ) else ( let full_bytes_len = (length plain) - num_extra in let full_blocks, final_block = split plain full_bytes_len in let full_quads = be_bytes_to_seq_quad32 full_blocks in let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in gctr_encrypt_recursive_length icb full_quads alg key 0; assert (length result == length cipher_bytes_full + length final_cipher_bytes); assert (length cipher_quads == length full_quads); assert (length cipher_bytes_full == 16 * length cipher_quads); assert (16 * length full_quads == length full_blocks); assert (length cipher_bytes_full == length full_blocks); () ) #reset-options let rec gctr_indexed_helper (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (i:int) : Lemma (requires True) (ensures (let cipher = gctr_encrypt_recursive icb plain alg key i in length cipher == length plain /\ (forall j . {:pattern index cipher j} 0 <= j /\ j < length plain ==> index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) )))) (decreases %[length plain]) = if length plain = 0 then () else let tl = tail plain in let cipher = gctr_encrypt_recursive icb plain alg key i in let r_cipher = gctr_encrypt_recursive icb tl alg key (i+1) in let helper (j:int) : Lemma ((0 <= j /\ j < length plain) ==> (index cipher j == quad32_xor (index plain j) (aes_encrypt_word alg key (inc32 icb (i + j)) ))) = aes_encrypt_word_reveal (); if 0 < j && j < length plain then ( gctr_indexed_helper icb tl alg key (i+1); assert(index r_cipher (j-1) == quad32_xor (index tl (j-1)) (aes_encrypt_word alg key (inc32 icb (i + 1 + j - 1)) )) // OBSERVE ) else () in FStar.Classical.forall_intro helper let gctr_indexed (icb:quad32) (plain:gctr_plain_internal) (alg:algorithm) (key:aes_key_word alg) (cipher:seq quad32) : Lemma (requires length cipher == length plain /\ (forall i . {:pattern index cipher i} 0 <= i /\ i < length cipher ==> index cipher i == quad32_xor (index plain i) (aes_encrypt_word alg key (inc32 icb i) ))) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_indexed_helper icb plain alg key 0; let c = gctr_encrypt_recursive icb plain alg key 0 in assert(equal cipher c) // OBSERVE: Invoke extensionality lemmas let gctr_partial_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) = gctr_indexed icb plain alg key cipher; () let gctr_partial_opaque_completed (alg:algorithm) (plain cipher:seq quad32) (key:seq nat32) (icb:quad32) : Lemma (requires is_aes_key_word alg key /\ length plain == length cipher /\ length plain < pow2_32 /\ gctr_partial alg (length cipher) plain cipher key icb ) (ensures cipher == gctr_encrypt_recursive icb plain alg key 0) = gctr_partial_reveal (); gctr_partial_completed alg plain cipher key icb let gctr_partial_to_full_basic (icb:quad32) (plain:seq quad32) (alg:algorithm) (key:seq nat32) (cipher:seq quad32) = gctr_encrypt_reveal (); let p = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE plain) in assert (length p % 16 == 0); let plain_quads = be_bytes_to_seq_quad32 p in let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in let cipher_bytes = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in be_bytes_to_seq_quad32_to_bytes plain; () let step1 (p:seq quad32) (num_bytes:nat{ num_bytes < 16 * length p }) : Lemma (let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in p_prefix == full_quads_BE) = let num_extra = num_bytes % 16 in let num_blocks = num_bytes / 16 in let full_blocks, final_block = split (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) (num_blocks * 16) in let full_quads_BE = be_bytes_to_seq_quad32 full_blocks in let p_prefix = slice p 0 num_blocks in assert (length full_blocks == num_blocks * 16); assert (full_blocks == slice (slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 num_bytes) 0 (num_blocks * 16)); assert (full_blocks == slice (seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE p)) 0 (num_blocks * 16)); slice_commutes_be_seq_quad32_to_bytes0 p num_blocks; assert (full_blocks == seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE (slice p 0 num_blocks))); be_bytes_to_seq_quad32_to_bytes (slice p 0 num_blocks); assert (full_quads_BE == (slice p 0 num_blocks)); () #reset-options "--smtencoding.elim_box true --z3rlimit 30" let lemma_slice_orig_index (#a:Type) (s s':seq a) (m n:nat) : Lemma (requires length s == length s' /\ m <= n /\ n <= length s /\ slice s m n == slice s' m n) (ensures (forall (i:int).{:pattern (index s i) \/ (index s' i)} m <= i /\ i < n ==> index s i == index s' i)) = let aux (i:nat{m <= i /\ i < n}) : Lemma (index s i == index s' i) = lemma_index_slice s m n (i - m); lemma_index_slice s' m n (i - m) in Classical.forall_intro aux let lemma_ishr_ixor_32 (x y:nat32) (k:nat) : Lemma (ensures ishr #pow2_32 (ixor x y) k == ixor (ishr x k) (ishr y k)) = Vale.Def.TypesNative_s.reveal_ishr 32 x k; Vale.Def.TypesNative_s.reveal_ishr 32 y k; Vale.Def.TypesNative_s.reveal_ishr 32 (ixor x y) k; Vale.Def.TypesNative_s.reveal_ixor 32 x y; Vale.Def.TypesNative_s.reveal_ixor 32 (ishr x k) (ishr y k); FStar.UInt.shift_right_logxor_lemma #32 x y k; () let nat32_xor_bytewise_1_helper1 (x0 x0':nat8) (x1 x1':nat24) (x x':nat32) : Lemma (requires x == 0x1000000 * x0 + x1 /\ x' == 0x1000000 * x0' + x1' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_2_helper1 (x0 x0' x1 x1':nat16) (x x':nat32) : Lemma (requires x == 0x10000 * x0 + x1 /\ x' == 0x10000 * x0' + x1' /\ x / 0x10000 == x' / 0x10000 ) (ensures x0 == x0') = () let nat32_xor_bytewise_3_helper1 (x0 x0':nat24) (x1 x1':nat8) (x x':nat32) : Lemma (requires x == 0x100 * x0 + x1 /\ x' == 0x100 * x0' + x1' /\ x / 0x100 == x' / 0x100 ) (ensures x0 == x0') = () let nat32_xor_bytewise_1_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x1000000 == x' / 0x1000000 ) (ensures t.hi3 == t'.hi3) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t012 = t0 + 0x100 * t1 + 0x10000 * t2 in let t012' = t0' + 0x100 * t1' + 0x10000 * t2' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_1_helper1 t3 t3' t012 t012' x x'; () let nat32_xor_bytewise_2_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x10000 == x' / 0x10000 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t01 = t0 + 0x100 * t1 in let t23 = t2 + 0x100 * t3 in let t01' = t0' + 0x100 * t1' in let t23' = t2' + 0x100 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_2_helper1 t23 t23' t01 t01' x x'; () let nat32_xor_bytewise_3_helper2 (x x':nat32) (t t':four nat8) : Lemma (requires x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ x / 0x100 == x' / 0x100 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in let t123 = t1 + 0x100 * t2 + 0x10000 * t3 in let t123' = t1' + 0x100 * t2' + 0x10000 * t3' in assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); nat32_xor_bytewise_3_helper1 t123 t123' t0 t0' x x'; () let nat32_xor_bytewise_1_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 ) (ensures k / 0x1000000 == k' / 0x1000000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_2_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures k / 0x10000 == k' / 0x10000) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_3_helper3 (k k':nat32) (s s':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures k / 0x100 == k' / 0x100) = let Mkfour _ _ _ _ = s in let Mkfour _ _ _ _ = s' in assert_norm (four_to_nat 8 s == four_to_nat_unfold 8 s ); assert_norm (four_to_nat 8 s' == four_to_nat_unfold 8 s'); () let nat32_xor_bytewise_1 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 ) (ensures t.hi3 == t'.hi3) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_1_helper3 k k' s s'; lemma_ishr_32 k 24; lemma_ishr_32 k' 24; lemma_ishr_32 x 24; lemma_ishr_32 x' 24; lemma_ishr_ixor_32 k m 24; lemma_ishr_ixor_32 k' m 24; assert_norm (pow2 24 == pow2_24); nat32_xor_bytewise_1_helper2 x x' t t'; () let nat32_xor_bytewise_2 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_2_helper3 k k' s s'; lemma_ishr_32 k 16; lemma_ishr_32 k' 16; lemma_ishr_32 x 16; lemma_ishr_32 x' 16; lemma_ishr_ixor_32 k m 16; lemma_ishr_ixor_32 k' m 16; nat32_xor_bytewise_2_helper2 x x' t t'; () let nat32_xor_bytewise_3 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s.hi3 == s'.hi3 /\ s.hi2 == s'.hi2 /\ s.lo1 == s'.lo1 ) (ensures t.hi3 == t'.hi3 /\ t.hi2 == t'.hi2 /\ t.lo1 == t'.lo1) = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in nat32_xor_bytewise_3_helper3 k k' s s'; lemma_ishr_32 k 8; lemma_ishr_32 k' 8; lemma_ishr_32 x 8; lemma_ishr_32 x' 8; lemma_ishr_ixor_32 k m 8; lemma_ishr_ixor_32 k' m 8; nat32_xor_bytewise_3_helper2 x x' t t'; () #reset-options "--z3rlimit 50 --smtencoding.nl_arith_repr boxwrap --smtencoding.l_arith_repr boxwrap" let nat32_xor_bytewise_4 (k k' x x' m:nat32) (s s' t t':four nat8) : Lemma (requires k == four_to_nat 8 s /\ k' == four_to_nat 8 s' /\ x == four_to_nat 8 t /\ x' == four_to_nat 8 t' /\ ixor k m == x /\ ixor k' m == x' /\ s == s' ) (ensures t == t') = let Mkfour s0 s1 s2 s3 = s in let Mkfour s0' s1' s2' s3' = s' in let Mkfour t0 t1 t2 t3 = t in let Mkfour t0' t1' t2' t3' = t' in assert_norm (four_to_nat 8 t' == four_to_nat_unfold 8 t'); assert_norm (four_to_nat 8 t == four_to_nat_unfold 8 t ); () #reset-options let nat32_xor_bytewise (k k' m:nat32) (s s' t t':seq4 nat8) (n:nat) : Lemma (requires n <= 4 /\ k == four_to_nat 8 (seq_to_four_BE s) /\ k' == four_to_nat 8 (seq_to_four_BE s') /\ ixor k m == four_to_nat 8 (seq_to_four_BE t) /\ ixor k' m == four_to_nat 8 (seq_to_four_BE t') /\ equal (slice s 0 n) (slice s' 0 n) ) (ensures (forall (i:nat).{:pattern (index t i) \/ (index t' i)} i < n ==> index t i == index t' i)) = assert (n > 0 ==> index (slice s 0 n) 0 == index (slice s' 0 n) 0); assert (n > 1 ==> index (slice s 0 n) 1 == index (slice s' 0 n) 1); assert (n > 2 ==> index (slice s 0 n) 2 == index (slice s' 0 n) 2); assert (n > 3 ==> index (slice s 0 n) 3 == index (slice s' 0 n) 3); let x = ixor k m in let x' = ixor k' m in if n = 1 then nat32_xor_bytewise_1 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 2 then nat32_xor_bytewise_2 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 3 then nat32_xor_bytewise_3 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); if n = 4 then nat32_xor_bytewise_4 k k' x x' m (seq_to_four_BE s) (seq_to_four_BE s') (seq_to_four_BE t) (seq_to_four_BE t'); assert (equal (slice t 0 n) (slice t' 0 n)); lemma_slice_orig_index t t' 0 n; ()
{ "checked_file": "/", "dependencies": [ "Vale.Lib.Seqs.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Seq_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.TypesNative_s.fst.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.Types_helpers.fsti.checked", "Vale.AES.GCTR_BE_s.fst.checked", "Vale.AES.GCM_helpers_BE.fsti.checked", "Vale.AES.AES_BE_s.fst.checked", "prims.fst.checked", "FStar.UInt.fsti.checked", "FStar.Seq.Properties.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Classical.fsti.checked" ], "interface_file": true, "source_file": "Vale.AES.GCTR_BE.fst" }
[ { "abbrev": false, "full_module": "FStar.Seq.Properties", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.Types_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers_BE", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_BE_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_BE_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
q: Vale.Def.Types_s.quad32 -> q': Vale.Def.Types_s.quad32 -> r: Vale.Def.Types_s.quad32 -> n: Prims.nat{n <= 16} -> FStar.Pervasives.Lemma (requires (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q'_bytes = Vale.Arch.Types.be_quad32_to_bytes q' in FStar.Seq.Base.slice q_bytes 0 n == FStar.Seq.Base.slice q'_bytes 0 n)) (ensures (let q_bytes = Vale.Arch.Types.be_quad32_to_bytes q in let q'_bytes = Vale.Arch.Types.be_quad32_to_bytes q' in let qr_bytes = Vale.Arch.Types.be_quad32_to_bytes (Vale.Def.Types_s.quad32_xor q r) in let q'r_bytes = Vale.Arch.Types.be_quad32_to_bytes (Vale.Def.Types_s.quad32_xor q' r) in FStar.Seq.Base.slice qr_bytes 0 n == FStar.Seq.Base.slice q'r_bytes 0 n))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Vale.Def.Types_s.quad32", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.unit", "Prims._assert", "FStar.Seq.Base.equal", "Vale.Def.Words_s.nat8", "FStar.Seq.Base.slice", "Prims.op_LessThan", "Vale.AES.GCTR_BE.nat32_xor_bytewise", "Vale.Def.Words_s.__proj__Mkfour__item__hi3", "Vale.Def.Types_s.nat32", "Prims.bool", "Vale.Def.Words_s.__proj__Mkfour__item__hi2", "Prims.op_Subtraction", "Vale.Def.Words_s.__proj__Mkfour__item__lo1", "Vale.Def.Words_s.__proj__Mkfour__item__lo0", "Vale.Def.Types_s.quad32_xor_reveal", "Vale.AES.GCTR_BE.lemma_slice_orig_index", "Vale.AES.Types_helpers.lemma_slices_be_quad32_to_bytes", "Vale.Def.Types_s.quad32_xor", "Vale.Def.Words.Seq_s.seq16", "Vale.Arch.Types.be_quad32_to_bytes", "Prims.eq2", "FStar.Seq.Base.seq", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
false
false
true
false
false
let quad32_xor_bytewise (q q' r: quad32) (n: nat{n <= 16}) : Lemma (requires (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in slice q_bytes 0 n == slice q'_bytes 0 n)) (ensures (let q_bytes = be_quad32_to_bytes q in let q'_bytes = be_quad32_to_bytes q' in let qr_bytes = be_quad32_to_bytes (quad32_xor q r) in let q'r_bytes = be_quad32_to_bytes (quad32_xor q' r) in slice qr_bytes 0 n == slice q'r_bytes 0 n)) =
let s = be_quad32_to_bytes q in let s' = be_quad32_to_bytes q' in let t = be_quad32_to_bytes (quad32_xor q r) in let t' = be_quad32_to_bytes (quad32_xor q' r) in lemma_slices_be_quad32_to_bytes q; lemma_slices_be_quad32_to_bytes q'; lemma_slices_be_quad32_to_bytes (quad32_xor q r); lemma_slices_be_quad32_to_bytes (quad32_xor q' r); lemma_slice_orig_index s s' 0 n; quad32_xor_reveal (); if n < 4 then nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) n else (nat32_xor_bytewise q.hi3 q'.hi3 r.hi3 (slice s 0 4) (slice s' 0 4) (slice t 0 4) (slice t' 0 4) 4; if n < 8 then nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) (n - 4) else (nat32_xor_bytewise q.hi2 q'.hi2 r.hi2 (slice s 4 8) (slice s' 4 8) (slice t 4 8) (slice t' 4 8) 4; if n < 12 then nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) (n - 8) else (nat32_xor_bytewise q.lo1 q'.lo1 r.lo1 (slice s 8 12) (slice s' 8 12) (slice t 8 12) (slice t' 8 12) 4; nat32_xor_bytewise q.lo0 q'.lo0 r.lo0 (slice s 12 16) (slice s' 12 16) (slice t 12 16) (slice t' 12 16) (n - 12); ()))); assert (equal (slice t 0 n) (slice t' 0 n)); ()
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.rounds
val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st))
val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st))
let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 17, "end_line": 51, "start_col": 0, "start_line": 29 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
st: Hacl.Impl.Chacha20.Core32.state -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Hacl.Impl.Chacha20.Core32.double_round", "Prims.unit", "Lib.LoopCombinators.unfold_repeat", "Spec.Chacha20.state", "Spec.Chacha20.double_round", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint32", "FStar.UInt32.__uint_to_t", "Lib.LoopCombinators.eq_repeat0", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
false
true
false
false
false
let rounds st =
let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Stack_lemma
val va_code_Stack_lemma : va_dummy:unit -> Tot va_code
val va_code_Stack_lemma : va_dummy:unit -> Tot va_code
let va_code_Stack_lemma () = (va_Block (va_CNil ()))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 25, "end_line": 27, "start_col": 0, "start_line": 26 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_dummy: Prims.unit -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Stack_lemma () =
(va_Block (va_CNil ()))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Push
val va_code_Push : src:va_operand_reg_opr64 -> Tot va_code
val va_code_Push : src:va_operand_reg_opr64 -> Tot va_code
let va_code_Push src = (Ins (BC.Push src Public))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 88, "start_col": 0, "start_line": 87 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Push src =
(Ins (BC.Push src Public))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Pop
val va_codegen_success_Pop : dst:va_operand_dst_opr64 -> Tot va_pbool
val va_codegen_success_Pop : dst:va_operand_dst_opr64 -> Tot va_pbool
let va_codegen_success_Pop dst = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 60, "start_col": 0, "start_line": 59 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Pop dst =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Pop
val va_code_Pop : dst:va_operand_dst_opr64 -> Tot va_code
val va_code_Pop : dst:va_operand_dst_opr64 -> Tot va_code
let va_code_Pop dst = (Ins (BC.Pop dst Public))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 56, "start_col": 0, "start_line": 55 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Pop dst =
(Ins (BC.Pop dst Public))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Stack_lemma
val va_codegen_success_Stack_lemma : va_dummy:unit -> Tot va_pbool
val va_codegen_success_Stack_lemma : va_dummy:unit -> Tot va_pbool
let va_codegen_success_Stack_lemma () = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 31, "start_col": 0, "start_line": 30 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ()))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_dummy: Prims.unit -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Prims.unit", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Stack_lemma () =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Push
val va_codegen_success_Push : src:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_Push : src:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_Push src = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 92, "start_col": 0, "start_line": 91 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Push src =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Pop_Secret
val va_codegen_success_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_pbool
val va_codegen_success_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_pbool
let va_codegen_success_Pop_Secret dst = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 124, "start_col": 0, "start_line": 123 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Pop_Secret dst =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Push_Secret
val va_codegen_success_Push_Secret : src:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_Push_Secret : src:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_Push_Secret src = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 156, "start_col": 0, "start_line": 155 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Push_Secret src =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_PopXmm
val va_code_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
val va_code_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 272, "start_col": 0, "start_line": 268 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsStack.va_code_Pop", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_code_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_PopXmm dst tmp =
(va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))) )
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_init
val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0))
val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0))
let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); ()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 4, "end_line": 113, "start_col": 0, "start_line": 95 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctx: Hacl.Impl.Chacha20.Core32.state -> k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul -> ctr0: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "Prims.unit", "Prims._assert", "Prims.eq2", "Lib.Sequence.lseq", "Lib.IntTypes.uint32", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Spec.Chacha20.setup", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.update_sub_f", "Lib.ByteSequence.uints_from_bytes_le", "Lib.IntTypes.SEC", "Lib.ByteBuffer.uints_from_bytes_le", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "FStar.UInt32.uint_to_t", "Lib.Buffer.sub", "Lib.Buffer.op_Array_Assignment", "Lib.IntTypes.size_to_uint32", "Lib.Sequence.map", "Lib.IntTypes.secret", "Spec.Chacha20.chacha20_constants", "Lib.Buffer.mapT", "Lib.Buffer.CONST", "Hacl.Impl.Chacha20.chacha20_constants", "FStar.UInt32.t", "Lib.Buffer.recall_contents" ]
[]
false
true
false
false
false
let chacha20_init ctx k n ctr =
let h0 = ST.get () in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get () in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get () in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get () in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get () in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); ()
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Pop_Secret
val va_code_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_code
val va_code_Pop_Secret : dst:va_operand_dst_opr64 -> Tot va_code
let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 27, "end_line": 120, "start_col": 0, "start_line": 119 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Pop_Secret dst =
(Ins (BC.Pop dst Secret))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_PopXmm
val va_codegen_success_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 90, "end_line": 279, "start_col": 0, "start_line": 275 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsStack.va_codegen_success_Pop", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_codegen_success_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_PopXmm dst tmp =
(va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_Load64_stack
val va_codegen_success_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_pbool
val va_codegen_success_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_pbool
let va_codegen_success_Load64_stack dst src offset = (va_ttrue ())
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 15, "end_line": 189, "start_col": 0, "start_line": 188 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public)))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "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_reg_opr64 -> offset: Prims.int -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_Load64_stack dst src offset =
(va_ttrue ())
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_PushXmm
val va_codegen_success_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ())))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 21, "end_line": 228, "start_col": 0, "start_line": 224 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ()))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_codegen_success_Push", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_PushXmm src tmp =
(va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ())))))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_PushXmm
val va_code_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
val va_code_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ()))))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 50, "end_line": 221, "start_col": 0, "start_line": 218 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_code_Push", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_PushXmm src tmp =
(va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ()))))))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Push_Secret
val va_code_Push_Secret : src:va_operand_reg_opr64 -> Tot va_code
val va_code_Push_Secret : src:va_operand_reg_opr64 -> Tot va_code
let va_code_Push_Secret src = (Ins (BC.Push src Secret))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 152, "start_col": 0, "start_line": 151 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Machine_s.Ins", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Push_Secret src =
(Ins (BC.Push src Secret))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_PushXmm_Secret
val va_code_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
val va_code_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ()))))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 60, "end_line": 323, "start_col": 0, "start_line": 320 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsVector.va_code_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_code_Push_Secret", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_PushXmm_Secret src tmp =
(va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ()))))))
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_encrypt_block
val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text))
val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text))
let chacha20_encrypt_block ctx out incr text = push_frame(); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 133, "start_col": 0, "start_line": 128 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0)) let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); () val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctx: Hacl.Impl.Chacha20.Core32.state -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> incr: Lib.IntTypes.size_t -> text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 64ul -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.size_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Chacha20.Core32.xor_block", "Hacl.Impl.Chacha20.chacha20_core", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint32", "Lib.IntTypes.u32", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let chacha20_encrypt_block ctx out incr text =
push_frame (); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame ()
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_PushXmm_Secret
val va_codegen_success_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ())))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 26, "end_line": 330, "start_col": 0, "start_line": 326 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ()))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsVector.va_codegen_success_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsStack.va_codegen_success_Push_Secret", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_PushXmm_Secret src tmp =
(va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ())))))
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_decrypt
val chacha20_decrypt: len:size_t -> out:lbuffer uint8 len -> cipher:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher))
val chacha20_decrypt: len:size_t -> out:lbuffer uint8 len -> cipher:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher))
let chacha20_decrypt len out cipher key n ctr = push_frame(); let ctx = create_state () in chacha20_init ctx key n ctr; chacha20_update ctx len out cipher; pop_frame()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 225, "start_col": 0, "start_line": 220 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0)) let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); () val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text)) let chacha20_encrypt_block ctx out incr text = push_frame(); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame() val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text)) [@CInline] let chacha20_encrypt_last ctx len out incr text = push_frame(); let plain = create (size 64) (u8 0) in update_sub plain 0ul len text; chacha20_encrypt_block ctx plain incr plain; copy out (sub plain 0ul len); pop_frame() val chacha20_update: ctx:state -> len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ eq_or_disjoint text out /\ disjoint text ctx /\ disjoint out ctx) (ensures fun h0 _ h1 -> modifies (loc ctx |+| loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_update (as_seq h0 ctx) (as_seq h0 text)) let chacha20_update ctx len out text = push_frame(); let blocks = len /. size 64 in let rem = len %. size 64 in let h0 = ST.get() in map_blocks h0 len 64ul text out (fun h -> Spec.chacha20_encrypt_block (as_seq h0 ctx)) (fun h -> Spec.chacha20_encrypt_last (as_seq h0 ctx)) (fun i -> chacha20_encrypt_block ctx (sub out (i *! 64ul) 64ul) i (sub text (i *! 64ul) 64ul)) (fun i -> chacha20_encrypt_last ctx rem (sub out (i *! 64ul) rem) i (sub text (i *! 64ul) rem)); pop_frame() inline_for_extraction val chacha20_encrypt: len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text)) let chacha20_encrypt len out text key n ctr = push_frame(); let ctx = create_state () in chacha20_init ctx key n ctr; chacha20_update ctx len out text; pop_frame() inline_for_extraction val chacha20_decrypt: len:size_t -> out:lbuffer uint8 len -> cipher:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h cipher /\ live h out /\ eq_or_disjoint cipher out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_decrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 cipher))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> cipher: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul -> ctr: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Chacha20.chacha20_update", "Hacl.Impl.Chacha20.chacha20_init", "Hacl.Impl.Chacha20.Core32.state", "Hacl.Impl.Chacha20.Core32.create_state", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let chacha20_decrypt len out cipher key n ctr =
push_frame (); let ctx = create_state () in chacha20_init ctx key n ctr; chacha20_update ctx len out cipher; pop_frame ()
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_PopXmm_Secret
val va_code_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
val va_code_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_code
let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 59, "end_line": 374, "start_col": 0, "start_line": 370 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_Block", "Vale.X64.Decls.va_CCons", "Vale.X64.InsStack.va_code_Pop_Secret", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_code_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_CNil", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_PopXmm_Secret dst tmp =
(va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))) )
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_encrypt
val chacha20_encrypt: len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text))
val chacha20_encrypt: len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text))
let chacha20_encrypt len out text key n ctr = push_frame(); let ctx = create_state () in chacha20_init ctx key n ctr; chacha20_update ctx len out text; pop_frame()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 203, "start_col": 0, "start_line": 198 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0)) let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); () val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text)) let chacha20_encrypt_block ctx out incr text = push_frame(); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame() val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text)) [@CInline] let chacha20_encrypt_last ctx len out incr text = push_frame(); let plain = create (size 64) (u8 0) in update_sub plain 0ul len text; chacha20_encrypt_block ctx plain incr plain; copy out (sub plain 0ul len); pop_frame() val chacha20_update: ctx:state -> len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ eq_or_disjoint text out /\ disjoint text ctx /\ disjoint out ctx) (ensures fun h0 _ h1 -> modifies (loc ctx |+| loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_update (as_seq h0 ctx) (as_seq h0 text)) let chacha20_update ctx len out text = push_frame(); let blocks = len /. size 64 in let rem = len %. size 64 in let h0 = ST.get() in map_blocks h0 len 64ul text out (fun h -> Spec.chacha20_encrypt_block (as_seq h0 ctx)) (fun h -> Spec.chacha20_encrypt_last (as_seq h0 ctx)) (fun i -> chacha20_encrypt_block ctx (sub out (i *! 64ul) 64ul) i (sub text (i *! 64ul) 64ul)) (fun i -> chacha20_encrypt_last ctx rem (sub out (i *! 64ul) rem) i (sub text (i *! 64ul) rem)); pop_frame() inline_for_extraction val chacha20_encrypt: len:size_t -> out:lbuffer uint8 len -> text:lbuffer uint8 len -> key:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr:size_t -> Stack unit (requires fun h -> live h key /\ live h n /\ live h text /\ live h out /\ eq_or_disjoint text out) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_bytes (as_seq h0 key) (as_seq h0 n) (v ctr) (as_seq h0 text))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
len: Lib.IntTypes.size_t -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> key: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul -> n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul -> ctr: Lib.IntTypes.size_t -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Lib.IntTypes.size_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.UInt32.__uint_to_t", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Chacha20.chacha20_update", "Hacl.Impl.Chacha20.chacha20_init", "Hacl.Impl.Chacha20.Core32.state", "Hacl.Impl.Chacha20.Core32.create_state", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let chacha20_encrypt len out text key n ctr =
push_frame (); let ctx = create_state () in chacha20_init ctx key n ctr; chacha20_update ctx len out text; pop_frame ()
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_codegen_success_PopXmm_Secret
val va_codegen_success_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
val va_codegen_success_PopXmm_Secret : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Tot va_pbool
let va_codegen_success_PopXmm_Secret dst tmp = (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 11, "end_line": 382, "start_col": 0, "start_line": 377 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm_Secret [@ "opaque_to_smt"] let va_code_PopXmm_Secret dst tmp = (va_Block (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ()))))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Vale.X64.Decls.va_pbool
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_pbool_and", "Vale.X64.InsStack.va_codegen_success_Pop_Secret", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.InsVector.va_codegen_success_Pinsrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_opr64", "Vale.X64.Decls.va_ttrue", "Vale.X64.Decls.va_pbool" ]
[]
false
false
false
true
false
let va_codegen_success_PopXmm_Secret dst tmp =
(va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop_Secret (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ())))))
false
Pulse.Soundness.VPropEquiv.fst
Pulse.Soundness.VPropEquiv.vprop_equiv_refl_type
val vprop_equiv_refl_type : FStar.Stubs.Reflection.Types.term
let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 52, "end_line": 39, "start_col": 0, "start_line": 34 }
(* Copyright 2023 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module Pulse.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **)
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "FStar.Reflection.Typing.close_term", "Pulse.Reflection.Util.stt_vprop_equiv", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.tm_vprop", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let vprop_equiv_refl_type =
let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var)
false
Pulse.Soundness.VPropEquiv.fst
Pulse.Soundness.VPropEquiv.vprop_equiv_sym_type
val vprop_equiv_sym_type : FStar.Stubs.Reflection.Types.term
let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0)
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 13, "end_line": 62, "start_col": 0, "start_line": 47 }
(* 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.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "Pulse.Reflection.Util.mk_arrow", "FStar.Pervasives.Native.Mktuple2", "FStar.Stubs.Reflection.Types.term", "FStar.Stubs.Reflection.V2.Data.aqualv", "FStar.Stubs.Reflection.V2.Data.Q_Implicit", "FStar.Reflection.Typing.close_term", "Pulse.Reflection.Util.stt_vprop_equiv", "FStar.Stubs.Reflection.V2.Data.Q_Explicit", "Pulse.Elaborate.Pure.elab_term", "Pulse.Syntax.Base.tm_vprop", "Pulse.Reflection.Util.mk_name", "Prims.int" ]
[]
false
false
false
true
false
let vprop_equiv_sym_type =
let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Stack_lemma
val va_wpProof_Stack_lemma : base:operand64 -> offset:int -> t:taint -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Stack_lemma base offset t va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Stack_lemma ()) ([]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Stack_lemma : base:operand64 -> offset:int -> t:taint -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Stack_lemma base offset t va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Stack_lemma ()) ([]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 49, "start_col": 0, "start_line": 43 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
base: Vale.X64.Machine_s.operand64 -> offset: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Machine_s.operand64", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Nil", "Vale.X64.QuickCode.mod_t", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Stack_lemma", "Vale.X64.InsStack.va_code_Stack_lemma" ]
[]
false
false
false
false
false
let va_wpProof_Stack_lemma base offset t va_s0 va_k =
let va_sM, va_f0 = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Pulse.Soundness.VPropEquiv.fst
Pulse.Soundness.VPropEquiv.vprop_tm
val vprop_tm : FStar.Stubs.Reflection.Types.term
let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid))
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 59, "end_line": 124, "start_col": 0, "start_line": 124 }
(* 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.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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.Stubs.Reflection.Types.term
Prims.Tot
[ "total" ]
[]
[ "FStar.Stubs.Reflection.V2.Builtins.pack_ln", "FStar.Stubs.Reflection.V2.Data.Tv_FVar", "FStar.Stubs.Reflection.V2.Builtins.pack_fv", "Pulse.Reflection.Util.vprop_lid" ]
[]
false
false
false
true
false
let vprop_tm =
R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid))
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Push
val va_wpProof_Push : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Push : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 113, "start_col": 0, "start_line": 106 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Push", "Vale.X64.InsStack.va_code_Push" ]
[]
false
false
false
false
false
let va_wpProof_Push src va_s0 va_k =
let va_sM, va_f0 = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_Push_Secret
val va_lemma_Push_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push_Secret src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Secret (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
val va_lemma_Push_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push_Secret src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Secret (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 166, "start_col": 0, "start_line": 159 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_Sems.equiv_store_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Decls.va_eval_reg_opr64", "Vale.X64.Decls.va_get_stack", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Push_Secret" ]
[]
false
false
false
false
false
let va_lemma_Push_Secret va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_Stack_lemma
val va_lemma_Stack_lemma : va_b0:va_code -> va_s0:va_state -> base:operand64 -> offset:int -> t:taint -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Stack_lemma ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_state_eq va_sM (va_update_ok va_sM va_s0)))
val va_lemma_Stack_lemma : va_b0:va_code -> va_s0:va_state -> base:operand64 -> offset:int -> t:taint -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Stack_lemma ()) va_s0 /\ va_get_ok va_s0)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_state_eq va_sM (va_update_ok va_sM va_s0)))
let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 39, "start_col": 0, "start_line": 34 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> base: Vale.X64.Machine_s.operand64 -> offset: Prims.int -> t: Vale.Arch.HeapTypes_s.taint -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Machine_s.operand64", "Prims.int", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Stack_lemma" ]
[]
false
false
false
false
false
let va_lemma_Stack_lemma va_b0 va_s0 base offset t =
va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_sM, va_fM = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Pop
val va_wpProof_Pop : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Pop : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 81, "start_col": 0, "start_line": 74 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Pop", "Vale.X64.InsStack.va_code_Pop" ]
[]
false
false
false
false
false
let va_wpProof_Pop dst va_s0 va_k =
let va_sM, va_f0 = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Load64_stack
val va_wpProof_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Load64_stack dst src offset va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load64_stack dst src offset) ([va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Load64_stack dst src offset va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Load64_stack dst src offset) ([va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 212, "start_col": 0, "start_line": 205 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "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_reg_opr64 -> offset: Prims.int -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Load64_stack", "Vale.X64.InsStack.va_code_Load64_stack" ]
[]
false
false
false
false
false
let va_wpProof_Load64_stack dst src offset va_s0 va_k =
let va_sM, va_f0 = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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)
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mont_one
val mont_one: n:pos -> r:pos -> nat_mod n
val mont_one: n:pos -> r:pos -> nat_mod n
let mont_one n r = 1 * r % n
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 20, "start_col": 0, "start_line": 20 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> r: Prims.pos -> Lib.NatMod.nat_mod n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod" ]
[]
false
false
false
false
false
let mont_one n r =
1 * r % n
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Push_Secret
val va_wpProof_Push_Secret : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push_Secret src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push_Secret src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Push_Secret : src:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Push_Secret src va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Push_Secret src) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 177, "start_col": 0, "start_line": 170 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Push_Secret", "Vale.X64.InsStack.va_code_Push_Secret" ]
[]
false
false
false
false
false
let va_wpProof_Push_Secret src va_s0 va_k =
let va_sM, va_f0 = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Hacl.Impl.Chacha20.fst
Hacl.Impl.Chacha20.chacha20_encrypt_last
val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text))
val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text))
let chacha20_encrypt_last ctx len out incr text = push_frame(); let plain = create (size 64) (u8 0) in update_sub plain 0ul len text; chacha20_encrypt_block ctx plain incr plain; copy out (sub plain 0ul len); pop_frame()
{ "file_name": "code/chacha20/Hacl.Impl.Chacha20.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 13, "end_line": 156, "start_col": 0, "start_line": 150 }
module Hacl.Impl.Chacha20 open FStar.HyperStack open FStar.HyperStack.All open FStar.Mul open Lib.IntTypes open Lib.Buffer open Lib.ByteBuffer open Hacl.Impl.Chacha20.Core32 module ST = FStar.HyperStack.ST module Spec = Spec.Chacha20 module Loop = Lib.LoopCombinators #set-options "--z3rlimit 200 --max_fuel 2" //#set-options "--debug Hacl.Impl.Curve25519.Generic --debug_level ExtractNorm" val rounds: st:state -> Stack unit (requires fun h -> live h st) (ensures fun h0 _ h1 -> modifies (loc st) h0 h1 /\ as_seq h1 st == Spec.rounds (as_seq h0 st)) [@ CInline] let rounds st = let h0 = ST.get () in Loop.eq_repeat0 #Spec.state Spec.double_round (as_seq h0 st); Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 0; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 1; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 2; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 3; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 4; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 5; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 6; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 7; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 8; Loop.unfold_repeat 10 Spec.double_round (as_seq h0 st) 9; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st; double_round st val chacha20_core: k:state -> ctx0:state -> ctr:size_t -> Stack unit (requires fun h -> live h ctx0 /\ live h k /\ disjoint ctx0 k) (ensures fun h0 _ h1 -> modifies (loc k) h0 h1 /\ as_seq h1 k == Spec.chacha20_core (v ctr) (as_seq h0 ctx0)) [@ CInline ] let chacha20_core k ctx ctr = copy_state k ctx; let ctr_u32 = size_to_uint32 ctr in k.(12ul) <- k.(12ul) +. ctr_u32; rounds k; sum_state k ctx; k.(12ul) <- k.(12ul) +. ctr_u32 val chacha20_constants: b:glbuffer size_t 4ul{recallable b /\ witnessed b Spec.Chacha20.chacha20_constants} let chacha20_constants = [@ inline_let] let l = [Spec.c0;Spec.c1;Spec.c2;Spec.c3] in assert_norm(List.Tot.length l == 4); createL_global l val chacha20_init: ctx:state -> k:lbuffer uint8 32ul -> n:lbuffer uint8 12ul -> ctr0:size_t -> Stack unit (requires fun h -> live h ctx /\ live h k /\ live h n /\ disjoint ctx k /\ disjoint ctx n /\ as_seq h ctx == Lib.Sequence.create 16 (u32 0)) (ensures fun h0 _ h1 -> modifies (loc ctx) h0 h1 /\ as_seq h1 ctx == Spec.chacha20_init (as_seq h0 k) (as_seq h0 n) (v ctr0)) let chacha20_init ctx k n ctr = let h0 = ST.get() in recall_contents chacha20_constants Spec.chacha20_constants; update_sub_f h0 ctx 0ul 4ul (fun h -> Lib.Sequence.map secret Spec.chacha20_constants) (fun _ -> mapT 4ul (sub ctx 0ul 4ul) secret chacha20_constants); let h1 = ST.get() in update_sub_f h1 ctx 4ul 8ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h k)) (fun _ -> uints_from_bytes_le (sub ctx 4ul 8ul) k); let h2 = ST.get() in ctx.(12ul) <- size_to_uint32 ctr; let h3 = ST.get() in update_sub_f h3 ctx 13ul 3ul (fun h -> Lib.ByteSequence.uints_from_bytes_le (as_seq h n)) (fun _ -> uints_from_bytes_le (sub ctx 13ul 3ul) n); let h4 = ST.get() in assert (as_seq h4 ctx == Spec.setup (as_seq h0 k) (as_seq h0 n) (v ctr) (as_seq h0 ctx)); () val chacha20_encrypt_block: ctx:state -> out:lbuffer uint8 64ul -> incr:size_t -> text:lbuffer uint8 64ul -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_block (as_seq h0 ctx) (v incr) (as_seq h0 text)) let chacha20_encrypt_block ctx out incr text = push_frame(); let k = create 16ul (u32 0) in chacha20_core k ctx incr; xor_block out k text; pop_frame() val chacha20_encrypt_last: ctx:state -> len:size_t{v len < 64} -> out:lbuffer uint8 len -> incr:size_t -> text:lbuffer uint8 len -> Stack unit (requires fun h -> live h ctx /\ live h text /\ live h out /\ disjoint out ctx /\ disjoint text ctx) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ as_seq h1 out == Spec.chacha20_encrypt_last (as_seq h0 ctx) (v incr) (v len) (as_seq h0 text))
{ "checked_file": "/", "dependencies": [ "Spec.Chacha20.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "Lib.ByteBuffer.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Chacha20.Core32.fst.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Chacha20.fst" }
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loop" }, { "abbrev": true, "full_module": "Spec.Chacha20", "short_module": "Spec" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Chacha20.Core32", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteBuffer", "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.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 2, "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": 200, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
ctx: Hacl.Impl.Chacha20.Core32.state -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len < 64} -> out: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> incr: Lib.IntTypes.size_t -> text: Lib.Buffer.lbuffer Lib.IntTypes.uint8 len -> FStar.HyperStack.ST.Stack Prims.unit
FStar.HyperStack.ST.Stack
[]
[]
[ "Hacl.Impl.Chacha20.Core32.state", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint8", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.Buffer.copy", "Lib.Buffer.MUT", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Buffer.sub", "Lib.IntTypes.size", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Chacha20.chacha20_encrypt_block", "Lib.Buffer.update_sub", "Lib.IntTypes.mk_int", "Lib.Buffer.create", "Lib.IntTypes.u8", "FStar.HyperStack.ST.push_frame" ]
[]
false
true
false
false
false
let chacha20_encrypt_last ctx len out incr text =
push_frame (); let plain = create (size 64) (u8 0) in update_sub plain 0ul len text; chacha20_encrypt_block ctx plain incr plain; copy out (sub plain 0ul len); pop_frame ()
false
Pulse.Soundness.VPropEquiv.fst
Pulse.Soundness.VPropEquiv.vprop_equiv_unit_soundness
val vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1)))
val vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1)))
let vprop_equiv_unit_soundness (#g:stt_env) (#v0 #v1:term) (d0:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1))) = let (| pf, s |) = vprop_equiv_soundness d0 eq in let d1 = fst (vprop_equiv_typing eq) d0 in let s_prop = stt_vprop_equiv_is_prop (tot_typing_soundness d0) (tot_typing_soundness d1) in RT.T_PropIrrelevance _ _ _ _ _ s s_prop
{ "file_name": "lib/steel/pulse/Pulse.Soundness.VPropEquiv.fst", "git_rev": "f984200f79bdc452374ae994a5ca837496476c41", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
{ "end_col": 43, "end_line": 273, "start_col": 0, "start_line": 266 }
(* 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.Soundness.VPropEquiv module RT = FStar.Reflection.Typing module R = FStar.Reflection.V2 module L = FStar.List.Tot module T = FStar.Tactics.V2 open FStar.List.Tot open Pulse.Syntax open Pulse.Reflection.Util open Pulse.Elaborate.Pure open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Elaborate open Pulse.Soundness.Common open Pulse.Checker.VPropEquiv (*** Soundness of vprop equivalence **) let vprop_equiv_refl_type = let var = 0 in let v = mk_name var in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Explicit) (RT.close_term (stt_vprop_equiv v v) var) let inst_vprop_equiv_refl #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v v)) = admit() let vprop_equiv_sym_type = let var0 = 0 in let v0 = mk_name var0 in let var1 = 1 in let v1 = mk_name var1 in let v_typ = elab_term tm_vprop in mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (v_typ, R.Q_Implicit) (RT.close_term (mk_arrow (stt_vprop_equiv v0 v1, R.Q_Explicit) (stt_vprop_equiv v0 v1)) var1)) var0) let inst_vprop_equiv_sym #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (#pf:_) (deq:RT.tot_typing g pf (stt_vprop_equiv v0 v1)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v1 v0)) = admit() let inst_vprop_equiv_trans #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) (#pf01:_) (d01:RT.tot_typing g pf01 (stt_vprop_equiv v0 v1)) (#pf12:_) (d12:RT.tot_typing g pf12 (stt_vprop_equiv v1 v2)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v2)) = admit() let inst_vprop_equiv_cong #g #v0 #v1 #v0' #v1' (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d0':RT.tot_typing g v0' (elab_term tm_vprop)) (d1':RT.tot_typing g v1' (elab_term tm_vprop)) (#pf0:_) (eq0:RT.tot_typing g pf0 (stt_vprop_equiv v0 v0')) (#pf1:_) (eq1:RT.tot_typing g pf1 (stt_vprop_equiv v1 v1')) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v0' v1'))) = admit() let inst_vprop_equiv_unit #g #v (d:RT.tot_typing g v (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star (elab_term tm_emp) v) v)) = admit() let inst_vprop_equiv_comm #g #v0 #v1 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 v1) (mk_star v1 v0))) = admit() let inst_vprop_equiv_assoc #g #v0 #v1 #v2 (d0:RT.tot_typing g v0 (elab_term tm_vprop)) (d1:RT.tot_typing g v1 (elab_term tm_vprop)) (d2:RT.tot_typing g v2 (elab_term tm_vprop)) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv (mk_star v0 (mk_star v1 v2)) (mk_star (mk_star v0 v1) v2))) = admit() let vprop_tm = R.pack_ln (R.Tv_FVar (R.pack_fv vprop_lid)) let vprop_equiv_ext_type : R.term = let open R in let v_typ = pack_ln (Tv_FVar (pack_fv vprop_lid)) in let mk_bv index = pack_ln (Tv_BVar (pack_bv { ppname = RT.pp_name_default; index = index; sort = Sealed.seal tun; })) in mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_tm, Q_Explicit) ( mk_arrow (vprop_eq_tm (mk_bv 1) (mk_bv 0), Q_Explicit) ( stt_vprop_equiv (mk_bv 2) (mk_bv 1) ) ) ) let inst_vprop_equiv_ext_aux #g #v0 #v1 (token:T.equiv_token g v0 v1) : GTot (RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1)) = let ctxt = RT.Ctxt_app_arg (R.pack_ln (R.Tv_App stt_vprop_equiv_tm (v0, R.Q_Explicit))) R.Q_Explicit RT.Ctxt_hole in RT.Rel_ctxt _ _ _ ctxt (RT.Rel_eq_token _ _ _ (Squash.return_squash token)) let inst_vprop_equiv_ext #g #v0 #v1 (d0:RT.tot_typing g v0 vprop_tm) (d1:RT.tot_typing g v1 vprop_tm) (token:T.equiv_token g v0 v1) : GTot (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v1)) = let (| pf, typing |) : (pf:R.term & RT.tot_typing g pf (stt_vprop_equiv v0 v0)) = inst_vprop_equiv_refl d0 in let d_st_equiv : RT.equiv g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = inst_vprop_equiv_ext_aux token in let sub_typing : RT.sub_typing g (stt_vprop_equiv v0 v0) (stt_vprop_equiv v0 v1) = RT.Rel_equiv _ _ _ _ d_st_equiv in let pf_typing : RT.tot_typing g pf (stt_vprop_equiv v0 v1) = RT.T_Sub _ _ _ _ typing (RT.Relc_typ _ _ _ _ _ sub_typing) in (| pf, pf_typing |) #push-options "--z3rlimit_factor 4" let rec vprop_equiv_soundness (#g:stt_env) (#v0 #v1:term) (d:tot_typing g v0 tm_vprop) (eq:vprop_equiv g v0 v1) : GTot (pf:R.term & RT.tot_typing (elab_env g) pf (stt_vprop_equiv (elab_term v0) (elab_term v1))) (decreases eq) = match eq with | VE_Refl _ _ -> let d = tot_typing_soundness d in inst_vprop_equiv_refl d | VE_Sym g _v1 _v0 eq' -> let fwd, _ = vprop_equiv_typing eq in let d' = fwd d in let (| pf, dd |) = vprop_equiv_soundness d' eq' in inst_vprop_equiv_sym (tot_typing_soundness d') (tot_typing_soundness d) dd | VE_Trans _ _ v _ eq_0v eq_v1 -> let dv = fst (vprop_equiv_typing eq_0v) d in let d1 = fst (vprop_equiv_typing eq_v1) dv in let (| pf_0v, eq_0v |) = vprop_equiv_soundness d eq_0v in let (| pf_v1, eq_v1 |) = vprop_equiv_soundness dv eq_v1 in inst_vprop_equiv_trans (tot_typing_soundness d) (tot_typing_soundness dv) (tot_typing_soundness d1) eq_0v eq_v1 | VE_Ctxt _ t0 t1 t0' t1' eq0 eq1 -> let t0_typing, t1_typing = star_typing_inversion d in let t0'_typing = fst (vprop_equiv_typing eq0) t0_typing in let t1'_typing = fst (vprop_equiv_typing eq1) t1_typing in let (| pf0, dd0 |) = vprop_equiv_soundness t0_typing eq0 in let (| pf1, dd1 |) = vprop_equiv_soundness t1_typing eq1 in inst_vprop_equiv_cong (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t0'_typing) (tot_typing_soundness t1'_typing) dd0 dd1 | VE_Unit _ _v1 -> let v1_typing = fst (vprop_equiv_typing eq) d in inst_vprop_equiv_unit (tot_typing_soundness v1_typing) | VE_Comm _ t0 t1 -> let t0_typing, t1_typing = star_typing_inversion #_ #t0 #t1 d in inst_vprop_equiv_comm (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) | VE_Assoc _ t0 t1 t2 -> let t0_typing, t12_typing = star_typing_inversion #_ #t0 #(tm_star t1 t2) d in let t1_typing, t2_typing = star_typing_inversion #_ #t1 #t2 t12_typing in inst_vprop_equiv_assoc (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) (tot_typing_soundness t2_typing) | VE_Ext _ t0 t1 token -> let t0_typing, t1_typing = vprop_eq_typing_inversion _ t0 t1 token in inst_vprop_equiv_ext (tot_typing_soundness t0_typing) (tot_typing_soundness t1_typing) token | VE_Fa _ _ _ _ _ _ _ -> (* see Pulse.Lib.Core.vprop_equiv_forall *) admit() #pop-options let stt_vprop_equiv_is_prop (#g:R.env) (#v0 #v1:R.term) (d0: RT.tot_typing g v0 (elab_term tm_vprop)) (d1: RT.tot_typing g v1 (elab_term tm_vprop)) : GTot (RT.tot_typing g (stt_vprop_equiv v0 v1) RT.tm_prop) = admit()
{ "checked_file": "/", "dependencies": [ "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.fst.checked", "Pulse.Soundness.Common.fst.checked", "Pulse.Reflection.Util.fst.checked", "Pulse.Elaborate.Pure.fst.checked", "Pulse.Elaborate.fsti.checked", "Pulse.Checker.VPropEquiv.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Squash.fsti.checked", "FStar.Sealed.fsti.checked", "FStar.Reflection.V2.fst.checked", "FStar.Reflection.Typing.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": true, "source_file": "Pulse.Soundness.VPropEquiv.fst" }
[ { "abbrev": false, "full_module": "Pulse.Checker.VPropEquiv", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness.Common", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Elaborate.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Reflection.Util", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Reflection.V2", "short_module": "R" }, { "abbrev": true, "full_module": "FStar.Reflection.Typing", "short_module": "RT" }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Soundness", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
d0: Pulse.Typing.tot_typing g v0 Pulse.Syntax.Base.tm_vprop -> eq: Pulse.Typing.vprop_equiv g v0 v1 -> Prims.GTot (FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g) (`()) (Pulse.Reflection.Util.stt_vprop_equiv (Pulse.Elaborate.Pure.elab_term v0) (Pulse.Elaborate.Pure.elab_term v1)))
Prims.GTot
[ "sometrivial" ]
[]
[ "Pulse.Soundness.Common.stt_env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.vprop_equiv", "FStar.Stubs.Reflection.Types.term", "FStar.Reflection.Typing.tot_typing", "Pulse.Typing.elab_env", "Pulse.Reflection.Util.stt_vprop_equiv", "Pulse.Elaborate.Pure.elab_term", "FStar.Reflection.Typing.T_PropIrrelevance", "FStar.Stubs.TypeChecker.Core.E_Total", "FStar.Reflection.Typing.tm_prop", "Pulse.Soundness.VPropEquiv.stt_vprop_equiv_is_prop", "Pulse.Soundness.Common.tot_typing_soundness", "FStar.Pervasives.Native.fst", "Pulse.Typing.Combinators.vprop_equiv_typing", "Prims.dtuple2", "Pulse.Soundness.VPropEquiv.vprop_equiv_soundness" ]
[]
false
false
false
false
false
let vprop_equiv_unit_soundness (#g: stt_env) (#v0 #v1: term) (d0: tot_typing g v0 tm_vprop) (eq: vprop_equiv g v0 v1) : GTot (RT.tot_typing (elab_env g) (`()) (stt_vprop_equiv (elab_term v0) (elab_term v1))) =
let (| pf , s |) = vprop_equiv_soundness d0 eq in let d1 = fst (vprop_equiv_typing eq) d0 in let s_prop = stt_vprop_equiv_is_prop (tot_typing_soundness d0) (tot_typing_soundness d1) in RT.T_PropIrrelevance _ _ _ _ _ s s_prop
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mont_mul
val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n
val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n
let mont_mul n d a b = a * b * d % n
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 36, "end_line": 23, "start_col": 0, "start_line": 23 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> d: Prims.int -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> Lib.NatMod.nat_mod n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.int", "Lib.NatMod.nat_mod", "Prims.op_Modulus", "FStar.Mul.op_Star" ]
[]
false
false
false
false
false
let mont_mul n d a b =
(a * b) * d % n
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid
val mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n)
val mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n)
let mk_nat_mont_ll_comm_monoid (pbits:pos) (rLen:pos) (n:pos) (mu:nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu; }
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 210, "start_col": 0, "start_line": 203 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a) let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod n)
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.Exponentiation.Definition.Mkcomm_monoid", "Lib.NatMod.nat_mod", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one_ll", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_assoc", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_comm", "Lib.Exponentiation.Definition.comm_monoid" ]
[]
false
false
false
false
false
let mk_nat_mont_ll_comm_monoid (pbits rLen n: pos) (mu: nat{M.mont_pre pbits rLen n mu}) : LE.comm_monoid (nat_mod n) =
{ LE.one = mont_one_ll pbits rLen n mu; LE.mul = mont_mul_ll pbits rLen n mu; LE.lemma_one = lemma_mont_one_ll pbits rLen n mu; LE.lemma_mul_assoc = lemma_mont_mul_ll_assoc pbits rLen n mu; LE.lemma_mul_comm = lemma_mont_mul_ll_comm pbits rLen n mu }
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_Push
val va_lemma_Push : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Public (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
val va_lemma_Push : va_b0:va_code -> va_s0:va_state -> src:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Push src) va_s0 /\ va_is_src_reg_opr64 src va_s0 /\ va_get_ok va_s0 /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 8)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_s0 src) (va_get_stack va_s0) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_sM) Public (va_get_stackTaint va_s0) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))))
let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 102, "start_col": 0, "start_line": 95 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_Sems.equiv_store_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Decls.va_eval_reg_opr64", "Vale.X64.Decls.va_get_stack", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Push", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Push" ]
[]
false
false
false
false
false
let va_lemma_Push va_b0 va_s0 src =
va_reveal_opaque (`%va_code_Push) (va_code_Push src); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_PushXmm
val va_wpProof_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_PushXmm : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 262, "start_col": 0, "start_line": 254 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PushXmm", "Vale.X64.InsStack.va_code_PushXmm" ]
[]
false
false
false
false
false
let va_wpProof_PushXmm src tmp va_s0 va_k =
let va_sM, va_f0 = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_PushXmm
val va_lemma_PushXmm : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Public (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Public (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
val va_lemma_PushXmm : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Public (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Public (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 250, "start_col": 0, "start_line": 231 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ())))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsStack.va_lemma_Push", "Vale.X64.Decls.va_hd", "Vale.X64.InsVector.va_lemma_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PushXmm" ]
[]
false
false
false
false
false
let va_lemma_PushXmm va_b0 va_s0 src tmp =
va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_Pop_Secret
val va_wpProof_Pop_Secret : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop_Secret dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop_Secret dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_Pop_Secret : dst:va_operand_dst_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_Pop_Secret dst va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Pop_Secret dst) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 145, "start_col": 0, "start_line": 138 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_dst_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_dst_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_dst_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_Pop_Secret", "Vale.X64.InsStack.va_code_Pop_Secret" ]
[]
false
false
false
false
false
let va_wpProof_Pop_Secret dst va_s0 va_k =
let va_sM, va_f0 = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_code_Load64_stack
val va_code_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_code
val va_code_Load64_stack : dst:va_operand_dst_opr64 -> src:va_operand_reg_opr64 -> offset:int -> Tot va_code
let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public)))))
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 23, "end_line": 185, "start_col": 0, "start_line": 183 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "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_reg_opr64 -> offset: Prims.int -> Vale.X64.Decls.va_code
Prims.Tot
[ "total" ]
[]
[ "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.Decls.va_operand_reg_opr64", "Prims.int", "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.Machine_s.OStack", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_s.MReg", "Vale.X64.Decls.get_reg", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_code" ]
[]
false
false
false
true
false
let va_code_Load64_stack dst src offset =
(mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public)))))
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mod_exp_mont
val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n
val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n
let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 115, "start_col": 0, "start_line": 111 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> r: Prims.pos -> d: Prims.int{r * d % n == 1} -> a: Lib.NatMod.nat_mod n -> b: Prims.nat -> Lib.NatMod.nat_mod n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.int", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "Prims.nat", "Lib.Exponentiation.Definition.pow", "Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid" ]
[]
false
false
false
false
false
let mod_exp_mont n r d a b =
let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_comm_monoid
val mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n)
val mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n)
let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; }
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 3, "end_line": 72, "start_col": 0, "start_line": 66 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = ()
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> r: Prims.nat -> d: Prims.int{r * d % n = 1} -> Lib.Exponentiation.Definition.comm_monoid (Lib.NatMod.nat_mod n)
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Prims.int", "Prims.b2t", "Prims.op_Equality", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.Exponentiation.Definition.Mkcomm_monoid", "Lib.NatMod.nat_mod", "Hacl.Spec.Exponentiation.Lemmas.mont_one", "Hacl.Spec.Exponentiation.Lemmas.mont_mul", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_comm", "Lib.Exponentiation.Definition.comm_monoid" ]
[]
false
false
false
false
false
let mk_nat_mont_comm_monoid (n: pos) (r: nat) (d: int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) =
{ LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d }
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc
val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c))
val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c))
let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); }
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 59, "start_col": 0, "start_line": 42 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n ->
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> d: Prims.int -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> c: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul n d (Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a b) c == Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a (Hacl.Spec.Exponentiation.Lemmas.mont_mul n d b c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.int", "Lib.NatMod.nat_mod", "FStar.Calc.calc_finish", "Prims.eq2", "Hacl.Spec.Exponentiation.Lemmas.mont_mul", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Prims.op_Modulus", "FStar.Mul.op_Star", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "FStar.Math.Lemmas.paren_mul_right", "Hacl.Spec.Montgomery.Lemmas.lemma_mod_mul_distr3" ]
[]
false
false
true
false
false
let lemma_mont_mul_assoc n d a b c =
calc ( == ) { mont_mul n d (mont_mul n d a b) c; ( == ) { () } (((a * b) * d % n) * c) * d % n; ( == ) { Math.Lemmas.paren_mul_right ((a * b) * d % n) c d } ((a * b) * d % n) * (c * d) % n; ( == ) { M.lemma_mod_mul_distr3 1 ((a * b) * d) (c * d) n } ((a * b) * d) * (c * d) % n; ( == ) { Math.Lemmas.paren_mul_right ((a * b) * d) c d } (((a * b) * d) * c) * d % n; ( == ) { (Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c) } (a * ((b * d) * c)) * d % n; ( == ) { (Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d) } (a * ((b * c) * d)) * d % n; ( == ) { M.lemma_mod_mul_distr3 a ((b * c) * d) d n } mont_mul n d a (mont_mul n d b c); }
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_PushXmm_Secret
val va_wpProof_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm_Secret src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm_Secret src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_PushXmm_Secret : src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PushXmm_Secret src tmp va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PushXmm_Secret src tmp) ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_PushXmm_Secret src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 364, "start_col": 0, "start_line": 356 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stackTaint", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stackTaint", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PushXmm_Secret", "Vale.X64.InsStack.va_code_PushXmm_Secret" ]
[]
false
false
false
false
false
let va_wpProof_PushXmm_Secret src tmp va_s0 va_k =
let va_sM, va_f0 = va_lemma_PushXmm_Secret (va_code_PushXmm_Secret src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one
val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a)
val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a)
let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; }
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 5, "end_line": 38, "start_col": 0, "start_line": 27 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n ->
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
n: Prims.pos -> r: Prims.pos -> d: Prims.int{r * d % n = 1} -> a: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul n d a (Hacl.Spec.Exponentiation.Lemmas.mont_one n r) == a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.int", "Prims.b2t", "Prims.op_Equality", "Prims.op_Modulus", "FStar.Mul.op_Star", "Lib.NatMod.nat_mod", "FStar.Calc.calc_finish", "Prims.eq2", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.Montgomery.Lemmas.lemma_mod_mul_distr3", "Prims.squash", "FStar.Math.Lemmas.lemma_mod_mul_distr_r", "FStar.Math.Lemmas.paren_mul_right", "Prims._assert", "FStar.Math.Lemmas.small_mod" ]
[]
false
false
true
false
false
let lemma_mont_one n r d a =
calc ( == ) { (a * (1 * r % n)) * d % n; ( == ) { M.lemma_mod_mul_distr3 a r d n } (a * r) * d % n; ( == ) { (Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n) } a * (r * d % n) % n; ( == ) { assert (r * d % n = 1) } a % n; ( == ) { Math.Lemmas.small_mod a n } a; }
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_wpProof_PopXmm
val va_wpProof_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
val va_wpProof_PopXmm : dst:va_operand_xmm -> tmp:va_operand_reg_opr64 -> expected_xmm:quad32 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_PopXmm dst tmp expected_xmm va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_PopXmm dst tmp) ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_s0 va_k ((va_sM, va_f0, va_g))))
let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 22, "end_line": 314, "start_col": 0, "start_line": 306 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
dst: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> expected_xmm: Vale.X64.Decls.quad32 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.quad32", "Vale.X64.Decls.va_state", "Prims.unit", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple3", "Vale.X64.QuickCode.va_lemma_norm_mods", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_stack", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rRsp", "Vale.X64.QuickCode.va_mod_reg_opr64", "Vale.X64.QuickCode.va_mod_xmm", "Prims.Nil", "Prims._assert", "Vale.X64.Decls.va_state_eq", "Vale.X64.Decls.va_update_stack", "Vale.X64.Decls.va_update_reg64", "Vale.X64.Decls.va_update_ok", "Vale.X64.Decls.va_update_operand_reg_opr64", "Vale.X64.Decls.va_update_operand_xmm", "Vale.X64.Decls.va_lemma_upd_update", "FStar.Pervasives.Native.tuple3", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.InsStack.va_lemma_PopXmm", "Vale.X64.InsStack.va_code_PopXmm" ]
[]
false
false
false
false
false
let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k =
let va_sM, va_f0 = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0))))) ); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_PushXmm_Secret
val va_lemma_PushXmm_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm_Secret src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Secret (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Secret (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
val va_lemma_PushXmm_Secret : va_b0:va_code -> va_s0:va_state -> src:va_operand_xmm -> tmp:va_operand_reg_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_PushXmm_Secret src tmp) va_s0 /\ va_is_src_xmm src va_s0 /\ va_is_dst_reg_opr64 tmp va_s0 /\ va_get_ok va_s0 /\ sse_enabled /\ va_get_reg64 rRsp va_s0 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) /\ Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 <= va_get_reg64 rRsp va_s0 - 16)) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (let src_lo = Vale.Arch.Types.lo64 (va_eval_xmm va_sM src) in let src_hi = Vale.Arch.Types.hi64 (va_eval_xmm va_sM src) in va_get_stack va_sM == Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 16) src_hi (Vale.X64.Stack_i.store_stack64 (va_get_reg64 rRsp va_s0 - 8) src_lo (va_get_stack va_s0)) /\ va_get_stackTaint va_sM == Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 16) Secret (Vale.X64.Stack_i.store_taint_stack64 (va_get_reg64 rRsp va_s0 - 8) Secret (va_get_stackTaint va_s0)) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 - 16) /\ va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))))
let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 352, "start_col": 0, "start_line": 333 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop_Secret dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop_Secret (va_code_Pop_Secret dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push_Secret [@ "opaque_to_smt"] let va_code_Push_Secret src = (Ins (BC.Push src Secret)) [@ "opaque_to_smt"] let va_codegen_success_Push_Secret src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push_Secret va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push_Secret) (va_code_Push_Secret src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Secret)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push_Secret src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push_Secret (va_code_Push_Secret src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Load64_stack [@ "opaque_to_smt"] let va_code_Load64_stack dst src offset = (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) [@ "opaque_to_smt"] let va_codegen_success_Load64_stack dst src offset = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Load64_stack va_b0 va_s0 dst src offset = va_reveal_opaque (`%va_code_Load64_stack) (va_code_Load64_stack dst src offset); let (va_old_s:va_state) = va_s0 in va_ins_lemma (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0; let (va_sM, va_fM) = va_eval_ins (mk_ins (make_instr_annotate (I.ins_Mov64) (S.AnnotateMov64 ()) dst (OStack ((MReg (get_reg src) offset, Public))))) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_eval_reg_opr64 va_old_s src + offset) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Load64_stack dst src offset va_s0 va_k = let (va_sM, va_f0) = va_lemma_Load64_stack (va_code_Load64_stack dst src offset) va_s0 dst src offset 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) //-- //-- PushXmm [@ "opaque_to_smt"] let va_code_PushXmm src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push tmp) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PushXmm va_b0 va_s0 src tmp = va_reveal_opaque (`%va_code_PushXmm) (va_code_PushXmm src tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Push (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Push (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PushXmm src tmp va_s0 va_k = let (va_sM, va_f0) = va_lemma_PushXmm (va_code_PushXmm src tmp) va_s0 src tmp in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PopXmm [@ "opaque_to_smt"] let va_code_PopXmm dst tmp = (va_Block (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_CCons (va_code_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_CCons (va_code_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PopXmm dst tmp = (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 1) (va_pbool_and (va_codegen_success_Pop (va_coerce_reg_opr64_to_dst_opr64 tmp)) (va_pbool_and (va_codegen_success_Pinsrq dst (va_coerce_reg_opr64_to_opr64 tmp) 0) (va_ttrue ()))))) [@"opaque_to_smt"] let va_lemma_PopXmm va_b0 va_s0 dst tmp expected_xmm = va_reveal_opaque (`%va_code_PopXmm) (va_code_PopXmm dst tmp); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_s2, va_fc2) = va_lemma_Pop (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b2 = va_tl va_b1 in let (va_s3, va_fc3) = va_lemma_Pinsrq (va_hd va_b2) va_s2 dst (va_coerce_reg_opr64_to_opr64 tmp) 1 in let va_b3 = va_tl va_b2 in let (va_s4, va_fc4) = va_lemma_Pop (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) in let va_b4 = va_tl va_b3 in let (va_s5, va_fc5) = va_lemma_Pinsrq (va_hd va_b4) va_s4 dst (va_coerce_reg_opr64_to_opr64 tmp) 0 in let va_b5 = va_tl va_b4 in Vale.Arch.Types.push_pop_xmm expected_xmm (va_eval_xmm va_old_s dst); let (va_sM, va_f5) = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_PopXmm dst tmp expected_xmm va_s0 va_k = let (va_sM, va_f0) = va_lemma_PopXmm (va_code_PopXmm dst tmp) va_s0 dst tmp expected_xmm in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_reg_opr64 tmp va_sM (va_update_operand_xmm dst va_sM va_s0)))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_reg_opr64 tmp; va_mod_xmm dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- PushXmm_Secret [@ "opaque_to_smt"] let va_code_PushXmm_Secret src tmp = (va_Block (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_CCons (va_code_Push_Secret tmp) (va_CCons (va_code_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_CCons (va_code_Push_Secret tmp) (va_CNil ())))))) [@ "opaque_to_smt"] let va_codegen_success_PushXmm_Secret src tmp = (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_pbool_and (va_codegen_success_Pextrq (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1) (va_pbool_and (va_codegen_success_Push_Secret tmp) (va_ttrue ())))))
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> src: Vale.X64.Decls.va_operand_xmm -> tmp: Vale.X64.Decls.va_operand_reg_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_xmm", "Vale.X64.Decls.va_operand_reg_opr64", "Vale.X64.Decls.va_fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_lemma_merge_total", "FStar.Pervasives.Native.tuple2", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_lemma_empty_total", "Prims.list", "Vale.X64.Machine_s.precode", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_tl", "Vale.X64.InsStack.va_lemma_Push_Secret", "Vale.X64.Decls.va_hd", "Vale.X64.InsVector.va_lemma_Pextrq", "Vale.X64.Decls.va_coerce_reg_opr64_to_dst_opr64", "Vale.X64.Decls.va_get_block", "Prims.unit", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_PushXmm_Secret" ]
[]
false
false
false
false
false
let va_lemma_PushXmm_Secret va_b0 va_s0 src tmp =
va_reveal_opaque (`%va_code_PushXmm_Secret) (va_code_PushXmm_Secret src tmp); let va_old_s:va_state = va_s0 in let va_b1:va_codes = va_get_block va_b0 in let va_s2, va_fc2 = va_lemma_Pextrq (va_hd va_b1) va_s0 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 0 in let va_b2 = va_tl va_b1 in let va_s3, va_fc3 = va_lemma_Push_Secret (va_hd va_b2) va_s2 tmp in let va_b3 = va_tl va_b2 in let va_s4, va_fc4 = va_lemma_Pextrq (va_hd va_b3) va_s3 (va_coerce_reg_opr64_to_dst_opr64 tmp) src 1 in let va_b4 = va_tl va_b3 in let va_s5, va_fc5 = va_lemma_Push_Secret (va_hd va_b4) va_s4 tmp in let va_b5 = va_tl va_b4 in let va_sM, va_f5 = va_lemma_empty_total va_s5 va_b5 in let va_f4 = va_lemma_merge_total va_b4 va_s4 va_fc5 va_s5 va_f5 va_sM in let va_f3 = va_lemma_merge_total va_b3 va_s3 va_fc4 va_s4 va_f4 va_sM in let va_f2 = va_lemma_merge_total va_b2 va_s2 va_fc3 va_s3 va_f3 va_sM in let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc2 va_s2 va_f2 va_sM in (va_sM, va_fM)
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mont_one_ll
val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n
val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n
let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 28, "end_line": 149, "start_col": 0, "start_line": 147 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> Lib.NatMod.nat_mod n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Hacl.Spec.Montgomery.Lemmas.mont_one", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_one_lemma", "Lib.NatMod.nat_mod" ]
[]
false
false
false
false
false
let mont_one_ll pbits rLen n mu =
M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one_ll
val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a)
val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a)
let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 24, "end_line": 169, "start_col": 0, "start_line": 160 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n ->
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a (Hacl.Spec.Exponentiation.Lemmas.mont_one_ll pbits rLen n mu) == a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_one", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Prims._assert", "Prims.eq2", "Prims.op_Modulus", "FStar.Mul.op_Star", "Hacl.Spec.Montgomery.Lemmas.mont_one_lemma", "Hacl.Spec.Exponentiation.Lemmas.mont_one_ll", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "Prims.pow2" ]
[]
false
false
true
false
false
let lemma_mont_one_ll pbits rLen n mu a =
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll
val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n
val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n
let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 155, "start_col": 0, "start_line": 153 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu}
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> Lib.NatMod.nat_mod n
Prims.Tot
[ "total" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Hacl.Spec.Montgomery.Lemmas.mont_mul", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma" ]
[]
false
false
false
false
false
let mont_mul_ll pbits rLen n mu a b =
M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_assoc
val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 32, "end_line": 186, "start_col": 0, "start_line": 177 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c))
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> c: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu (Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a b) c == Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a (Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu b c))
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_assoc", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
false
false
true
false
false
let lemma_mont_mul_ll_assoc pbits rLen n mu a b c =
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c
false
Hacl.Spec.Exponentiation.Lemmas.fst
Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_ll_comm
val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
let lemma_mont_mul_ll_comm pbits rLen n mu a b = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b
{ "file_name": "code/bignum/Hacl.Spec.Exponentiation.Lemmas.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 29, "end_line": 200, "start_col": 0, "start_line": 193 }
module Hacl.Spec.Exponentiation.Lemmas open FStar.Mul open Lib.NatMod open Lib.Sequence module Loops = Lib.LoopCombinators module LSeq = Lib.Sequence module LE = Lib.Exponentiation module SE = Spec.Exponentiation module M = Hacl.Spec.Montgomery.Lemmas module AM = Hacl.Spec.AlmostMontgomery.Lemmas #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" (* Modular exponentiation with Montgomery arithmetic *) val mont_one: n:pos -> r:pos -> nat_mod n let mont_one n r = 1 * r % n val mont_mul: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul n d a b = a * b * d % n val lemma_mont_one: n:pos -> r:pos -> d:int{r * d % n = 1} -> a:nat_mod n -> Lemma (mont_mul n d a (mont_one n r) == a) let lemma_mont_one n r d a = calc (==) { a * (1 * r % n) * d % n; (==) { M.lemma_mod_mul_distr3 a r d n } a * r * d % n; (==) { Math.Lemmas.paren_mul_right a r d; Math.Lemmas.lemma_mod_mul_distr_r a (r * d) n } a * (r * d % n) % n; (==) { assert (r * d % n = 1) } a % n; (==) { Math.Lemmas.small_mod a n } a; } val lemma_mont_mul_assoc: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul n d (mont_mul n d a b) c == mont_mul n d a (mont_mul n d b c)) let lemma_mont_mul_assoc n d a b c = calc (==) { mont_mul n d (mont_mul n d a b) c; (==) { } (a * b * d % n) * c * d % n; (==) { Math.Lemmas.paren_mul_right (a * b * d % n) c d } (a * b * d % n) * (c * d) % n; (==) { M.lemma_mod_mul_distr3 1 (a * b * d) (c * d) n } a * b * d * (c * d) % n; (==) { Math.Lemmas.paren_mul_right (a * b * d) c d } a * b * d * c * d % n; (==) { Math.Lemmas.paren_mul_right a b d; Math.Lemmas.paren_mul_right a (b * d) c } a * (b * d * c) * d % n; (==) { Math.Lemmas.paren_mul_right b d c; Math.Lemmas.paren_mul_right b c d } a * (b * c * d) * d % n; (==) { M.lemma_mod_mul_distr3 a (b * c * d) d n } mont_mul n d a (mont_mul n d b c); } val lemma_mont_mul_comm: n:pos -> d:int -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul n d a b == mont_mul n d a b) let lemma_mont_mul_comm n d a b = () let mk_nat_mont_comm_monoid (n:pos) (r:nat) (d:int{r * d % n = 1}) : LE.comm_monoid (nat_mod n) = { LE.one = mont_one n r; LE.mul = mont_mul n d; LE.lemma_one = lemma_mont_one n r d; LE.lemma_mul_assoc = lemma_mont_mul_assoc n d; LE.lemma_mul_comm = lemma_mont_mul_comm n d; } val pow_nat_mont_is_pow: n:pos -> r:nat -> d:int{r * d % n = 1} -> aM:nat_mod n -> b:nat -> Lemma (pow (aM * d % n) b * r % n == LE.pow (mk_nat_mont_comm_monoid n r d) aM b) let rec pow_nat_mont_is_pow n r d aM b = let k = mk_nat_mont_comm_monoid n r d in if b = 0 then begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow0 (aM * d % n) } 1 * r % n; (==) { LE.lemma_pow0 k aM } LE.pow k aM b; }; () end else begin calc (==) { pow (aM * d % n) b * r % n; (==) { lemma_pow_unfold (aM * d % n) b } (aM * d % n) * pow (aM * d % n) (b - 1) * r % n; (==) { Math.Lemmas.paren_mul_right (aM * d % n) (pow (aM * d % n) (b - 1)) r; Math.Lemmas.lemma_mod_mul_distr_r (aM * d % n) (pow (aM * d % n) (b - 1) * r) n } (aM * d % n) * (pow (aM * d % n) (b - 1) * r % n) % n; (==) { pow_nat_mont_is_pow n r d aM (b - 1) } (aM * d % n) * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.lemma_mod_mul_distr_l (aM * d) (LE.pow k aM (b - 1)) n } aM * d * LE.pow k aM (b - 1) % n; (==) { Math.Lemmas.paren_mul_right aM d (LE.pow k aM (b - 1)); Math.Lemmas.paren_mul_right aM (LE.pow k aM (b - 1)) d } aM * LE.pow k aM (b - 1) * d % n; (==) { LE.lemma_pow_unfold k aM b } LE.pow k aM b; }; () end val mod_exp_mont: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> nat_mod n let mod_exp_mont n r d a b = let aM = a * r % n in let accM = LE.pow (mk_nat_mont_comm_monoid n r d) aM b in let acc = accM * d % n in acc val mod_exp_mont_lemma: n:pos -> r:pos -> d:int{r * d % n == 1} -> a:nat_mod n -> b:nat -> Lemma (mod_exp_mont n r d a b == pow_mod #n a b) let mod_exp_mont_lemma n r d a b = let k = mk_nat_mont_comm_monoid n r d in let aM = a * r % n in //let accM = LE.pow k aM b in //let acc = accM * d % n in calc (==) { // acc LE.pow k aM b * d % n; (==) { pow_nat_mont_is_pow n r d aM b } (pow (aM * d % n) b * r % n) * d % n; (==) { M.lemma_mont_id n r d (pow (aM * d % n) b) } pow (aM * d % n) b % n; (==) { } pow (a * r % n * d % n) b % n; (==) { M.lemma_mont_id n r d a } pow (a % n) b % n; (==) { Math.Lemmas.small_mod a n } pow a b % n; }; assert (mod_exp_mont n r d a b == pow a b % n); lemma_pow_mod #n a b (* Modular exponentiation with Montgomery arithmetic using functions from Hacl.Spec.Montgomery.Lemmas *) val mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> nat_mod n let mont_one_ll pbits rLen n mu = M.mont_one_lemma pbits rLen n mu; M.mont_one pbits rLen n mu val mont_mul_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> nat_mod n let mont_mul_ll pbits rLen n mu a b = M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul pbits rLen n mu a b val lemma_mont_one_ll: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a (mont_one_ll pbits rLen n mu) == a) let lemma_mont_one_ll pbits rLen n mu a = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; let mont_one = mont_one_ll pbits rLen n mu in M.mont_one_lemma pbits rLen n mu; assert (mont_one == 1 * r % n); M.mont_mul_lemma pbits rLen n mu a mont_one; lemma_mont_one n r d a val lemma_mont_mul_ll_assoc: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> c:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c == mont_mul_ll pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c)) let lemma_mont_mul_ll_assoc pbits rLen n mu a b c = let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu (mont_mul_ll pbits rLen n mu a b) c; M.mont_mul_lemma pbits rLen n mu b c; M.mont_mul_lemma pbits rLen n mu a (mont_mul_ll pbits rLen n mu b c); lemma_mont_mul_assoc n d a b c val lemma_mont_mul_ll_comm: pbits:pos -> rLen:pos -> n:pos -> mu:nat{M.mont_pre pbits rLen n mu} -> a:nat_mod n -> b:nat_mod n -> Lemma (mont_mul_ll pbits rLen n mu a b == mont_mul_ll pbits rLen n mu b a)
{ "checked_file": "/", "dependencies": [ "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.NatMod.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.Exponentiation.fsti.checked", "Hacl.Spec.Montgomery.Lemmas.fst.checked", "Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Spec.Exponentiation.Lemmas.fst" }
[ { "abbrev": true, "full_module": "Hacl.Spec.AlmostMontgomery.Lemmas", "short_module": "AM" }, { "abbrev": true, "full_module": "Hacl.Spec.Montgomery.Lemmas", "short_module": "M" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.NatMod", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Spec.Exponentiation", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": 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
pbits: Prims.pos -> rLen: Prims.pos -> n: Prims.pos -> mu: Prims.nat{Hacl.Spec.Montgomery.Lemmas.mont_pre pbits rLen n mu} -> a: Lib.NatMod.nat_mod n -> b: Lib.NatMod.nat_mod n -> FStar.Pervasives.Lemma (ensures Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu a b == Hacl.Spec.Exponentiation.Lemmas.mont_mul_ll pbits rLen n mu b a)
FStar.Pervasives.Lemma
[ "lemma" ]
[]
[ "Prims.pos", "Prims.nat", "Hacl.Spec.Montgomery.Lemmas.mont_pre", "Lib.NatMod.nat_mod", "Prims.int", "Hacl.Spec.Exponentiation.Lemmas.lemma_mont_mul_comm", "Prims.unit", "Hacl.Spec.Montgomery.Lemmas.mont_mul_lemma", "Hacl.Spec.Montgomery.Lemmas.mont_preconditions_d", "FStar.Pervasives.Native.tuple2", "Hacl.Spec.Montgomery.Lemmas.eea_pow2_odd", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
false
false
true
false
false
let lemma_mont_mul_ll_comm pbits rLen n mu a b =
let r = pow2 (pbits * rLen) in let d, _ = M.eea_pow2_odd (pbits * rLen) n in M.mont_preconditions_d pbits rLen n; M.mont_mul_lemma pbits rLen n mu a b; M.mont_mul_lemma pbits rLen n mu b a; lemma_mont_mul_comm n d a b
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_Pop_Secret
val va_lemma_Pop_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop_Secret dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
val va_lemma_Pop_Secret : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop_Secret dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Secret (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
let va_lemma_Pop_Secret va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 134, "start_col": 0, "start_line": 127 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Pop dst va_s0 va_k = let (va_sM, va_f0) = va_lemma_Pop (va_code_Pop dst) va_s0 dst in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stack; va_Mod_reg64 rRsp; va_mod_dst_opr64 dst]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Push [@ "opaque_to_smt"] let va_code_Push src = (Ins (BC.Push src Public)) [@ "opaque_to_smt"] let va_codegen_success_Push src = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Push va_b0 va_s0 src = va_reveal_opaque (`%va_code_Push) (va_code_Push src); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Push src Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Push src Public)) va_s0 in Vale.X64.Stack_Sems.equiv_store_stack64 (va_get_reg64 rRsp va_sM) (va_eval_reg_opr64 va_old_s src) (va_get_stack va_old_s); (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Push src va_s0 va_k = let (va_sM, va_f0) = va_lemma_Push (va_code_Push src) va_s0 src in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM va_s0))))); va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_reg64 rRsp]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop_Secret [@ "opaque_to_smt"] let va_code_Pop_Secret dst = (Ins (BC.Pop dst Secret)) [@ "opaque_to_smt"] let va_codegen_success_Pop_Secret dst = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_dst_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_i.lemma_valid_taint_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Decls.va_get_stackTaint", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Pop_Secret" ]
[]
false
false
false
false
false
let va_lemma_Pop_Secret va_b0 va_s0 dst =
va_reveal_opaque (`%va_code_Pop_Secret) (va_code_Pop_Secret dst); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Pop dst Secret)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Pop dst Secret)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Secret (va_get_stackTaint va_old_s); (va_sM, va_fM)
false
Vale.X64.InsStack.fst
Vale.X64.InsStack.va_lemma_Pop
val va_lemma_Pop : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
val va_lemma_Pop : va_b0:va_code -> va_s0:va_state -> dst:va_operand_dst_opr64 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_Pop dst) va_s0 /\ va_is_dst_dst_opr64 dst va_s0 /\ va_get_ok va_s0 /\ Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ Vale.X64.Stack_i.valid_taint_stack64 (va_get_reg64 rRsp va_s0) Public (va_get_stackTaint va_s0) /\ va_get_reg64 rRsp va_s0 >= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0) - 4096 /\ va_get_reg64 rRsp va_s0 + 8 <= Vale.X64.Stack_i.init_rsp (va_get_stack va_s0))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ va_eval_dst_opr64 va_sM dst == Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0) (va_get_stack va_s0) /\ va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0 + 8 /\ va_get_stack va_sM == Vale.X64.Stack_i.free_stack64 (va_get_reg64 rRsp va_sM - 8) (va_get_reg64 rRsp va_sM) (va_get_stack va_s0) /\ va_state_eq va_sM (va_update_stack va_sM (va_update_reg64 rRsp va_sM (va_update_ok va_sM (va_update_operand_dst_opr64 dst va_sM va_s0))))))
let va_lemma_Pop va_b0 va_s0 dst = va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let (va_old_s:va_state) = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let (va_sM, va_fM) = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
{ "file_name": "obj/Vale.X64.InsStack.fst", "git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872", "git_url": "https://github.com/project-everest/hacl-star.git", "project_name": "hacl-star" }
{ "end_col": 16, "end_line": 70, "start_col": 0, "start_line": 63 }
module Vale.X64.InsStack open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.Stack_i open Vale.X64 open Vale.X64.State open Vale.X64.StateLemmas open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsVector open Vale.X64.InsLemmas module I = Vale.X64.Instructions_s module BC = Vale.X64.Bytes_Code_s module S = Vale.X64.Machine_Semantics_s module P = Vale.X64.Print_s open Vale.X64.Taint_Semantics friend Vale.X64.Decls friend Vale.X64.Stack_i #reset-options "--initial_fuel 2 --max_fuel 4 --max_ifuel 2 --z3rlimit 50" //-- Stack_in //-- //-- Stack_lemma [@ "opaque_to_smt"] let va_code_Stack_lemma () = (va_Block (va_CNil ())) [@ "opaque_to_smt"] let va_codegen_success_Stack_lemma () = (va_ttrue ()) [@"opaque_to_smt"] let va_lemma_Stack_lemma va_b0 va_s0 base offset t = va_reveal_opaque (`%va_code_Stack_lemma) (va_code_Stack_lemma ()); let (va_old_s:va_state) = va_s0 in let (va_b1:va_codes) = va_get_block va_b0 in let (va_sM, va_fM) = va_lemma_empty_total va_s0 va_b1 in (va_sM, va_fM) [@"opaque_to_smt"] let va_wpProof_Stack_lemma base offset t va_s0 va_k = let (va_sM, va_f0) = va_lemma_Stack_lemma (va_code_Stack_lemma ()) va_s0 base offset t in va_lemma_upd_update va_sM; assert (va_state_eq va_sM (va_update_ok va_sM va_s0)); va_lemma_norm_mods ([]) va_sM va_s0; let va_g = () in (va_sM, va_f0, va_g) //-- //-- Pop [@ "opaque_to_smt"] let va_code_Pop dst = (Ins (BC.Pop dst Public)) [@ "opaque_to_smt"] let va_codegen_success_Pop dst = (va_ttrue ())
{ "checked_file": "/", "dependencies": [ "Vale.X64.Taint_Semantics.fst.checked", "Vale.X64.StateLemmas.fsti.checked", "Vale.X64.State.fsti.checked", "Vale.X64.Stack_Sems.fsti.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Stack_i.fst.checked", "Vale.X64.Print_s.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.InsLemmas.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Decls.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Arch.Types.fsti.checked", "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Vale.X64.InsStack.fst" }
[ { "abbrev": false, "full_module": "Vale.X64.Taint_Semantics", "short_module": null }, { "abbrev": true, "full_module": "Vale.X64.Print_s", "short_module": "P" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": true, "full_module": "Vale.X64.Instructions_s", "short_module": "I" }, { "abbrev": false, "full_module": "Vale.X64.InsLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.StateLemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "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.Stack_i", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Seq_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 4, "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": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
false
va_b0: Vale.X64.Decls.va_code -> va_s0: Vale.X64.Decls.va_state -> dst: Vale.X64.Decls.va_operand_dst_opr64 -> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel)
Prims.Ghost
[]
[]
[ "Vale.X64.Decls.va_code", "Vale.X64.Decls.va_state", "Vale.X64.Decls.va_operand_dst_opr64", "Vale.X64.State.vale_state", "Vale.X64.Lemmas.fuel", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Decls.va_fuel", "Prims.unit", "Vale.X64.Stack_i.lemma_valid_taint_stack64", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rRsp", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.va_get_stackTaint", "FStar.Pervasives.Native.tuple2", "Prims.nat", "Vale.X64.Decls.va_eval_ins", "Vale.X64.Machine_s.Ins", "Vale.X64.Bytes_Code_s.instruction_t", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Bytes_Code_s.ocmp", "Vale.X64.Bytes_Code_s.Pop", "Vale.X64.Decls.va_ins_lemma", "Vale.X64.Decls.ins", "Vale.X64.Decls.ocmp", "Vale.X64.Decls.va_reveal_opaque", "Vale.X64.InsStack.va_code_Pop" ]
[]
false
false
false
false
false
let va_lemma_Pop va_b0 va_s0 dst =
va_reveal_opaque (`%va_code_Pop) (va_code_Pop dst); let va_old_s:va_state = va_s0 in va_ins_lemma (Ins (BC.Pop dst Public)) va_s0; let va_sM, va_fM = va_eval_ins (Ins (BC.Pop dst Public)) va_s0 in Vale.X64.Stack_i.lemma_valid_taint_stack64 (va_get_reg64 rRsp va_old_s) Public (va_get_stackTaint va_old_s); (va_sM, va_fM)
false